lemon-mse 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/flv.js +1 -1
- package/dist/es/hls.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/lemon.css +1 -1
- package/dist/lemon.js +1 -1
- package/package.json +1 -1
- package/dist/es/_hls.d.ts +0 -3105
- package/dist/es/flv.d.ts +0 -587
- package/dist/es/hls.d.ts +0 -3
- package/dist/es/index.d.ts +0 -4
- package/dist/flv.js +0 -1
- package/dist/hls.js +0 -1
- package/dist/index.js +0 -1
package/dist/es/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var e={228:e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){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,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},539:e=>{!function t(r){e.exports=function(){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,a,s;r=t,a=e,s=i[e],(a=n(a))in r?Object.defineProperty(r,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[a]=s})):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 n(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,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function a(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,n(i.key),i)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(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 u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function h(e,t,r){return h=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 n=new(Function.bind.apply(e,i));return r&&d(n,r.prototype),n},h.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 h(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},c(e)}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v={exports:{}};!function(e,t){var r,i,n,a,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var n=s.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):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 u=i.exec(o.path);o.netLoc=u[1],o.path=u[2]}o.netLoc&&!o.path&&(o.path="/");var l={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(l.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+a.path;l.path=s.normalizePath(h)}else l.path=o.path,a.params||(l.params=o.params,a.query||(l.query=o.query));return null===l.path&&(l.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(l)},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(n,"");e.length!==(e=e.replace(a,"")).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}(v);var p=v.exports,g=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},m=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=y},y=Number.MAX_SAFE_INTEGER||9007199254740991,_=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}({}),E=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}({}),b=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}({}),T=function(){},S={trace:T,debug:T,log:T,warn:T,info:T,error:T},L=S;function k(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}(t)}))}function w(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){k(e,"debug","log","info","warn","error");try{L.log('Debug logs enabled for "'+t+'" in hls.js version 1.5.13')}catch(e){L=S}}else L=S}var A=L,x=/^(\d+)x(\d+)$/,R=/(.+?)=(".*?"|.*?)(?:,|$)/g,D=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=x.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(R.lastIndex=0;null!==(t=R.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},s(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function C(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var P=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 D({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);g(n.getTime())&&(this._endDate=n)}}return s(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(g(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&&g(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),I=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}},O="audio",F="video",M="audiovideo",B=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[O]=null,t[F]=null,t[M]=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]},s(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 I,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}u(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,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[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,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[O]=null,e[F]=null,e[M]=null},s(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(!g(this.programDateTime))return null;var e=g(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}(B),U=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new I,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),s(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}(B),G=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},s(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&g(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}(),V=f(void 0);function j(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var H,K=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},z=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},W=function(e,t){for(var r=t,i=0;K(e,t);)i+=10,i+=q(e,t+6),z(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},q=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]},Y=function(e,t){return K(e,t)&&q(e,t+6)+10<=e.length-t},X=function(e){for(var t=Z(e),r=0;r<t.length;r++){var i=t[r];if(Q(i))return ie(i)}},Q=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},J=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=q(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},Z=function(e){for(var t=0,r=[];K(e,t);){for(var i=q(e,t+6),n=(t+=10)+i;t+8<n;){var a=J(e.subarray(t)),s=$(a);s&&r.push(s),t+=a.size+10}z(e,t)&&(t+=10)}return r},$=function(e){return"PRIV"===e.type?ee(e):"W"===e.type[0]?re(e):te(e)},ee=function(e){if(!(e.size<2)){var t=ne(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},te=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data.subarray(1));return{key:e.type,data:n}}},re=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data);return{key:e.type,data:n}},ie=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)}},ne=function(e,t){void 0===t&&(t=!1);var r=ae();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,u=e.length,l="",d=0;d<u;){if(0===(a=e[d++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],l+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],o=e[d++],l+=String.fromCharCode((15&a)<<12|(63&s)<<6|63&o)}}return l};function ae(){if(!navigator.userAgent.includes("PlayStation 4"))return H||void 0===self.TextDecoder||(H=new self.TextDecoder("utf-8")),H}var se=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},oe=Math.pow(2,32)-1,ue=[].push,le={video:1,audio:2,id3:3,text:4};function de(e){return String.fromCharCode.apply(null,e)}function he(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ce(e,t){var r=ve(e,t);return r<0?4294967296+r:r}function fe(e,t){var r=ce(e,t);return(r*=Math.pow(2,32))+ce(e,t+4)}function ve(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function pe(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 ge(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=ce(e,n),s=a>1?n+a:i;if(de(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=ge(e.subarray(n+8,s),t.slice(1));o.length&&ue.apply(r,o)}n=s}return r}function me(e){var t=[],r=e[0],i=8,n=ce(e,i);i+=4;var a=0,s=0;0===r?(a=ce(e,i),s=ce(e,i+4),i+=8):(a=fe(e,i),s=fe(e,i+8),i+=16),i+=2;var o=e.length+s,u=he(e,i);i+=2;for(var l=0;l<u;l++){var d=i,h=ce(e,d);d+=4;var c=2147483647&h;if(1==(2147483648&h)>>>31)return A.warn("SIDX has hierarchical references (not supported)"),null;var f=ce(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+c-1}}),o+=c,i=d+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:u,references:t}}function ye(e){for(var t=[],r=ge(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=ge(a,["tkhd"])[0];if(s){var o=s[0],u=ce(s,0===o?12:20),l=ge(a,["mdia","mdhd"])[0];if(l){var d=ce(l,0===(o=l[0])?12:20),h=ge(a,["mdia","hdlr"])[0];if(h){var c=de(h.subarray(8,12)),f={soun:O,vide:F}[c];if(f){var v=_e(ge(a,["mdia","minf","stbl","stsd"])[0]);t[u]={timescale:d,type:f},t[f]=i({timescale:d,id:u},v)}}}}}return ge(e,["moov","mvex","trex"]).forEach((function(e){var r=ce(e,4),i=t[r];i&&(i.default={duration:ce(e,12),flags:ce(e,20)})})),t}function _e(e){var t=e.subarray(8),r=t.subarray(86),i=de(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=ge(t,[i])[0];ge(s.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=ge(e,["frma"])[0];i&&(n=de(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var o=ge(r,["avcC"])[0];n+="."+be(o[1])+be(o[2])+be(o[3]);break;case"mp4a":var u=ge(t,[i])[0],l=ge(u.subarray(28),["esds"])[0];if(l&&l.length>12){var d=4;if(3!==l[d++])break;d=Ee(l,d),d+=2;var h=l[d++];if(128&h&&(d+=2),64&h&&(d+=l[d++]),4!==l[d++])break;d=Ee(l,d);var c=l[d++];if(64!==c)break;if(n+="."+be(c),d+=12,5!==l[d++])break;d=Ee(l,d);var f=l[d++],v=(248&f)>>3;31===v&&(v+=1+((7&f)<<3)+((224&l[d])>>5)),n+="."+v}break;case"hvc1":case"hev1":var p=ge(r,["hvcC"])[0],g=p[1],m=["","A","B","C"][g>>6],y=31&g,_=ce(p,2),E=(32&g)>>5?"H":"L",b=p[12],T=p.subarray(6,12);n+="."+m+y,n+="."+_.toString(16).toUpperCase(),n+="."+E+b;for(var S="",L=T.length;L--;){var k=T[L];(k||S)&&(S="."+k.toString(16).toUpperCase()+S)}n+=S;break;case"dvh1":case"dvhe":var w=ge(r,["dvcC"])[0],A=w[2]>>1&127,x=w[2]<<5&32|w[3]>>3&31;n+="."+Te(A)+"."+Te(x);break;case"vp09":var R=ge(r,["vpcC"])[0],D=R[4],C=R[5],P=R[6]>>4&15;n+="."+Te(D)+"."+Te(C)+"."+Te(P);break;case"av01":var I=ge(r,["av1C"])[0],O=I[1]>>>5,F=31&I[1],M=I[2]>>>7?"H":"M",B=(64&I[2])>>6,N=(32&I[2])>>5,U=2===O&&B?N?12:10:B?10:8,G=(16&I[2])>>4,V=(8&I[2])>>3,j=(4&I[2])>>2,H=3&I[2];n+="."+O+"."+Te(F)+M+"."+Te(U)+"."+G+"."+V+j+H+"."+Te(1)+"."+Te(1)+"."+Te(1)+".0"}return{codec:n,encrypted:a}}function Ee(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function be(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Te(e){return(e<10?"0":"")+e}function Se(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&ge(e,["moov","trak"]).forEach((function(e){var t=ge(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=ge(t,["enca"]),n=i.length>0;n||(i=ge(t,["encv"])),i.forEach((function(e){ge(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return ge(e,["schi","tenc"])[0]}return A.error("[eme] missing 'schm' box"),null}(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(A.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+se(i)+" -> "+se(r)),t.set(r,8))}}))}))})),e}function Le(e){var t=ce(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=ce(e,4),a=0;a<n;a++)256&t&&(i+=ce(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function ke(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function we(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1;return ge(i,["moof"]).map((function(o){var u=o.byteOffset-8;ge(o,["traf"]).map((function(o){var l=ge(o,["tfdt"]).map((function(e){var t=e[0],r=ce(e,4);return 1===t&&(r*=Math.pow(2,32),r+=ce(e,8)),r/n}))[0];return void 0!==l&&(e=l),ge(o,["tfhd"]).map((function(l){var d=ce(l,4),h=16777215&ce(l,0),c=0,f=!!(16&h),v=0,p=!!(32&h),g=8;d===a&&(!!(1&h)&&(g+=8),!!(2&h)&&(g+=4),!!(8&h)&&(c=ce(l,g),g+=4),f&&(v=ce(l,g),g+=4),p&&(g+=4),"video"===t.type&&(s=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)),ge(o,["trun"]).map((function(a){var o=a[0],l=16777215&ce(a,0),d=!!(1&l),h=0,f=!!(4&l),p=!!(256&l),g=0,m=!!(512&l),y=0,_=!!(1024&l),E=!!(2048&l),b=0,T=ce(a,4),S=8;d&&(h=ce(a,S),S+=4),f&&(S+=4);for(var L=h+u,k=0;k<T;k++){if(p?(g=ce(a,S),S+=4):g=c,m?(y=ce(a,S),S+=4):y=v,_&&(S+=4),E&&(b=0===o?ce(a,S):ve(a,S),S+=4),t.type===F)for(var w=0;w<y;){var A=ce(i,L);Ae(s,i[L+=4])&&xe(i.subarray(L,L+A),s?2:1,e+b/n,r),L+=A,w+=A+4}e+=g/n}})))}))}))})),r}function Ae(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function xe(e,t,r,i){var n=Re(e),a=0;a+=t;for(var s=0,o=0,u=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var l=n.length-a,d=a;if(o<l)a+=o;else if(o>l){A.error("Malformed SEI payload. "+o+" is too small, only "+l+" bytes left to parse.");break}if(4===s){if(181===n[d++]){var h=he(n,d);if(d+=2,49===h){var c=ce(n,d);if(d+=4,1195456820===c){var f=n[d++];if(3===f){var v=n[d++],p=64&v,g=p?2+3*(31&v):0,m=new Uint8Array(g);if(p){m[0]=v;for(var y=1;y<g;y++)m[y]=n[d++]}i.push({type:f,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var _=[],E=0;E<16;E++){var b=n[d++].toString(16);_.push(1==b.length?"0"+b:b),3!==E&&5!==E&&7!==E&&9!==E||_.push("-")}for(var T=o-16,S=new Uint8Array(T),L=0;L<T;L++)S[L]=n[d++];i.push({payloadType:s,pts:r,uuid:_.join(""),userData:ne(S),userDataBytes:S})}}}function Re(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 n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}var De=function(){function e(e,t,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=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=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){};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}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)}return this},e}();function Ce(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Pe={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 Ie(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!Oe(e,t,r)}))}function Oe(e,t,r){var i;void 0===r&&(r=!0);var n=Ce(r);return null!=(i=null==n?void 0:n.isTypeSupported(Fe(e,t)))&&i}function Fe(e,t){return t+'/mp4;codecs="'+e+'"'}function Me(e){if(e){var t=e.substring(0,4);return Pe.video[t]}return 2}function Be(e){return e.split(",").reduce((function(e,t){var r=Pe.video[t];return r?(2*r+e)/(e?3:2):(Pe.audio[t]+e)/(e?2:1)}),0)}var Ne={};var Ue=/flac|opus/i;function Ge(e,t){return void 0===t&&(t=!0),e.replace(Ue,(function(e){return function(e,t){if(void 0===t&&(t=!0),Ne[e])return Ne[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(Oe(r[i],"audio",t))return Ne[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function Ve(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}var je=/#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,He=/#EXT-X-MEDIA:(.*)/g,Ke=/^#EXT(?:INF|-X-TARGETDURATION):/m,ze=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"),We=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("|")),qe=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 Ke.test(e)},e.parseMasterPlaylist=function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},a=[];for(je.lastIndex=0;null!=(i=je.exec(t));)if(i[1]){var s,o=new D(i[1]),u=i[2],l={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(u,r)},d=o.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),Qe(o.CODECS,l),null!=(s=l.unknownCodecs)&&s.length||a.push(l),n.levels.push(l)}else if(i[3]){var h=i[3],c=i[4];switch(h){case"SESSION-DATA":var f=new D(c),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var p=Ye(c,r);p.encrypted&&p.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(p)):A.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var g=new D(c);n.contentSteering={uri:e.resolve(g["SERVER-URI"],r),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=Xe(c)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n},e.parseMasterPlaylistMedia=function(t,r,i){var n,a={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},u=0;for(He.lastIndex=0;null!==(n=He.exec(t));){var l=new D(n[1]),d=l.TYPE;if(d){var h=o[d],c=a[d]||[];a[d]=c;var f=l.LANGUAGE,v=l["ASSOC-LANGUAGE"],p=l.CHANNELS,g=l.CHARACTERISTICS,m=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?e.resolve(l.URI,r):""};if(v&&(y.assocLang=v),p&&(y.channels=p),g&&(y.characteristics=g),m&&(y.instreamId=m),null!=h&&h.length){var _=e.findGroup(h,y.groupId)||h[0];Je(y,_,"audioCodec"),Je(y,_,"textCodec")}c.push(y)}}return a},e.parseLevelPlaylist=function(e,t,r,i,n,a){var s,u,l,d=new G(t),h=d.fragments,c=null,f=0,v=0,p=0,m=0,y=null,_=new N(i,t),E=-1,b=!1,T=null;for(ze.lastIndex=0,d.m3u8=e,d.hasVariableRefs=!1;null!==(s=ze.exec(e));){b&&(b=!1,(_=new N(i,t)).start=p,_.sn=f,_.cc=m,_.level=r,c&&(_.initSegment=c,_.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,T&&(_.setByteRange(T),T=null)));var S=s[1];if(S){_.duration=parseFloat(S);var L=(" "+s[2]).slice(1);_.title=L||null,_.tagList.push(L?["INF",S,L]:["INF",S])}else if(s[3]){if(g(_.duration)){_.start=p,l&&et(_,l,d),_.sn=f,_.level=r,_.cc=m,h.push(_);var k=(" "+s[3]).slice(1);_.relurl=k,Ze(_,y),y=_,p+=_.duration,f++,v=0,b=!0}}else if(s[4]){var w=(" "+s[4]).slice(1);y?_.setByteRange(w,y):_.setByteRange(w)}else if(s[5])_.rawProgramDateTime=(" "+s[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===E&&(E=h.length);else{if(!(s=s[0].match(We))){A.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var x=(" "+s[u]).slice(1),R=(" "+s[u+1]).slice(1),C=s[u+2]?(" "+s[u+2]).slice(1):"";switch(x){case"PLAYLIST-TYPE":d.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":f=d.startSN=parseInt(R);break;case"SKIP":var I=new D(R),O=I.decimalInteger("SKIPPED-SEGMENTS");if(g(O)){d.skippedSegments=O;for(var F=O;F--;)h.unshift(null);f+=O}var M=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");M&&(d.recentlyRemovedDateranges=M.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(R),1);break;case"VERSION":d.version=parseInt(R);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(R||C)&&_.tagList.push(C?[R,C]:[R]);break;case"DISCONTINUITY":m++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([x]);break;case"BITRATE":_.tagList.push([x,R]);break;case"DATERANGE":var B=new D(R),V=new P(B,d.dateRanges[B.ID]);V.isValid||d.skippedSegments?d.dateRanges[V.id]=V:A.warn('Ignoring invalid DATERANGE tag: "'+R+'"'),_.tagList.push(["EXT-X-DATERANGE",R]);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(R);break;case"KEY":var j=Ye(R,t);if(j.isSupported()){if("NONE"===j.method){l=void 0;break}l||(l={}),l[j.keyFormat]&&(l=o({},l)),l[j.keyFormat]=j}else A.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+R+'"');break;case"START":d.startTimeOffset=Xe(R);break;case"MAP":var H=new D(R);if(_.duration){var K=new N(i,t);$e(K,H,r,l),c=K,_.initSegment=c,c.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=c.rawProgramDateTime)}else{var z=_.byteRangeEndOffset;if(z){var W=_.byteRangeStartOffset;T=z-W+"@"+W}else T=null;$e(_,H,r,l),c=_,b=!0}break;case"SERVER-CONTROL":var q=new D(R);d.canBlockReload=q.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=q.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&q.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=q.optionalFloat("PART-HOLD-BACK",0),d.holdBack=q.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new D(R);d.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=d.partList;X||(X=d.partList=[]);var Q=v>0?X[X.length-1]:void 0,J=v++,Z=new D(R),$=new U(Z,_,t,J,Q);X.push($),_.duration+=$.duration;break;case"PRELOAD-HINT":var ee=new D(R);d.preloadHint=ee;break;case"RENDITION-REPORT":var te=new D(R);d.renditionReports=d.renditionReports||[],d.renditionReports.push(te);break;default:A.warn("line parsed but not handled: "+s)}}}y&&!y.relurl?(h.pop(),p-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(Ze(_,y),_.cc=m,d.fragmentHint=_,l&&et(_,l,d));var re=h.length,ie=h[0],ne=h[re-1];if((p+=d.skippedSegments*d.targetduration)>0&&re&&ne){d.averagetargetduration=p/re;var ae=ne.sn;d.endSN="initSegment"!==ae?ae:0,d.live||(ne.endList=!0),ie&&(d.startCC=ie.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(p+=d.fragmentHint.duration),d.totalduration=p,d.endCC=m,E>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,E),d},e}();function Ye(e,t,r){var i,n,a=new D(e),s=null!=(i=a.METHOD)?i:"",o=a.URI,u=a.hexadecimalInteger("IV"),l=a.KEYFORMATVERSIONS,d=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!u&&A.error("Invalid IV: "+a.IV);var h=o?qe.resolve(o,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new De(s,h,d,c,u)}function Xe(e){var t=new D(e).decimalFloatingPoint("TIME-OFFSET");return g(t)?t:null}function Qe(e,t){var r=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var i=r.filter((function(t){return function(e,t){var r=Pe[t];return!!r&&!!r[e.slice(0,4)]}(t,e)}));i.length&&(t[e+"Codec"]=i.join(","),r=r.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=r}function Je(e,t,r){var i=t[r];i&&(e[r]=i)}function Ze(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),g(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function $e(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function et(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}var tt="manifest",rt="level",it="audioTrack",nt="subtitleTrack",at="main",st="audio",ot="subtitle";function ut(e){switch(e.type){case it:return st;case nt:return ot;default:return at}}function lt(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var dt=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:tt,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.pathwayId,a=t.url,s=t.deliveryDirectives;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:rt,url:a,deliveryDirectives:s})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:it,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:nt,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var u=s.context;if(u&&u.url===e.url&&u.level===e.level)return void A.trace("[playlist-loader]: playlist request ongoing");A.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(r=e.type===tt?a.manifestLoadPolicy.default:o({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),g(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===rt&&null!==e.level?i=this.hls.levels[e.level].details:e.type===it&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===nt&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var l=i.partTarget,d=i.targetduration;if(l&&d){var h=1e3*Math.max(3*l,.8*d);r=o({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),qe.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,f,v)},t.handleMasterPlaylist=function(e,t,r,i){var n=this.hls,a=e.data,s=lt(e,r),o=qe.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var u=o.contentSteering,l=o.levels,d=o.sessionData,h=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=qe.parseMasterPlaylistMedia(a,s,o),p=v.AUDIO,g=void 0===p?[]:p,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];g.length&&(g.some((function(e){return!e.url}))||!l[0].audioCodec||l[0].attrs.AUDIO||(A.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D({}),bitrate:0,url:""}))),n.trigger(_.MANIFEST_LOADED,{levels:l,audioTracks:g,subtitles:m,captions:y,contentSteering:u,url:s,stats:t,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:f})}},t.handleTrackOrLevelPlaylist=function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,u=r.type,l=lt(e,r),d=g(o)?o:g(s)?s:0,h=ut(r),c=qe.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===tt){var f={attrs:new D({}),bitrate:0,details:c,name:"",url:l};a.trigger(_.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,e,t,r,i,n)},t.handleManifestParsingError=function(e,t,r,i,n){this.hls.trigger(_.ERROR,{type:E.NETWORK_ERROR,details:b.MANIFEST_PARSING_ERROR,fatal:t.type===tt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})},t.handleNetworkError=function(e,t,r,n,a){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+e.type;e.type===rt?s+=": "+e.level+" id: "+e.id:e.type!==it&&e.type!==nt||(s+=" id: "+e.id+' group-id: "'+e.groupId+'"');var o=new Error(s);A.warn("[playlist-loader]: "+s);var u=b.UNKNOWN,l=!1,d=this.getInternalLoader(e);switch(e.type){case tt:u=r?b.MANIFEST_LOAD_TIMEOUT:b.MANIFEST_LOAD_ERROR,l=!0;break;case rt:u=r?b.LEVEL_LOAD_TIMEOUT:b.LEVEL_LOAD_ERROR,l=!1;break;case it:u=r?b.AUDIO_TRACK_LOAD_TIMEOUT:b.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case nt:u=r?b.SUBTITLE_TRACK_LOAD_TIMEOUT:b.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);var h={type:E.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:a};if(n){var c=(null==t?void 0:t.url)||e.url;h.response=i({url:c,data:void 0},n)}this.hls.trigger(_.ERROR,h)},t.handlePlaylistLoaded=function(e,t,r,i,n,a){var s=this.hls,o=i.type,u=i.level,l=i.id,d=i.groupId,h=i.deliveryDirectives,c=lt(t,i),f=ut(i),v="number"==typeof i.level&&f===at?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var p=e.playlistParsingError;if(p)s.trigger(_.ERROR,{type:E.NETWORK_ERROR,details:b.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case tt:case rt:s.trigger(_.LEVEL_LOADED,{details:e,level:v||0,id:l||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case it:s.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case nt:s.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h})}}else{var g=new Error("No Segments found in Playlist");s.trigger(_.ERROR,{type:E.NETWORK_ERROR,details:b.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r})}},e}();function ht(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ct(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}var ft="org.id3",vt="com.apple.quicktime.HLS",pt="https://aomedia.org/emsg/ID3";function gt(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function mt(e,t,r,n,a){var s=new e(t,r,"");try{s.value=n,a&&(s.type=a)}catch(o){s=new e(t,r,JSON.stringify(a?i({type:a},n):n))}return s}var yt=function(){var e=gt();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function _t(e,t){return e.getTime()/1e3-t}var Et=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(function(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=gt();if(s)for(var o=0;o<a.length;o++){var u=a[o].type;if((u!==pt||i)&&n){var l=Z(a[o].data);if(l){var d=a[o].pts,h=d+a[o].duration;h>yt&&(h=yt),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var f=l[c];if(!Q(f)){this.updateId3CueEnds(d,u);var v=mt(s,d,h,f,u);v&&this.id3Track.addCue(v)}}}}}}}},t.updateId3CueEnds=function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.type===t&&a.startTime<e&&a.endTime===yt&&(a.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,u=o.enableEmsgMetadataCues,l=o.enableID3MetadataCues;a&&(u||l)&&ct(a,r,i,"audio"===n?function(e){return e.type===ft&&l}:"video"===n?function(e){return e.type===pt&&u}:function(e){return e.type===ft&&l||e.type===pt&&u})}},t.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n=this.dateRangeCuesAppended,a=this.id3Track,s=i.dateRanges,o=Object.keys(s);if(a)for(var u=Object.keys(n).filter((function(e){return!o.includes(e)})),l=function(){var e=u[d];Object.keys(n[e].cues).forEach((function(t){a.removeCue(n[e].cues[t])})),delete n[e]},d=u.length;d--;)l();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&g(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=h.programDateTime/1e3-h.start,f=gt(),v=function(){var e,t,i=o[p],a=s[i],u=_t(a.startDate,c),l=n[i],d=(null==l?void 0:l.cues)||{},h=(null==l?void 0:l.durationKnown)||!1,v=yt,g=a.endDate;if(g)v=_t(g,c),h=!0;else if(a.endOnNext&&!h){var m=o.reduce((function(e,t){if(t!==a.id){var r=s[t];if(r.class===a.class&&r.startDate>a.startDate&&(!e||a.startDate<e.startDate))return r}return e}),null);m&&(v=_t(m.startDate,c),h=!0)}for(var y=Object.keys(a.attr),_=0;_<y.length;_++){var E=y[_];if("ID"!==(t=E)&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t){var b=d[E];if(b)h&&!l.durationKnown&&(b.endTime=v);else if(f){var T=a.attr[E];C(E)&&(e=T,T=Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=mt(f,u,v,{key:E,data:T},vt);S&&(S.id=i,r.id3Track.addCue(S),d[E]=S)}}}n[i]={cues:d,dateRange:a,durationKnown:h}},p=0;p<o.length;p++)v()}}},e}(),bt=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){var r;t.details===b.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&A.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a&&t.live){var s=this.targetLatency;if(null!==s){var o=r-s;if(o<Math.min(this.maxLatency,s+t.targetduration)&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),l=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,l))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,u=this.hls.userConfig,l=o&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==a?a:s*i);var d=i;return l+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),e}(),Tt=["NONE","TYPE-0","TYPE-1",null];var St=["SDR","PQ","HLG"];var Lt="",kt="YES",wt="v2";function At(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?wt:kt:Lt}var xt=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),Rt=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return Dt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return Dt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}},t.addFallback=function(){},s(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),e}();function Dt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Ct(e,t){var r=t.startPTS;if(g(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&(i.duration=n)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function Pt(e,t,r,i,n,a){i-r<=0&&(A.warn("Fragment should have a positive duration",t),i=r+t.duration,a=n+t.duration);var s=r,o=i,u=t.startPTS,l=t.endPTS;if(g(u)){var d=Math.abs(u-r);g(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(r,u),r=Math.min(r,u),n=Math.min(n,t.startDTS),o=Math.min(i,l),i=Math.max(i,l),a=Math.max(a,t.endDTS)}var h=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=s,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=a;var c,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,c=v;c>0;c--)Ct(p[c],p[c-1]);for(c=v;c<p.length-1;c++)Ct(p[c],p[c+1]);return e.fragmentHint&&Ct(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function It(e,t){for(var r=null,i=e.fragments,n=i.length-1;n>=0;n--){var a=i[n].initSegment;if(a){r=a;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var s,u,l,d,h,c=0;if(function(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=n;l<=a;l++){var d=u[s+l],h=o[l];i&&!h&&l<i&&(h=t.fragments[l]=d),d&&h&&r(d,h)}}(e,t,(function(e,i){e.relurl&&(c=e.cc-i.cc),g(e.startPTS)&&g(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){A.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(u=e.dateRanges,l=t.dateRanges,d=t.recentlyRemovedDateranges,h=o({},u),d&&d.forEach((function(e){delete h[e]})),Object.keys(l).forEach((function(e){var t=new P(l[e].attr,h[e]);t.isValid?h[e]=t:A.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[e].attr)+'"')})),h));var v=t.fragments;if(c){A.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),s?Pt(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Ot(e,t),v.length&&(t.totalduration=t.edge-v[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function Ot(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||function(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}(t,i[r].start)}function Ft(e,t,r){var i;return null!=e&&e.details?Mt(null==(i=e.details)?void 0:i.partList,t,r):null}function Mt(e,t,r){if(e)for(var i=e.length;i--;){var n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function Bt(e){e.forEach((function(e,t){var r=e.details;null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t}))}))}function Nt(e){switch(e.details){case b.FRAG_LOAD_TIMEOUT:case b.KEY_LOAD_TIMEOUT:case b.LEVEL_LOAD_TIMEOUT:case b.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ut(e,t){var r=Nt(t);return e.default[(r?"timeout":"error")+"Retry"]}function Gt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Vt(e){return i(i({},e),{errorRetry:null,timeoutRetry:null})}function jt(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var Ht=function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function Kt(e,t,r,i,n){void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=.005);var a=null;if(e){a=t[e.sn-t[0].sn+1]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===zt(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}(a,e,Math.min(n,i))))return a;var o=Ht(t,zt.bind(null,r,i));return!o||o===e&&a?a:o}function zt(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Wt(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var qt=0,Yt=2,Xt=3,Qt=5,Jt=0,Zt=1,$t=2,er=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=A.log.bind(A,"[info]:"),this.warn=A.warn.bind(A,"[warning]:"),this.error=A.error.bind(A,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(e){},t.stopLoad=function(){this.playlistError=0},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===at?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var r,i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case b.FRAG_LOAD_ERROR:case b.FRAG_LOAD_TIMEOUT:case b.KEY_LOAD_ERROR:case b.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case b.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:qt,flags:Jt});case b.FRAG_GAP:case b.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Yt);case b.LEVEL_EMPTY_ERROR:case b.LEVEL_PARSING_ERROR:var s,o,u=t.parent===at?t.level:n.loadLevel;return void(t.details===b.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(o=s.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u)));case b.LEVEL_LOAD_ERROR:case b.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case b.AUDIO_TRACK_LOAD_ERROR:case b.AUDIO_TRACK_LOAD_TIMEOUT:case b.SUBTITLE_LOAD_ERROR:case b.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=n.levels[n.loadLevel];if(l&&(a.type===it&&l.hasAudioGroup(a.groupId)||a.type===nt&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Yt,void(t.errorAction.flags=Zt)}return;case b.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=n.levels[n.loadLevel],h=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(h?t.errorAction={action:Yt,flags:$t,hdcpLevel:h}:this.keySystemError(t));case b.BUFFER_ADD_CODEC_ERROR:case b.REMUX_ALLOC_ERROR:case b.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:n.loadLevel));case b.INTERNAL_EXCEPTION:case b.BUFFER_APPENDING_ERROR:case b.BUFFER_FULL_ERROR:case b.LEVEL_SWITCH_ERROR:case b.BUFFER_STALLED_ERROR:case b.BUFFER_SEEK_OVER_HOLE:case b.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:qt,flags:Jt})}t.type===E.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},t.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},t.getPlaylistRetryOrSwitchAction=function(e,t){var r=Ut(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(jt(r,i,Nt(e),e.response))return{action:Qt,flags:Jt,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],n=t.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=Ut(e.details.startsWith("key")?s:a,e),u=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==b.FRAG_GAP&&i.fragmentError++,jt(o,u,Nt(e),e.response)))return{action:Qt,flags:Jt,retryConfig:o,retryCount:u};var l=this.getLevelSwitchAction(e,r);return o&&(l.retryConfig=o,l.retryCount=u),l},t.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var n,a,s=e.details;i.loadError++,s===b.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,u=r.levels,l=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var c,f=null==(n=e.frag)?void 0:n.type,v=(f===st&&s===b.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===b.BUFFER_ADD_CODEC_ERROR||s===b.BUFFER_APPEND_ERROR))&&u.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),p="video"===e.sourceBufferName&&(s===b.BUFFER_ADD_CODEC_ERROR||s===b.BUFFER_APPEND_ERROR)&&u.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},m=g.type,y=g.groupId,_=function(){var t=(E+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var r,n,a=u[t];if(s===b.FRAG_GAP&&f===at&&e.frag){var c=u[t].details;if(c){var g=Kt(e.frag,c.fragments,e.frag.start);if(null!=g&&g.gap)return 0}}else{if(m===it&&a.hasAudioGroup(y)||m===nt&&a.hasSubtitleGroup(y))return 0;if(f===st&&null!=(r=i.audioGroups)&&r.some((function(e){return a.hasAudioGroup(e)}))||f===ot&&null!=(n=i.subtitleGroups)&&n.some((function(e){return a.hasSubtitleGroup(e)}))||v&&i.audioCodec===a.audioCodec||!v&&i.audioCodec!==a.audioCodec||p&&i.codecSet===a.codecSet)return 0}return o=t,1}},E=u.length;E--&&(0===(c=_())||1!==c););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Yt,flags:Jt,nextAutoLevel:o}}return{action:Yt,flags:Zt}},t.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case qt:break;case Yt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===b.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case Jt:this.switchLevel(e,a);break;case $t:n&&(t.maxHdcpLevel=Tt[Tt.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,a)}},t.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e}(),tr=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=A.log.bind(A,t+":"),this.warn=A.warn.bind(A,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},t.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){A.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var u=i[n],l=parseInt(u["LAST-MSN"])||(null==t?void 0:t.lastPartSn),d=parseInt(u["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=r&&At(r);return new xt(l,d>=0?d:void 0,c)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,a=t.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&It(r,n),!this.canLoad||!n.live)return;var u,l=void 0,d=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var h=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,v=n.lastPartIndex,p=c===f;-1!==v?(l=p?f+1:c,d=p?h?0:v:v+1):l=f+1;var g=n.age,m=g+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var _=Math.floor(y/n.targetduration);l+=_,void 0!==d&&(d+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+_+" to part "+d)}n.tuneInGoal=y}if(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d),h||!p)return void this.loadPlaylist(u)}else(n.canBlockReload||n.canSkipUntil)&&(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d));var E=this.hls.mainForwardBufferInfo,b=E?E.end-E.len:0,T=function(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}(n,1e3*(n.edge-b));n.updated&&s>this.requestScheduled+T&&(this.requestScheduled=a.loading.start),void 0!==l&&n.canBlockReload?this.requestScheduled=a.loading.first+T-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+T<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=T);var S=this.requestScheduled-s;S=Math.max(0,S),this.log("reload live playlist "+e+" in "+Math.round(S)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(u)}),S)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var n=At(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Lt),new xt(r,i,n)},t.checkRetry=function(e){var t=this,r=e.details,i=Nt(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,u=void 0===o?0:o,l=a.retryConfig,d=!!n&&!!l&&(s===Qt||!n.resolved&&s===Yt);if(d){var h;if(this.requestScheduled=-1,u>=l.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var c=Gt(l,u);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" in '+c+"ms")}e.levelRetry=!0,n.resolved=!0}return d},e}(),rr=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),ir=function(){function e(e,t,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new rr(e),this.fast_=new rr(t),this.defaultTTFB_=i,this.ttfb_=new rr(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new rr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new rr(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new rr(e,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}();function nr(e,t){var r=!1,i=[];return e&&(r="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||St.slice(0),i=(r=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())?i.filter((function(e){return"SDR"!==e})):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function ar(e,t){A.log('[abr] start candidates with "'+e+'" ignored because '+t)}var sr=function(){function e(e){var t=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var e=t.fragCurrent,r=t.partCurrent,i=t.hls,n=i.autoLevelEnabled,a=i.media;if(e&&a){var s=performance.now(),o=r?r.stats:e.stats,u=r?r.duration:e.duration,l=s-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=d)return t.clearTimer(),void(t._nextAutoLevel=-1);if(n&&!a.paused&&a.playbackRate&&a.readyState){var h=i.mainForwardBufferInfo;if(null!==h){var c=t.bwEstimator.getEstimateTTFB(),f=Math.abs(a.playbackRate);if(!(l<=Math.max(c,u/(2*f)*1e3))){var v=h.len/f,p=o.loading.first?o.loading.first-o.loading.start:-1,m=o.loaded&&p>-1,y=t.getBwEstimate(),E=i.levels,b=E[e.level],T=o.total||Math.max(o.loaded,Math.round(u*b.averageBitrate/8)),S=m?l-p:l;S<1&&m&&(S=Math.min(l,8*o.loaded/y));var L=m?1e3*o.loaded/S:0,k=L?(T-o.loaded)/L:8*T/y+c/1e3;if(!(k<=v)){var w,x=L?8*L:y,R=Number.POSITIVE_INFINITY;for(w=e.level-1;w>d;w--){var D=E[w].maxBitrate;if((R=t.getTimeToLoadFrag(c/1e3,x,u*D,!E[w].details))<v)break}if(!(R>=k||R>10*u)){i.nextLoadLevel=i.nextAutoLevel=w,m?t.bwEstimator.sample(l-Math.min(c,p),o.loaded):t.bwEstimator.sampleTTFB(l);var C=E[w].maxBitrate;t.getBwEstimate()*t.hls.config.abrBandWidthUpFactor>C&&t.resetEstimator(C),t.clearTimer(),A.warn("[abr] Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+v.toFixed(3)+" s\n Estimated load time for current fragment: "+k.toFixed(3)+" s\n Estimated load time for down switch fragment: "+R.toFixed(3)+" s\n TTFB estimate: "+(0|p)+" ms\n Current BW estimate: "+(g(y)?0|y:"Unknown")+" bps\n New BW estimate: "+(0|t.getBwEstimate())+" bps\n Switching to level "+w+" @ "+(0|C)+" bps"),i.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:o})}}}}}}},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}var t=e.prototype;return t.resetEstimator=function(e){e&&(A.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},t.initEstimator=function(){var e=this.hls.config;return new ir(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(_.ERROR,this.onError,this))},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},t.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},t.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},t.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},t.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},t.onLevelSwitching=function(e,t){this.clearTimer()},t.onError=function(e,t){if(!t.fatal)switch(t.details){case b.BUFFER_ADD_CODEC_ERROR:case b.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case b.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,u=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(l,u),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},t.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},t.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,n=i.end-i.start;g(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(r.type===at&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,u=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:u},s.realBitrate=Math.round(8*o/u)}if(r.bitrateTest){var l={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(_.FRAG_BUFFERED,l),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},t.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},t.ignoreFragment=function(e){return e.type!==at||"initSegment"===e.sn},t.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},t.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),u=this.getStarvationDelay(),l=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(o,a,i,u,0,l,d);if(h>=0)return h}var c=s?Math.min(s,n.maxStarvationDelay):n.maxStarvationDelay;if(!u){var f=this.bitrateTestDelay;f&&(c=(s?Math.min(s,n.maxLoadingDelay):n.maxLoadingDelay)-f,A.info("[abr] bitrate test took "+Math.round(1e3*f)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),l=d=1)}var v=this.findBestLevel(o,a,i,u,c,l,d);if(A.info("[abr] "+(u?"rebuffering expected":"buffer is empty")+", optimal quality level "+v),v>-1)return v;var p=r.levels[a],g=r.levels[r.loadLevel];return(null==p?void 0:p.bitrate)<(null==g?void 0:g.bitrate)?a:r.loadLevel},t.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r},t.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},t.findBestLevel=function(e,t,r,i,n,a,s){var o,u=this,l=i+n,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,f=this.partCurrent,v=this.hls,p=v.levels,m=v.allAudioTracks,y=v.loadLevel,_=v.config;if(1===p.length)return 0;var E,b=p[h],T=!(null==b||null==(o=b.details)||!o.live),S=-1===y||-1===d,L="SDR",k=(null==b?void 0:b.frameRate)||0,w=_.audioPreference,x=_.videoPreference;this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce((function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(m));if(S){if(-1!==this.firstSelection)return this.firstSelection;var R=function(e,t,r,i,n){for(var a=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,u=s&&2===parseInt(s),l=!0,d=!1,h=1/0,c=1/0,f=1/0,v=0,p=[],m=nr(t,n),y=m.preferHDR,_=m.allowedVideoRanges,E=function(){var t=e[a[b]];l=t.channels[2]>0,h=Math.min(h,t.minHeight),c=Math.min(c,t.minFramerate),f=Math.min(f,t.minBitrate);var r=_.filter((function(e){return t.videoRanges[e]>0}));r.length>0&&(d=!0,p=r)},b=a.length;b--;)E();h=g(h)?h:0,c=g(c)?c:0;var T=Math.max(1080,h),S=Math.max(30,c);return f=g(f)?f:r,r=Math.max(f,r),d||(t=void 0,p=[]),{codecSet:a.reduce((function(t,i){var n=e[i];if(i===t)return t;if(n.minBitrate>r)return ar(i,"min bitrate of "+n.minBitrate+" > current estimate of "+r),t;if(!n.hasDefaultAudio)return ar(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return ar(i,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!n.channels[s])return ar(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(n.channels)+")"),t}else if((!o||u)&&l&&0===n.channels[2])return ar(i,"no renditions with stereo sound found"),t;return n.minHeight>T?(ar(i,"min resolution of "+n.minHeight+" > maximum of "+T),t):n.minFramerate>S?(ar(i,"min framerate of "+n.minFramerate+" > maximum of "+S),t):p.some((function(e){return n.videoRanges[e]>0}))?n.maxScore<v?(ar(i,"max score of "+n.maxScore+" < selected max of "+v),t):t&&(Be(i)>=Be(t)||n.fragmentError>e[t].fragmentError)?t:(v=n.maxScore,i):(ar(i,"no variants with VIDEO-RANGE of "+JSON.stringify(p)+" found"),t)}),void 0),videoRanges:p,preferHDR:y,minFramerate:c,minBitrate:f}}(this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((function(e,t){if(!t.codecSet)return e;var r=t.audioGroups,i=e[t.codecSet];i||(e[t.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,t.bitrate);var n=Math.min(t.height,t.width);return i.minHeight=Math.min(i.minHeight,n),i.minFramerate=Math.min(i.minFramerate,t.frameRate),i.maxScore=Math.max(i.maxScore,t.score),i.fragmentError+=t.fragmentError,i.videoRanges[t.videoRange]=(i.videoRanges[t.videoRange]||0)+1,e}),{})}(p,0,t,r)),L,e,w,x),D=R.codecSet,C=R.videoRanges,P=R.minFramerate,I=R.minBitrate,O=R.preferHDR;E=D,L=O?C[C.length-1]:C[0],k=P,e=Math.max(e,I),A.log("[abr] picked start tier "+JSON.stringify(R))}else E=null==b?void 0:b.codecSet,L=null==b?void 0:b.videoRange;for(var F,M=f?f.duration:c?c.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,N=[],U=function(){var t,o=p[G],c=G>h;if(!o)return 0;if(E&&o.codecSet!==E||L&&o.videoRange!==L||c&&k>o.frameRate||!c&&k>0&&k<o.frameRate||o.supportedResult&&(null==(t=o.supportedResult.decodingInfoResults)||!t[0].smooth))return N.push(G),0;var v,m=o.details,_=(f?null==m?void 0:m.partTarget:null==m?void 0:m.averagetargetduration)||M;v=c?s*e:a*e;var w=M&&i>=2*M&&0===n?p[G].averageBitrate:p[G].maxBitrate,x=u.getTimeToLoadFrag(B,v,w*_,void 0===m);if(v>=w&&(G===d||0===o.loadError&&0===o.fragmentError)&&(x<=B||!g(x)||T&&!u.bitrateTestDelay||x<l)){var R=u.forcedAutoLevel;return G===y||-1!==R&&R===y||(N.length&&A.trace("[abr] Skipped level(s) "+N.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+p[N[0]].codecs+'" '+p[N[0]].videoRange+'; not compatible with "'+b.codecs+'" '+L),A.info("[abr] switch candidate:"+h+"->"+G+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-w)+" ttfb:"+B.toFixed(1)+" avgDuration:"+_.toFixed(1)+" maxFetchDuration:"+l.toFixed(1)+" fetchDuration:"+x.toFixed(1)+" firstSelection:"+S+" codecSet:"+E+" videoRange:"+L+" hls.loadLevel:"+y)),S&&(u.firstSelection=G),{v:G}}},G=r;G>=t;G--)if(0!==(F=U())&&F)return F.v;return-1},s(e,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,a=this.findBestLevel(i,r,t,0,n,1,1);if(a>-1)return a;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return A.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),e}(),or={length:0,start:function(){return 0},end:function(){return 0}},ur=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,u=0,l=t,d=t,h=0;h<i.length;h++){var c=i[h].start,f=i[h].end;if(t+r>=c&&t<f)l=c,u=(d=f)-t;else if(t+r<c){o=c;break}}return{len:u,start:l||0,end:d||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return A.log("failed to get media.buffered",e),or}},e}(),lr=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,r){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){A.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+t),r.onError(t);var i=this.buffers[e];null!=i&&i.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),dr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hr=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(e){t.hls&&t.hls.pauseBuffering()},this._onStartStreaming=function(e){t.hls&&t.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var e=t.media,r=t.mediaSource;t.log("Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(_.MEDIA_ATTACHED,{media:e,mediaSource:r})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){t.log("Media source closed")},this._onMediaSourceEnded=function(){t.log("Media source ended")},this._onMediaEmptied=function(){var e=t.mediaSrc,r=t._objectUrl;e!==r&&A.error("Media element src was set while attaching MediaSource ("+r+" > "+e+")")},this.hls=e;var r,i="[buffer-controller]";this.appendSource=(r=Ce(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.log=A.log.bind(A,i),this.warn=A.warn.bind(A,i),this.error=A.error.bind(A,i),this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},t.registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new lr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){t.audio&&!t.video||t.altAudio,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=1,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media,i=Ce(this.appendSource);if(r&&i){var n,a=this.mediaSource=new i;this.log("created media source: "+(null==(n=a.constructor)?void 0:n.name)),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));var s=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,cr(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(e){r.src=s}else r.src=s;r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&cr(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(_.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){e.resetBuffer(t)})),this._initSourceBuffer()},t.resetBuffer=function(e){var t=this.sourceBuffer[e];try{var r;t&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t))}catch(t){this.warn("onBufferReset "+e,t)}},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length,n=Object.keys(t);if(n.forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var a,s=t[e],o=s.id,u=s.codec,l=s.levelCodec,d=s.container,h=s.metadata,c=Ve(n.codec,n.levelCodec),f=null==c?void 0:c.replace(dr,"$1"),v=Ve(u,l),p=null==(a=v)?void 0:a.replace(dr,"$1");if(v&&f!==p){"audio"===e.slice(0,5)&&(v=Ge(v,r.appendSource));var g=d+";codecs="+v;r.appendChangeType(e,g),r.log("switching codec "+c+" to "+v),r.tracks[e]={buffer:n.buffer,codec:u,container:d,levelCodec:l,metadata:h,id:o}}}}else r.pendingTracks[e]=t[e]})),!i){var a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(a+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(r.log("changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){r.warn("Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e,!!this.pendingTracks[e])},t.onBufferAppending=function(e,t){var r=this,i=this.hls,n=this.operationQueue,a=this.tracks,s=t.data,o=t.type,u=t.frag,l=t.part,d=t.chunkMeta,h=d.buffering[o],c=self.performance.now();h.start=c;var f=u.stats.buffering,v=l?l.stats.buffering:null;0===f.start&&(f.start=c),v&&0===v.start&&(v.start=c);var p=a.audio,g=!1;"audio"===o&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var m=u.start,y={execute:function(){if(h.executeStart=self.performance.now(),g){var e=r.sourceBuffer[o];if(e){var t=m-e.timestampOffset;Math.abs(t)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+m+" (delta: "+t+") sn: "+u.sn+")"),e.timestampOffset=m)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var e=self.performance.now();h.executeEnd=h.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t=r.sourceBuffer,i={};for(var n in t)i[n]=ur.getBuffered(t[n]);r.appendErrors[o]=0,"audio"===o||"video"===o?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(_.BUFFER_APPENDED,{type:o,frag:u,part:l,chunkMeta:d,parent:u.type,timeRanges:i})},onError:function(e){var t={type:E.MEDIA_ERROR,parent:u.type,details:b.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:u,part:l,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=b.BUFFER_FULL_ERROR;else{var n=++r.appendErrors[o];t.details=b.BUFFER_APPEND_ERROR,r.warn("Failed "+n+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+o+'" sourceBuffer'),n>=i.config.appendErrorMaxRetry&&(t.fatal=!0)}i.trigger(_.ERROR,t)}};n.append(y,o,!!this.pendingTracks[o])},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,n=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(_.BUFFER_FLUSHED,{type:e})},onError:function(t){r.warn("Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(n(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(n(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[M]?a.push("audiovideo"):(s[O]&&a.push("audio"),s[F]&&a.push("video"));0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(_.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)},t.onFragChanged=function(e,t){this.trimBuffers()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return!n||t.type&&t.type!==i||(n.ending=!0,n.ended||(n.ended=!0,r.log(i+" sourceBuffer now EOS"))),e&&!(n&&!n.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(r.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.getSourceBufferTypes().length){var i=e.config,n=r.currentTime,a=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(g(s)&&s>0){var o=Math.max(s,a),u=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,u)}if(g(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var l=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),d=Math.max(l,a),h=Math.floor(n/a)*a+d;this.flushFrontBuffer(n,a,h)}}},t.flushBackBuffer=function(e,t,r){var i=this,n=this.details,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(s){var o=a[s];if(o){var u=ur.getBuffered(o);if(u.length>0&&r>u.start(0)){if(i.hls.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=n&&n.live)i.hls.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&u.end(u.length-1)-e<2*t)return void i.log("Cannot flush "+s+" back buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))},t.flushFrontBuffer=function(e,t,r){var i=this,n=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(a){var s=n[a];if(s){var o=ur.getBuffered(s),u=o.length;if(u<2)return;var l=o.start(u-1),d=o.end(u-1);if(r>l||e>=l&&e<=d)return;if(s.ended&&e-d<2*t)return void i.log("Cannot flush "+a+" front buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:a})}}))},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,n=e.fragments[0].start+e.totalduration,a=r.duration,s=g(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(n>s&&n>a||!g(a))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+i+"-"+n+"."),t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(_.BUFFER_CREATED,{tracks:this.tracks}),n.forEach((function(e){t.executeNext(e)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},t.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=function(n){if(!r[n]){var a,s=e[n];if(!s)throw Error("source buffer exists for track "+n+", however track does not");var o=-1===(null==(a=s.levelCodec)?void 0:a.indexOf(","))?s.levelCodec:s.codec;o&&"audio"===n.slice(0,5)&&(o=Ge(o,t.appendSource));var u=s.container+";codecs="+o;t.log("creating sourceBuffer("+u+")");try{var l=r[n]=i.addSourceBuffer(u),d=n;t.addBufferListener(d,"updatestart",t._onSBUpdateStart),t.addBufferListener(d,"updateend",t._onSBUpdateEnd),t.addBufferListener(d,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(d,"bufferedchange",(function(e,r){var i=r.removedRanges;null!=i&&i.length&&t.hls.trigger(_.BUFFER_FLUSHED,{type:n})})),t.tracks[n]={buffer:l,codec:o,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:u})}}};for(var a in e)n(a)},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.operationQueue;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}else this.resetBuffer(e)},t._onSBUpdateError=function(e,t){var r,i=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,t),this.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var n=this.operationQueue.current(e);n&&n.onError(i)},t.removeExecutor=function(e,t,r){var i=this.media,n=this.mediaSource,a=this.operationQueue,s=this.sourceBuffer[e];if(!i||!n||!s)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(e);var o=g(i.duration)?i.duration:1/0,u=g(n.duration)?n.duration:1/0,l=Math.max(0,t),d=Math.min(r,o,u);d>l&&(!s.ending||s.ended)?(s.ended=!1,this.log("Removing ["+l+","+d+"] from the "+e+" SourceBuffer"),s.remove(l,d)):a.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(r)r.ended=!1,r.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist")},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},s(e,[{key:"mediaSrc",get:function(){var e,t=(null==(e=this.media)?void 0:e.firstChild)||this.media;return null==t?void 0:t.src}}]),e}();function cr(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}var fr=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&g(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&A.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i=e.length-1,n=Math.max(t,r),a=0;a<e.length;a+=1){var s=e[a];if((s.width>=n||s.height>=n)&&(o=s,!(u=e[a+1])||o.width!==u.width||o.height!==u.height)){i=a;break}}var o,u;return i},s(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),e}(),vr=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,u=this.hls;if(u.trigger(_.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>u.config.fpsDroppedMonitoringThreshold*s){var l=u.currentLevel;A.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(_.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),pr=function(){function e(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=A.log.bind(A,"[content-steering]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.ERROR,this.onError,this))},t.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},t.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},t.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},t.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},t.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},t.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},t.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},t.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},t.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===Yt&&r.flags===Zt){var i=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,u=s.pathwayId,l=s.type;o&&i?a=this.getPathwayForGroupId(o,l,a):u&&(a=u)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&i&&(n=i.reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||A.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+a+" levels: "+(i?i.length:i)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},t.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var n=0;n<e.length;n++){var a=e[n];if(!(a in r)){if(a===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(a)).length>0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,Bt(t),this.hls.trigger(_.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[s];o&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=s);break}}}},t.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),n=0;n<i.length;n++)if(t===it&&i[n].hasAudioGroup(e)||t===nt&&i[n].hasSubtitleGroup(e))return i[n].pathwayId;return r},t.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},n={};e.forEach((function(e){var a=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===a}))){var u=t.getLevelsForPathway(s).map((function(e){var t=new D(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&t.AUDIO+"_clone_"+a,s=t.SUBTITLES&&t.SUBTITLES+"_clone_"+a;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=mr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new Rt({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",e.audioGroups[d]+"_clone_"+a);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",e.subtitleGroups[h]+"_clone_"+a);return l}));r.push.apply(r,u),gr(t.audioTracks,i,o,a),gr(t.subtitleTracks,n,o,a)}}))}},t.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,u=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:function(e,i,n,a){r.log('Loaded steering manifest: "'+t+'"');var s=e.data;if(1===s.VERSION){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],u=s["PATHWAY-CLONES"],l=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||n.url),u&&r.clonePathways(u);var d={steeringManifest:s,url:t.toString()};r.hls.trigger(_.STEERING_MANIFEST_LOADED,d),l&&r.updatePathwayPriority(l)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(e,t,i,n){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,a);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(s,l,d)},t.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var t,i=null==(t=r.hls)?void 0:t.media;!i||i.ended?r.scheduleRefresh(e,1e3*r.timeToLoad):r.loadSteeringManifest(e)}),t)},e}();function gr(e,t,r,i){e&&Object.keys(t).forEach((function(n){var a=e.filter((function(e){return e.groupId===n})).map((function(e){var a=o({},e);return a.details=void 0,a.attrs=new D(a.attrs),a.url=a.attrs.URI=mr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[n],a.attrs["PATHWAY-ID"]=i,a}));e.push.apply(e,a)}))}function mr(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var u=new self.URL(e);return a&&!n&&(u.host=a),s&&Object.keys(s).sort().forEach((function(e){e&&u.searchParams.set(e,s[e])})),u.href}var yr=/^age:\s*[\d.]+\s*$/im,_r=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new I,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,n=r.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);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,self.clearTimeout(this.requestTimeout),r.timeout=a&&g(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,s="text"!==t.responseType;if(a>=200&&a<300&&(s&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?t.response:t.responseText,u="arraybuffer"===t.responseType?o.byteLength:o.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(r,e,o,t),!this.callbacks)return;var d={url:t.responseURL,data:o,code:a};this.callbacks.onSuccess(d,r,e,t)}else{var h=n.loadPolicy.errorRetry;jt(h,r.retry,!1,{url:e.url,data:void 0,code:a})?this.retry(h):(A.error(a+" while loading "+e.url),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(jt(e,this.stats.retry,!0))this.retry(e);else{var t;A.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,A.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&yr.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),Er=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();var br=/(\d+)-(\d+)\/(\d+)/,Tr=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Sr,this.controller=new self.AbortController,this.stats=new I}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(o({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),s=r.onProgress,u="arraybuffer"===e.responseType,l=u?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,c=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=h&&g(h)?h:c,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=c,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),c-(o-n.loading.start)),!a.ok){var l=a.status,d=a.statusText;throw new kr(d||"fetch, bad network response",l,a)}return n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=br.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(g(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&g(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):u?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var d={url:o.url,data:a,code:o.status};s&&!g(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(d,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var a=new Er,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));var u=s.value,l=u.length;return t.loaded+=l,l<i||a.dataLength?(a.push(u),a.dataLength>=i&&n(t,r,a.flush(),e)):n(t,r,u,e),o()})).catch((function(){return Promise.reject()}))}()},e}();function Sr(e,t){return new self.Request(e.url,t)}var Lr,kr=function(e){function t(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return u(t,e),t}(c(Error)),wr=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_r,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:sr,bufferController:hr,capLevelController:fr,errorController:er,fpsController:vr,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:V,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:pr});function Ar(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Ar):Object.keys(e).reduce((function(t,r){return t[r]=Ar(e[r]),t}),{}):e}function xr(e){var t=e.loader;t!==Tr&&t!==_r?(A.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Tr,e.progressive=!0,e.enableSoftwareAES=!0,A.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Rr=function(e){function t(t,r){var i;return(i=e.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this.hls.config.preferManagedMediaSource,i=[],n={},a={},s=!1,o=!1,u=!1;t.levels.forEach((function(e){var t,l,d=e.attrs,h=e.audioCodec,c=e.videoCodec;-1!==(null==(t=h)?void 0:t.indexOf("mp4a.40.34"))&&(Lr||(Lr=/chrome|firefox/i.test(navigator.userAgent)),Lr&&(e.audioCodec=h=void 0)),h&&(e.audioCodec=h=Ge(h,r)),0===(null==(l=c)?void 0:l.indexOf("avc1"))&&(c=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n=i.shift()+".";n+=parseInt(i.shift()).toString(16),n+=("000"+parseInt(i.shift()).toString(16)).slice(-4),t[r]=n}}return t.join(",")}(c));var f=e.width,v=e.height,p=e.unknownCodecs;if(s||(s=!(!f||!v)),o||(o=!!c),u||(u=!!h),!(null!=p&&p.length||h&&!Ie(h,"audio",r)||c&&!Ie(c,"video",r))){var g=d.CODECS,m=d["FRAME-RATE"],y=d["HDCP-LEVEL"],_=d["PATHWAY-ID"],E=d.RESOLUTION,b=d["VIDEO-RANGE"],T=(_||".")+"-"+e.bitrate+"-"+E+"-"+m+"-"+g+"-"+b+"-"+y;if(n[T])if(n[T].uri===e.url||e.attrs["PATHWAY-ID"])n[T].addGroupId("audio",d.AUDIO),n[T].addGroupId("text",d.SUBTITLES);else{var S=a[T]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var L=new Rt(e);n[T]=L,i.push(L)}else{var k=new Rt(e);n[T]=k,a[T]=1,i.push(k)}}})),this.filterAndSortMediaOptions(i,t,s,o,u)},r.filterAndSortMediaOptions=function(e,t,r,i,n){var a=this,s=[],o=[],u=e;if((r||i)&&n&&(u=u.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&St.indexOf(t)>-1)}))),0!==u.length){if(t.audioTracks){var l=this.hls.config.preferManagedMediaSource;Dr(s=t.audioTracks.filter((function(e){return!e.audioCodec||Ie(e.audioCodec,"audio",l)})))}t.subtitles&&Dr(o=t.subtitles);var d=u.slice(0);u.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return St.indexOf(e.videoRange)-St.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Me(e.videoCodec),n=Me(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=Be(e.codecSet),s=Be(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var f=0;f<u.length;f++)if(u[f]===h){var v;this._firstLevel=f;var p=h.bitrate,g=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+p),void 0===(null==(v=this.hls.userConfig)?void 0:v.abrEwmaDefaultEstimate)){var m=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);m>g&&g===wr.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var y=n&&!i,T={levels:u,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!y&&s.some((function(e){return!!e.url}))};this.hls.trigger(_.MANIFEST_PARSED,T),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===rt&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(void 0!==r&&r.type===at){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var n=this._levels[r.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,t,s.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.uri;if(t)try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with"+(a?" Pathway "+a:"")+" "+n),this.clearTimer(),this.hls.trigger(_.LEVEL_LOADING,{url:n,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},r.removeLevel=function(e){var t,r=this,i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));Bt(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(_.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(_.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},s(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(_.ERROR,{type:E.OTHER_ERROR,details:b.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=t[e],u=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,n!==e||!o.details||!a||s!==u){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(u?" with Pathway "+u:"")+" from level "+n+(s?" with Pathway "+s:""));var l={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(_.LEVEL_SWITCHING,l);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==a?void 0:a.details,d);this.loadPlaylist(h)}}}}},{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.hls.firstAutoLevel}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}(tr);function Dr(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Cr="NOT_LOADED",Pr="APPENDING",Ir="PARTIAL",Or="OK",Fr=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[e];o&&o.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=Br(i),s=this.fragments[a];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var u=r[e],l=o||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,u)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Mr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var r=Br(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,u=e.maxStartPTS||a,l=0;l<i.length;l++){var d=i.start(l)-this.bufferPadding,h=i.end(l)+this.bufferPadding;if(u>=d&&o<=h){n.time.push({startPTS:Math.max(a,i.start(l)),endPTS:Math.min(s,i.end(l))});break}if(a<h&&s>d){var c=Math.max(a,i.start(l)),f=Math.min(s,i.end(l));f>c&&(n.partial=!0,n.time.push({startPTS:c,endPTS:f}))}else if(s<=d)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(u){var l=o[u];l&&Mr(l)&&(r=l.body.start-s,i=l.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=l.body,a=t)))})),n},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Mr(t))},t.getState=function(e){var t=Br(e),r=this.fragments[t];return r?r.buffered?Mr(r)?Ir:Or:Pr:Cr},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:t,a=Br(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,a=t.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(e){var t=a[e];r.detectEvictedFragments(e,t,s,n)}))}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Br(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var u=o.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(o.buffered||n)&&a.removeFragment(u)}}))},t.removeFragment=function(e){var t=Br(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Mr(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Br(e){return e.type+"_"+e.level+"_"+e.sn}var Nr=Math.pow(2,17),Ur=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,n=e.url;if(!n)return Promise.reject(new jr({type:E.NETWORK_ERROR,details:b.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void l(Vr(e));e.gap=!1}var d=r.loader=e.loader=s?new s(a):new o(a),h=Gr(e),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Nr};e.stats=d.stats,d.load(h,f,{onSuccess:function(t,i,n,a){r.resetLoader(e,d);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),u({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,a,s,o){r.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:i({url:n,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:s,stats:o}))},onAbort:function(t,i,n){r.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,i,n){r.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:n,stats:t}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)l(Vr(e,t));else{var d=n.loader=e.loader=s?new s(a):new o(a),h=Gr(e,t),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Nr};t.stats=d.stats,d.load(h,f,{onSuccess:function(i,a,s,o){n.resetLoader(e,d),n.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:i.data,networkDetails:o};r(l),u(l)},onError:function(r,a,s,o){n.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:i({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,a){e.stats.aborted=t.stats.aborted,n.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,i,a){n.resetLoader(e,d),l(new jr({type:E.NETWORK_ERROR,details:b.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var u=r.loading,l=i.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Gr(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(g(n)&&g(a)){var s,o=n,u=a;if("initSegment"===e.sn&&"AES-128"===(null==(s=e.decryptdata)?void 0:s.method)){var l=a-n;l%16&&(u=a+(16-l%16)),0!==n&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=u}return i}function Vr(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:E.MEDIA_ERROR,details:b.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new jr(i)}var jr=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return u(t,e),t}(c(Error)),Hr=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,i,n){return void 0===t&&(t=b.KEY_LOAD_ERROR),new jr({type:E.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),1},s=0;s<t.length&&!a();s++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)},t.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,b.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,b.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o,u=this.keyUriToKeyInfo[s];if(null!=(r=u)&&r.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(null!=(i=u)&&i.keyLoadPromise)switch(null==(o=u.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then((function(t){return n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:u}}))}switch(u=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,b.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+n.method+'"')))}},t.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)},t.loadKeyHTTP=function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(s,o){var u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,n){var a=i.frag,u=i.keyInfo,l=i.url;if(!a.decryptdata||u!==r.keyUriToKeyInfo[l])return o(r.createKeyLoadError(a,b.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));u.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,u.loader=null,s({frag:a,keyInfo:u})},onError:function(e,n,a,s){r.resetLoader(n),o(r.createKeyLoadError(t,b.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),a,i({url:u.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,b.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,b.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};a.load(u,d,h)}))},t.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},e}(),Kr=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),zr=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a};function Wr(e,t){for(var r=0,i=e.length;r<i;r++){var n;if((null==(n=e[r])?void 0:n.cc)===t)return e[r]}return null}function qr(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function Yr(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)qr(r[i],e);t.fragmentHint&&qr(t.fragmentHint,e),t.alignedSliding=!0}function Xr(e,t,r){t&&(function(e,t,r){if(function(e,t,r){return!(!t||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}(e,r,t)){var i=function(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var n=Wr(r,i[0].cc);if(n&&(!n||n.startPTS))return n;A.log("No frag in previous level to align on")}else A.log("No fragments to align")}(r,t);i&&g(i.start)&&(A.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Yr(i.start,t))}}(e,r,t),!r.alignedSliding&&t&&function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(n=Wr(i,s),a=Wr(r,s)),n&&a||(a=Wr(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,u=a.programDateTime;o&&u&&Yr((u-o)/1e3-(a.start-n.start),e)}}}(r,t),r.alignedSliding||!t||r.skippedSegments||Ot(t,r))}var Qr=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),Jr=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}();var Zr=function(){function 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.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,u=o[0],l=o[1],d=o[2],h=o[3],c=new Uint32Array(256),f=0,v=0,p=0;for(p=0;p<256;p++)c[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=v^v<<1^v<<2^v<<3^v<<4;g=g>>>8^255&g^99,e[f]=g,t[g]=f;var m=c[f],y=c[m],_=c[y],E=257*c[g]^16843008*g;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*_^65537*y^257*m^16843008*f,u[g]=E<<24|E>>>8,l[g]=E<<16|E>>>16,d[g]=E<<8|E>>>24,h[g]=E,f?(f=m^c[c[c[_^m]]],v^=c[c[v]]):f=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,u,l=this.ksRows=4*(n+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,f=this.rcon,v=this.invSubMix,p=v[0],g=v[1],m=v[2],y=v[3];for(a=0;a<l;a++)a<n?o=d[a]=t[a]:(u=o,a%n==0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=f[a/n|0]<<24):n>6&&a%n==4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[a]=o=(d[a-n]^u)>>>0);for(s=0;s<l;s++)a=l-s,u=3&s?d[a]:d[a-4],h[s]=s<4||a<=4?u:p[c[u>>>24]]^g[c[u>>>16&255]]^m[c[u>>>8&255]]^y[c[255&u]],h[s]=h[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,u,l,d,h,c,f,v,p,g,m=this.keySize+6,y=this.invKeySchedule,_=this.invSBox,E=this.invSubMix,b=E[0],T=E[1],S=E[2],L=E[3],k=this.uint8ArrayToUint32Array_(r),w=k[0],A=k[1],x=k[2],R=k[3],D=new Int32Array(e),C=new Int32Array(D.length),P=this.networkToHostOrderSwap;t<D.length;){for(h=P(D[t]),c=P(D[t+1]),f=P(D[t+2]),v=P(D[t+3]),o=h^y[0],u=v^y[1],l=f^y[2],d=c^y[3],p=4,g=1;g<m;g++)i=b[o>>>24]^T[u>>16&255]^S[l>>8&255]^L[255&d]^y[p],n=b[u>>>24]^T[l>>16&255]^S[d>>8&255]^L[255&o]^y[p+1],a=b[l>>>24]^T[d>>16&255]^S[o>>8&255]^L[255&u]^y[p+2],s=b[d>>>24]^T[o>>16&255]^S[u>>8&255]^L[255&l]^y[p+3],o=i,u=n,l=a,d=s,p+=4;i=_[o>>>24]<<24^_[u>>16&255]<<16^_[l>>8&255]<<8^_[255&d]^y[p],n=_[u>>>24]<<24^_[l>>16&255]<<16^_[d>>8&255]<<8^_[255&o]^y[p+1],a=_[l>>>24]<<24^_[d>>16&255]<<16^_[o>>8&255]<<8^_[255&u]^y[p+2],s=_[d>>>24]<<24^_[o>>16&255]<<16^_[u>>8&255]<<8^_[255&l]^y[p+3],C[t]=P(i^w),C[t+1]=P(s^A),C[t+2]=P(a^x),C[t+3]=P(n^R),w=h,A=c,x=f,R=v,t+=4}return C.buffer},e}(),$r=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?j(r,0,i-n):r):a},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise((function(n,a){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();s?n(s.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(e=ke(a,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new Zr),o.expandKey(t);var u=n;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=j(s,-16).buffer,u||null},t.webCryptoDecrypt=function(e,t,r){var i=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Jr(this.subtle,t)}return this.fastAesKey.expandKey().then((function(t){return i.subtle?(i.logOnce("WebCrypto AES decrypt"),new Qr(i.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return A.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),i.onWebCryptoError(e,t,r)}))},t.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=j(e,0,r),this.remainderData=j(e,r)),t},t.logOnce=function(e){this.logEnabled&&(A.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),ei=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t},ti="STOPPED",ri="IDLE",ii="KEY_LOADING",ni="FRAG_LOADING",ai="FRAG_LOADING_WAITING_RETRY",si="PARSING",oi="PARSED",ui="ENDED",li="ERROR",di="WAITING_LEVEL",hi=function(e){function t(t,r,i,n,a){var s;return(s=e.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=ti,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.loadedmetadata=!1,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.playlistType=a,s.logPrefix=n,s.log=A.log.bind(A,n+":"),s.warn=A.warn.bind(A,n+":"),s.hls=t,s.fragmentLoader=new Ur(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new $r(t.config),t.on(_.MANIFEST_LOADED,s.onManifestLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}u(t,e);var r=t.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ti},r._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){var i=r[r.length-1];return ur.isBuffered(this.media,i.start+i.duration/2)}var n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)},r.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details},r.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===ti&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,n=this.state,a=r?r.currentTime:0,s=ur.bufferInfo(i||r,a,e.maxBufferHole);if(this.log("media seeking to "+(g(a)?a.toFixed(3):a)+", state: "+n),this.state===ui)this.resetLoadingState();else if(t){var o=e.maxFragLookUpTolerance,u=t.start-o,l=t.start+t.duration+o;if(!s.len||l<s.start||u>s.end){var d=a>l;(a<u||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.hls.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=null},r.onHandlerDestroyed=function(){this.state=ti,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},r._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){var r=i.state;i.fragContextChanged(e)?(r===ni||!i.fragCurrent&&r===si)&&(i.fragmentTracker.removeFragment(e),i.state=ri):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(_.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==ti&&i.state!==li&&(i.warn("Frag error: "+((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))},r.clearTrackerIfNeeded=function(e){var t,r=this.fragmentTracker;if(r.getState(e)===Pr){var i=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1==(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Ir&&r.removeFragment(e))},r.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},r.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(_.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw new Error("init load aborted");return t})).then((function(t){var i=r.hls,n=t.payload,a=e.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(t){throw i.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(n){var a=self.performance.now();return i.trigger(_.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:s,tdecrypt:a}}),t.payload=n,r.completeInitSegmentLoad(t)}))}return r.completeInitSegmentLoad(t)})).catch((function(t){r.state!==ti&&r.state!==li&&(r.warn(t),r.resetFragmentLoading(e))}))},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state=ri,e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===at?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=e.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?ei(ur.getBuffered(s)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==ot){var u=e.elementaryStreams;if(!Object.keys(u).some((function(e){return!!u[e]})))return void(this.state=ri)}var l=null==(o=this.levels)?void 0:o[e.level];null!=l&&l.fragmentError&&(this.log("Resetting level fragment error count of "+l.fragmentError+" on frag buffered"),l.fragmentError=0)}this.state=ri,s&&(!this.loadedmetadata&&e.type==at&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new zr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,i){var n,a=this;void 0===r&&(r=null);var s=null==t?void 0:t.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key?!e.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(e,s.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=ii,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(_.KEY_LOADED,e),a.state===ii&&(a.state=ri),e})),this.hls.trigger(_.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var u=s.partList;if(u&&i){r>e.end&&s.fragmentHint&&(e=s.fragmentHint);var l=this.getNextPart(u,e,r);if(l>-1){var d,h=u[l];return this.log("Loading part sn: "+e.sn+" p: "+h.index+" cc: "+e.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+l+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ni,d=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(e,h,t,i)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,h,t,i).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),g(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ni;var c,f=this.config.progressive;return c=f&&o?o.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,i)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,f?i:void 0),o]).then((function(e){var t=e[0];return!f&&t&&i&&i(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},r.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o,u=[],l=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){u[o.index]=i;var s=i.part;n.hls.trigger(_.FRAG_LOADED,i);var d=Ft(r,e.sn,o.index+1)||Mt(l,e.sn,o.index+1);if(!d)return a({frag:e,part:s,partsLoaded:u});t(d)})).catch(s)}(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===b.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(_.ERROR,t)}else this.hls.trigger(_.ERROR,{type:E.OTHER_ERROR,details:b.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===si){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===ti||this.state===li||(this.state=ri)},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,n=e.sn,a=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=t[i],o=a>-1?Ft(s,n,a):null,u=o?o.fragment:function(e,t,r){if(null==e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}(s,n,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:o,level:s}):null},r.bufferFragmentData=function(e,t,r,i,n){var a;if(e&&this.state===si){var s=e.data1,o=e.data2,u=s;if(s&&o&&(u=ke(s,o)),null!=(a=u)&&a.length){var l={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:u};if(this.hls.trigger(_.BUFFER_APPENDING,l),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(ur.isBuffered(t,t.currentTime)){var r=t.currentTime,i=ur.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();return g(r)?this.getFwdBufferInfoAtPos(e,r,t):null},r.getFwdBufferInfoAtPos=function(e,t,r){var i=this.config.maxBufferHole,n=ur.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return ur.bufferInfo(e,t,Math.max(n.nextStart,i))}return n},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn("Reduce max buffer length to "+n+"s"),!0)},r.getAppendedFrag=function(e,t){var r=this.fragmentTracker.getAppendedFrag(e,at);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s)&&(n=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var u=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,u,t)}return this.mapToInitFragWhenRequired(n)},r.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===Or||r===Ir&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,r,i,n){var a=e.gap,s=this.getNextFragment(this.nextLoadPosition,t);if(null===s)return s;if(e=s,a&&e&&!e.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+e.sn),null}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var u=e[s];if(a=a&&!u.independent,i>-1&&r<u.start)break;var l=u.loaded;l?i=-1:(n||u.independent||a)&&u.fragment===t&&(i=s),n=l}return i},r.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},r.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!g(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var n=e[i];if(Wt(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t){return Ht(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,u=r.fragmentHint,l=n.maxFragLookUpTolerance,d=r.partList,h=!!(n.lowLatencyMode&&null!=d&&d.length&&u);if(h&&u&&!this.bitrateTest&&(s=s.concat(u),o=u.sn),i=e<t?Kt(a,s,e,e>t-l?0:l):s[s.length-1]){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===Or||f===Ir&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!h||d[0].fragment.sn>i.sn)&&a&&i.level===a.level){var v=s[c+1];i=i.sn<o&&this.fragmentTracker.getState(v)!==Or?v:null}}return i},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-u)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},r.alignPlaylists=function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragments[0].start,a=!t,s=e.alignedSliding&&g(n);if(a||!s&&!n){var o=this.fragPrevious;Xr(o,r,e);var u=e.fragments[0].start;return this.log("Live playlist sliding: "+u.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+i),u}return n},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,n=i?this.startTimeOffset:e.startTimeOffset;null!==n&&g(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},r.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ai)||(this.state=ri)},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n;this.warn("Frag load error must match current frag to retry "+i.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=t.details===b.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=t.errorAction,o=s||{},u=o.action,l=o.retryCount,d=void 0===l?0:l,h=o.retryConfig;if(s&&u===Qt&&h){this.resetStartWhenNotLoaded(this.levelLastLoaded);var c=Gt(h,d);this.warn("Fragment "+i.sn+" of "+e+" "+i.level+" errored with "+t.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+c+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+c,this.state=ai}else if(h&&s){if(this.resetFragmentErrors(e),!(d<h.maxNumRetry))return void A.warn(t.details+" reached or exceeded max retry ("+d+")");a||u===Xt||(s.resolved=!0)}else(null==s?void 0:s.action)===Yt?this.state=di:this.state=li;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(e){if(this.state===si||this.state===oi){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(e){e===st&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ti&&(this.state=ri)},r.afterBufferFlushed=function(e,t,r){if(e){var i=ur.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ui&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ri},r.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var n,a=this,s=r.details;if(s){if(!Object.keys(e.elementaryStreams).reduce((function(t,n){var o=e.elementaryStreams[n];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return a.warn("Could not parse fragment "+e.sn+" "+n+" duration reliably ("+u+")"),t||!1;var l=i?0:Pt(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(_.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(o.message),this.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=oi,this.hls.trigger(_.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(Kr);function ci(){return self.SourceBuffer||self.WebKitSourceBuffer}function fi(){if(!Ce())return!1;var e=ci();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function vi(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var pi=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=ke(this.cachedData,e),this.cachedData=null);var r,i=W(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?X(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&g(o))&&(this.basePTS=gi(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(e,n)){var l=this.appendFrame(a,e,n);l?(this.frameIndex++,this.lastPTS=l.sample.pts,r=n+=l.length):n=u}else Y(e,n)?(i=W(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===u&&r!==u){var d=j(e,r);this.cachedData?this.cachedData=ke(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:vi(),id3Track:s,textTrack:vi()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:vi(),id3Track:this._id3Track,textTrack:vi()}},t.destroy=function(){},e}(),gi=function(e,t,r){return g(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)};function mi(e,t){return 255===e[t]&&240==(246&e[t+1])}function yi(e,t){return 1&e[t+1]?7:9}function _i(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Ei(e,t){return t+1<e.length&&mi(e,t)}function bi(e,t){if(Ei(e,t)){var r=yi(e,t);if(t+r>=e.length)return!1;var i=_i(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||Ei(e,n)}return!1}function Ti(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,u=navigator.userAgent.toLowerCase(),l=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&t[r+2])>>>6);var h=(60&t[r+2])>>>2;if(!(h>d.length-1))return s=(1&t[r+2])<<2,s|=(192&t[r+3])>>>6,A.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+h),/firefox/i.test(u)?h>=6?(n=5,o=new Array(4),a=h-3):(n=2,o=new Array(2),a=h):-1!==u.indexOf("android")?(n=2,o=new Array(2),a=h):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&h>=6?a=h-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(h>=6&&1===s||/vivaldi/i.test(u))||!i&&1===s)&&(n=2,o=new Array(2)),a=h)),o[0]=n<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[h],channelCount:s,codec:"mp4a.40."+n,manifestCodec:l};var c=new Error("invalid ADTS sampling index:"+h);e.emit(_.ERROR,_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,r,i,n);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,A.log("parsed codec:"+e.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Si(e){return 9216e4/e}function Li(e,t,r,i,n){var a,s=i+n*Si(e.samplerate),o=function(e,t){var r=yi(e,t);if(t+r<=e.length){var i=_i(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var u=o.frameLength,l=o.headerLength,d=l+u,h=Math.max(0,r+d-t.length);h?(a=new Uint8Array(d-l)).set(t.subarray(r+l,t.length),0):a=t.subarray(r+l,r+d);var c={unit:a,pts:s};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var ki=null,wi=[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],Ai=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xi=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ri=[0,1,1,4];function Di(e,t,r,i,n){if(!(r+24>t.length)){var a=Ci(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Ci(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*wi[14*(3===r?3-i:3===i?3:4)+n-1],l=Ai[3*(3===r?0:2===r?1:2)+a],d=3===o?1:2,h=xi[r][i],c=Ri[i],f=8*h*c,v=Math.floor(h*u/l+s)*c;if(null===ki){var p=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ki=p?parseInt(p[1]):0}return!!ki&&ki<=87&&2===i&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:v,samplesPerFrame:f}}}function Pi(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Ii(e,t){return t+1<e.length&&Pi(e,t)}function Oi(e,t){if(t+1<e.length&&Pi(e,t)){var r=Ci(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||Ii(e,n)}return!1}var Fi=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(Oi(e,r))return!1;for(var i=e.length;r<i;r++)if(bi(e,r))return A.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&mi(e,t)&&_i(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){Ti(e,this.observer,t,r,e.manifestCodec);var i=Li(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},t}(pi),Mi=/\/emsg[-/]ID3/i,Bi=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=this.videoTrack=vi("video",1),a=this.audioTrack=vi("audio",1),s=this.txtTrack=vi("text",1);if(this.id3Track=vi("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=ye(e);if(o.video){var u=o.video,l=u.id,d=u.timescale,h=u.codec;n.id=l,n.timescale=s.timescale=d,n.codec=h}if(o.audio){var c=o.audio,f=c.id,v=c.timescale,p=c.codec;a.id=f,a.timescale=v,a.codec=p}s.id=le.text,n.sampleDuration=0,n.duration=a.duration=i}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=ce(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=ke(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=ge(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=j(e,0,i.byteOffset-8),t.remainder=j(e,i.byteOffset-8),t}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return n.samples=we(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=we(e,t),{videoTrack:t,audioTrack:vi(),id3Track:i,textTrack:vi()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=ge(e.samples,["emsg"]);i&&i.forEach((function(e){var i=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,u=0,l=0;if(0===t){for(;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1,n=ce(e,12),a=ce(e,16),o=ce(e,20),u=ce(e,24),l=28}else if(1===t){n=ce(e,l+=4);var d=ce(e,l+=4),h=ce(e,l+=4);for(l+=4,s=Math.pow(2,32)*d+h,m(s)||(s=Number.MAX_SAFE_INTEGER,A.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ce(e,l),u=ce(e,l+=4),l+=4;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(Mi.test(i.schemeIdUri)){var n=g(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:pt,duration:a})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),Ni=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}},t.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&A.log(e.pts+"/"+e.dts+":"+e.debug)},e}(),Ui=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),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)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&A.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),u=this.readBits.bind(this),l=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var p=o();if(u(5),h(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var g=l();if(3===g&&h(1),f(),f(),h(1),d())for(t=3!==g?8:12,r=0;r<t;r++)d()&&v(r<6?16:64)}f();var m=l();if(0===m)l();else if(1===m)for(h(1),c(),c(),e=l(),r=0;r<e;r++)c();f(),h(1);var y=l(),_=l(),E=u(1);0===E&&h(1),h(1),d()&&(i=l(),n=l(),a=l(),s=l());var b=[1,1];if(d()&&d())switch(o()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:b=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-E)*(_+1)*16-(E?2:4)*(a+s),pixelRatio:b}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),Gi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.parseAVCPES=function(e,t,r,i,n){var a,s=this,o=this.parseAVCNALu(e,r.data),u=this.VideoSample,l=!1;r.data=null,u&&o.length&&!e.audFound&&(this.pushAccessUnit(u,e),u=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),o.forEach((function(i){var o;switch(i.type){case 1:var d=!1;a=!0;var h,c=i.data;if(l&&c.length>4){var f=new Ui(c).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(d=!0)}d&&null!=(h=u)&&h.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.frame=!0,u.key=d;break;case 5:a=!0,null!=(o=u)&&o.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:a=!0,xe(i.data,1,r.pts,t.samples);break;case 7:var v,p;a=!0,l=!0;var g=i.data,m=new Ui(g).readSPS();if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(p=e.pixelRatio)?void 0:p[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[g],e.duration=n;for(var y=g.subarray(1,4),_="avc1.",E=0;E<3;E++){var b=y[E].toString(16);b.length<2&&(b="0"+b),_+=b}e.codec=_}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,u&&s.pushAccessUnit(u,e),u=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&a&&u.units.push(i)})),i&&u&&(this.pushAccessUnit(u,e),this.VideoSample=null)},r.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],u=0,l=-1,d=0;for(-1===a&&(l=0,d=31&t[0],a=0,u=1);u<n;)if(r=t[u++],a)if(1!==a)if(r)if(1===r){if(i=u-a-1,l>=0){var h={data:t.subarray(l,i),type:d};o.push(h)}else{var c=this.getLastNalUnit(e.samples);c&&(s&&u<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),i>0&&(c.data=ke(c.data,t.subarray(0,i)),c.state=0))}u<n?(l=u,d=31&t[u],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(l>=0&&a>=0){var f={data:t.subarray(l,n),type:d,state:a};o.push(f)}if(0===o.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=ke(v.data,t))}return e.naluState=a,o},t}(Ni),Vi=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new $r(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,r){var i=this,n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,n){var a=this,s=Re(n.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){n.data=a.getAvcDecryptedUnit(s,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}},e}(),ji=188,Hi=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Gi}e.probe=function(t){var r=e.syncOffset(t);return r>0&&A.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-ji)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=ji){if(71!==e[o]||t-o!==ji&&71!==e[o+ji]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-ji)+1),n||(n=0===Ki(e,o)),n&&s>1&&(0===a&&s>2||o+ji>r))return a}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:le[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=s.pid,h=s.pesData,c=o.pid,f=u.pid,v=o.pesData,p=u.pesData,g=null,m=this.pmtParsed,y=this._pmtId,_=t.length;if(this.remainderData&&(_=(t=ke(this.remainderData,t)).length,this.remainderData=null),_<ji&&!n)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};var E=Math.max(0,e.syncOffset(t));(_-=(_-E)%ji)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,_,t.buffer.byteLength-_));for(var b=0,T=E;T<_;T+=ji)if(71===t[T]){var S=!!(64&t[T+1]),L=Ki(t,T),k=void 0;if((48&t[T+3])>>4>1){if((k=T+5+t[T+4])===T+ji)continue}else k=T+4;switch(L){case d:S&&(h&&(a=Xi(h))&&this.videoParser.parseAVCPES(s,l,a,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(k,T+ji)),h.size+=T+ji-k);break;case c:if(S){if(v&&(a=Xi(v)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}v={data:[],size:0}}v&&(v.data.push(t.subarray(k,T+ji)),v.size+=T+ji-k);break;case f:S&&(p&&(a=Xi(p))&&this.parseID3PES(u,a),p={data:[],size:0}),p&&(p.data.push(t.subarray(k,T+ji)),p.size+=T+ji-k);break;case 0:S&&(k+=t[k]+1),y=this._pmtId=zi(t,k);break;case y:S&&(k+=t[k]+1);var w=Wi(t,k,this.typeSupported,i,this.observer);(d=w.videoPid)>0&&(s.pid=d,s.segmentCodec=w.segmentVideoCodec),(c=w.audioPid)>0&&(o.pid=c,o.segmentCodec=w.segmentAudioCodec),(f=w.id3Pid)>0&&(u.pid=f),null===g||m||(A.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+g+"'. Backtracking to sync byte @"+E+" to parse all TS packets."),g=null,T=E-188),m=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=L}}else b++;b>0&&qi(this.observer,new Error("Found "+b+" TS packet/s that do not start with 0x47")),s.pesData=h,o.pesData=v,u.pesData=p;var x={audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};return n&&this.extractRemainingSamples(x),x},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,u=n.pesData;if(s&&(t=Xi(s))?(this.videoParser.parseAVCPES(i,a,t,!0,this._duration),i.pesData=null):i.pesData=s,o&&(t=Xi(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&A.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;u&&(t=Xi(u))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=u},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Vi(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var r,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var u=s.missing,l=s.sample.unit.byteLength;if(-1===u)o=ke(s.sample.unit,o);else{var d=l-u;s.sample.unit.set(o.subarray(0,u),d),e.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r<i-1&&!Ei(o,r);r++);if(r!==a){var h,c=r<i-1;if(h=c?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",qi(this.observer,new Error(h),c),!c)return}if(Ti(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!s)return void A.warn("[tsdemuxer]: AAC PES unknown PTS");var f=Si(e.samplerate);n=s.sample.pts+f}for(var v,p=0;r<i;){if(r+=(v=Li(e,o,r,n,p)).length,v.missing){this.aacOverFlow=v;break}for(p++;r<i-1&&!Ei(o,r);r++);}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,n=0,a=0,s=t.pts;if(void 0!==s)for(;a<i;)if(Ii(r,a)){var o=Di(e,r,a,s,n);if(!o)break;a+=o.length,n++}else a++;else A.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=o({},t,{type:this._videoTrack?pt:ft,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else A.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function Ki(e,t){return((31&e[t+1])<<8)+e[t+2]}function zi(e,t){return(31&e[t+10])<<8|e[t+11]}function Wi(e,t,r,i,n){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var o=Ki(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Yi("ADTS AAC");break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Yi("H.264");break}case 27:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):A.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Yi("AC-3");break}case 129:A.warn("AC-3 in M2TS support not included in build");break;case 6:if(-1===a.audioPid&&u>0)for(var l=t+5,d=u;d>2;){106===e[l]&&A.warn("AC-3 in M2TS support not included in build");var h=e[l+1]+2;l+=h,d-=h}break;case 194:case 135:return qi(n,new Error("Unsupported EC-3 in M2TS found")),a;case 36:return qi(n,new Error("Unsupported HEVC in M2TS found")),a}t+=u+5}return a}function qi(e,t,r){A.warn("parsing error: "+t.message),e.emit(_.ERROR,_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Yi(e){A.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Xi(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=ke(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var u=t[7];192&u&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&u?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(A.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var l=(i=t[8])+9;if(e.size<=l)return null;e.size-=l;for(var d=new Uint8Array(e.size),h=0,c=o.length;h<c;h++){var f=(t=o[h]).byteLength;if(l){if(l>f){l-=f;continue}t=t.subarray(l),f-=l,l=0}d.set(t,s),s+=f}return r&&(r-=i+3),{data:d,pts:n,dts:a,len:r}}return null}var Qi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==X(t)&&function(e,t){var r=0,i=5;t+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),u=8-o;a[0]=4278190080>>>24+u<<u,n[0]=(s[0]&a[0])>>u,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r}(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(Oi(e,r))return A.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return Pi(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return Di(e,t,r,this.basePTS,this.frameIndex)},t}(pi),Ji=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}(),Zi=Math.pow(2,32)-1,$i=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},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]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,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 s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,u,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=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))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+1)),a=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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=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))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),u=t.width,l=t.height,d=t.pixelRatio[0],h=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,u>>8&255,255&u,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,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,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=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]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(Zi+1)),o=Math.floor(i%(Zi+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,o>>24,o>>16&255,o>>8&255,255&o,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,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(Zi+1)),s=Math.floor(r%(Zi+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,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=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]))},e.trun=function(t,r){var i,n,a,s,o,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(r+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=(n=l[i]).duration,s=n.size,o=n.flags,u=n.cts,c.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*i);return e.box(e.types.trun,c)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t);return ke(e.FTYP,r)},e}();$i.types=void 0,$i.HDLR_TYPES=void 0,$i.STTS=void 0,$i.STSC=void 0,$i.STCO=void 0,$i.STSZ=void 0,$i.VMHD=void 0,$i.SMHD=void 0,$i.STSD=void 0,$i.FTYP=void 0,$i.DINF=void 0;function en(e,t){return void 0===t&&(t=!1),function(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}(e,1e3,1/9e4,t)}var tn=null,rn=null,nn=function(){function e(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===tn){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tn=n?parseInt(n[1]):0}if(null===rn){var a=navigator.userAgent.match(/Safari\/(\d+)/i);rn=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){A.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){A.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){A.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,an(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&A.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var u,l,d,h,c,f,v=n,p=n,g=e.pid>-1,m=t.pid>-1,y=t.samples.length,_=e.samples.length>0,E=s&&y>0||y>1;if((!g||_)&&(!m||E)||this.ISGenerated||s){if(this.ISGenerated){var b,T,S,L,k=this.videoTrackConfig;!k||t.width===k.width&&t.height===k.height&&(null==(b=t.pixelRatio)?void 0:b[0])===(null==(T=k.pixelRatio)?void 0:T[0])&&(null==(S=t.pixelRatio)?void 0:S[1])===(null==(L=k.pixelRatio)?void 0:L[1])||this.resetInitSegment()}else d=this.generateIS(e,t,n,a);var w,x=this.isVideoContiguous,R=-1;if(E&&(R=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!x&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,R>0){A.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var D=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(R),t.dropped+=R,w=p+=(t.samples[0].pts-D)/t.inputTimeScale}else-1===R&&(A.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(_&&E){var C=this.getVideoStartPts(t.samples),P=(an(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,P),p+=Math.max(0,-P)}if(_){if(e.samplerate||(A.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,a)),l=this.remuxAudio(e,v,this.isAudioContiguous,a,m||E||o===st?p:void 0),E){var I=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(A.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,a)),u=this.remuxVideo(t,p,x,I)}}else E&&(u=this.remuxVideo(t,p,x,0));u&&(u.firstKeyFrame=R,u.independent=-1!==R,u.firstKeyFramePTS=w)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=sn(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=on(i,n,this._initPTS))),{audio:l,video:u,initSegment:d,independent:f,text:h,id3:c}},t.generateIS=function(e,t,r,i){var n,a,s,o=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||i,f="audio/mp4";if(c&&(n=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(f="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):$i.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(s=e.inputTimeScale,h&&s===h.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:$i.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(s=t.inputTimeScale,h&&s===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=Math.round(s*r);a=Math.min(a,an(u[0].dts,v)-p),n=Math.min(n,v-p)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:d,initPTS:n,timescale:s}},t.remuxVideo=function(e,t,r,i){var n,a,s=e.inputTimeScale,u=e.samples,l=[],d=u.length,h=this._initPTS,c=this.nextAvcDts,f=8,v=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;if(!r||null===c){var y=t*s,T=u[0].pts-an(u[0].dts,u[0].pts);tn&&null!==c&&Math.abs(y-T-c)<15e3?r=!0:c=y-T}for(var S=h.baseTime*s/h.timescale,L=0;L<d;L++){var k=u[L];k.pts=an(k.pts-S,c),k.dts=an(k.dts-S,c),k.dts<u[L>0?L-1:L].dts&&(m=!0)}m&&u.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=u[0].dts;var w=u[u.length-1].dts-n,x=w?Math.round(w/(d-1)):v||e.inputTimeScale/30;if(r){var R=n-c,D=R>x,C=R<-1;if((D||C)&&(D?A.warn("AVC: "+en(R,!0)+" ms ("+R+"dts) hole between fragments detected at "+t.toFixed(3)):A.warn("AVC: "+en(-R,!0)+" ms ("+R+"dts) overlapping between fragments detected at "+t.toFixed(3)),!C||c>=u[0].pts||tn)){n=c;var P=u[0].pts-R;if(D)u[0].dts=n,u[0].pts=P;else for(var I=0;I<u.length&&!(u[I].dts>P);I++)u[I].dts-=R,u[I].pts-=R;A.log("Video: Initial PTS/DTS adjusted: "+en(P,!0)+"/"+en(n,!0)+", delta: "+en(R,!0)+" ms")}}for(var O=0,F=0,M=n=Math.max(0,n),B=0;B<d;B++){for(var N=u[B],U=N.units,G=U.length,V=0,j=0;j<G;j++)V+=U[j].data.length;F+=V,O+=G,N.length=V,N.dts<M?(N.dts=M,M+=x/4|0||1):M=N.dts,p=Math.min(N.pts,p),g=Math.max(N.pts,g)}a=u[d-1].dts;var H,K=F+4*O+8;try{H=new Uint8Array(K)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:E.MUX_ERROR,details:b.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:K,reason:"fail allocating video mdat "+K})}var z=new DataView(H.buffer);z.setUint32(0,K),H.set($i.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,J=0;J<d;J++){for(var Z=u[J],$=Z.units,ee=0,te=0,re=$.length;te<re;te++){var ie=$[te],ne=ie.data,ae=ie.data.byteLength;z.setUint32(f,ae),f+=4,H.set(ne,f),f+=ae,ee+=4+ae}var se=void 0;if(J<d-1)v=u[J+1].dts-Z.dts,se=u[J+1].pts-Z.pts;else{var oe=this.config,ue=J>0?Z.dts-u[J-1].dts:x;if(se=J>0?Z.pts-u[J-1].pts:x,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var le=Math.floor(oe.maxBufferHole*s),de=(i?p+i*s:this.nextAudioPts)-Z.pts;de>le?((v=de-ue)<0?v=ue:W=!0,A.log("[mp4-remuxer]: It is approximately "+de/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=ue}else v=ue}var he=Math.round(Z.pts-Z.dts);q=Math.min(q,v),X=Math.max(X,v),Y=Math.min(Y,se),Q=Math.max(Q,se),l.push(new un(Z.key,v,ee,he))}if(l.length)if(tn){if(tn<70){var ce=l[0].flags;ce.dependsOn=2,ce.isNonSync=0}}else if(rn&&Q-Y<X-q&&x/X<.025&&0===l[0].cts){A.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,ve=0,pe=l.length;ve<pe;ve++){var ge=fe+l[ve].duration,me=fe+l[ve].cts;if(ve<pe-1){var ye=ge+l[ve+1].cts;l[ve].duration=ye-me}else l[ve].duration=ve?l[ve-1].duration:x;l[ve].cts=0,fe=ge}}v=W||!v?x:v,this.nextAvcDts=c=a+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var _e={data1:$i.moof(e.sequenceNumber++,n,o({},e,{samples:l})),data2:H,startPTS:p/s,endPTS:(g+v)/s,startDTS:n/s,endDTS:c/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_e},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},t.remuxAudio=function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),u=this.getSamplesPerFrame(e),l=u*s,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],f=void 0!==n,v=e.samples,p=h?0:8,g=this.nextAudioPts||-1,m=t*a,y=d.baseTime*a/d.timescale;if(this.isAudioContiguous=r=r||v.length&&g>0&&(i&&Math.abs(m-g)<9e3||Math.abs(an(v[0].pts-y,m)-g)<20*l),v.forEach((function(e){e.pts=an(e.pts-y,m)})),!r||g<0){if(v=v.filter((function(e){return e.pts>=0})),!v.length)return;g=0===n?0:i&&!f?Math.max(0,m):v[0].pts}if("aac"===e.segmentCodec)for(var T=this.config.maxAudioFramesDrift,S=0,L=g;S<v.length;S++){var k=v[S],w=k.pts,x=w-L,R=Math.abs(1e3*x/a);if(x<=-T*l&&f)0===S&&(A.warn("Audio frame @ "+(w/a).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*x/a)+" ms."),this.nextAudioPts=g=L=w);else if(x>=T*l&&R<1e4&&f){var D=Math.round(x/l);(L=w-D*l)<0&&(D--,L+=l),0===S&&(this.nextAudioPts=g=L),A.warn("[mp4-remuxer]: Injecting "+D+" audio frame @ "+(L/a).toFixed(3)+"s due to "+Math.round(1e3*x/a)+" ms gap.");for(var C=0;C<D;C++){var P=Math.max(L,0),I=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);I||(A.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),I=k.unit.subarray()),v.splice(S,0,{unit:I,pts:P}),L+=l,S++}}k.pts=L,L+=l}for(var O,F=null,M=null,B=0,N=v.length;N--;)B+=v[N].unit.byteLength;for(var U=0,G=v.length;U<G;U++){var V=v[U],j=V.unit,H=V.pts;if(null!==M)c[U-1].duration=Math.round((H-M)/s);else{if(r&&"aac"===e.segmentCodec&&(H=g),F=H,!(B>0))return;B+=p;try{O=new Uint8Array(B)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:E.MUX_ERROR,details:b.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:B,reason:"fail allocating audio mdat "+B})}h||(new DataView(O.buffer).setUint32(0,B),O.set($i.types.mdat,4))}O.set(j,p);var K=j.byteLength;p+=K,c.push(new un(!0,u,K,0)),M=H}var z=c.length;if(z){var W=c[c.length-1];this.nextAudioPts=g=M+s*W.duration;var q=h?new Uint8Array(0):$i.moof(e.sequenceNumber++,F/s,o({},e,{samples:c}));e.samples=[];var Y=F/a,X=g/a,Q={data1:q,data2:O,startPTS:Y,endPTS:X,startDTS:Y,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,Q}},t.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,o=this._initDTS,u=9e4*o.baseTime/o.timescale,l=(null!==s?s:i.startDTS*n)+u,d=i.endDTS*n+u,h=1024*a,c=Math.ceil((d-l)/h),f=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.warn("[mp4-remuxer]: remux empty Audio"),f){for(var v=[],p=0;p<c;p++){var g=l+p*h;v.push({unit:f,pts:g,dts:g})}return e.samples=v,this.remuxAudio(e,t,r,!1)}A.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function an(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function sn(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=an(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=an(o.dts-i.baseTime*a/i.timescale,t*a)/a}var u=e.samples;return e.samples=[],{samples:u}}}function on(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=an(s.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var un=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},ln=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Se(e,i)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=ye(e);i.audio&&(t=dn(i.audio,O)),i.video&&(r=dn(i.video,F));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:A.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,i,n,a){var s,o,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};g(l)||(l=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return d;var c={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return A.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=ge(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],u=ge(o,["tfhd"])[0],l=t[ce(u,4)];if(l){var d=l.default,h=ce(u,0)|(null==d?void 0:d.flags),c=null==d?void 0:d.duration;8&h&&(c=ce(u,2&h?12:8));for(var f=l.timescale||9e4,v=ge(o,["trun"]),p=0;p<v.length;p++)!(r=Le(v[p]))&&c&&(r=c*ce(v[p],4)),l.type===F?i+=r/f:l.type===O&&(n+=r/f)}}if(0===i&&0===n){for(var m=1/0,y=0,_=0,E=ge(e,["sidx"]),b=0;b<E.length;b++){var T=me(E[b]);if(null!=T&&T.references){m=Math.min(m,T.earliestPresentationTime/T.timescale);var S=T.references.reduce((function(e,t){return e+t.info.duration||0}),0);_=(y=Math.max(y,S+T.earliestPresentationTime/T.timescale))-m}}if(_&&g(_))return _}return i||n}(h,f),p=function(e,t){return ge(t,["moof","traf"]).reduce((function(t,r){var i=ge(r,["tfdt"])[0],n=i[0],a=ge(r,["tfhd"]).reduce((function(t,r){var a=ce(r,4),s=e[a];if(s){var o=ce(i,4);if(1===n){if(o===oe)return A.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=oe+1,o+=ce(i,8)}var u=o/(s.timescale||9e4);if(g(u)&&(null===t||u<t))return u}return t}),null);return null!==a&&g(a)&&(null===t||a<t)?a:t}),null)}(f,h),m=null===p?n:p;(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(u,m,n,v)||c.timescale!==u.timescale&&a)&&(c.initPTS=m-n,u&&1===u.timescale&&A.warn("Adjusting initPTS by "+(c.initPTS-u.baseTime)),this.initPTS=u={baseTime:c.initPTS,timescale:1});var y=e?m-u.baseTime/u.timescale:l,_=y+v;(function(e,t,r){ge(t,["moof","traf"]).forEach((function(t){ge(t,["tfhd"]).forEach((function(i){var n=ce(i,4),a=e[n];if(a){var s=a.timescale||9e4;ge(t,["tfdt"]).forEach((function(e){var t=e[0],i=r*s;if(i){var n=ce(e,4);if(0===t)n-=i,pe(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=ce(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(oe+1)),o=Math.floor(n%(oe+1));pe(e,4,a),pe(e,8,o)}}}))}}))}))})(f,h,u.baseTime/u.timescale),v>0?this.lastEndTime=_:(A.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!f.audio,b=!!f.video,T="";E&&(T+="audio"),b&&(T+="video");var S={data1:h,startPTS:y,startDTS:y,endPTS:_,endDTS:_,type:T,hasAudio:E,hasVideo:b,nb:1,dropped:0};return d.audio="audio"===S.type?S:void 0,d.video="audio"!==S.type?S:void 0,d.initSegment=c,d.id3=sn(r,n,u,u),i.samples.length&&(d.text=on(i,n,u)),d},e}();function dn(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===O){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return Ge(r,!1);var i="mp4a.40.5";return A.info('Parsed audio codec "'+r+'" or audio object type not handled. Using "'+i+'"'),i}return A.warn('Unhandled video codec "'+r+'"'),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}var hn,cn="undefined"!=typeof self?self:void 0;try{hn=self.performance.now.bind(self.performance)}catch(e){A.debug("Unable to use Performance API on this environment"),hn=null==cn?void 0:cn.Date.now}var fn=[{demux:Bi,remux:ln},{demux:Hi,remux:nn},{demux:Fi,remux:nn},{demux:Qi,remux:nn}],vn=function(){function e(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=hn();var s=new Uint8Array(e),o=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var l=i||o,d=l.contiguous,h=l.discontinuity,c=l.trackSwitch,f=l.accurateTimeOffset,v=l.timeOffset,p=l.initSegmentChange,g=u.audioCodec,m=u.videoCodec,y=u.defaultInitPts,T=u.duration,S=u.initSegmentData,L=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(L&&"AES-128"===L.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,L.key.buffer,L.iv.buffer).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var w=k.softwareDecrypt(s,L.key.buffer,L.iv.buffer);if(r.part>-1&&(w=k.flush()),!w)return a.executeEnd=hn(),pn(r);s=new Uint8Array(w)}var x=this.needsProbing(h,c);if(x){var R=this.configureTransmuxer(s);if(R)return A.warn("[transmuxer] "+R.message),this.observer.emit(_.ERROR,_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,fatal:!1,error:R,reason:R.message}),a.executeEnd=hn(),pn(r)}(h||c||p||x)&&this.resetInitSegment(S,g,m,T,t),(h||p||x)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var D=this.transmux(s,L,v,f,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,a.executeEnd=hn(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=hn();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(i){var u=i.flush();u&&s.push(this.push(u,null,e))}var l=this.demuxer,d=this.remuxer;if(!l||!d)return r.executeEnd=hn(),[pn(e)];var h=l.flush(o);return gn(h)?h.then((function(r){return t.flushRemux(s,r,e),s})):(this.flushRemux(s,h,e),s)},t.flushRemux=function(e,t,r){var i=t.audioTrack,n=t.videoTrack,a=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,u=o.accurateTimeOffset,l=o.timeOffset;A.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,n,a,s,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=hn()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,u=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,u,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=fn.length;s<o;s++){var u;if(null!=(u=fn[s].demux)&&u.probe(e)){t=fn[s];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,d=this.remuxer,h=t.remux,c=t.demux;d&&d instanceof h||(this.remuxer=new h(i,r,n,a)),l&&l instanceof c||(this.demuxer=new c(i,r,n),this.probe=c.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new $r(this.config)),e},e}();var pn=function(e){return{remuxResult:{},chunkMeta:e}};function gn(e){return"then"in e&&e.then instanceof Function}var mn=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null},yn=function(e,t,r,i,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a},_n={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){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,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(_n);var En=f(_n.exports);function bn(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&Tn(i,a),s&&Tn(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function Tn(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function Sn(e,t,r){t.reduce((function(t,r){return bn(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}void 0!==r&&r&&function(e){var t=new En,r=function(t,r){e.postMessage({event:t,data:r})};t.on(_.FRAG_DECRYPTED,r),t.on(_.ERROR,r),e.addEventListener("message",(function(i){var n=i.data;switch(n.cmd){case"init":var a=JSON.parse(n.config);e.transmuxer=new vn(t,n.typeSupported,a,"",n.id),w(a.debug,n.id),function(){var e=function(e){A[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in A)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(n.config);break;case"demux":var s=e.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);gn(s)?(e.transmuxer.async=!0,s.then((function(t){bn(e,t)})).catch((function(e){r(_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,bn(e,s));break;case"flush":var o=n.chunkMeta,u=e.transmuxer.flush(o);gn(u)||e.transmuxer.async?(gn(u)||(u=Promise.resolve(u)),u.then((function(t){Sn(e,t,o)})).catch((function(e){r(_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):Sn(e,u,o)}}))}(self);var Ln=function(){function e(e,r,i,n){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var s=e.config;this.hls=e,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var o=function(e,t){(t=t||{}).frag=a.frag,t.id=a.id,e===_.ERROR&&(a.error=t.error),a.hls.trigger(e,t)};this.observer=new En,this.observer.on(_.FRAG_DECRYPTED,o),this.observer.on(_.ERROR,o);var u,l,d,h,c=Ce(s.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},f={mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath,1))try{s.workerPath?(A.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(A.log('injecting Web Worker for "'+r+'"'),this.workerContext=(u=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),l=self.URL.createObjectURL(u),{worker:new self.Worker(l),objectURL:l})),this.onwmsg=function(e){return a.onWorkerMessage(e)};var v=this.workerContext.worker;v.addEventListener("message",this.onwmsg),v.onerror=function(e){var t=new Error(e.message+" ("+e.filename+":"+e.lineno+")");s.enableWorker=!1,A.warn('Error in "'+r+'" Web Worker, fallback to inline'),a.hls.trigger(_.ERROR,{type:E.OTHER_ERROR,details:b.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},v.postMessage({cmd:"init",typeSupported:f,vendor:"",id:r,config:JSON.stringify(s)})}catch(e){A.warn('Error setting up "'+r+'" Web Worker, fallback to inline',e),this.resetWorker(),this.error=null,this.transmuxer=new vn(this.observer,f,s,"",r)}else this.transmuxer=new vn(this.observer,f,s,"",r)}var r=e.prototype;return r.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},r.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},r.push=function(e,t,r,i,n,a,s,o,u,l){var d,h,c=this;u.transmuxing.start=self.performance.now();var f=this.transmuxer,v=a?a.start:n.start,p=n.decryptdata,g=this.frag,m=!(g&&n.cc===g.cc),y=!(g&&u.level===g.level),_=g?u.sn-g.sn:-1,E=this.part?u.part-this.part.index:-1,b=0===_&&u.id>1&&u.id===(null==g?void 0:g.stats.chunkCount),T=!y&&(1===_||0===_&&(1===E||b&&E<=0)),S=self.performance.now();(y||_||0===n.stats.parsing.start)&&(n.stats.parsing.start=S),!a||!E&&T||(a.stats.parsing.start=S);var L=!(g&&(null==(d=n.initSegment)?void 0:d.url)===(null==(h=g.initSegment)?void 0:h.url)),k=new yn(m,T,o,y,v,L);if(!T||m||L){A.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+m+"\n trackSwitch: "+y+"\n contiguous: "+T+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+L);var w=new mn(r,i,t,s,l);this.configureTransmuxer(w)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:u,state:k},e instanceof ArrayBuffer?[e]:[]);else if(f){var x=f.push(e,p,u,k);gn(x)?(f.async=!0,x.then((function(e){c.handleTransmuxComplete(e)})).catch((function(e){c.transmuxerError(e,u,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(x))}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);gn(i)||r.async?(gn(i)||(i=Promise.resolve(i)),i.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data;if(null!=t&&t.event){var r=this.hls;if(this.hls)switch(t.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":A[t.data.logType]&&A[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}else A.warn("worker message received with no "+(t?"event name":"data"))},r.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),kn=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,i=this.media,n=this.stalled;if(null!==i){var a=i.currentTime,s=i.seeking,o=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,a===e)if(u||o)this.stalled=null;else if(i.paused&&!s||i.ended||0===i.playbackRate||!ur.getBuffered(i).length)this.nudgeRetry=0;else{var l=ur.bufferInfo(i,a,0),d=l.nextStart||0;if(s){var h=l.len>2,c=!d||t&&t.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(h||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var f;if(!(l.len>0||d))return;var v=Math.max(d,l.start||0)-a,p=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,g=(null==p||null==(f=p.details)?void 0:f.live)?2*p.details.targetduration:2,m=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=g||m))return void(i.paused||this._trySkipBufferHole(m))}var y=self.performance.now();if(null!==n){var _=y-n;if(s||!(_>=250)||(this._reportStall(l),this.media)){var E=ur.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(E,_)}}else this.stalled=y}else if(this.moved=!0,s||(this.nudgeRetry=0),null!==n){if(this.stallReported){var b=self.performance.now()-n;A.warn("playback not stuck anymore @"+a+", after "+Math.round(b)+"ms"),this.stallReported=!1}this.stalled=null}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(A.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");A.warn(i.message),t.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=ur.bufferInfo(i,n,0),s=n<a.start?a.start:a.nextStart;if(s){var o=a.len<=t.maxBufferHole,u=a.len>0&&a.len<1&&i.readyState<3,l=s-n;if(l>0&&(o||u)){if(l>t.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===n){var c=d.getAppendedFrag(0,at);c&&s<c.end&&(h=!0)}if(!h){var f=e||d.getAppendedFrag(n,at);if(f){for(var v=!1,p=f.end;p<s;){var g=d.getPartialFragment(p);if(!g){v=!0;break}p+=g.duration}if(v)return 0}}}var m=Math.max(s+.05,n+.1);if(A.warn("skipping hole, adjusting currentTime from "+n+" to "+m),this.moved=!0,this.stalled=null,i.currentTime=m,e&&!e.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+m);r.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:e})}return m}}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a=n+(i+1)*e.nudgeOffset,s=new Error("Nudging 'currentTime' from "+n+" to "+a);A.warn(s.message),r.currentTime=a,t.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges");A.error(o.message),t.trigger(_.ERROR,{type:E.MEDIA_ERROR,details:b.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},e}(),wn=function(e){function t(t,r,i){var n;return(n=e.call(this,t,r,i,"[stream-controller]",at)||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(_.ERROR,this.onError,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(_.ERROR,this.onError,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=ri,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=ti},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case di:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=ri;break}if(this.hls.nextLoadLevel!==this.level){this.state=ri;break}break;case ai:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,u=this.level,l=null==o?void 0:o[u];this.resetStartWhenNotLoaded(l||null),this.state=ri}}this.state===ri&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=e.nextLoadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(_.BUFFER_EOS,u),void(this.state=ui)}e.loadLevel!==n&&-1===e.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=e.nextLoadLevel=n;var l=a.details;if(!l||this.state===di||l.live&&this.levelLastLoaded!==a)return this.level=n,void(this.state=di);var d=s.len,h=this.getMaxBufferLength(a.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&"initSegment"!==f.sn&&this.fragmentTracker.getState(f)!==Or){var v,p=(null!=(v=this.backtrackFragment)?v:f).sn-l.startSN,g=l.fragments[p-1];g&&f.cc===g.cc&&(f=g,this.fragmentTracker.removeFragment(g))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,c)){if(!f.gap){var m=this.audioOnly&&!this.altAudio?O:F,y=(m===F?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,m,at)}f=this.getNextFragmentLoopLoading(f,l,s,at,h)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,a,c))}}}}},r.loadFragment=function(t,r,i){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Cr||n===Ir?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,at)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var u=this.getBufferedFrag(t.currentTime+r);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ii:case ni:case ai:case si:case oi:this.state=ri}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new kn(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;g(t)&&this.log("Media seeked to "+t.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(_.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},r.onManifestParsed=function(e,t){var r,i,n=!1,a=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(n=n||-1!==t.indexOf("mp4a.40.2"),a=a||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!("function"==typeof(null==(i=ci())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===ri){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=di)}},r.onLevelLoaded=function(e,t){var r,i=this.levels,n=t.level,a=t.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],u=this.fragCurrent;!u||this.state!==ni&&this.state!==ai||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var l=0;if(a.live||null!=(r=o.details)&&r.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;l=this.alignPlaylists(a,o.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(o.details=a,this.levelLastLoaded=o,this.hls.trigger(_.LEVEL_UPDATED,{details:a,level:n}),this.state===di){if(this.waitForCdnTuneIn(a))return;this.state=ri}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,l),this.tick()}else this.warn("Levels were reset while loading level "+n)},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var u=s.videoCodec,l=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,h=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new Ln(this.hls,at,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,v=-1!==f,p=new zr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,v),g=this.initPTS[r.cc];c.push(n,d,h,u,r,i,o.totalduration,l,p,g)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(_.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},r.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var u=n[s];u&&(this.videoBuffer=u.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===at){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===oi&&(this.state=ri));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(e,t){var r;if(t.fatal)this.state=li;else switch(t.details){case b.FRAG_GAP:case b.FRAG_PARSING_ERROR:case b.FRAG_DECRYPT_ERROR:case b.FRAG_LOAD_ERROR:case b.FRAG_LOAD_TIMEOUT:case b.KEY_LOAD_ERROR:case b.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(at,t);break;case b.LEVEL_LOAD_ERROR:case b.LEVEL_LOAD_TIMEOUT:case b.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==di||(null==(r=t.context)?void 0:r.type)!==rt||(this.state=ri);break;case b.BUFFER_APPEND_ERROR:case b.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===b.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case b.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!ur.getBuffered(e).length){var r=this.state!==ri?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=ri,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==O||this.audioOnly&&!this.altAudio){var i=(r===F?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,at),this.tick()}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=ur.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},r._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(i){var n=r.hls;if(i&&!r.fragContextChanged(e)){t.fragmentError=0,r.state=ri,r.startFragRequested=!1,r.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(_.FRAG_LOADED,i),e.bitrateTest=!1}}))},r._handleTransmuxComplete=function(e){var t,r="main",i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,u=s.part,l=s.level,d=n.video,h=n.text,c=n.id3,f=n.initSegment,v=l.details,p=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=si,f){if(null!=f&&f.tracks){var m=o.initSegment||o;this._bufferInitSegment(l,f.tracks,m,a),i.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:f.tracks})}var y=f.initPTS,E=f.timescale;g(y)&&(this.initPTS[o.cc]={baseTime:y,timescale:E},i.trigger(_.INIT_PTS_FOUND,{frag:o,id:r,initPTS:y,timescale:E}))}if(d&&v&&"initSegment"!==o.sn){var b=v.fragments[o.sn-1-v.startSN],T=o.sn===v.startSN,S=!b||o.cc>b.cc;if(!1!==n.independent){var L=d.startPTS,k=d.endPTS,w=d.startDTS,A=d.endDTS;if(u)u.elementaryStreams[d.type]={startPTS:L,endPTS:k,startDTS:w,endDTS:A};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!S&&(this.couldBacktrack=!0),d.dropped&&d.independent){var x=this.getMainFwdBufferInfo(),R=(x?x.end:this.getLoadPosition())+this.config.maxBufferHole,D=d.firstKeyFramePTS?d.firstKeyFramePTS:L;if(!T&&R<D-this.config.maxBufferHole&&!S)return void this.backtrack(o);S&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,k,o.start,A,!0)}else T&&L>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,L,k,w,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,u,a,T||S)}else{if(!T&&!S)return void this.backtrack(o);o.gap=!0}}if(p){var C=p.startPTS,P=p.endPTS,I=p.startDTS,F=p.endDTS;u&&(u.elementaryStreams[O]={startPTS:C,endPTS:P,startDTS:I,endDTS:F}),o.setElementaryStreamInfo(O,C,P,I,F),this.bufferFragmentData(p,o,u,a)}if(v&&null!=c&&null!=(t=c.samples)&&t.length){var M={id:r,frag:o,details:v,samples:c.samples};i.trigger(_.FRAG_PARSING_METADATA,M)}if(v&&h){var B={id:r,frag:o,details:v,samples:h.samples};i.trigger(_.FRAG_PARSING_USERDATA,B)}}}else this.resetWhenMissingContext(a)},r._bufferInitSegment=function(e,t,r,i){var n=this;if(this.state===si){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a=t.audio,s=t.video,o=t.audiovideo;if(a){var u=e.audioCodec,l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),e.audioCodec&&e.audioCodec!==u&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+u+'"'),a.levelCodec=u,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]")}s&&(s.levelCodec=e.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(_.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(_.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tickImmediate()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,at)},r.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ri},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(ur.isBuffered(e,r)?t=this.getAppendedFrag(r):ur.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n||(this.fragPlaying=t,this.hls.trigger(_.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(_.LEVEL_SWITCHED,{level:n}))}}},s(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&g(t)&&g(r.programDateTime)){var i=r.programDateTime+1e3*(t-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(hi),An=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new En,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,w(t.debug||!1,"Hls instance");var r=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Ar(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var i=("level"===e?"playlist":e)+"LoadPolicy",a=void 0===t[i],s=[];n.forEach((function(n){var o=e+"Loading"+n,u=t[o];if(void 0!==u&&a){s.push(o);var l=r[i].default;switch(t[i]={default:l},n){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}})),s.length&&A.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(t[i]))})),i(i({},r),t)}(e.DefaultConfig,t);this.userConfig=t,r.progressive&&xr(r);var n=r.abrController,a=r.bufferController,s=r.capLevelController,o=r.errorController,u=r.fpsController,l=new o(this),d=this.abrController=new n(this),h=this.bufferController=new a(this),c=this.capLevelController=new s(this),f=new u(this),v=new dt(this),p=new Et(this),g=r.contentSteeringController,m=g?new g(this):null,y=this.levelController=new Rr(this,m),E=new Fr(this),b=new Hr(this.config),T=this.streamController=new wn(this,E,b);c.setStreamController(T),f.setStreamController(T);var S=[v,y,T];m&&S.splice(1,0,m),this.networkControllers=S;var L=[d,h,c,f,p,E];this.audioTrackController=this.createController(r.audioTrackController,S);var k=r.audioStreamController;k&&S.push(new k(this,E,b)),this.subtitleTrackController=this.createController(r.subtitleTrackController,S);var x=r.subtitleStreamController;x&&S.push(new x(this,E,b)),this.createController(r.timelineController,L),b.emeController=this.emeController=this.createController(r.emeController,L),this.cmcdController=this.createController(r.cmcdController,L),this.latencyController=this.createController(bt,L),this.coreComponents=L,S.push(l);var R=l.onErrorOut;"function"==typeof R&&this.on(_.ERROR,R,l)}e.isMSESupported=function(){return fi()},e.isSupported=function(){return function(){if(!fi())return!1;var e=Ce();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(Fe(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(Fe(t,"audio"))})))}()},e.getMediaSource=function(){return Ce()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(A.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===_.ERROR;this.trigger(_.ERROR,{type:E.OTHER_ERROR,details:b.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){A.log("destroy"),this.trigger(_.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){A.log("attachMedia"),this._media=e,this.trigger(_.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){A.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=p.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,A.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),A.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){A.log("stopLoad"),this.started=!1,this.networkControllers.forEach((function(e){e.stopLoad()}))},t.resumeBuffering=function(){this.started&&this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.startLoad(-1)}))},t.pauseBuffering=function(){this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.stopLoad()}))},t.swapAudioCodec=function(){A.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){A.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null},s(e,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){A.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){A.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){A.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){A.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){A.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(A.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return Tt.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{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:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{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:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.13"}},{key:"Events",get:function(){return _}},{key:"ErrorTypes",get:function(){return E}},{key:"ErrorDetails",get:function(){return b}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:wr},set:function(t){e.defaultConfig=t}}]),e}();return An.defaultConfig=void 0,An}()}(!1)},21:(e,t,r)=>{r.d(t,{c:()=>n.a});var i=r(539),n=r.n(i)}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};function n(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 a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(){s=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var c={};function f(){}function v(){}function p(){}var g={};l(g,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(A([])));y&&y!==t&&r.call(y,a)&&(g=y);var _=p.prototype=f.prototype=Object.create(g);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(i,a,s,o){var u=h(e[i],e,a);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===c)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=h(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),c;var n=h(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function A(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:x}}function x(){return{value:void 0,done:!0}}return v.prototype=p,i(_,"constructor",{value:p,configurable:!0}),i(p,"constructor",{value:v,configurable:!0}),v.displayName=l(p,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},E(b.prototype),l(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new b(d(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(_),l(_,u,"Generator"),l(_,a,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=A,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function o(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){o(a,i,n,s,u,"next",e)}function u(e){o(a,i,n,s,u,"throw",e)}s(void 0)}))}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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,g(i.key),i)}}function h(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){var t=function(e,t){if("object"!=typeof e||null===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)}r.d(i,{N:()=>$t,c:()=>er.c});var m=r(228),y=r.n(m);function _(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 E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){x(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(){b=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof c?t:c,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function c(){}function f(){}function v(){}var p={};u(p,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(A([])));m&&m!==t&&r.call(m,a)&&(p=m);var y=v.prototype=c.prototype=Object.create(p);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=d(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var n=d(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function A(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:x}}function x(){return{value:void 0,done:!0}}return f.prototype=v,i(y,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:f,configurable:!0}),f.displayName=u(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},_(E.prototype),u(E.prototype,s,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new E(l(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(y),u(y,o,"Generator"),u(y,a,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=A,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function T(e){return(T="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})(e)}function S(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function L(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){S(a,i,n,s,o,"next",e)}function o(e){S(a,i,n,s,o,"throw",e)}s(void 0)}))}}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(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,U(i.key),i)}}function A(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function x(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&C(e,t)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function P(){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}}function I(e,t,r){return(I=P()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&C(n,r.prototype),n}).apply(null,arguments)}function O(e){var t="function"==typeof Map?new Map:void 0;return O=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;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,i)}function i(){return I(e,arguments,D(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),C(i,e)},O(e)}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e){var t=P();return function(){var r,i=D(e);if(t){var n=D(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return F(e)}(this,r)}}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=D(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},B.apply(this,arguments)}function N(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}function U(e){var t=function(e,t){if("object"!=typeof e||null===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)}var G={DEBUG:1,LOG:2,WARN:3,ERROR:4},V=["Boolean","Number","String","Undefined","Null","Date","Object"],j=function(){function e(t,r){k(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return A(e,[{key:"debug",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.DEBUG].concat(i)),e.disabled||(t=console).debug.apply(t,[this._prefix,H()].concat(i))}},{key:"log",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.LOG].concat(i)),e.disabled||(t=console).log.apply(t,[this._prefix,H()].concat(i))}},{key:"warn",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.WARN].concat(i)),e.disabled||(t=console).warn.apply(t,[this._prefix,H()].concat(i))}},{key:"error",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.ERROR].concat(i)),e.disabled||(t=console).error.apply(t,[this._prefix,H()].concat(i))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];var a=i.map((function(e){return z(e)}));t=this._prefix+H()+JSON.stringify(a)}catch(e){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function H(){return(new Date).toLocaleString()}function K(e){if("object"!==T(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function z(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==T(e))return e;var n=Object.prototype.toString.call(e).slice(8,-1);if(!V.includes(n))return n;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?i[a]=K(e[a]):"object"===T(e[a])?i[a]=z(e[a],t,r+1):i[a]=e[a]);return i}}x(j,"disabled",!0);var W,q="core.ttfb",Y="core.metadataparsed",X="core.sei",Q="core.flvscriptdata",J="core.demuxedtrack",Z="core.streamexception",$="real_time_speed",ee="network",te="network_timeout",re="demux",ie="remux",ne="media",ae="other",se="FLV",oe="FMP4",ue="MSE_ADD_SB",le="MSE_APPEND_BUFFER",de="MSE_OTHER",he="MSE_FULL",ce="MSE_CHANGE_TYPE",fe=(x(W={},"manifest",{HLS:1100,DASH:1200}),x(W,ee,2100),x(W,te,2101),x(W,"network_forbidden",2103),x(W,"network_notfound",2104),x(W,"network_range_not_satisfiable",2116),x(W,re,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),x(W,ie,{FMP4:4100,MP4:4200}),x(W,ne,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),x(W,"drm",{LICENSE:7100,CUSTOM_LICENSE:7200}),x(W,ae,8e3),x(W,"runtime",{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),W),ve=function(e){R(r,O(Error));var t=M(r);function r(e,i,n,a,s){var o;return k(this,r),(o=t.call(this,s||(null==n?void 0:n.message))).errorType=e===te?ee:e,o.originError=n,o.ext=a,o.errorCode=fe[e][i]||fe[e],o.errorMessage=o.message,o.errorCode||(o.errorType=ae,o.errorCode=fe[o.errorType]),o}return A(r,null,[{key:"create",value:function(e,t,i,n,a){return e instanceof r?e:(e instanceof Error&&(i=e,e=""),e||(e=ae),new r(e,t,i,n,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?te:ee,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(),pe=function(){function e(){k(this,e)}return A(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(e){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],i=0,n=e.length;i<n;i++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(i)-o<=t){var u=e.end(i);u>o&&(s[1]=u)}else r.push([e.start(i),e.end(i)])}else r.push([e.start(i),e.end(i)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var n=0,a=0,s=0,o=0,u=0,l=0,d=0,h=e.buffers(t,i),c=0,f=h.length;c<f;c++){var v=h[c];if(r+i>=v[0]&&r<=v[1])n=v[0],a=v[1],s=c;else{if(r+i<v[0]){o=v[0],u=v[1];break}r+i>v[1]&&(l=v[0],d=v[1])}}return{start:n,end:a,index:s,buffers:h,nextStart:o,nextEnd:u,prevStart:l,prevEnd:d,currentTime:r,behind:r-n,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(h)}}},{key:"isBuffered",value:function(t,r){if(t){var i=e.get(t);if(null!=i&&i.length)for(var n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}return!1}}]),e}();function ge(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var ye="fetch",_e="arraybuffer",Ee="text",be=function(e){R(r,O(Error));var t=M(r);function r(e,i,n,a){var s;return k(this,r),x(F(s=t.call(this,a)),"retryCount",0),x(F(s),"isTimeout",!1),x(F(s),"loaderType",ye),x(F(s),"startTime",0),x(F(s),"endTime",0),x(F(s),"options",{}),s.url=e,s.request=i,s.response=n,s}return A(r)}(),Te=Object.prototype.toString;function Se(e){if("[object Object]"!==Te.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Le(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function ke(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function we(e,t){if(e){if(!t)return e;var r,i=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===Te.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===T(e)}(t)&&(t=JSON.stringify(t)),"".concat(ke(e),"=").concat(ke(t))})).join("&")})).filter(Boolean).join("&");if(i){var n=e.indexOf("#");-1!==n&&(e=e.slice(0,n)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function Ae(e,t,r,i,n,a,s,o,u,l,d){return n=null!=n?parseFloat(n):null,i=parseInt(i||"0",10),Number.isNaN(i)&&(i=0),{data:e,done:t,options:{range:u,vid:l,index:o,contentLength:i,age:n,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:d},response:r}}function xe(e,t){return Math.round(8*e*1e3/t/1024)}var Re=2097152,De=function(e){R(i,y());var t,r=M(i);function i(){var e;return k(this,i),x(F(e=r.call(this)),"_abortController",null),x(F(e),"_timeoutTimer",null),x(F(e),"_reader",null),x(F(e),"_response",null),x(F(e),"_aborted",!1),x(F(e),"_index",-1),x(F(e),"_range",null),x(F(e),"_receivedLength",0),x(F(e),"_running",!1),x(F(e),"_logger",null),x(F(e),"_vid",""),x(F(e),"_onProcessMinLen",0),x(F(e),"_onCancel",null),x(F(e),"_priOptions",null),e}return A(i,[{key:"load",value:function(e){var t,r=this,i=e.url,n=e.vid,a=e.timeout,s=e.responseType,o=e.onProgress,u=e.index,l=e.onTimeout,d=e.onCancel,h=e.range,c=e.transformResponse,f=e.request,v=e.params,p=e.logger,g=e.method,m=e.headers,y=e.body,_=e.mode,E=e.credentials,T=e.cache,S=e.redirect,k=e.referrer,w=e.referrerPolicy,A=e.onProcessMinLen,x=e.priOptions;this._logger=p,this._aborted=!1,this._onProcessMinLen=A,this._onCancel=d,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=h||[0,0],this._vid=n||i,this._priOptions=x||{};var R={method:g,headers:m,body:y,mode:_,credentials:E,cache:T,redirect:S,referrer:k,referrerPolicy:w,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},D=!1;clearTimeout(this._timeoutTimer),i=we(i,v);var C=Le(h);C&&(m=f?f.headers:R.headers=R.headers||(Headers?new Headers:{}),Headers&&m instanceof Headers?m.append("Range",C):m.Range=C),a&&(this._timeoutTimer=setTimeout((function(){if(D=!0,r.cancel(),l){var e=new be(i,R,null,"timeout");e.isTimeout=!0,l(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var P=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",h),new Promise((function(e,t){fetch(f||i,f?void 0:R).then(function(){var n=L(b().mark((function n(a){var l,d,f,v;return b().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){n.next=4;break}return n.abrupt("return");case 4:if(c&&(a=c(a,i)||a),a.ok){n.next=7;break}throw new be(i,R,a,"bad network response");case 7:if(l=Date.now(),s!==Ee){n.next=15;break}return n.next=11,a.text();case 11:d=n.sent,r._running=!1,n.next=37;break;case 15:if("json"!==s){n.next=22;break}return n.next=18,a.json();case 18:d=n.sent,r._running=!1,n.next=37;break;case 22:if(!o){n.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,o,P,l),n.abrupt("return");case 29:return n.next=31,a.arrayBuffer();case 31:d=n.sent,d=new Uint8Array(d),r._running=!1,f=Date.now()-P,v=xe(d.byteLength,f),r.emit($,{speed:v,len:d.byteLength,time:f,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",h),e(Ae(d,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),P,l,u,h,r._vid,r._priOptions));case 39:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){var n;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!D||((e=e instanceof be?e:new be(i,R,null,null===(n=e)||void 0===n?void 0:n.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=D,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(t=L(b().mark((function e(){return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,i){var n=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new be(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Re),this._writeIdx=0);var s,o,u,l=this._reader=e.body.getReader(),d=function(){var a=L(b().mark((function a(){var h,c,f,v,p,g,m,y;return b().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return o=Date.now(),a.prev=1,a.next=4,l.read();case 4:s=a.sent,u=Date.now(),a.next=13;break;case 8:return a.prev=8,a.t0=a.catch(1),u=Date.now(),n._aborted||(n._running=!1,a.t0.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n.reject(a.t0)),a.abrupt("return");case 13:if(c=(null===(h=n._range)||void 0===h?void 0:h.length)>0?n._range[0]:0,f=c+n._receivedLength,!n._aborted){a.next=19;break}return n._running=!1,t(void 0,!1,{range:[f,f],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),a.abrupt("return");case 19:v=s.value?s.value.byteLength:0,n._receivedLength+=v,n._logger.debug("【fetchLoader,onProgress call】,task,",n._range,", start,",f,", end,",c+n._receivedLength,", done,",s.done),n._onProcessMinLen>0?n._writeIdx+v>=n._onProcessMinLen||s.done?((p=new Uint8Array(n._writeIdx+v)).set(n._cache.slice(0,n._writeIdx),0),v>0&&p.set(s.value,n._writeIdx),n._writeIdx=0,n._logger.debug("【fetchLoader,onProgress enough】,done,",s.done,",len,",p.byteLength,", writeIdx,",n._writeIdx)):v>0&&n._writeIdx+v<Re?(n._cache.set(s.value,n._writeIdx),n._writeIdx+=v,n._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",n._writeIdx)):v>0&&(g=new Uint8Array(n._writeIdx+v+2048),n._logger.debug("【fetchLoader,onProgress extra start】,size,",n._writeIdx+v+2048,", datalen,",v,", writeIdx,",n._writeIdx),g.set(n._cache.slice(0,n._writeIdx),0),v>0&&g.set(s.value,n._writeIdx),n._writeIdx+=v,delete n._cache,n._cache=g,n._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",n._writeIdx)):p=s.value,(p&&p.byteLength>0||s.done)&&t(p,s.done,{range:[n._range[0]+n._receivedLength-(p?p.byteLength:0),n._range[0]+n._receivedLength],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),s.done?(m=Date.now()-r,y=xe(n._receivedLength,m),n.emit($,{speed:y,len:n._receivedLength,time:m,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions}),n._running=!1,n._logger.debug("[fetchLoader onProgress end],task,",n._range,",done,",s.done),n.resolve(Ae(s,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,i,n._index,n._range,n._vid,n._priOptions))):d();case 25:case"end":return a.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();d()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),i}(),Ce=function(e){R(r,y());var t=M(r);function r(){var e;return k(this,r),x(F(e=t.call(this)),"_xhr",null),x(F(e),"_aborted",!1),x(F(e),"_timeoutTimer",null),x(F(e),"_range",null),x(F(e),"_receivedLength",0),x(F(e),"_url",null),x(F(e),"_onProgress",null),x(F(e),"_index",-1),x(F(e),"_headers",null),x(F(e),"_currentChunkSizeKB",384),x(F(e),"_timeout",null),x(F(e),"_xhr",null),x(F(e),"_withCredentials",null),x(F(e),"_startTime",-1),x(F(e),"_loadCompleteResolve",null),x(F(e),"_loadCompleteReject",null),x(F(e),"_runing",!1),x(F(e),"_logger",!1),x(F(e),"_vid",""),x(F(e),"_responseType",void 0),x(F(e),"_credentials",void 0),x(F(e),"_method",void 0),x(F(e),"_transformResponse",void 0),x(F(e),"_firstRtt",void 0),x(F(e),"_onCancel",null),x(F(e),"_priOptions",null),e}return A(r,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=we(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof be?e:new be(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===_e&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,i=this._range[1];t<this._range[1]-r&&(i=r+t),e=[r,i],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,i,n;t._running=!1;var a=new be(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.status)+",statusText,"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new be(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var i=this._headers||{},n=Le(e);n&&(i.Range=n),i&&Object.keys(i).forEach((function(e){r.setRequestHeader(e,i[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var i=new be(this._url,null,E(E({},e.target.response),{},{status:r}),"bad response,status:"+r);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var n,a=null,s=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===_e){var u,l=new Uint8Array(e.target.response);if(n=o+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=xe(this._receivedLength,d);this.emit($,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[n,o+this._receivedLength],priOptions:this._priOptions})}a=l,s=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",n,"end ",o+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",s)}else s=!0,a=e.target.response;var c={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(c=this._transformResponse(c,this._url)||c),this._onProgress&&this._onProgress(a,s,{index:this._index,vid:this._vid,range:[n,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},c),s?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Ae(this._onProgress?null:a,s,c,c.headers["content-length"],c.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,B(D(r.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(i.s();!(t=i.n()).done;){var n=t.value.split(": ");r[n[0].toLowerCase()]=n.slice(1).join(": ")}}catch(e){i.e(e)}finally{i.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),r}();function Pe(){var e,t,r=new Promise((function(r,i){e=r,t=i}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function Ie(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var Oe=["retry","retryDelay","onRetryError","transformError"],Fe=function(){function e(t,r){k(this,e),this.promise=Pe(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new j("Loader")),this._loaderType=t,this._loader=t===ye&&"undefined"!=typeof fetch?new De:new Ce,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return A(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,i=t.retryDelay,n=t.onRetryError,a=t.transformError,s=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(t,Oe),o=function(){var t=L(b().mark((function t(){var u,l,d;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(s);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,a&&(l=a(l)||l),n&&e._retryCount>0&&n(l,e._retryCount,{index:s.index,vid:s.vid,range:s.range,priOptions:s.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",s.range),e._retryTimer=setTimeout(o,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=L(b().mark((function e(){return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}(),Me=function(e){R(i,y());var t,r=M(i);function i(e){var t;return k(this,i),x(F(t=r.call(this,e)),"type",ye),x(F(t),"_queue",[]),x(F(t),"_alive",[]),x(F(t),"_currentTask",null),x(F(t),"_finnalUrl",""),x(F(t),"_config",void 0),t._config=function(e){return E({loaderType:ye,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:Ee,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),"xhr"!==t._config.loaderType&&De.isSupported()||(t.type="xhr"),t.log=e.logger,t}return A(i,[{key:"isFetch",value:function(){return this.type===ye}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&Se(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&Se(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var i=new Fe(this.type,r);return i.loader.on($,(function(e){t.emit($,e)})),this._queue.push(i),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),i.promise}},{key:"cancel",value:(t=L(b().mark((function e(){var t;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,me();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return De.isSupported()}}]),i}(),Be=function(){function e(t){var r=this;k(this,e),x(this,"_seiSet",new Set),this.emitter=t,t.on(X,(function(e){e&&r._seiSet.add(e)}))}return A(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var i=e-.2,n=e+.2,a=[];this._seiSet.forEach((function(e){e.time>=i&&e.time<=n&&a.push(e)})),a.forEach((function(e){r._seiSet.delete(e),r.emitter.emit("core.seiintime",e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),Ne=function(){function e(t){k(this,e),x(this,"_chunkSpeed",0),x(this,"_chunkCache",[]),x(this,"_speeds",[]),x(this,"_totalSize",0),x(this,"_totalCost",0),this._opts=t||{}}return A(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,i;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var n=(null===(i=this._opts)||void 0===i?void 0:i.chunkCountForSpeed)||50;this._chunkCache.length>n&&(this._chunkCache=this._chunkCache.slice(-n))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),Ue=function(){function e(t){k(this,e),x(this,"encodeType",""),x(this,"audioCodec",""),x(this,"videoCodec",""),x(this,"domain",""),x(this,"fps",0),x(this,"bitrate",0),x(this,"width",0),x(this,"height",0),x(this,"samplerate",0),x(this,"channelCount",0),x(this,"gop",0),x(this,"_bitsAccumulateSize",0),x(this,"_bitsAccumulateDuration",0),x(this,"_startGopId",-1),this._timescale=t}return A(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,i=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;i&&i>0&&i<100&&(this.fps=i)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ge=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;k(this,e),x(this,"_core",null),x(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new Ue(r),this._bindEvents()}return A(e,[{key:"getStats",value:function(){var e,t,r,i,n,a,s,o,u,l,d,h=(null===(e=this._core)||void 0===e?void 0:e.media)||{},c=h.currentTime,f=void 0===c?0:c,v=h.decodeFps,p=void 0===v?0:v;return E(E({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(i=this._core)||void 0===i||null===(n=i.speedInfo)||void 0===n?void 0:n.call(i).avgSpeed)||0,totalReceivedByte:(null===(a=this._core)||void 0===a||null===(s=a.speedInfo)||void 0===s?void 0:s.call(a).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:f,bufferEnd:(null===(l=this._core)||void 0===l||null===(d=l.bufferInfo())||void 0===d?void 0:d.remaining)||0,decodeFps:p})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(J,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Q,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Y,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(q,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new Ue(this._timescale)}}]),e}(),Ve=function(){function e(){k(this,e),x(this,"_prevCurrentTime",0)}return A(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var n=e.currentTime,a=0;if(this._prevCurrentTime===n){var s=pe.info(pe.get(e),n);if(!s.buffers.length)return;r&&s.nextStart||s.nextStart&&s.nextStart-n<t?a=s.nextStart+.1:s.end&&s.end-n>i&&!e.seeking&&(a=n+.1)}this._prevCurrentTime=n,a&&n!==a&&(e.currentTime=a)}}}]),e}(),je="undefined"!=typeof window;function He(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return je?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(e){}}function Ke(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var ze="updateDuration",We=function(){function e(t,r){var i=this;k(this,e),x(this,"media",null),x(this,"mediaSource",null),x(this,"_openPromise",Pe()),x(this,"_queue",Object.create(null)),x(this,"_sourceBuffer",Object.create(null)),x(this,"_mseFullFlag",{}),x(this,"_st",0),x(this,"_opst",0),x(this,"_logger",null),x(this,"_config",null),x(this,"_url",null),x(this,"_onStartStreaming",(function(){i._logger.debug("startstreaming")})),x(this,"_onEndStreaming",(function(){i._logger.debug("endstreaming")})),x(this,"_onSBUpdateEnd",(function(e){var t=i._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==ze&&t.shift(),r){var n,a,s=Ie()-i._opst;i._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),function(e){try{return JSON.stringify(e)}catch(e){return""}}(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(n=i._sourceBuffer[e])||void 0===n?void 0:n.buffered)),s,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:s});var o=null===(a=r.context)||void 0===a?void 0:a.callback;o&&"function"==typeof o&&o(r.context),i._startQueue(e)}}})),x(this,"_onSBUpdateError",(function(e,t){var r=i._queue[e];if(r){var n=r[0];n&&(i._logger.error("UpdateError",e,n.opName,n.context),n.promise.reject(new ve(ne,le,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new j("MSE"),this._config.openLog&&j.enable()}var t,r,i;return A(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var i=e._queue[r];Array.isArray(i)&&(t||(t=i.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!Ke(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var i=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{i=Math.max(t.bufferEnd(e)||0,i)}catch(e){}})),e<i)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),ze,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var i=Ie()-e._st;e._logger.debug("sourceopen",i),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:i})})),this._openPromise=Pe()}return this._openPromise}},{key:"bindMedia",value:(i=L(b().mark((function e(t){var r,i,n,a,s=this;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=He(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new r,n=Ke(i),this._st=Ie(),a=function e(){var r=Ie()-s._st;s._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",a),n&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=n,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(r=L(b().mark((function e(){var t,r,i,n=this;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=n._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,r&&i)try{t.endOfStream()}catch(e){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(n._sourceBuffer[e])}catch(e){}})),Ke(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(e){}this.media=null}this.mediaSource=null,this._openPromise=Pe(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(e){throw new ve(ne,ue,e)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,i=this._sourceBuffer[e];return this.mediaSource&&i&&i.mimeType!==t?"function"!=typeof i.changeType?Promise.reject(new ve(ne,ce,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{i.changeType(t)}catch(e){throw new ve(ne,ce,e)}i.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var i=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var n;i.mediaSource&&!i.media.error&&(i._logger.debug("MSE APPEND START",r),i._opst=Ie(),null===(n=i._sourceBuffer[e])||void 0===n||n.appendBuffer(t))}),"appendBuffer",r):Promise.resolve()}},{key:"remove",value:function(e,t,r,i){var n=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(n.mediaSource&&!n.media.error){var a=n._sourceBuffer[e];t>=r||!a?n._onSBUpdateEnd(e):(n._opst=Ie(),n._logger.debug("MSE REMOVE START",e,t,r,i),a.remove(t,r))}}),"removeBuffer",i,a)}},{key:"clearBuffer",value:function(e,t){var r,i=this;return Object.keys(this._sourceBuffer).forEach((function(n){r=i.remove(n,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var i=t._sourceBuffer[r];e=t.remove(r,0,pe.end(pe.get(i)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var i=this._queue[e];if(t&&i)this._queue[e]=[];else if(i&&i[e]&&!(i.length<5)){var n=[];i.forEach((function(e){e.context&&e.context.isinit&&n.push(e)})),this._queue[e]=i.slice(0,2),n.length>0&&(r=this._queue[e]).push.apply(r,n)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return pe.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return pe.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return pe.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,i,n){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:Pe(),opName:r,context:i};return n?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=L(b().mark((function e(t,r,i){var n,a,s=this;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((n=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],n.forEach((function(e){var t=s._queue[e],n=Pe();a.push(n),t.push({exec:function(){n.resolve()},promise:n,opName:r,context:i}),1===t.length&&s._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{n.forEach((function(e){var t=s._queue[e],r=s._sourceBuffer[e];null==t||t.shift(),r&&r.updating||s._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,i){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(i){i&&i.message&&i.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,r.context&&"object"===T(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new ve(ne,he,i))):(this._logger.error(i),r.promise.reject(i.constructor===ve?i:new ve(ne,de,i)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var i=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),i._sourceBuffer[e].timestampOffset=t,i._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=He();if(!t)return!1;try{return t.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ye(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,nt(i.key),i)}}function Xe(e,t,r){return t&&Ye(e.prototype,t),r&&Ye(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Qe(e,t,r){return(t=nt(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$e(e,t)}function Ze(e){return(Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t){return($e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t=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}}();return function(){var r,i=Ze(e);if(t){var n=Ze(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function tt(e){return function(e){if(Array.isArray(e))return it(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rt(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rt(e,t){if(e){if("string"==typeof e)return it(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?it(e,t):void 0}}function it(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}function nt(e){var t=function(e,t){if("object"!=typeof e||null===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)}x(We,"VIDEO","video"),x(We,"AUDIO","audio");var at=function(){function e(t){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return Xe(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(at,"disabled",!0);var st="video",ot="hevc",ut="aac",lt="LARGE_AV_SHIFT",dt="LARGE_VIDEO_GAP",ht="LARGE_VIDEO_GAP_BETWEEN_CHUNK",ct="LARGE_AUDIO_GAP",ft="AUDIO_FILLED",vt="AUDIO_DROPPED",pt=function(){function e(){qe(this,e),Qe(this,"id",1),Qe(this,"type",st),Qe(this,"codecType","avc"),Qe(this,"pid",-1),Qe(this,"hvcC",void 0),Qe(this,"codec",""),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"sequenceNumber",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"baseDts",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"pps",[]),Qe(this,"sps",[]),Qe(this,"vps",[]),Qe(this,"fpsNum",0),Qe(this,"fpsDen",0),Qe(this,"sarRatio",[]),Qe(this,"width",0),Qe(this,"height",0),Qe(this,"nalUnitSize",4),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"isVideo",!0),Qe(this,"kid",null),Qe(this,"pssh",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),gt=function(){function e(){qe(this,e),Qe(this,"id",2),Qe(this,"type","audio"),Qe(this,"codecType",ut),Qe(this,"pid",-1),Qe(this,"codec",""),Qe(this,"sequenceNumber",0),Qe(this,"sampleDuration",0),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"baseDts",0),Qe(this,"sampleSize",16),Qe(this,"sampleRate",0),Qe(this,"channelCount",0),Qe(this,"objectType",0),Qe(this,"sampleRateIndex",0),Qe(this,"config",[]),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"kid",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===ut)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),mt=function(){function e(t,r,i){qe(this,e),Qe(this,"flag",{}),Qe(this,"keyframe",!1),Qe(this,"gopId",0),Qe(this,"duration",0),Qe(this,"size",0),Qe(this,"units",[]),Qe(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,i&&(this.units=i)}return Xe(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),yt=Xe((function e(t,r,i,n){qe(this,e),Qe(this,"duration",1024),Qe(this,"flag",{dependsOn:2,isNonSyncSample:0}),Qe(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=n,i&&(this.duration=i)})),_t=Xe((function e(t,r){qe(this,e),Qe(this,"time",0),this.data=t,this.originPts=this.pts=r})),Et=function(e){Je(r,_t);var t=et(r);function r(){return qe(this,r),t.apply(this,arguments)}return Xe(r)}(),bt=function(e){Je(r,_t);var t=et(r);function r(){return qe(this,r),t.apply(this,arguments)}return Xe(r)}(),Tt=function(){function e(){qe(this,e),Qe(this,"id",3),Qe(this,"type","metadata"),Qe(this,"timescale",0),Qe(this,"flvScriptSamples",[]),Qe(this,"seiSamples",[])}return Xe(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),St="undefined"!=typeof window,Lt=St&&navigator.userAgent.toLocaleLowerCase(),kt=St&&/^((?!chrome|android).)*safari/.test(Lt),wt=St&&Lt.includes("firefox"),At=St&&Lt.includes("android"),xt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var i=t.length,n=0;n+2<i&&(255!==t[n]||240!=(246&t[n+1]));)n++;if(!(n>=i)){var a=n,s=[],o=(60&t[n+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var l,d,h=1+((192&t[n+2])>>>6),c=(1&t[n+2])<<2|(192&t[n+3])>>>6,f=e._getConfig(o,c,h),v=f.config,p=f.codec,g=0,m=e.getFrameDuration(u);n+7<i;)if(255===t[n]&&240==(246&t[n+1])){if(!(d=(3&t[n+3])<<11|t[n+4]<<3|(224&t[n+5])>>5)||i-n<d)break;l=2*(1&~t[n+1]),s.push({pts:r+g*m,data:t.subarray(n+7+l,n+d)}),g++,n+=d}else n++;return{skip:a,remaining:n>=i?void 0:t.subarray(n),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:h,channelCount:c,codec:p,config:v,originCodec:"mp4a.40.".concat(h)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,i=(7&t[0])<<1|t[1]>>>7,n=(120&t[1])>>>3,a=e.FREQ[i];if(a){var s=e._getConfig(i,n,r);return{samplingFrequencyIndex:i,sampleRate:a,objectType:r,channelCount:n,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}},{key:"_getConfig",value:function(e,t,r){var i,n,a=[];return wt?e>=6?(i=5,n=e-3):(i=2,n=e):At?(i=2,n=e):(i=2===r||5===r?r:5,n=e,e>=6?n=e-3:1===t&&(i=2,n=e)),a[0]=i<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===i&&(a[1]|=(14&n)>>1,a[2]=(1&n)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(i)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();Qe(xt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Rt=5e3,Dt=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=i,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return Xe(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var n=this.videoTrack,a=this.audioTrack;if(!r&&i||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!i&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,n),!i&&t&&(this._audioNextPts=this._videoNextDts=t),this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist())&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(n),this.metadataTrack.exist()){var s=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s}))}n.samples.length&&(n.baseMediaDecodeTime=n.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var i;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)i=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var n=e.samples[0],a=e.samples[r.length-1];i=Math.floor((a.dts-n.dts)/(r.length-1))}else i=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u,l=r.length,d=0,h=r[0],c=this._videoNextDts-h.dts;if(Math.abs(c)>200)Math.abs(h.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3&&(this._lastVideoExceptionChunkFirstDtsDot=h.dts,e.warnings.push({type:ht,nextDts:this._videoNextDts,firstSampleDts:h.dts,nextSampleDts:null===(u=r[1])||void 0===u?void 0:u.dts,sampleDuration:c})),this._videoTimestampBreak>=5?(this._videoNextDts=h.dts,this._videoTimestampBreak=0):(h.dts+=c,h.pts+=c,this.audioTrack.exist()||(this._videoTimestampBreak=1));for(var f=0;f<l;f++){var v=r[f].dts,p=r[f+1];((d=f<l-1?p.dts-v:s?s.dts-v:i)>1e3||d<0)&&(this._videoTimestampBreak++,Math.abs(v-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=v,e.warnings.push({type:dt,time:v/e.timescale,dts:v,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:d,refSampleDuration:i})),d=i),r[f].duration=d,this._videoNextDts+=d,this._lastVideoDuration=d}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,i=t.samples;if(!r.length&&!i.length)return!1;var n=1/0,a=1/0;r.length&&(e.baseDts=n=r[0].pts),i.length&&(t.baseDts=a=i[0].dts),this._baseDts=Math.min(n,a);var s=a-n;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:lt,videoBaseDts:a,audioBasePts:n,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=e.codecType===ut?xt.getFrameDuration(e.timescale,r):this._getG711Duration(e));var i=e.sampleDuration,n=e.codecType===ut?1024:i*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],l=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,l=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&l>=3*i&&l<=1e3&&!kt){var d=this._getSilentFrame(e)||t[0].data.subarray(),h=Math.floor(l/i);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Rt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:ft,pts:u.pts,originPts:u.originPts,count:h,nextPts:o,refSampleDuration:i}));for(var c=0;c<h;c++){var f=new yt(Math.floor(this._audioNextPts+i)-Math.floor(this._audioNextPts),d,n);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=i,s++}s--}else l<=-3*i&&l>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Rt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:vt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:i})),t.splice(s,1),s--):(Math.abs(l)>1e3&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Rt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:ct,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:l,refSampleDuration:i}))),u.dts=u.pts=o,u.duration=n,this._audioNextPts+=i)}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,i=e.sampleRate,n=e.samples[0];if(n)return 2*n.data.byteLength/r/(t/8)/i*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===ut?xt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}();function Ct(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function Pt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function It(e){for(var t,r="avc1.",i=0;i<3;i++)(t=e[i].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function Ot(e){if(!Array.isArray(e)){for(var t=[],r="",i=0;i<e.length;i++)i%2&&(r=e[i-1]+e[i],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}Math.pow(2,32);var Ft=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,i=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((i=2+ ++r)>=t)return[];for(var n=[];i<t;)switch(e[i]){case 0:if(0!==e[i-1]){i+=2;break}if(0!==e[i-2]){i++;break}r!==i-2&&n.push(e.subarray(r,i-2));do{i++}while(1!==e[i]&&i<t);i=(r=i+1)+2;break;case 1:if(0!==e[i-1]||0!==e[i-2]){i+=3;break}r!==i-2&&n.push(e.subarray(r,i-2)),i=(r=i+1)+2;break;default:i+=3}return r<t&&n.push(e.subarray(r)),n}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,i=e.length,n=[],a=0;a+t<i;)if(r=Pt(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>i)break;n.push(e.subarray(a,a+r)),a+=r}return n}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,i=t?2:1,n=0,a=0,s="";255===e[i];)n+=255,i++;for(n+=e[i++];255===e[i];)a+=255,i++;if(a+=e[i++],5===n&&r>i+16)for(var o=0;o<16;o++)s+=e[i].toString(16),i++;return{payload:e.subarray(i,i+a),type:n,size:a,uuid:s}}},{key:"removeEPB",value:function(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(!r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}}]),e}(),Mt=function(){function e(t){if(qe(this,e),Qe(this,"_bytesAvailable",void 0),Qe(this,"_bitsAvailable",0),Qe(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return Xe(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return 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;for(e=0;e<this._bitsAvailable;++e)if(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:"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:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Bt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,i,n=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],l=0;l<u;l++)if(i=t[o]<<8|t[o+1],o+=2,i){var d=t.subarray(o,o+i);o+=i,a.push(d),r||(r=e.parseSPS(Ft.removeEPB(d)))}var h,c=t[o];o++;for(var f=0;f<c;f++)h=t[o]<<8|t[o+1],o+=2,h&&(s.push(t.subarray(o,o+h)),o+=h);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:n}}}},{key:"parseSPS",value:function(e){var t=new Mt(e);t.readUByte();var r=t.readUByte(),i=t.readUByte(),n=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var l=t.readUEG();if(0===l)t.readUEG();else if(1===l){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var d=t.readUEG(),h=0;h<d;h++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var c=t.readUEG(),f=t.readUEG(),v=t.readBits(1);0===v&&t.skipBits(1),t.skipBits(1);var p,g,m,y,_,E=0,b=0,T=0,S=0;if(t.readBool()&&(E=t.readUEG(),b=t.readUEG(),T=t.readUEG(),S=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:p=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var L=t.readBits(32),k=t.readBits(32);g=t.readBool(),_=(m=k)/(y=2*L)}}return{codec:It(e.subarray(1,4)),profileIdc:r,profileCompatibility:i,levelIdc:n,chromaFormat:a,width:Math.ceil(16*(c+1)-2*(E+b)),height:(2-v)*(f+1)*16-(v?2:4)*(T+S),sarRatio:p,fpsNum:m,fpsDen:y,fps:_,fixedFrame:g}}}]),e}(),Nt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var i,n,a,s,o,u=1+(3&t[21]),l=[],d=[],h=[],c=23,f=t[22],v=0;v<f;v++){a=63&t[c],s=t[c+1]<<8|t[c+2],c+=3;for(var p=0;p<s;p++)if(o=t[c]<<8|t[c+1],c+=2,o){switch(a){case 32:var g=t.subarray(c,c+o);i||(i=e.parseVPS(Ft.removeEPB(g),r)),h.push(g);break;case 33:var m=t.subarray(c,c+o);n||(n=e.parseSPS(Ft.removeEPB(m),r)),l.push(m);break;case 34:d.push(t.subarray(c,c+o))}c+=o}}return{hvcC:r,sps:n,spsArr:l,ppsArr:d,vpsArr:h,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var i=new Mt(t);i.readUByte(),i.readUByte(),i.readBits(12);var n=i.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,n+1),i.readBits(17),e._parseProfileTierLevel(i,n,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var i=new Mt(t);i.readUByte(),i.readUByte(),i.readBits(4);var n=i.readBits(3);r.numTemporalLayers=Math.max(n+1,r.numTemporalLayers||0),r.temporalIdNested=i.readBits(1),e._parseProfileTierLevel(i,n,r),i.readUEG();var a=r.chromaFormatIdc=i.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=i.readBits(1));var u,l,d,h,c=i.readUEG(),f=i.readUEG(),v=i.readBits(1);return 1===v&&(u=i.readUEG(),l=i.readUEG(),d=i.readUEG(),h=i.readUEG()),r.bitDepthLumaMinus8=i.readUEG(),r.bitDepthChromaMinus8=i.readUEG(),1===v&&(c-=(1!==a&&2!==a||0!==o?1:2)*(l+u),f-=(1===a&&0===o?2:1)*(h+d)),{codec:"hev1.1.6.L93.B0",width:c,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var i=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),i),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var n=e.readBits(8);i<r.generalTierFlag?r.generalLevelIdc=n:r.generalLevelIdc=Math.max(n,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==s[u]&&e.readBits(8)}}]),e}(),Ut=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"decode",value:function(t){for(var r=[],i=t,n=0,a=t.length;n<a;)if(i[n]<128)r.push(String.fromCharCode(i[n])),++n;else{if(i[n]<192);else if(i[n]<224){if(e._checkContinuation(i,n,1)){var s=(31&i[n])<<6|63&i[n+1];if(s>=128){r.push(String.fromCharCode(65535&s)),n+=2;continue}}}else if(i[n]<240){if(e._checkContinuation(i,n,2)){var o=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),n+=3;continue}}}else if(i[n]<248&&e._checkContinuation(i,n,3)){var u=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),n+=4;continue}}r.push(String.fromCharCode(65533)),++n}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var i=e;if(t+r<i.length){for(;r--;)if(128!=(192&i[++t]))return!1;return!0}return!1}}]),e}(),Gt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},i=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),n=e._parseValue(new DataView(t.buffer,t.byteOffset+i.size,t.byteLength-i.size));return r[i.data]=n.data,r}}},{key:"_parseValue",value:function(t){var r,i=t.byteLength,n=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),n+=8;break;case 1:r=!!t.getUint8(1),n+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n));r=s.data,n+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(i-4))&&(o=3);n<i-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-o)),l=u.size,d=u.data;if(u.isEnd)break;r[d.name]=d.value,n+=l}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 8:r={},n+=4;var h=0;for(9==(16777215&t.getUint32(i-4))&&(h=3);n<i-8;){var c=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-h)),f=c.size,v=c.data;if(c.isEnd)break;r[v.name]=v.value,n+=f}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 9:r=void 0,n=1,a=!0;break;case 10:r=[];var p=t.getUint32(1);n+=4;for(var g=0;g<p;g++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n)),y=m.data,_=m.size;r.push(y),n+=_}break;case 11:var E=t.getFloat64(n)+6e4*t.getInt16(n+8);r=new Date(E),n+=10;break;case 12:var b=t.getUint32(1);n+=4,r="",b>0&&(r=Ut.decode(new Uint8Array(t.buffer,t.byteOffset+n,b))),n+=b;break;default:n=i}return{data:r,size:n,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Ut.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),i=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:i.data},size:r.size+i.size,isEnd:i.isEnd}}}}]),e}(),Vt=new at("FlvDemuxer"),jt=function(){function e(t,r,i){qe(this,e),Qe(this,"_headerParsed",!1),Qe(this,"_remainingData",null),Qe(this,"_gopId",0),Qe(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new pt,this.audioTrack=r||new gt,this.metadataTrack=i||new Tt,this._fixer=new Dt(this.videoTrack,this.audioTrack,this.metadataTrack)}return Xe(e,[{key:"demux",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.audioTrack,a=this.videoTrack,s=this.metadataTrack;if(!r&&i||(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),n.reset(),s.reset()):(a.samples=[],n.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],n.warnings=[],this._remainingData&&(t=Ct(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:a,audioTrack:n,metadataTrack:s};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");n.present=(4&t[4])>>>2!=0,a.present=!!(1&t[4]),this._headerParsed=!0,o=Pt(t,5)+4}for(var u,l,d,h,c,f=t.length;o+15<f&&(u=t[o],!(o+15+(l=t[o+1]<<16|t[o+2]<<8|t[o+3])>f));)d=(t[o+7]<<24>>>0)+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6],o+=11,h=t.subarray(o,o+l),8===u?this._parseAudio(h,d):9===u?this._parseVideo(h,d):18===u?this._parseScript(h,d):Vt.warn("Invalid tag type: ".concat(u)),(c=Pt(t,o+=l))!==11+l&&Vt.warn("Invalid PrevTagSize ".concat(c," (").concat(11+l,")")),o+=4;return o<f&&(this._remainingData=t.subarray(o)),n.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,n.timescale=n.sampleRate||0,!n.exist()&&n.hasSample()&&n.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:n,metadataTrack:s}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,i){return this.demux(e,t,r),this.fix(i,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var i=(240&t[0])>>>4,n=this.audioTrack;if(10!==i&&7!==i&&8!==i)return Vt.warn("Unsupported sound format: ".concat(i)),void n.reset();if(10!==i){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];n.sampleRate=e.AUDIO_RATE[a],n.sampleSize=s?16:8,n.channelCount=o+1}10===i?this._parseAac(t,r):this._parseG711(t,r,i)}}},{key:"_parseG711",value:function(e,t,r){var i=this.audioTrack;i.codecType=7===r?"g7110a":"g7110m",i.sampleRate=8e3,i.codec=i.codecType,i.samples.push(new yt(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=ut,0===e[1]){var i=xt.parseAudioSpecificConfig(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.objectType=i.objectType,r.sampleRateIndex=i.samplingFrequencyIndex):(r.reset(),Vt.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new yt(t,e.subarray(2)))}else Vt.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var i=(240&e[0])>>>4,n=15&e[0],a=this.videoTrack;if(7!==n&&12!==n)return a.reset(),void Vt.warn("Unsupported codecId: ".concat(n));var s=12===n;a.codecType=s?ot:"avc";var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var l=e.subarray(5),d=s?Nt.parseHEVCDecoderConfigurationRecord(l):Bt.parseAVCDecoderConfigurationRecord(l);if(d){var h=d.hvcC,c=d.sps,f=d.ppsArr,v=d.spsArr,p=d.vpsArr,g=d.nalUnitSize;h&&(a.hvcC=a.hvcC||h),c&&(a.codec=c.codec,a.width=c.width,a.height=c.height,a.sarRatio=c.sarRatio,a.fpsNum=c.fpsNum,a.fpsDen=c.fpsDen),v.length&&(a.sps=v),f.length&&(a.pps=f),p&&p.length&&(a.vps=p),g&&(a.nalUnitSize=g)}else Vt.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Ft.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var y=new mt(t+u,t,m);1===i&&y.setToKeyframe(),a.samples.push(y),m.forEach((function(e){var i=s?e[0]>>>1&63:31&e[0];switch(i){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==i||s&&5===i)break;y.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==i||s&&6===i)break;r.metadataTrack.seiSamples.push(new bt(Ft.parseSEI(Ft.removeEPB(e),s),t+u))}})),y.keyframe&&this._gopId++,y.gopId=this._gopId}else Vt.warn("Cannot parse NALUs",e)}else 2===o||Vt.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new Et(Gt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Pt(e,5)>=9}}]),e}();Qe(jt,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var Ht=function(){function e(){qe(this,e),this.buffer=new Uint8Array(0)}return Xe(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach((function(t){t?e.buffer=function(e){for(var t=0,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];i.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return i.forEach((function(e){a.set(e,s),s+=e.length})),a}(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),Kt=Math.pow(2,32)-1,zt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"box",value: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];var n=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(n);a[0]=n>>24&255,a[1]=n>>16&255,a[2]=n>>8&255,a[3]=255&n,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===st&&e.codecType===ot}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Ct(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Ot(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(tt(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(tt(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,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,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,i=t.enca.sampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>8&255,255&i,0,0]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,n,a,s)}},{key:"encv",value:function(t){var r,i,n=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],l=t.sarRatio[1],d=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,s>>8&255,255&s,o>>8&255,255&o,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]),h=new Uint8Array((r=(i=[1,n[1],n[2],n[3],255,225,n.length>>>8&255,255&n.length]).concat.apply(i,tt(n)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,tt(a))),c=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),v=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,l>>24,l>>16&255,l>>8&255,255&l]);return e.box(e.types.encv,d,e.box(e.types.avcC,h),e.box(e.types.btrt,c),f,e.box(e.types.pasp,v))}},{key:"schi",value:function(t){var r=new Uint8Array([]),i=e.tenc(t);return e.box(e.types.schi,r,i)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Ot(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),i=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),n=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,i),e.box(e.types.schm,n),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===ot,i=r?e.types.hvc1:e.types.avc1,n=r?e.hvcC(t):e.avcC(t),a=[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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),n];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[i].concat(a))}},{key:"avcC",value:function(t){var r,i,n,a=[],s=[];return t.sps.forEach((function(e){n=e.byteLength,a.push(n>>>8&255),a.push(255&n),a.push.apply(a,tt(e))})),t.pps.forEach((function(e){n=e.byteLength,s.push(n>>>8&255),s.push(255&n),s.push.apply(s,tt(e))})),e.box(e.types.avcC,new Uint8Array((r=(i=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(i,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var i,n=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,l=(n.length&&1)+(a.length&&1)+(s.length&&1);i=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,l];var d=function(e){var t;i.push(e.length>>8,e.length),(t=i).push.apply(t,tt(e))};n.length&&(i.push(160,0,n.length),n.forEach(d)),a.length&&(i.push(161,0,a.length),a.forEach(d)),s.length&&(i.push(162,0,s.length),s.forEach(d))}else i=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(i))}},{key:"pasp",value:function(t){var r,i,n=(i=2,function(e){if(Array.isArray(e))return e}(r=t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);u=!0);}catch(e){l=!0,n=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(r,i)||rt(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=n[0],s=n[1];return e.box(e.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]))}},{key:"mp4a",value:function(t){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,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(tt(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(tt(t.map((function(t){return e.traf(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:"traf",value:function(t){var r=e.tfhd(t.id),i=e.tfdt(t,t.baseMediaDecodeTime),n=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){n+=8,e.subsamples&&e.subsamples.length&&(n+=2,n+=6*e.subsamples.length)})),t.videoSencLength=n,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,i,a,s,o,u)}if(t.isAudioEncryption){var l=e.sbgp(),d=e.saiz(t),h=e.saio(t),c=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,i,l,d,h,c,f)}var v=e.sbgp(),p=e.trun1(t);return e.box(e.types.traf,r,i,v,p)}if(t.isVideo){var g=e.trun1(t);return e.box(e.types.traf,r,i,g)}var m=e.sbgp(),y=e.saiz(t),_=e.saio(t),E=e.senc(t),b=e.trun1(t);return e.box(e.types.traf,r,i,m,y,_,E,b)}var T=e.sdtp(t);return e.box(e.types.traf,r,i,T,e.trun(t.samples,T.byteLength+76))}},{key:"sdtp",value:function(t){var r=new Ht;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new Ht,i=Ht.writeUint32(t.samples.length),n=null;if(t.isVideo){var a=t.videoSencLength;n=Ht.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(n=Ht.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),n=Ht.writeUint32(s)}return t.samples.forEach((function(e){r.write(Ht.writeUint32(e.duration)),r.write(Ht.writeUint32(e.size)),r.write(Ht.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Ht.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),i,n,r.buffer)}},{key:"senc",value:function(t){var r=new Ht,i=t.samples.length,n=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||n*i,r.write(Ht.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Ht.writeUint32(i)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(Ht.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Ht.writeUint16(e.BytesOfClearData)),r.write(Ht.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var i=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,i)}},{key:"saiz",value:function(t){var r=t.samples.length,i=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,i)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var i=Math.floor(r/(Kt+1)),n=Math.floor(r%(Kt+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var i=t.length,n=12+16*i;r+=8+n;var a=new Uint8Array(n);a.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);for(var s=0;s<i;s++){var o=t[s],u=o.duration,l=o.size,d=o.flag,h=void 0===d?{}:d,c=o.cts,f=void 0===c?0:c;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|(null===h.dependsOn||void 0===h.dependsOn?1:h.dependsOn),h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|(null===h.isNonSyncSample||void 0===h.isNonSyncSample?1:h.isNonSyncSample),61440&h.degradationPriority,15&h.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(tt(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,i=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&i.push(e.stss(r.stss)),r.ctts.length&&i.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(i))}},{key:"stts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.stts,Ct(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsc",value:function(t){var r=t.length,i=new Uint8Array(12*r),n=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;i.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],n),n+=12})),e.box(e.types.stsc,Ct(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsz",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stsz,Ct(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stco",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stco,Ct(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stss",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stss,Ct(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"ctts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.ctts,Ct(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,i=t.samples[0].duration,n=i*t.samples.length,a=t.samples[0].sampleOffset*i,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,l=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){l+=8,e.subsamples&&e.subsamples.length&&(l+=2,l+=6*e.subsamples.length)})),t.videoSencLength=l,o=s+141+16*t.samples.length+l,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var d=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,n>>24&255,n>>16&255,n>>8&255,255&n,144,0,0,0]);return e.box(e.types.sidx,d)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();Qe(zt,"types",["av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),Qe(zt,"HDLR_TYPES",{video: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]),audio: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])}),Qe(zt,"FTYPAVC1",zt.box(zt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),Qe(zt,"FTYPHEV1",zt.box(zt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),Qe(zt,"DINF",zt.box(zt.types.dinf,zt.box(zt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),Qe(zt,"VMHD",zt.box(zt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),Qe(zt,"SMHD",zt.box(zt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),Qe(zt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),Qe(zt,"STTS",zt.box(zt.types.stts,zt.StblTable)),Qe(zt,"STSC",zt.box(zt.types.stsc,zt.StblTable)),Qe(zt,"STSZ",zt.box(zt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),Qe(zt,"STCO",zt.box(zt.types.stco,zt.StblTable));var Wt=function(){function e(t,r){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return Xe(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).debug.apply(t,[this._prefix].concat(i))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).log.apply(t,[this._prefix].concat(i))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).error.apply(t,[this._prefix].concat(i))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(Wt,"disabled",!0);var qt=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r;var n=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=n&&Number(n[1])<50,this.log=new Wt("FMP4Remuxer",!i||!i.openLog||!i.openLog)}return Xe(e,[{key:"remux",value:function(){var e,t,r,i,n,a=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,l=o.exist(),d=u.exist(),h=[];return a&&(s&&s.initMerge?(l&&h.push(this.videoTrack),d&&h.push(this.audioTrack),r=zt.initSegment(h)):(l&&(e=zt.initSegment([this.videoTrack])),d&&(t=zt.initSegment([this.audioTrack])))),l&&o.hasSample()&&(i=this._remuxVideo()),d&&u.hasSample()&&(n=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:i,audioSegment:n}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),i=0;r?t.forEach((function(e){i+=e.data.byteLength})):t.forEach((function(e){i+=e.units.reduce((function(e,t){return e+t.byteLength}),0),i+=4*e.units.length}));var n=new Uint8Array(i);if(r)for(var a,s=0,o=t.length,u=0;s<o;s++)a=t[s],n.set(a.data,u),a.size=a.data.byteLength,u+=a.size;else for(var l,d=new DataView(n.buffer),h=function(e,r){r=t[c];var i=0;r.units.forEach((function(t){d.setUint32(e,t.byteLength),e+=4,n.set(t,e),e+=t.byteLength,i+=4+t.byteLength})),r.size=i,v=e,l=r},c=0,f=t.length,v=0;c<f;c++)h(v,l);var p=zt.mdat(n);return Ct(zt.moof([e]),p)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=zt.mdat(t);return Ct(zt.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Yt=new j("BufferService"),Xt=function(){function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this,e),c(this,"flv",null),c(this,"_demuxer",new jt),c(this,"_remuxer",null),c(this,"_mse",null),c(this,"_softVideo",null),c(this,"_sourceCreated",!1),c(this,"_needInitSegment",!0),c(this,"_discontinuity",!0),c(this,"_contiguous",!1),c(this,"_initSegmentId",""),c(this,"_cachedBuffer",null),c(this,"_demuxStartTime",0),c(this,"_opts",null),this.flv=t,this._opts=i,r?this._softVideo=r:(this._remuxer=new qt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new We(null,{preferMMS:"boolean"==typeof i.preferMMS?i.preferMMS:!!i.perferMMS}),this._mse.bindMedia(t.media))}var t,r,i,n,o,d;return h(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:We.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:(d=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="";case 11:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"endOfStream",value:(o=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit("core.buffereos");case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"updateDuration",value:(n=u(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return Yt.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:(i=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"appendBuffer",value:(r=u(s().mark((function e(t){var r,i,n,a,o,u,l,d,h,c,f,v,p,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._cachedBuffer&&(t=ge(this._cachedBuffer,t),this._cachedBuffer=null),r=this._demuxer,t&&t.length&&r){e.next=4;break}return e.abrupt("return");case 4:e.prev=4,r.demuxAndFix(t,this._discontinuity,this._contiguous,this._demuxStartTime),e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(4),new ve(re,se,e.t0);case 11:if(i=r.videoTrack,n=r.audioTrack,a=r.metadataTrack,o=i.exist(),u=n.exist(),this._opts.onlyAudio&&(o=!1,i.present=!1),this._opts.onlyVideo&&(u=!1,n.present=!1),!(!o&&i.present||!u&&n.present)){e.next=29;break}if(l=0,(d=o?i:u?n:void 0)&&d.samples.length&&(l=(d.samples[d.samples.length-1].originPts-d.samples[0].originPts)/d.timescale*1e3),!(l>this._opts.analyzeDuration)){e.next=27;break}Yt.warn("analyze duration exceeded, ".concat(l,"ms"),d),i.present=o,n.present=u,this.flv.emit("core.analyzedurationexceeded",{duration:l}),e.next=29;break;case 27:return this._cachedBuffer=t,e.abrupt("return");case 29:if(h=i.type,c=n.type,this._fireEvents(i,n,a),this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0,f=this._mse,this.flv.emit(J,{videoTrack:i}),(v="".concat(i.codec,"/").concat(i.width,"/").concat(i.height,"/").concat(n.codec,"/").concat(n.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=v,this._emitMetaParsedEvent(i,n)),!f){e.next=66;break}if(this._sourceCreated){e.next=47;break}return e.next=43,f.open();case 43:o&&(Yt.log("codec: video/mp4;codecs=".concat(i.codec)),f.createSource(h,"video/mp4;codecs=".concat(i.codec))),u&&(Yt.log("codec: audio/mp4;codecs=".concat(n.codec)),f.createSource(c,"audio/mp4;codecs=".concat(n.codec))),this._sourceCreated=!0,this.flv.emit("core.sourcebuffercreated");case 47:e.prev=47,this._needInitSegment&&!this._opts.mseLowLatency&&(i.duration=this._opts.durationForMSELowLatencyOff*i.timescale,n.duration=this._opts.durationForMSELowLatencyOff*u.timescale),p=this._remuxer.remux(this._needInitSegment),e.next=55;break;case 52:throw e.prev=52,e.t1=e.catch(47),new ve(ie,oe,e.t1);case 55:if(!this._needInitSegment||p.videoInitSegment||p.audioInitSegment){e.next=57;break}return e.abrupt("return");case 57:return this._needInitSegment=!1,g=[],p.videoInitSegment&&g.push(f.append(h,p.videoInitSegment)),p.audioInitSegment&&g.push(f.append(c,p.audioInitSegment)),p.videoSegment&&g.push(f.append(h,p.videoSegment)),p.audioSegment&&g.push(f.append(c,p.audioSegment)),e.abrupt("return",Promise.all(g));case 66:this._softVideo&&this._softVideo.appendBuffer(i,n);case 67:case"end":return e.stop()}}),e,this,[[4,8],[47,52]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=u(s().mark((function e(t){var r,i,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(i=r.currentTime,!((n=i-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(pe.start(pe.get(r))+1>=n)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,n).then((function(){return a.flv.emit("core.removebuffer",{removeEnd:n})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(Y,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(Y,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),Yt.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i=this;Yt.debug(e.samples,t.samples),r.flvScriptSamples.forEach((function(e){i.flv.emit(Q,e),Yt.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&i.flv.emit("core.keyframe",{pts:e.pts})})),e.warnings.forEach((function(e){var t;switch(e.type){case lt:t="LARGE_AV_FIRST_FRAME_GAP_DETECT";break;case dt:t="LARGE_VIDEO_DTS_GAP_DETECT";break;case ht:t="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),Yt.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case ct:t="LARGE_AUDIO_DTS_GAP_DETECT";break;case ft:t="AUDIO_GAP_DETECT";break;case vt:t="AUDIO_OVERLAP_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),Yt.warn("audio exception",e)})),r.seiSamples.forEach((function(e){i.flv.emit(X,a(a({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function Qt(e,t){var r=0,i=e.length-1,n=0,a=0,s=i;for(t<e[0]&&(r=0,a=s+1);a<=s;){if((n=a+Math.floor((s-a)/2))===i||t>=e[n]&&t<e[n+1]){r=n;break}e[n]<t?a=n+1:s=n-1}return r}var Jt=new j("flv"),Zt=.1,$t=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(b,y());var t,r,i,n,o,d,g,m,_,E=(m=b,_=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}}(),function(){var e,t=f(m);if(_){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}(this,e)});function b(e){var t,r;return l(this,b),c(p(t=E.call(this)),"media",null),c(p(t),"_loading",!1),c(p(t),"_opts",null),c(p(t),"_bufferService",null),c(p(t),"_gapService",null),c(p(t),"_stats",null),c(p(t),"_mediaLoader",null),c(p(t),"_maxChunkWaitTimer",null),c(p(t),"_tickTimer",null),c(p(t),"_tickInterval",500),c(p(t),"_urlSwitching",!1),c(p(t),"_seamlessSwitching",!1),c(p(t),"_disconnectRetryCount",0),c(p(t),"_preLoadEndPoint",0),c(p(t),"_keyframes",null),c(p(t),"_acceptRanges",!0),c(p(t),"_onProgress",function(){var e=u(s().mark((function e(r,i,n,a){var o,u,l,d,h,c,f,v,p;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.startTime,u=n.endTime,l=n.st,d=n.firstByteTime,t._loading=!i,t._firstProgressEmit){e.next=11;break}if(t.media){e.next=6;break}return null===(h=t._mediaLoader)||void 0===h||h.cancel(),e.abrupt("return");case 6:c=a.headers,t.emit(q,{url:t._opts.url,responseUrl:a.url,elapsed:l?d-l:u-o}),t.emit("core.loadresponseheaders",{headers:c}),t._acceptRanges=!(null==c||!c.get("Accept-Ranges"))||!(null==c||!c.get("Content-Range")),t._firstProgressEmit=!0;case 11:if(t._bufferService){e.next=13;break}return e.abrupt("return");case 13:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=15,e.next=18,t._bufferService.appendBuffer(r);case 18:null===(f=t._bufferService)||void 0===f||f.evictBuffer(t._opts.bufferBehind),e.next=31;break;case 21:if(e.prev=21,e.t0=e.catch(15),t.isLive||!t._bufferService.isFull()){e.next=30;break}return e.next=26,t._mediaLoader.cancel();case 26:return t._loading=!1,v=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(v)/2,e.abrupt("return");case 30:return e.abrupt("return",t._emitError(ve.create(e.t0)));case 31:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit("core.switchurlsuccess",{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!i||t.media.seeking){e.next=38;break}return t.emit("core.loadcomplete"),Jt.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),e.abrupt("return");case 38:if(t.isLive){e.next=40;break}return e.abrupt("return");case 40:(p=t._opts.maxReaderInterval)&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){if(t._disconnectRetryCount)return t._disconnectRetryCount--,void t.load();Jt.debug("onMaxChunkWait",p),t._end()}),p));case 42:case"end":return e.stop()}}),e,null,[[15,21]])})));return function(t,r,i,n){return e.apply(this,arguments)}}()),c(p(t),"_onRetryError",(function(e,r){Jt.debug("load retry",e,r),t.emit("core.loadretry",{error:ve.network(e),retryTime:r})})),c(p(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),Jt.debug("end stream")})),c(p(t),"_resetDisconnectCount",(function(){t._disconnectRetryCount=t._opts.disconnectRetryCount})),c(p(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=p(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=pe.end(pe.get(e));if(!(r<Zt)&&e.readyState){var i=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e))t._gapService&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService)return void((t._opts.mseLowLatency||!1===t._opts.mseLowLatency&&t.bufferInfo(.3).nextStart)&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3));i.isLive&&4===e.readyState&&r-e.currentTime>i.disconnectTime&&t.disconnect()}}}})),c(p(t),"_onPlay",(function(){var e,r,i=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);if(t.isLive)!t._loading&&i&&t.replay(void 0,!0);else{var n=t.bufferInfo();(n.start||n.nextStart)>Zt&&t._tick()}})),c(p(t),"_onLoadeddata",(function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),c(p(t),"_onSeeking",u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return e.stop()}}),e)})))),c(p(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var i=pe.end(pe.get(t.media));i-r>=e.maxLatency&&(t.media.currentTime=i-e.targetLatency,t.emit("core.chaseframe",{currentTime:t.media.currentTime,latency:e.targetLatency}))}t._seiService.throw(r,!0),e.isLive||!t.seekable||t._loading||t._checkPreload()}})),c(p(t),"_onWaiting",(function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())})),c(p(t),"_onBufferUpdate",(function(){if(!t._opts.isLive){var e=t.bufferInfo(),r=e.end,i=e.nextEnd;Math.abs((r||i)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}})),c(p(t),"_checkPreload",u(s().mark((function e(){var r,i,n,a,o,u,l,d,h,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.bufferInfo(),i=r.remaining,n=void 0===i?0:i,a=t._opts,o=t._keyframes.filepositions,u=t._keyframes.times,l=t.media.currentTime,!(n<a.preloadTime)){e.next=19;break}if(d=Qt(t._keyframes.times,l+n+Zt),(h=Qt(t._keyframes.times,l+n+t._opts.preloadTime))===d&&(h=d+1),t._preLoadEndPoint!==h){e.next=11;break}return e.abrupt("return");case 11:if(null!=(c=o[d])){e.next=14;break}return e.abrupt("return");case 14:return e.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[c,o[h]]),t._preLoadEndPoint=h,t._bufferService.unContiguous(u[d]);case 19:case"end":return e.stop()}}),e)})))),c(p(t),"_onFlvScriptData",(function(e){var r,i,n,a,s=null===(r=e.data)||void 0===r||null===(i=r.onMetaData)||void 0===i?void 0:i.keyframes,o=null===(n=e.data)||void 0===n||null===(a=n.onMetaData)||void 0===a?void 0:a.duration;s&&(t._keyframes=s),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=a({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new Me(a(a({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._disconnectRetryCount=t._opts.disconnectRetryCount,t._bufferService=new Xt(p(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new Be(p(t)),t._bandwidthService=new Ne({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new Ge(p(t)),t._opts.softDecode||(t._gapService=new Ve),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.media.addEventListener("progress",t._onBufferUpdate),t.media.addEventListener("waiting",t._onWaiting),t.on(Q,t._onFlvScriptData),t}return h(b,[{key:"version",get:function(){return"3.0.19"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Zt;return pe.info(pe.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(g=u(s().mark((function e(t){var r,i=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],this._bufferService){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._reset(r);case 5:this._loadData(t,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"replay",value:(d=u(s().mark((function e(){var t,r,i=this,n=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:this._opts.seamlesslyReload,r=n.length>1?n[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(this._resetDisconnectCount(),!t){e.next=11;break}return e.next=8,this._clear();case 8:setTimeout((function(){i._loadData(i._opts.url),i._bufferService.seamlessSwitch(),i._seamlessSwitching=!0})),e.next=13;break;case 11:return e.next=13,this.load();case 13:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 14:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"disconnect",value:function(){return Jt.debug("disconnect!"),this._clear()}},{key:"switchURL",value:(o=u(s().mark((function e(t,r){var i=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(this._resetDisconnectCount(),r&&this._opts.isLive){e.next=8;break}return e.next=6,this.load(t);case 6:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 8:return e.next=10,this._clear();case 10:setTimeout((function(){i._urlSwitching=!0,i._seamlessSwitching=!0,i._loadData(t),i._bufferService.seamlessSwitch()}));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"destroy",value:(n=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),e.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Jt.table(e),Jt.error(e),Jt.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit("core.switchurlfailed",e)),this.emit("error",e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(i=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_loadData",value:(r=u(s().mark((function e(t,r){var i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),i=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(i=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=i,this.emit("core.loadstart",{url:i,seamlessSwitching:this._seamlessSwitching}),Jt.debug("load data, loading:",this._loading,i),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:i,range:r});case 15:e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(12),this._loading=!1,e.abrupt("return",this._emitError(ve.network(e.t0),!1));case 21:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,t){return r.apply(this,arguments)})},{key:"_clear",value:(t=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:We.isSupported()}},{key:"enableLogger",value:function(){j.enable(),at.enable()}},{key:"disableLogger",value:function(){j.disable(),at.disable()}}]),b}();try{localStorage.getItem("xgd")?$t.enableLogger():$t.disableLogger()}catch(e){}var er=r(21),tr=i.N,rr=i.c;export{tr as Flv,rr as Hls};
|
1
|
+
var e={228:e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){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,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},539:e=>{!function t(r){e.exports=function(){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,a,s;r=t,a=e,s=i[e],(a=n(a))in r?Object.defineProperty(r,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[a]=s})):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 n(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,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function a(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,n(i.key),i)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(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 u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function h(e,t,r){return h=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 n=new(Function.bind.apply(e,i));return r&&d(n,r.prototype),n},h.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 h(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},c(e)}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v={exports:{}};!function(e){var t,r,i,n,a;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=a.normalizePath(n.path),a.buildURLFromParts(n)}var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):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 u=r.exec(o.path);o.netLoc=u[1],o.path=u[2]}o.netLoc&&!o.path&&(o.path="/");var l={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(l.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+s.path;l.path=a.normalizePath(h)}else l.path=o.path,s.params||(l.params=o.params,s.query||(l.query=o.query));return null===l.path&&(l.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(l)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");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}(v);var p=v.exports,g=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},m=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=y},y=Number.MAX_SAFE_INTEGER||9007199254740991,_=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}({}),b=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}({}),E=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}({}),T=function(){},S={trace:T,debug:T,log:T,warn:T,info:T,error:T},L=S;function k(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}(t)}))}function w(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){k(e,"debug","log","info","warn","error");try{L.log('Debug logs enabled for "'+t+'" in hls.js version 1.5.17')}catch(e){L=S}}else L=S}var x=L,A=/^(\d+)x(\d+)$/,R=/(.+?)=(".*?"|.*?)(?:,|$)/g,D=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=A.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(R.lastIndex=0;null!==(t=R.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},s(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function C(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var P=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]){x.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=o(new D({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);g(n.getTime())&&(this._endDate=n)}}return s(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(g(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&&g(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),O=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}},I="audio",F="video",M="audiovideo",B=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[I]=null,t[F]=null,t[M]=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]},s(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 O,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}u(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,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[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,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[I]=null,e[F]=null,e[M]=null},s(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(!g(this.programDateTime))return null;var e=g(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}(B),U=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new O,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),s(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}(B),G=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},s(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&g(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}(),V=f(void 0);function j(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var H,K=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},z=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},W=function(e,t){for(var r=t,i=0;K(e,t);)i+=10,i+=q(e,t+6),z(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},q=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]},Y=function(e,t){return K(e,t)&&q(e,t+6)+10<=e.length-t},X=function(e){for(var t=Z(e),r=0;r<t.length;r++){var i=t[r];if(Q(i))return ie(i)}},Q=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},J=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=q(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},Z=function(e){for(var t=0,r=[];K(e,t);){for(var i=q(e,t+6),n=(t+=10)+i;t+8<n;){var a=J(e.subarray(t)),s=$(a);s&&r.push(s),t+=a.size+10}z(e,t)&&(t+=10)}return r},$=function(e){return"PRIV"===e.type?ee(e):"W"===e.type[0]?re(e):te(e)},ee=function(e){if(!(e.size<2)){var t=ne(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},te=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data.subarray(1));return{key:e.type,data:n}}},re=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data);return{key:e.type,data:n}},ie=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)}},ne=function(e,t){void 0===t&&(t=!1);var r=ae();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,u=e.length,l="",d=0;d<u;){if(0===(a=e[d++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],l+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],o=e[d++],l+=String.fromCharCode((15&a)<<12|(63&s)<<6|63&o)}}return l};function ae(){if(!navigator.userAgent.includes("PlayStation 4"))return H||void 0===self.TextDecoder||(H=new self.TextDecoder("utf-8")),H}var se=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},oe=Math.pow(2,32)-1,ue=[].push,le={video:1,audio:2,id3:3,text:4};function de(e){return String.fromCharCode.apply(null,e)}function he(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ce(e,t){var r=ve(e,t);return r<0?4294967296+r:r}function fe(e,t){var r=ce(e,t);return(r*=Math.pow(2,32))+ce(e,t+4)}function ve(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function pe(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 ge(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=ce(e,n),s=a>1?n+a:i;if(de(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=ge(e.subarray(n+8,s),t.slice(1));o.length&&ue.apply(r,o)}n=s}return r}function me(e){var t=[],r=e[0],i=8,n=ce(e,i);i+=4;var a=0,s=0;0===r?(a=ce(e,i),s=ce(e,i+4),i+=8):(a=fe(e,i),s=fe(e,i+8),i+=16),i+=2;var o=e.length+s,u=he(e,i);i+=2;for(var l=0;l<u;l++){var d=i,h=ce(e,d);d+=4;var c=2147483647&h;if(1==(2147483648&h)>>>31)return x.warn("SIDX has hierarchical references (not supported)"),null;var f=ce(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+c-1}}),o+=c,i=d+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:u,references:t}}function ye(e){for(var t=[],r=ge(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=ge(a,["tkhd"])[0];if(s){var o=s[0],u=ce(s,0===o?12:20),l=ge(a,["mdia","mdhd"])[0];if(l){var d=ce(l,0===(o=l[0])?12:20),h=ge(a,["mdia","hdlr"])[0];if(h){var c=de(h.subarray(8,12)),f={soun:I,vide:F}[c];if(f){var v=_e(ge(a,["mdia","minf","stbl","stsd"])[0]);t[u]={timescale:d,type:f},t[f]=i({timescale:d,id:u},v)}}}}}return ge(e,["moov","mvex","trex"]).forEach((function(e){var r=ce(e,4),i=t[r];i&&(i.default={duration:ce(e,12),flags:ce(e,20)})})),t}function _e(e){var t=e.subarray(8),r=t.subarray(86),i=de(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=ge(t,[i])[0];ge(s.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=ge(e,["frma"])[0];i&&(n=de(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var o=ge(r,["avcC"])[0];n+="."+Ee(o[1])+Ee(o[2])+Ee(o[3]);break;case"mp4a":var u=ge(t,[i])[0],l=ge(u.subarray(28),["esds"])[0];if(l&&l.length>12){var d=4;if(3!==l[d++])break;d=be(l,d),d+=2;var h=l[d++];if(128&h&&(d+=2),64&h&&(d+=l[d++]),4!==l[d++])break;d=be(l,d);var c=l[d++];if(64!==c)break;if(n+="."+Ee(c),d+=12,5!==l[d++])break;d=be(l,d);var f=l[d++],v=(248&f)>>3;31===v&&(v+=1+((7&f)<<3)+((224&l[d])>>5)),n+="."+v}break;case"hvc1":case"hev1":var p=ge(r,["hvcC"])[0],g=p[1],m=["","A","B","C"][g>>6],y=31&g,_=ce(p,2),b=(32&g)>>5?"H":"L",E=p[12],T=p.subarray(6,12);n+="."+m+y,n+="."+_.toString(16).toUpperCase(),n+="."+b+E;for(var S="",L=T.length;L--;){var k=T[L];(k||S)&&(S="."+k.toString(16).toUpperCase()+S)}n+=S;break;case"dvh1":case"dvhe":var w=ge(r,["dvcC"])[0],x=w[2]>>1&127,A=w[2]<<5&32|w[3]>>3&31;n+="."+Te(x)+"."+Te(A);break;case"vp09":var R=ge(r,["vpcC"])[0],D=R[4],C=R[5],P=R[6]>>4&15;n+="."+Te(D)+"."+Te(C)+"."+Te(P);break;case"av01":var O=ge(r,["av1C"])[0],I=O[1]>>>5,F=31&O[1],M=O[2]>>>7?"H":"M",B=(64&O[2])>>6,N=(32&O[2])>>5,U=2===I&&B?N?12:10:B?10:8,G=(16&O[2])>>4,V=(8&O[2])>>3,j=(4&O[2])>>2,H=3&O[2];n+="."+I+"."+Te(F)+M+"."+Te(U)+"."+G+"."+V+j+H+"."+Te(1)+"."+Te(1)+"."+Te(1)+".0"}return{codec:n,encrypted:a}}function be(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Ee(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Te(e){return(e<10?"0":"")+e}function Se(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&ge(e,["moov","trak"]).forEach((function(e){var t=ge(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=ge(t,["enca"]),n=i.length>0;n||(i=ge(t,["encv"])),i.forEach((function(e){ge(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return ge(e,["schi","tenc"])[0]}return null}(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(x.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+se(i)+" -> "+se(r)),t.set(r,8))}}))}))})),e}function Le(e){var t=ce(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=ce(e,4),a=0;a<n;a++)256&t&&(i+=ce(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function ke(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function we(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1;return ge(i,["moof"]).map((function(o){var u=o.byteOffset-8;ge(o,["traf"]).map((function(o){var l=ge(o,["tfdt"]).map((function(e){var t=e[0],r=ce(e,4);return 1===t&&(r*=Math.pow(2,32),r+=ce(e,8)),r/n}))[0];return void 0!==l&&(e=l),ge(o,["tfhd"]).map((function(l){var d=ce(l,4),h=16777215&ce(l,0),c=0,f=!!(16&h),v=0,p=!!(32&h),g=8;d===a&&(!!(1&h)&&(g+=8),!!(2&h)&&(g+=4),!!(8&h)&&(c=ce(l,g),g+=4),f&&(v=ce(l,g),g+=4),p&&(g+=4),"video"===t.type&&(s=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)),ge(o,["trun"]).map((function(a){var o=a[0],l=16777215&ce(a,0),d=!!(1&l),h=0,f=!!(4&l),p=!!(256&l),g=0,m=!!(512&l),y=0,_=!!(1024&l),b=!!(2048&l),E=0,T=ce(a,4),S=8;d&&(h=ce(a,S),S+=4),f&&(S+=4);for(var L=h+u,k=0;k<T;k++){if(p?(g=ce(a,S),S+=4):g=c,m?(y=ce(a,S),S+=4):y=v,_&&(S+=4),b&&(E=0===o?ce(a,S):ve(a,S),S+=4),t.type===F)for(var w=0;w<y;){var x=ce(i,L);xe(s,i[L+=4])&&Ae(i.subarray(L,L+x),s?2:1,e+E/n,r),L+=x,w+=x+4}e+=g/n}})))}))}))})),r}function xe(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function Ae(e,t,r,i){var n=Re(e),a=0;a+=t;for(var s=0,o=0,u=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var l=n.length-a,d=a;if(o<l)a+=o;else if(o>l){x.error("Malformed SEI payload. "+o+" is too small, only "+l+" bytes left to parse.");break}if(4===s){if(181===n[d++]){var h=he(n,d);if(d+=2,49===h){var c=ce(n,d);if(d+=4,1195456820===c){var f=n[d++];if(3===f){var v=n[d++],p=64&v,g=p?2+3*(31&v):0,m=new Uint8Array(g);if(p){m[0]=v;for(var y=1;y<g;y++)m[y]=n[d++]}i.push({type:f,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var _=[],b=0;b<16;b++){var E=n[d++].toString(16);_.push(1==E.length?"0"+E:E),3!==b&&5!==b&&7!==b&&9!==b||_.push("-")}for(var T=o-16,S=new Uint8Array(T),L=0;L<T;L++)S[L]=n[d++];i.push({payloadType:s,pts:r,uuid:_.join(""),userData:ne(S),userDataBytes:S})}}}function Re(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 n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}var De=function(){function e(e,t,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=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=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){};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}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||x.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)}return this},e}();function Ce(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Pe={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 Oe(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!Ie(e,t,r)}))}function Ie(e,t,r){var i;void 0===r&&(r=!0);var n=Ce(r);return null!=(i=null==n?void 0:n.isTypeSupported(Fe(e,t)))&&i}function Fe(e,t){return t+'/mp4;codecs="'+e+'"'}function Me(e){if(e){var t=e.substring(0,4);return Pe.video[t]}return 2}function Be(e){return e.split(",").reduce((function(e,t){var r=Pe.video[t];return r?(2*r+e)/(e?3:2):(Pe.audio[t]+e)/(e?2:1)}),0)}var Ne={};var Ue=/flac|opus/i;function Ge(e,t){return void 0===t&&(t=!0),e.replace(Ue,(function(e){return function(e,t){if(void 0===t&&(t=!0),Ne[e])return Ne[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(Ie(r[i],"audio",t))return Ne[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function Ve(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}var je=/#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,He=/#EXT-X-MEDIA:(.*)/g,Ke=/^#EXT(?:INF|-X-TARGETDURATION):/m,ze=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"),We=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("|")),qe=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 Ke.test(e)},e.parseMasterPlaylist=function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},a=[];for(je.lastIndex=0;null!=(i=je.exec(t));)if(i[1]){var s,o=new D(i[1]),u=i[2],l={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(u,r)},d=o.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),Qe(o.CODECS,l),null!=(s=l.unknownCodecs)&&s.length||a.push(l),n.levels.push(l)}else if(i[3]){var h=i[3],c=i[4];switch(h){case"SESSION-DATA":var f=new D(c),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var p=Ye(c,r);p.encrypted&&p.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(p)):x.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var g=new D(c);n.contentSteering={uri:e.resolve(g["SERVER-URI"],r),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=Xe(c)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n},e.parseMasterPlaylistMedia=function(t,r,i){var n,a={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},u=0;for(He.lastIndex=0;null!==(n=He.exec(t));){var l=new D(n[1]),d=l.TYPE;if(d){var h=o[d],c=a[d]||[];a[d]=c;var f=l.LANGUAGE,v=l["ASSOC-LANGUAGE"],p=l.CHANNELS,g=l.CHARACTERISTICS,m=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?e.resolve(l.URI,r):""};if(v&&(y.assocLang=v),p&&(y.channels=p),g&&(y.characteristics=g),m&&(y.instreamId=m),null!=h&&h.length){var _=e.findGroup(h,y.groupId)||h[0];Je(y,_,"audioCodec"),Je(y,_,"textCodec")}c.push(y)}}return a},e.parseLevelPlaylist=function(e,t,r,i,n,a){var s,u,l,d=new G(t),h=d.fragments,c=null,f=0,v=0,p=0,m=0,y=null,_=new N(i,t),b=-1,E=!1,T=null;for(ze.lastIndex=0,d.m3u8=e,d.hasVariableRefs=!1;null!==(s=ze.exec(e));){E&&(E=!1,(_=new N(i,t)).start=p,_.sn=f,_.cc=m,_.level=r,c&&(_.initSegment=c,_.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,T&&(_.setByteRange(T),T=null)));var S=s[1];if(S){_.duration=parseFloat(S);var L=(" "+s[2]).slice(1);_.title=L||null,_.tagList.push(L?["INF",S,L]:["INF",S])}else if(s[3]){if(g(_.duration)){_.start=p,l&&et(_,l,d),_.sn=f,_.level=r,_.cc=m,h.push(_);var k=(" "+s[3]).slice(1);_.relurl=k,Ze(_,y),y=_,p+=_.duration,f++,v=0,E=!0}}else if(s[4]){var w=(" "+s[4]).slice(1);y?_.setByteRange(w,y):_.setByteRange(w)}else if(s[5])_.rawProgramDateTime=(" "+s[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===b&&(b=h.length);else{if(!(s=s[0].match(We))){x.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var A=(" "+s[u]).slice(1),R=(" "+s[u+1]).slice(1),C=s[u+2]?(" "+s[u+2]).slice(1):"";switch(A){case"PLAYLIST-TYPE":d.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":f=d.startSN=parseInt(R);break;case"SKIP":var O=new D(R),I=O.decimalInteger("SKIPPED-SEGMENTS");if(g(I)){d.skippedSegments=I;for(var F=I;F--;)h.unshift(null);f+=I}var M=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");M&&(d.recentlyRemovedDateranges=M.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(R),1);break;case"VERSION":d.version=parseInt(R);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(R||C)&&_.tagList.push(C?[R,C]:[R]);break;case"DISCONTINUITY":m++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([A]);break;case"BITRATE":_.tagList.push([A,R]);break;case"DATERANGE":var B=new D(R),V=new P(B,d.dateRanges[B.ID]);V.isValid||d.skippedSegments?d.dateRanges[V.id]=V:x.warn('Ignoring invalid DATERANGE tag: "'+R+'"'),_.tagList.push(["EXT-X-DATERANGE",R]);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(R);break;case"KEY":var j=Ye(R,t);if(j.isSupported()){if("NONE"===j.method){l=void 0;break}l||(l={}),l[j.keyFormat]&&(l=o({},l)),l[j.keyFormat]=j}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+R+'"');break;case"START":d.startTimeOffset=Xe(R);break;case"MAP":var H=new D(R);if(_.duration){var K=new N(i,t);$e(K,H,r,l),c=K,_.initSegment=c,c.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=c.rawProgramDateTime)}else{var z=_.byteRangeEndOffset;if(z){var W=_.byteRangeStartOffset;T=z-W+"@"+W}else T=null;$e(_,H,r,l),c=_,E=!0}break;case"SERVER-CONTROL":var q=new D(R);d.canBlockReload=q.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=q.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&q.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=q.optionalFloat("PART-HOLD-BACK",0),d.holdBack=q.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new D(R);d.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=d.partList;X||(X=d.partList=[]);var Q=v>0?X[X.length-1]:void 0,J=v++,Z=new D(R),$=new U(Z,_,t,J,Q);X.push($),_.duration+=$.duration;break;case"PRELOAD-HINT":var ee=new D(R);d.preloadHint=ee;break;case"RENDITION-REPORT":var te=new D(R);d.renditionReports=d.renditionReports||[],d.renditionReports.push(te);break;default:x.warn("line parsed but not handled: "+s)}}}y&&!y.relurl?(h.pop(),p-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(Ze(_,y),_.cc=m,d.fragmentHint=_,l&&et(_,l,d));var re=h.length,ie=h[0],ne=h[re-1];if((p+=d.skippedSegments*d.targetduration)>0&&re&&ne){d.averagetargetduration=p/re;var ae=ne.sn;d.endSN="initSegment"!==ae?ae:0,d.live||(ne.endList=!0),ie&&(d.startCC=ie.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(p+=d.fragmentHint.duration),d.totalduration=p,d.endCC=m,b>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,b),d},e}();function Ye(e,t,r){var i,n,a=new D(e),s=null!=(i=a.METHOD)?i:"",o=a.URI,u=a.hexadecimalInteger("IV"),l=a.KEYFORMATVERSIONS,d=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!u&&x.error("Invalid IV: "+a.IV);var h=o?qe.resolve(o,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new De(s,h,d,c,u)}function Xe(e){var t=new D(e).decimalFloatingPoint("TIME-OFFSET");return g(t)?t:null}function Qe(e,t){var r=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var i=r.filter((function(t){return function(e,t){var r=Pe[t];return!!r&&!!r[e.slice(0,4)]}(t,e)}));i.length&&(t[e+"Codec"]=i.join(","),r=r.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=r}function Je(e,t,r){var i=t[r];i&&(e[r]=i)}function Ze(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),g(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function $e(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function et(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}var tt="manifest",rt="level",it="audioTrack",nt="subtitleTrack",at="main",st="audio",ot="subtitle";function ut(e){switch(e.type){case it:return st;case nt:return ot;default:return at}}function lt(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var dt=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:tt,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.pathwayId,a=t.url,s=t.deliveryDirectives;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:rt,url:a,deliveryDirectives:s})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:it,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:nt,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var u=s.context;if(u&&u.url===e.url&&u.level===e.level)return void x.trace("[playlist-loader]: playlist request ongoing");x.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(r=e.type===tt?a.manifestLoadPolicy.default:o({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),g(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===rt&&null!==e.level?i=this.hls.levels[e.level].details:e.type===it&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===nt&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var l=i.partTarget,d=i.targetduration;if(l&&d){var h=1e3*Math.max(3*l,.8*d);r=o({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),qe.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,f,v)},t.handleMasterPlaylist=function(e,t,r,i){var n=this.hls,a=e.data,s=lt(e,r),o=qe.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var u=o.contentSteering,l=o.levels,d=o.sessionData,h=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=qe.parseMasterPlaylistMedia(a,s,o),p=v.AUDIO,g=void 0===p?[]:p,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];g.length&&(g.some((function(e){return!e.url}))||!l[0].audioCodec||l[0].attrs.AUDIO||(x.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D({}),bitrate:0,url:""}))),n.trigger(_.MANIFEST_LOADED,{levels:l,audioTracks:g,subtitles:m,captions:y,contentSteering:u,url:s,stats:t,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:f})}},t.handleTrackOrLevelPlaylist=function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,u=r.type,l=lt(e,r),d=g(o)?o:g(s)?s:0,h=ut(r),c=qe.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===tt){var f={attrs:new D({}),bitrate:0,details:c,name:"",url:l};a.trigger(_.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,e,t,r,i,n)},t.handleManifestParsingError=function(e,t,r,i,n){this.hls.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.MANIFEST_PARSING_ERROR,fatal:t.type===tt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})},t.handleNetworkError=function(e,t,r,n,a){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+e.type;e.type===rt?s+=": "+e.level+" id: "+e.id:e.type!==it&&e.type!==nt||(s+=" id: "+e.id+' group-id: "'+e.groupId+'"');var o=new Error(s);x.warn("[playlist-loader]: "+s);var u=E.UNKNOWN,l=!1,d=this.getInternalLoader(e);switch(e.type){case tt:u=r?E.MANIFEST_LOAD_TIMEOUT:E.MANIFEST_LOAD_ERROR,l=!0;break;case rt:u=r?E.LEVEL_LOAD_TIMEOUT:E.LEVEL_LOAD_ERROR,l=!1;break;case it:u=r?E.AUDIO_TRACK_LOAD_TIMEOUT:E.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case nt:u=r?E.SUBTITLE_TRACK_LOAD_TIMEOUT:E.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);var h={type:b.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:a};if(n){var c=(null==t?void 0:t.url)||e.url;h.response=i({url:c,data:void 0},n)}this.hls.trigger(_.ERROR,h)},t.handlePlaylistLoaded=function(e,t,r,i,n,a){var s=this.hls,o=i.type,u=i.level,l=i.id,d=i.groupId,h=i.deliveryDirectives,c=lt(t,i),f=ut(i),v="number"==typeof i.level&&f===at?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var p=e.playlistParsingError;if(p)s.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case tt:case rt:s.trigger(_.LEVEL_LOADED,{details:e,level:v||0,id:l||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case it:s.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case nt:s.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h})}}else{var g=new Error("No Segments found in Playlist");s.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r})}},e}();function ht(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ct(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}var ft="org.id3",vt="com.apple.quicktime.HLS",pt="https://aomedia.org/emsg/ID3";function gt(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function mt(e,t,r,n,a){var s=new e(t,r,"");try{s.value=n,a&&(s.type=a)}catch(o){s=new e(t,r,JSON.stringify(a?i({type:a},n):n))}return s}var yt=function(){var e=gt();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function _t(e,t){return e.getTime()/1e3-t}var bt=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(function(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=gt();if(s)for(var o=0;o<a.length;o++){var u=a[o].type;if((u!==pt||i)&&n){var l=Z(a[o].data);if(l){var d=a[o].pts,h=d+a[o].duration;h>yt&&(h=yt),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var f=l[c];if(!Q(f)){this.updateId3CueEnds(d,u);var v=mt(s,d,h,f,u);v&&this.id3Track.addCue(v)}}}}}}}},t.updateId3CueEnds=function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.type===t&&a.startTime<e&&a.endTime===yt&&(a.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,u=o.enableEmsgMetadataCues,l=o.enableID3MetadataCues;a&&(u||l)&&ct(a,r,i,"audio"===n?function(e){return e.type===ft&&l}:"video"===n?function(e){return e.type===pt&&u}:function(e){return e.type===ft&&l||e.type===pt&&u})}},t.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n=this.dateRangeCuesAppended,a=this.id3Track,s=i.dateRanges,o=Object.keys(s);if(a)for(var u=Object.keys(n).filter((function(e){return!o.includes(e)})),l=function(){var e=u[d];Object.keys(n[e].cues).forEach((function(t){a.removeCue(n[e].cues[t])})),delete n[e]},d=u.length;d--;)l();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&g(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=h.programDateTime/1e3-h.start,f=gt(),v=function(){var e,t,i=o[p],a=s[i],u=_t(a.startDate,c),l=n[i],d=(null==l?void 0:l.cues)||{},h=(null==l?void 0:l.durationKnown)||!1,v=yt,g=a.endDate;if(g)v=_t(g,c),h=!0;else if(a.endOnNext&&!h){var m=o.reduce((function(e,t){if(t!==a.id){var r=s[t];if(r.class===a.class&&r.startDate>a.startDate&&(!e||a.startDate<e.startDate))return r}return e}),null);m&&(v=_t(m.startDate,c),h=!0)}for(var y=Object.keys(a.attr),_=0;_<y.length;_++){var b=y[_];if("ID"!==(t=b)&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t){var E=d[b];if(E)h&&!l.durationKnown&&(E.endTime=v);else if(f){var T=a.attr[b];C(b)&&(e=T,T=Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=mt(f,u,v,{key:b,data:T},vt);S&&(S.id=i,r.id3Track.addCue(S),d[b]=S)}}}n[i]={cues:d,dateRange:a,durationKnown:h}},p=0;p<o.length;p++)v()}}},e}(),Et=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){var r;t.details===E.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&x.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a&&t.live){var s=this.targetLatency;if(null!==s){var o=r-s;if(o<Math.min(this.maxLatency,s+t.targetduration)&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),l=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,l))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,u=this.hls.userConfig,l=o&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==a?a:s*i);var d=i;return l+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),e}(),Tt=["NONE","TYPE-0","TYPE-1",null];var St=["SDR","PQ","HLG"];var Lt="",kt="YES",wt="v2";function xt(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?wt:kt:Lt}var At=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),Rt=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return Dt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return Dt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}},t.addFallback=function(){},s(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),e}();function Dt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Ct(e,t){var r=t.startPTS;if(g(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&(i.duration=n)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function Pt(e,t,r,i,n,a){i-r<=0&&(x.warn("Fragment should have a positive duration",t),i=r+t.duration,a=n+t.duration);var s=r,o=i,u=t.startPTS,l=t.endPTS;if(g(u)){var d=Math.abs(u-r);g(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(r,u),r=Math.min(r,u),n=Math.min(n,t.startDTS),o=Math.min(i,l),i=Math.max(i,l),a=Math.max(a,t.endDTS)}var h=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=s,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=a;var c,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,c=v;c>0;c--)Ct(p[c],p[c-1]);for(c=v;c<p.length-1;c++)Ct(p[c],p[c+1]);return e.fragmentHint&&Ct(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function Ot(e,t){for(var r=null,i=e.fragments,n=i.length-1;n>=0;n--){var a=i[n].initSegment;if(a){r=a;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var s,u,l,d,h,c=0;if(function(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=n;l<=a;l++){var d=u[s+l],h=o[l];i&&!h&&l<i&&(h=t.fragments[l]=d),d&&h&&r(d,h)}}(e,t,(function(e,i){e.relurl&&(c=e.cc-i.cc),g(e.startPTS)&&g(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){x.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(u=e.dateRanges,l=t.dateRanges,d=t.recentlyRemovedDateranges,h=o({},u),d&&d.forEach((function(e){delete h[e]})),Object.keys(l).forEach((function(e){var t=new P(l[e].attr,h[e]);t.isValid?h[e]=t:x.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[e].attr)+'"')})),h));var v=t.fragments;if(c){x.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),s?Pt(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):It(e,t),v.length&&(t.totalduration=t.edge-v[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function It(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||function(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}(t,i[r].start)}function Ft(e,t,r){var i;return null!=e&&e.details?Mt(null==(i=e.details)?void 0:i.partList,t,r):null}function Mt(e,t,r){if(e)for(var i=e.length;i--;){var n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function Bt(e){e.forEach((function(e,t){var r=e.details;null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t}))}))}function Nt(e){switch(e.details){case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_TIMEOUT:case E.LEVEL_LOAD_TIMEOUT:case E.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ut(e,t){var r=Nt(t);return e.default[(r?"timeout":"error")+"Retry"]}function Gt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Vt(e){return i(i({},e),{errorRetry:null,timeoutRetry:null})}function jt(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var Ht=function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function Kt(e,t,r,i,n){void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=.005);var a=null;if(e){a=t[e.sn-t[0].sn+1]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===zt(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}(a,e,Math.min(n,i))))return a;var o=Ht(t,zt.bind(null,r,i));return!o||o===e&&a?a:o}function zt(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Wt(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var qt=0,Yt=2,Xt=3,Qt=5,Jt=0,Zt=1,$t=2,er=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=x.log.bind(x,"[info]:"),this.warn=x.warn.bind(x,"[warning]:"),this.error=x.error.bind(x,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(e){},t.stopLoad=function(){this.playlistError=0},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===at?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var r,i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case E.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:qt,flags:Jt});case E.FRAG_GAP:case E.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Yt);case E.LEVEL_EMPTY_ERROR:case E.LEVEL_PARSING_ERROR:var s,o,u=t.parent===at?t.level:n.loadLevel;return void(t.details===E.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(o=s.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u)));case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case E.AUDIO_TRACK_LOAD_ERROR:case E.AUDIO_TRACK_LOAD_TIMEOUT:case E.SUBTITLE_LOAD_ERROR:case E.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=n.levels[n.loadLevel];if(l&&(a.type===it&&l.hasAudioGroup(a.groupId)||a.type===nt&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Yt,void(t.errorAction.flags=Zt)}return;case E.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=n.levels[n.loadLevel],h=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(h?t.errorAction={action:Yt,flags:$t,hdcpLevel:h}:this.keySystemError(t));case E.BUFFER_ADD_CODEC_ERROR:case E.REMUX_ALLOC_ERROR:case E.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:n.loadLevel));case E.INTERNAL_EXCEPTION:case E.BUFFER_APPENDING_ERROR:case E.BUFFER_FULL_ERROR:case E.LEVEL_SWITCH_ERROR:case E.BUFFER_STALLED_ERROR:case E.BUFFER_SEEK_OVER_HOLE:case E.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:qt,flags:Jt})}t.type===b.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},t.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},t.getPlaylistRetryOrSwitchAction=function(e,t){var r=Ut(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(jt(r,i,Nt(e),e.response))return{action:Qt,flags:Jt,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],n=t.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=Ut(e.details.startsWith("key")?s:a,e),u=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==E.FRAG_GAP&&i.fragmentError++,jt(o,u,Nt(e),e.response)))return{action:Qt,flags:Jt,retryConfig:o,retryCount:u};var l=this.getLevelSwitchAction(e,r);return o&&(l.retryConfig=o,l.retryCount=u),l},t.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var n,a,s=e.details;i.loadError++,s===E.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,u=r.levels,l=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var c,f=null==(n=e.frag)?void 0:n.type,v=(f===st&&s===E.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===E.BUFFER_ADD_CODEC_ERROR||s===E.BUFFER_APPEND_ERROR))&&u.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),p="video"===e.sourceBufferName&&(s===E.BUFFER_ADD_CODEC_ERROR||s===E.BUFFER_APPEND_ERROR)&&u.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},m=g.type,y=g.groupId,_=function(){var t=(b+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var r,n,a=u[t];if(s===E.FRAG_GAP&&f===at&&e.frag){var c=u[t].details;if(c){var g=Kt(e.frag,c.fragments,e.frag.start);if(null!=g&&g.gap)return 0}}else{if(m===it&&a.hasAudioGroup(y)||m===nt&&a.hasSubtitleGroup(y))return 0;if(f===st&&null!=(r=i.audioGroups)&&r.some((function(e){return a.hasAudioGroup(e)}))||f===ot&&null!=(n=i.subtitleGroups)&&n.some((function(e){return a.hasSubtitleGroup(e)}))||v&&i.audioCodec===a.audioCodec||!v&&i.audioCodec!==a.audioCodec||p&&i.codecSet===a.codecSet)return 0}return o=t,1}},b=u.length;b--&&(0===(c=_())||1!==c););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Yt,flags:Jt,nextAutoLevel:o}}return{action:Yt,flags:Zt}},t.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case qt:break;case Yt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===E.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case Jt:this.switchLevel(e,a);break;case $t:n&&(t.maxHdcpLevel=Tt[Tt.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,a)}},t.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e}(),tr=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=x.log.bind(x,t+":"),this.warn=x.warn.bind(x,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},t.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){x.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var u=i[n],l=parseInt(u["LAST-MSN"])||(null==t?void 0:t.lastPartSn),d=parseInt(u["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=r&&xt(r);return new At(l,d>=0?d:void 0,c)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,a=t.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&Ot(r,n),!this.canLoad||!n.live)return;var u,l=void 0,d=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var h=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,v=n.lastPartIndex,p=c===f;-1!==v?(l=p?f+1:c,d=p?h?0:v:v+1):l=f+1;var g=n.age,m=g+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var _=Math.floor(y/n.targetduration);l+=_,void 0!==d&&(d+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+_+" to part "+d)}n.tuneInGoal=y}if(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d),h||!p)return void this.loadPlaylist(u)}else(n.canBlockReload||n.canSkipUntil)&&(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d));var b=this.hls.mainForwardBufferInfo,E=b?b.end-b.len:0,T=function(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}(n,1e3*(n.edge-E));n.updated&&s>this.requestScheduled+T&&(this.requestScheduled=a.loading.start),void 0!==l&&n.canBlockReload?this.requestScheduled=a.loading.first+T-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+T<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=T);var S=this.requestScheduled-s;S=Math.max(0,S),this.log("reload live playlist "+e+" in "+Math.round(S)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(u)}),S)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var n=xt(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Lt),new At(r,i,n)},t.checkRetry=function(e){var t=this,r=e.details,i=Nt(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,u=void 0===o?0:o,l=a.retryConfig,d=!!n&&!!l&&(s===Qt||!n.resolved&&s===Yt);if(d){var h;if(this.requestScheduled=-1,u>=l.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var c=Gt(l,u);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" in '+c+"ms")}e.levelRetry=!0,n.resolved=!0}return d},e}(),rr=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),ir=function(){function e(e,t,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new rr(e),this.fast_=new rr(t),this.defaultTTFB_=i,this.ttfb_=new rr(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new rr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new rr(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new rr(e,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}();function nr(e,t){var r=!1,i=[];return e&&(r="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||St.slice(0),i=(r=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())?i.filter((function(e){return"SDR"!==e})):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function ar(e,t){x.log('[abr] start candidates with "'+e+'" ignored because '+t)}var sr=function(){function e(e){var t=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var e=t.fragCurrent,r=t.partCurrent,i=t.hls,n=i.autoLevelEnabled,a=i.media;if(e&&a){var s=performance.now(),o=r?r.stats:e.stats,u=r?r.duration:e.duration,l=s-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=d)return t.clearTimer(),void(t._nextAutoLevel=-1);if(n&&!a.paused&&a.playbackRate&&a.readyState){var h=i.mainForwardBufferInfo;if(null!==h){var c=t.bwEstimator.getEstimateTTFB(),f=Math.abs(a.playbackRate);if(!(l<=Math.max(c,u/(2*f)*1e3))){var v=h.len/f,p=o.loading.first?o.loading.first-o.loading.start:-1,m=o.loaded&&p>-1,y=t.getBwEstimate(),b=i.levels,E=b[e.level],T=o.total||Math.max(o.loaded,Math.round(u*E.averageBitrate/8)),S=m?l-p:l;S<1&&m&&(S=Math.min(l,8*o.loaded/y));var L=m?1e3*o.loaded/S:0,k=L?(T-o.loaded)/L:8*T/y+c/1e3;if(!(k<=v)){var w,A=L?8*L:y,R=Number.POSITIVE_INFINITY;for(w=e.level-1;w>d;w--){var D=b[w].maxBitrate;if((R=t.getTimeToLoadFrag(c/1e3,A,u*D,!b[w].details))<v)break}if(!(R>=k||R>10*u)){i.nextLoadLevel=i.nextAutoLevel=w,m?t.bwEstimator.sample(l-Math.min(c,p),o.loaded):t.bwEstimator.sampleTTFB(l);var C=b[w].maxBitrate;t.getBwEstimate()*t.hls.config.abrBandWidthUpFactor>C&&t.resetEstimator(C),t.clearTimer(),x.warn("[abr] Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+v.toFixed(3)+" s\n Estimated load time for current fragment: "+k.toFixed(3)+" s\n Estimated load time for down switch fragment: "+R.toFixed(3)+" s\n TTFB estimate: "+(0|p)+" ms\n Current BW estimate: "+(g(y)?0|y:"Unknown")+" bps\n New BW estimate: "+(0|t.getBwEstimate())+" bps\n Switching to level "+w+" @ "+(0|C)+" bps"),i.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:o})}}}}}}},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}var t=e.prototype;return t.resetEstimator=function(e){e&&(x.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},t.initEstimator=function(){var e=this.hls.config;return new ir(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(_.ERROR,this.onError,this))},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},t.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},t.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},t.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},t.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},t.onLevelSwitching=function(e,t){this.clearTimer()},t.onError=function(e,t){if(!t.fatal)switch(t.details){case E.BUFFER_ADD_CODEC_ERROR:case E.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case E.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,u=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(l,u),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},t.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},t.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,n=i.end-i.start;g(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(r.type===at&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,u=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:u},s.realBitrate=Math.round(8*o/u)}if(r.bitrateTest){var l={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(_.FRAG_BUFFERED,l),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},t.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},t.ignoreFragment=function(e){return e.type!==at||"initSegment"===e.sn},t.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},t.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),u=this.getStarvationDelay(),l=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(o,a,i,u,0,l,d);if(h>=0)return h}var c=s?Math.min(s,n.maxStarvationDelay):n.maxStarvationDelay;if(!u){var f=this.bitrateTestDelay;f&&(c=(s?Math.min(s,n.maxLoadingDelay):n.maxLoadingDelay)-f,x.info("[abr] bitrate test took "+Math.round(1e3*f)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),l=d=1)}var v=this.findBestLevel(o,a,i,u,c,l,d);if(x.info("[abr] "+(u?"rebuffering expected":"buffer is empty")+", optimal quality level "+v),v>-1)return v;var p=r.levels[a],g=r.levels[r.loadLevel];return(null==p?void 0:p.bitrate)<(null==g?void 0:g.bitrate)?a:r.loadLevel},t.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r},t.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},t.findBestLevel=function(e,t,r,i,n,a,s){var o,u=this,l=i+n,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,f=this.partCurrent,v=this.hls,p=v.levels,m=v.allAudioTracks,y=v.loadLevel,_=v.config;if(1===p.length)return 0;var b,E=p[h],T=!(null==E||null==(o=E.details)||!o.live),S=-1===y||-1===d,L="SDR",k=(null==E?void 0:E.frameRate)||0,w=_.audioPreference,A=_.videoPreference;this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce((function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(m));if(S){if(-1!==this.firstSelection)return this.firstSelection;var R=function(e,t,r,i,n){for(var a=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,u=s&&2===parseInt(s),l=!0,d=!1,h=1/0,c=1/0,f=1/0,v=0,p=[],m=nr(t,n),y=m.preferHDR,_=m.allowedVideoRanges,b=function(){var t=e[a[E]];l=t.channels[2]>0,h=Math.min(h,t.minHeight),c=Math.min(c,t.minFramerate),f=Math.min(f,t.minBitrate);var r=_.filter((function(e){return t.videoRanges[e]>0}));r.length>0&&(d=!0,p=r)},E=a.length;E--;)b();h=g(h)?h:0,c=g(c)?c:0;var T=Math.max(1080,h),S=Math.max(30,c);return f=g(f)?f:r,r=Math.max(f,r),d||(t=void 0,p=[]),{codecSet:a.reduce((function(t,i){var n=e[i];if(i===t)return t;if(n.minBitrate>r)return ar(i,"min bitrate of "+n.minBitrate+" > current estimate of "+r),t;if(!n.hasDefaultAudio)return ar(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return ar(i,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!n.channels[s])return ar(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(n.channels)+")"),t}else if((!o||u)&&l&&0===n.channels[2])return ar(i,"no renditions with stereo sound found"),t;return n.minHeight>T?(ar(i,"min resolution of "+n.minHeight+" > maximum of "+T),t):n.minFramerate>S?(ar(i,"min framerate of "+n.minFramerate+" > maximum of "+S),t):p.some((function(e){return n.videoRanges[e]>0}))?n.maxScore<v?(ar(i,"max score of "+n.maxScore+" < selected max of "+v),t):t&&(Be(i)>=Be(t)||n.fragmentError>e[t].fragmentError)?t:(v=n.maxScore,i):(ar(i,"no variants with VIDEO-RANGE of "+JSON.stringify(p)+" found"),t)}),void 0),videoRanges:p,preferHDR:y,minFramerate:c,minBitrate:f}}(this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((function(e,t){if(!t.codecSet)return e;var r=t.audioGroups,i=e[t.codecSet];i||(e[t.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,t.bitrate);var n=Math.min(t.height,t.width);return i.minHeight=Math.min(i.minHeight,n),i.minFramerate=Math.min(i.minFramerate,t.frameRate),i.maxScore=Math.max(i.maxScore,t.score),i.fragmentError+=t.fragmentError,i.videoRanges[t.videoRange]=(i.videoRanges[t.videoRange]||0)+1,e}),{})}(p,0,t,r)),L,e,w,A),D=R.codecSet,C=R.videoRanges,P=R.minFramerate,O=R.minBitrate,I=R.preferHDR;b=D,L=I?C[C.length-1]:C[0],k=P,e=Math.max(e,O),x.log("[abr] picked start tier "+JSON.stringify(R))}else b=null==E?void 0:E.codecSet,L=null==E?void 0:E.videoRange;for(var F,M=f?f.duration:c?c.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,N=[],U=function(){var t,o=p[G],c=G>h;if(!o)return 0;if(b&&o.codecSet!==b||L&&o.videoRange!==L||c&&k>o.frameRate||!c&&k>0&&k<o.frameRate||o.supportedResult&&(null==(t=o.supportedResult.decodingInfoResults)||!t[0].smooth))return N.push(G),0;var v,m=o.details,_=(f?null==m?void 0:m.partTarget:null==m?void 0:m.averagetargetduration)||M;v=c?s*e:a*e;var w=M&&i>=2*M&&0===n?p[G].averageBitrate:p[G].maxBitrate,A=u.getTimeToLoadFrag(B,v,w*_,void 0===m);if(v>=w&&(G===d||0===o.loadError&&0===o.fragmentError)&&(A<=B||!g(A)||T&&!u.bitrateTestDelay||A<l)){var R=u.forcedAutoLevel;return G===y||-1!==R&&R===y||(N.length&&x.trace("[abr] Skipped level(s) "+N.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+p[N[0]].codecs+'" '+p[N[0]].videoRange+'; not compatible with "'+E.codecs+'" '+L),x.info("[abr] switch candidate:"+h+"->"+G+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-w)+" ttfb:"+B.toFixed(1)+" avgDuration:"+_.toFixed(1)+" maxFetchDuration:"+l.toFixed(1)+" fetchDuration:"+A.toFixed(1)+" firstSelection:"+S+" codecSet:"+b+" videoRange:"+L+" hls.loadLevel:"+y)),S&&(u.firstSelection=G),{v:G}}},G=r;G>=t;G--)if(0!==(F=U())&&F)return F.v;return-1},s(e,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,a=this.findBestLevel(i,r,t,0,n,1,1);if(a>-1)return a;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return x.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),e}(),or={length:0,start:function(){return 0},end:function(){return 0}},ur=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,u=0,l=t,d=t,h=0;h<i.length;h++){var c=i[h].start,f=i[h].end;if(t+r>=c&&t<f)l=c,u=(d=f)-t;else if(t+r<c){o=c;break}}return{len:u,start:l||0,end:d||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return x.log("failed to get media.buffered",e),or}},e}(),lr=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,r){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){x.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+t),r.onError(t);var i=this.buffers[e];null!=i&&i.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),dr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hr=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(e){t.hls&&t.hls.pauseBuffering()},this._onStartStreaming=function(e){t.hls&&t.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var e=t.media,r=t.mediaSource;t.log("Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(_.MEDIA_ATTACHED,{media:e,mediaSource:r})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){t.log("Media source closed")},this._onMediaSourceEnded=function(){t.log("Media source ended")},this._onMediaEmptied=function(){var e=t.mediaSrc,r=t._objectUrl;e!==r&&x.error("Media element src was set while attaching MediaSource ("+r+" > "+e+")")},this.hls=e;var r,i="[buffer-controller]";this.appendSource=(r=Ce(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.log=x.log.bind(x,i),this.warn=x.warn.bind(x,i),this.error=x.error.bind(x,i),this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},t.registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new lr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){t.audio&&!t.video||t.altAudio,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=1,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media,i=Ce(this.appendSource);if(r&&i){var n,a=this.mediaSource=new i;this.log("created media source: "+(null==(n=a.constructor)?void 0:n.name)),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));var s=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,cr(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(e){r.src=s}else r.src=s;r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&cr(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(_.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){e.resetBuffer(t)})),this._initSourceBuffer()},t.resetBuffer=function(e){var t=this.sourceBuffer[e];try{var r;t&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t))}catch(t){this.warn("onBufferReset "+e,t)}},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length,n=Object.keys(t);if(n.forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var a,s=t[e],o=s.id,u=s.codec,l=s.levelCodec,d=s.container,h=s.metadata,c=Ve(n.codec,n.levelCodec),f=null==c?void 0:c.replace(dr,"$1"),v=Ve(u,l),p=null==(a=v)?void 0:a.replace(dr,"$1");if(v&&f!==p){"audio"===e.slice(0,5)&&(v=Ge(v,r.appendSource));var g=d+";codecs="+v;r.appendChangeType(e,g),r.log("switching codec "+c+" to "+v),r.tracks[e]={buffer:n.buffer,codec:u,container:d,levelCodec:l,metadata:h,id:o}}}}else r.pendingTracks[e]=t[e]})),!i){var a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(a+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(r.log("changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){r.warn("Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e,!!this.pendingTracks[e])},t.onBufferAppending=function(e,t){var r=this,i=this.hls,n=this.operationQueue,a=this.tracks,s=t.data,o=t.type,u=t.frag,l=t.part,d=t.chunkMeta,h=d.buffering[o],c=self.performance.now();h.start=c;var f=u.stats.buffering,v=l?l.stats.buffering:null;0===f.start&&(f.start=c),v&&0===v.start&&(v.start=c);var p=a.audio,g=!1;"audio"===o&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var m=u.start,y={execute:function(){if(h.executeStart=self.performance.now(),g){var e=r.sourceBuffer[o];if(e){var t=m-e.timestampOffset;Math.abs(t)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+m+" (delta: "+t+") sn: "+u.sn+")"),e.timestampOffset=m)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var e=self.performance.now();h.executeEnd=h.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t=r.sourceBuffer,i={};for(var n in t)i[n]=ur.getBuffered(t[n]);r.appendErrors[o]=0,"audio"===o||"video"===o?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(_.BUFFER_APPENDED,{type:o,frag:u,part:l,chunkMeta:d,parent:u.type,timeRanges:i})},onError:function(e){var t={type:b.MEDIA_ERROR,parent:u.type,details:E.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:u,part:l,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=E.BUFFER_FULL_ERROR;else{var n=++r.appendErrors[o];t.details=E.BUFFER_APPEND_ERROR,r.warn("Failed "+n+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+o+'" sourceBuffer'),n>=i.config.appendErrorMaxRetry&&(t.fatal=!0)}i.trigger(_.ERROR,t)}};n.append(y,o,!!this.pendingTracks[o])},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,n=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(_.BUFFER_FLUSHED,{type:e})},onError:function(t){r.warn("Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(n(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(n(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[M]?a.push("audiovideo"):(s[I]&&a.push("audio"),s[F]&&a.push("video"));0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(_.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)},t.onFragChanged=function(e,t){this.trimBuffers()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return!n||t.type&&t.type!==i||(n.ending=!0,n.ended||(n.ended=!0,r.log(i+" sourceBuffer now EOS"))),e&&!(n&&!n.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(r.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.getSourceBufferTypes().length){var i=e.config,n=r.currentTime,a=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(g(s)&&s>0){var o=Math.max(s,a),u=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,u)}if(g(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var l=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),d=Math.max(l,a),h=Math.floor(n/a)*a+d;this.flushFrontBuffer(n,a,h)}}},t.flushBackBuffer=function(e,t,r){var i=this,n=this.details,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(s){var o=a[s];if(o){var u=ur.getBuffered(o);if(u.length>0&&r>u.start(0)){if(i.hls.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=n&&n.live)i.hls.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&u.end(u.length-1)-e<2*t)return void i.log("Cannot flush "+s+" back buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))},t.flushFrontBuffer=function(e,t,r){var i=this,n=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(a){var s=n[a];if(s){var o=ur.getBuffered(s),u=o.length;if(u<2)return;var l=o.start(u-1),d=o.end(u-1);if(r>l||e>=l&&e<=d)return;if(s.ended&&e-d<2*t)return void i.log("Cannot flush "+a+" front buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:a})}}))},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,n=e.fragments[0].start+e.totalduration,a=r.duration,s=g(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(n>s&&n>a||!g(a))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+i+"-"+n+"."),t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(_.BUFFER_CREATED,{tracks:this.tracks}),n.forEach((function(e){t.executeNext(e)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},t.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=function(n){if(!r[n]){var a,s=e[n];if(!s)throw Error("source buffer exists for track "+n+", however track does not");var o=-1===(null==(a=s.levelCodec)?void 0:a.indexOf(","))?s.levelCodec:s.codec;o&&"audio"===n.slice(0,5)&&(o=Ge(o,t.appendSource));var u=s.container+";codecs="+o;t.log("creating sourceBuffer("+u+")");try{var l=r[n]=i.addSourceBuffer(u),d=n;t.addBufferListener(d,"updatestart",t._onSBUpdateStart),t.addBufferListener(d,"updateend",t._onSBUpdateEnd),t.addBufferListener(d,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(d,"bufferedchange",(function(e,r){var i=r.removedRanges;null!=i&&i.length&&t.hls.trigger(_.BUFFER_FLUSHED,{type:n})})),t.tracks[n]={buffer:l,codec:o,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:u})}}};for(var a in e)n(a)},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.operationQueue;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}else this.resetBuffer(e)},t._onSBUpdateError=function(e,t){var r,i=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,t),this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var n=this.operationQueue.current(e);n&&n.onError(i)},t.removeExecutor=function(e,t,r){var i=this.media,n=this.mediaSource,a=this.operationQueue,s=this.sourceBuffer[e];if(!i||!n||!s)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(e);var o=g(i.duration)?i.duration:1/0,u=g(n.duration)?n.duration:1/0,l=Math.max(0,t),d=Math.min(r,o,u);d>l&&(!s.ending||s.ended)?(s.ended=!1,this.log("Removing ["+l+","+d+"] from the "+e+" SourceBuffer"),s.remove(l,d)):a.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(r)r.ended=!1,r.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist")},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},s(e,[{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}}]),e}();function cr(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}var fr=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&g(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&x.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i=e.length-1,n=Math.max(t,r),a=0;a<e.length;a+=1){var s=e[a];if((s.width>=n||s.height>=n)&&(o=s,!(u=e[a+1])||o.width!==u.width||o.height!==u.height)){i=a;break}}var o,u;return i},s(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),e}(),vr=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,u=this.hls;if(u.trigger(_.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>u.config.fpsDroppedMonitoringThreshold*s){var l=u.currentLevel;x.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(_.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),pr=function(){function e(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=x.log.bind(x,"[content-steering]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.ERROR,this.onError,this))},t.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},t.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},t.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},t.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},t.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},t.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},t.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},t.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},t.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===Yt&&r.flags===Zt){var i=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,u=s.pathwayId,l=s.type;o&&i?a=this.getPathwayForGroupId(o,l,a):u&&(a=u)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&i&&(n=i.reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||x.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+a+" levels: "+(i?i.length:i)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},t.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var n=0;n<e.length;n++){var a=e[n];if(!(a in r)){if(a===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(a)).length>0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,Bt(t),this.hls.trigger(_.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[s];o&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=s);break}}}},t.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),n=0;n<i.length;n++)if(t===it&&i[n].hasAudioGroup(e)||t===nt&&i[n].hasSubtitleGroup(e))return i[n].pathwayId;return r},t.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},n={};e.forEach((function(e){var a=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===a}))){var u=t.getLevelsForPathway(s).map((function(e){var t=new D(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&t.AUDIO+"_clone_"+a,s=t.SUBTITLES&&t.SUBTITLES+"_clone_"+a;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=mr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new Rt({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",e.audioGroups[d]+"_clone_"+a);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",e.subtitleGroups[h]+"_clone_"+a);return l}));r.push.apply(r,u),gr(t.audioTracks,i,o,a),gr(t.subtitleTracks,n,o,a)}}))}},t.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,u=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:function(e,i,n,a){r.log('Loaded steering manifest: "'+t+'"');var s=e.data;if(1===s.VERSION){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],u=s["PATHWAY-CLONES"],l=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||n.url),u&&r.clonePathways(u);var d={steeringManifest:s,url:t.toString()};r.hls.trigger(_.STEERING_MANIFEST_LOADED,d),l&&r.updatePathwayPriority(l)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(e,t,i,n){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,a);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(s,l,d)},t.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var t,i=null==(t=r.hls)?void 0:t.media;!i||i.ended?r.scheduleRefresh(e,1e3*r.timeToLoad):r.loadSteeringManifest(e)}),t)},e}();function gr(e,t,r,i){e&&Object.keys(t).forEach((function(n){var a=e.filter((function(e){return e.groupId===n})).map((function(e){var a=o({},e);return a.details=void 0,a.attrs=new D(a.attrs),a.url=a.attrs.URI=mr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[n],a.attrs["PATHWAY-ID"]=i,a}));e.push.apply(e,a)}))}function mr(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var u=new self.URL(e);return a&&!n&&(u.host=a),s&&Object.keys(s).sort().forEach((function(e){e&&u.searchParams.set(e,s[e])})),u.href}var yr=/^age:\s*[\d.]+\s*$/im,_r=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new O,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,n=r.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);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,self.clearTimeout(this.requestTimeout),r.timeout=a&&g(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,s="text"!==t.responseType;if(a>=200&&a<300&&(s&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?t.response:t.responseText,u="arraybuffer"===t.responseType?o.byteLength:o.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(r,e,o,t),!this.callbacks)return;var d={url:t.responseURL,data:o,code:a};this.callbacks.onSuccess(d,r,e,t)}else{var h=n.loadPolicy.errorRetry;jt(h,r.retry,!1,{url:e.url,data:void 0,code:a})?this.retry(h):(x.error(a+" while loading "+e.url),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(jt(e,this.stats.retry,!0))this.retry(e);else{var t;x.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,x.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&yr.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),br=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();var Er=/(\d+)-(\d+)\/(\d+)/,Tr=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Sr,this.controller=new self.AbortController,this.stats=new O}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(o({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),s=r.onProgress,u="arraybuffer"===e.responseType,l=u?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,c=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=h&&g(h)?h:c,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=c,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),c-(o-n.loading.start)),!a.ok){var l=a.status,d=a.statusText;throw new kr(d||"fetch, bad network response",l,a)}return n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=Er.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(g(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&g(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):u?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var d={url:o.url,data:a,code:o.status};s&&!g(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(d,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var a=new br,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));var u=s.value,l=u.length;return t.loaded+=l,l<i||a.dataLength?(a.push(u),a.dataLength>=i&&n(t,r,a.flush(),e)):n(t,r,u,e),o()})).catch((function(){return Promise.reject()}))}()},e}();function Sr(e,t){return new self.Request(e.url,t)}var Lr,kr=function(e){function t(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return u(t,e),t}(c(Error)),wr=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_r,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:sr,bufferController:hr,capLevelController:fr,errorController:er,fpsController:vr,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:V,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:pr});function xr(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(xr):Object.keys(e).reduce((function(t,r){return t[r]=xr(e[r]),t}),{}):e}function Ar(e){var t=e.loader;t!==Tr&&t!==_r?(x.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Tr,e.progressive=!0,e.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Rr=function(e){function t(t,r){var i;return(i=e.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this.hls.config.preferManagedMediaSource,i=[],n={},a={},s=!1,o=!1,u=!1;t.levels.forEach((function(e){var t,l,d=e.attrs,h=e.audioCodec,c=e.videoCodec;-1!==(null==(t=h)?void 0:t.indexOf("mp4a.40.34"))&&(Lr||(Lr=/chrome|firefox/i.test(navigator.userAgent)),Lr&&(e.audioCodec=h=void 0)),h&&(e.audioCodec=h=Ge(h,r)),0===(null==(l=c)?void 0:l.indexOf("avc1"))&&(c=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n=i.shift()+".";n+=parseInt(i.shift()).toString(16),n+=("000"+parseInt(i.shift()).toString(16)).slice(-4),t[r]=n}}return t.join(",")}(c));var f=e.width,v=e.height,p=e.unknownCodecs;if(s||(s=!(!f||!v)),o||(o=!!c),u||(u=!!h),!(null!=p&&p.length||h&&!Oe(h,"audio",r)||c&&!Oe(c,"video",r))){var g=d.CODECS,m=d["FRAME-RATE"],y=d["HDCP-LEVEL"],_=d["PATHWAY-ID"],b=d.RESOLUTION,E=d["VIDEO-RANGE"],T=(_||".")+"-"+e.bitrate+"-"+b+"-"+m+"-"+g+"-"+E+"-"+y;if(n[T])if(n[T].uri===e.url||e.attrs["PATHWAY-ID"])n[T].addGroupId("audio",d.AUDIO),n[T].addGroupId("text",d.SUBTITLES);else{var S=a[T]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var L=new Rt(e);n[T]=L,i.push(L)}else{var k=new Rt(e);n[T]=k,a[T]=1,i.push(k)}}})),this.filterAndSortMediaOptions(i,t,s,o,u)},r.filterAndSortMediaOptions=function(e,t,r,i,n){var a=this,s=[],o=[],u=e;if((r||i)&&n&&(u=u.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&St.indexOf(t)>-1)}))),0!==u.length){if(t.audioTracks){var l=this.hls.config.preferManagedMediaSource;Dr(s=t.audioTracks.filter((function(e){return!e.audioCodec||Oe(e.audioCodec,"audio",l)})))}t.subtitles&&Dr(o=t.subtitles);var d=u.slice(0);u.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return St.indexOf(e.videoRange)-St.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Me(e.videoCodec),n=Me(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=Be(e.codecSet),s=Be(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var f=0;f<u.length;f++)if(u[f]===h){var v;this._firstLevel=f;var p=h.bitrate,g=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+p),void 0===(null==(v=this.hls.userConfig)?void 0:v.abrEwmaDefaultEstimate)){var m=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);m>g&&g===wr.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var y=n&&!i,T={levels:u,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!y&&s.some((function(e){return!!e.url}))};this.hls.trigger(_.MANIFEST_PARSED,T),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===rt&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(void 0!==r&&r.type===at){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var n=this._levels[r.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,t,s.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.uri;if(t)try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with"+(a?" Pathway "+a:"")+" "+n),this.clearTimer(),this.hls.trigger(_.LEVEL_LOADING,{url:n,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},r.removeLevel=function(e){var t,r=this,i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));Bt(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(_.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(_.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},s(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=t[e],u=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,n!==e||!o.details||!a||s!==u){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(u?" with Pathway "+u:"")+" from level "+n+(s?" with Pathway "+s:""));var l={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(_.LEVEL_SWITCHING,l);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==a?void 0:a.details,d);this.loadPlaylist(h)}}}}},{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.hls.firstAutoLevel}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}(tr);function Dr(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Cr="NOT_LOADED",Pr="APPENDING",Or="PARTIAL",Ir="OK",Fr=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[e];o&&o.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=Br(i),s=this.fragments[a];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var u=r[e],l=o||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,u)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Mr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var r=Br(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,u=e.maxStartPTS||a,l=0;l<i.length;l++){var d=i.start(l)-this.bufferPadding,h=i.end(l)+this.bufferPadding;if(u>=d&&o<=h){n.time.push({startPTS:Math.max(a,i.start(l)),endPTS:Math.min(s,i.end(l))});break}if(a<h&&s>d){var c=Math.max(a,i.start(l)),f=Math.min(s,i.end(l));f>c&&(n.partial=!0,n.time.push({startPTS:c,endPTS:f}))}else if(s<=d)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(u){var l=o[u];l&&Mr(l)&&(r=l.body.start-s,i=l.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=l.body,a=t)))})),n},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Mr(t))},t.getState=function(e){var t=Br(e),r=this.fragments[t];return r?r.buffered?Mr(r)?Or:Ir:Pr:Cr},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:t,a=Br(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,a=t.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(e){var t=a[e];r.detectEvictedFragments(e,t,s,n)}))}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Br(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var u=o.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(o.buffered||n)&&a.removeFragment(u)}}))},t.removeFragment=function(e){var t=Br(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Mr(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Br(e){return e.type+"_"+e.level+"_"+e.sn}var Nr=Math.pow(2,17),Ur=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,n=e.url;if(!n)return Promise.reject(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void l(Vr(e));e.gap=!1}var d=r.loader=e.loader=s?new s(a):new o(a),h=Gr(e),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Nr};e.stats=d.stats,d.load(h,f,{onSuccess:function(t,i,n,a){r.resetLoader(e,d);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),u({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,a,s,o){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:i({url:n,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:s,stats:o}))},onAbort:function(t,i,n){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,i,n){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:n,stats:t}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)l(Vr(e,t));else{var d=n.loader=e.loader=s?new s(a):new o(a),h=Gr(e,t),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Nr};t.stats=d.stats,d.load(h,f,{onSuccess:function(i,a,s,o){n.resetLoader(e,d),n.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:i.data,networkDetails:o};r(l),u(l)},onError:function(r,a,s,o){n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:i({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,a){e.stats.aborted=t.stats.aborted,n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,i,a){n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var u=r.loading,l=i.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Gr(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(g(n)&&g(a)){var s,o=n,u=a;if("initSegment"===e.sn&&"AES-128"===(null==(s=e.decryptdata)?void 0:s.method)){var l=a-n;l%16&&(u=a+(16-l%16)),0!==n&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=u}return i}function Vr(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:b.MEDIA_ERROR,details:E.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new jr(i)}var jr=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return u(t,e),t}(c(Error)),Hr=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,i,n){return void 0===t&&(t=E.KEY_LOAD_ERROR),new jr({type:b.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),1},s=0;s<t.length&&!a();s++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)},t.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o,u=this.keyUriToKeyInfo[s];if(null!=(r=u)&&r.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(null!=(i=u)&&i.keyLoadPromise)switch(null==(o=u.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then((function(t){return n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:u}}))}switch(u=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+n.method+'"')))}},t.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)},t.loadKeyHTTP=function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(s,o){var u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,n){var a=i.frag,u=i.keyInfo,l=i.url;if(!a.decryptdata||u!==r.keyUriToKeyInfo[l])return o(r.createKeyLoadError(a,E.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));u.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,u.loader=null,s({frag:a,keyInfo:u})},onError:function(e,n,a,s){r.resetLoader(n),o(r.createKeyLoadError(t,E.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),a,i({url:u.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,E.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,E.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};a.load(u,d,h)}))},t.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},e}(),Kr=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),zr=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a};function Wr(e,t){for(var r=0,i=e.length;r<i;r++){var n;if((null==(n=e[r])?void 0:n.cc)===t)return e[r]}return null}function qr(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function Yr(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)qr(r[i],e);t.fragmentHint&&qr(t.fragmentHint,e),t.alignedSliding=!0}function Xr(e,t,r){t&&(function(e,t,r){if(function(e,t,r){return!(!t||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}(e,r,t)){var i=function(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var n=Wr(r,i[0].cc);if(n&&(!n||n.startPTS))return n;x.log("No frag in previous level to align on")}else x.log("No fragments to align")}(r,t);i&&g(i.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Yr(i.start,t))}}(e,r,t),!r.alignedSliding&&t&&function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(n=Wr(i,s),a=Wr(r,s)),n&&a||(a=Wr(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,u=a.programDateTime;o&&u&&Yr((u-o)/1e3-(a.start-n.start),e)}}}(r,t),r.alignedSliding||!t||r.skippedSegments||It(t,r))}var Qr=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),Jr=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}();var Zr=function(){function 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.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,u=o[0],l=o[1],d=o[2],h=o[3],c=new Uint32Array(256),f=0,v=0,p=0;for(p=0;p<256;p++)c[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=v^v<<1^v<<2^v<<3^v<<4;g=g>>>8^255&g^99,e[f]=g,t[g]=f;var m=c[f],y=c[m],_=c[y],b=257*c[g]^16843008*g;i[f]=b<<24|b>>>8,n[f]=b<<16|b>>>16,a[f]=b<<8|b>>>24,s[f]=b,b=16843009*_^65537*y^257*m^16843008*f,u[g]=b<<24|b>>>8,l[g]=b<<16|b>>>16,d[g]=b<<8|b>>>24,h[g]=b,f?(f=m^c[c[c[_^m]]],v^=c[c[v]]):f=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,u,l=this.ksRows=4*(n+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,f=this.rcon,v=this.invSubMix,p=v[0],g=v[1],m=v[2],y=v[3];for(a=0;a<l;a++)a<n?o=d[a]=t[a]:(u=o,a%n==0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=f[a/n|0]<<24):n>6&&a%n==4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[a]=o=(d[a-n]^u)>>>0);for(s=0;s<l;s++)a=l-s,u=3&s?d[a]:d[a-4],h[s]=s<4||a<=4?u:p[c[u>>>24]]^g[c[u>>>16&255]]^m[c[u>>>8&255]]^y[c[255&u]],h[s]=h[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,u,l,d,h,c,f,v,p,g,m=this.keySize+6,y=this.invKeySchedule,_=this.invSBox,b=this.invSubMix,E=b[0],T=b[1],S=b[2],L=b[3],k=this.uint8ArrayToUint32Array_(r),w=k[0],x=k[1],A=k[2],R=k[3],D=new Int32Array(e),C=new Int32Array(D.length),P=this.networkToHostOrderSwap;t<D.length;){for(h=P(D[t]),c=P(D[t+1]),f=P(D[t+2]),v=P(D[t+3]),o=h^y[0],u=v^y[1],l=f^y[2],d=c^y[3],p=4,g=1;g<m;g++)i=E[o>>>24]^T[u>>16&255]^S[l>>8&255]^L[255&d]^y[p],n=E[u>>>24]^T[l>>16&255]^S[d>>8&255]^L[255&o]^y[p+1],a=E[l>>>24]^T[d>>16&255]^S[o>>8&255]^L[255&u]^y[p+2],s=E[d>>>24]^T[o>>16&255]^S[u>>8&255]^L[255&l]^y[p+3],o=i,u=n,l=a,d=s,p+=4;i=_[o>>>24]<<24^_[u>>16&255]<<16^_[l>>8&255]<<8^_[255&d]^y[p],n=_[u>>>24]<<24^_[l>>16&255]<<16^_[d>>8&255]<<8^_[255&o]^y[p+1],a=_[l>>>24]<<24^_[d>>16&255]<<16^_[o>>8&255]<<8^_[255&u]^y[p+2],s=_[d>>>24]<<24^_[o>>16&255]<<16^_[u>>8&255]<<8^_[255&l]^y[p+3],C[t]=P(i^w),C[t+1]=P(s^x),C[t+2]=P(a^A),C[t+3]=P(n^R),w=h,x=c,A=f,R=v,t+=4}return C.buffer},e}(),$r=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?j(r,0,i-n):r):a},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise((function(n,a){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();s?n(s.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(e=ke(a,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new Zr),o.expandKey(t);var u=n;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=j(s,-16).buffer,u||null},t.webCryptoDecrypt=function(e,t,r){var i=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Jr(this.subtle,t)}return this.fastAesKey.expandKey().then((function(t){return i.subtle?(i.logOnce("WebCrypto AES decrypt"),new Qr(i.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return x.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),i.onWebCryptoError(e,t,r)}))},t.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=j(e,0,r),this.remainderData=j(e,r)),t},t.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),ei=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t},ti="STOPPED",ri="IDLE",ii="KEY_LOADING",ni="FRAG_LOADING",ai="FRAG_LOADING_WAITING_RETRY",si="PARSING",oi="PARSED",ui="ENDED",li="ERROR",di="WAITING_LEVEL",hi=function(e){function t(t,r,i,n,a){var s;return(s=e.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=ti,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.loadedmetadata=!1,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.playlistType=a,s.logPrefix=n,s.log=x.log.bind(x,n+":"),s.warn=x.warn.bind(x,n+":"),s.hls=t,s.fragmentLoader=new Ur(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new $r(t.config),t.on(_.MANIFEST_LOADED,s.onManifestLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}u(t,e);var r=t.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ti},r._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){var i=r[r.length-1];return ur.isBuffered(this.media,i.start+i.duration/2)}var n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)},r.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details},r.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===ti&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,n=this.state,a=r?r.currentTime:0,s=ur.bufferInfo(i||r,a,e.maxBufferHole);if(this.log("media seeking to "+(g(a)?a.toFixed(3):a)+", state: "+n),this.state===ui)this.resetLoadingState();else if(t){var o=e.maxFragLookUpTolerance,u=t.start-o,l=t.start+t.duration+o;if(!s.len||l<s.start||u>s.end){var d=a>l;(a<u||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.hls.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=null},r.onHandlerDestroyed=function(){this.state=ti,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},r._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){var r=i.state;i.fragContextChanged(e)?(r===ni||!i.fragCurrent&&r===si)&&(i.fragmentTracker.removeFragment(e),i.state=ri):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(_.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==ti&&i.state!==li&&(i.warn("Frag error: "+((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))},r.clearTrackerIfNeeded=function(e){var t,r=this.fragmentTracker;if(r.getState(e)===Pr){var i=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1==(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Or&&r.removeFragment(e))},r.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},r.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(_.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw new Error("init load aborted");return t})).then((function(t){var i=r.hls,n=t.payload,a=e.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(t){throw i.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(n){var a=self.performance.now();return i.trigger(_.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:s,tdecrypt:a}}),t.payload=n,r.completeInitSegmentLoad(t)}))}return r.completeInitSegmentLoad(t)})).catch((function(t){r.state!==ti&&r.state!==li&&(r.warn(t),r.resetFragmentLoading(e))}))},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state=ri,e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===at?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=e.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?ei(ur.getBuffered(s)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==ot){var u=e.elementaryStreams;if(!Object.keys(u).some((function(e){return!!u[e]})))return void(this.state=ri)}var l=null==(o=this.levels)?void 0:o[e.level];null!=l&&l.fragmentError&&(this.log("Resetting level fragment error count of "+l.fragmentError+" on frag buffered"),l.fragmentError=0)}this.state=ri,s&&(!this.loadedmetadata&&e.type==at&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new zr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,i){var n,a=this;void 0===r&&(r=null);var s=null==t?void 0:t.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key?!e.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(e,s.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=ii,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(_.KEY_LOADED,e),a.state===ii&&(a.state=ri),e})),this.hls.trigger(_.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var u=s.partList;if(u&&i){r>e.end&&s.fragmentHint&&(e=s.fragmentHint);var l=this.getNextPart(u,e,r);if(l>-1){var d,h=u[l];return this.log("Loading part sn: "+e.sn+" p: "+h.index+" cc: "+e.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+l+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ni,d=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(e,h,t,i)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,h,t,i).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),g(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ni;var c,f=this.config.progressive;return c=f&&o?o.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,i)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,f?i:void 0),o]).then((function(e){var t=e[0];return!f&&t&&i&&i(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},r.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o,u=[],l=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){u[o.index]=i;var s=i.part;n.hls.trigger(_.FRAG_LOADED,i);var d=Ft(r,e.sn,o.index+1)||Mt(l,e.sn,o.index+1);if(!d)return a({frag:e,part:s,partsLoaded:u});t(d)})).catch(s)}(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===E.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(_.ERROR,t)}else this.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===si){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===ti||this.state===li||(this.state=ri)},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,n=e.sn,a=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=t[i],o=a>-1?Ft(s,n,a):null,u=o?o.fragment:function(e,t,r){if(null==e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}(s,n,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:o,level:s}):null},r.bufferFragmentData=function(e,t,r,i,n){var a;if(e&&this.state===si){var s=e.data1,o=e.data2,u=s;if(s&&o&&(u=ke(s,o)),null!=(a=u)&&a.length){var l={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:u};if(this.hls.trigger(_.BUFFER_APPENDING,l),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(ur.isBuffered(t,t.currentTime)){var r=t.currentTime,i=ur.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();return g(r)?this.getFwdBufferInfoAtPos(e,r,t):null},r.getFwdBufferInfoAtPos=function(e,t,r){var i=this.config.maxBufferHole,n=ur.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return ur.bufferInfo(e,t,Math.max(n.nextStart,i))}return n},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn("Reduce max buffer length to "+n+"s"),!0)},r.getAppendedFrag=function(e,t){var r=this.fragmentTracker.getAppendedFrag(e,at);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s)&&(n=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var u=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,u,t)}return this.mapToInitFragWhenRequired(n)},r.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===Ir||r===Or&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,r,i,n){var a=e.gap,s=this.getNextFragment(this.nextLoadPosition,t);if(null===s)return s;if(e=s,a&&e&&!e.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+e.sn),null}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var u=e[s];if(a=a&&!u.independent,i>-1&&r<u.start)break;var l=u.loaded;l?i=-1:(n||u.independent||a)&&u.fragment===t&&(i=s),n=l}return i},r.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},r.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!g(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var n=e[i];if(Wt(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t){return Ht(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,u=r.fragmentHint,l=n.maxFragLookUpTolerance,d=r.partList,h=!!(n.lowLatencyMode&&null!=d&&d.length&&u);if(h&&u&&!this.bitrateTest&&(s=s.concat(u),o=u.sn),i=e<t?Kt(a,s,e,e>t-l?0:l):s[s.length-1]){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===Ir||f===Or&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!h||d[0].fragment.sn>i.sn)&&a&&i.level===a.level){var v=s[c+1];i=i.sn<o&&this.fragmentTracker.getState(v)!==Ir?v:null}}return i},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-u)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},r.alignPlaylists=function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragments[0].start,a=!t,s=e.alignedSliding&&g(n);if(a||!s&&!n){var o=this.fragPrevious;Xr(o,r,e);var u=e.fragments[0].start;return this.log("Live playlist sliding: "+u.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+i),u}return n},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,n=i?this.startTimeOffset:e.startTimeOffset;null!==n&&g(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},r.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ai)||(this.state=ri)},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n;this.warn("Frag load error must match current frag to retry "+i.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=t.details===E.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=t.errorAction,o=s||{},u=o.action,l=o.retryCount,d=void 0===l?0:l,h=o.retryConfig;if(s&&u===Qt&&h){this.resetStartWhenNotLoaded(this.levelLastLoaded);var c=Gt(h,d);this.warn("Fragment "+i.sn+" of "+e+" "+i.level+" errored with "+t.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+c+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+c,this.state=ai}else if(h&&s){if(this.resetFragmentErrors(e),!(d<h.maxNumRetry))return void x.warn(t.details+" reached or exceeded max retry ("+d+")");a||u===Xt||(s.resolved=!0)}else(null==s?void 0:s.action)===Yt?this.state=di:this.state=li;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(e){if(this.state===si||this.state===oi){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(e){e===st&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ti&&(this.state=ri)},r.afterBufferFlushed=function(e,t,r){if(e){var i=ur.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ui&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ri},r.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var n,a=this,s=r.details;if(s){if(!Object.keys(e.elementaryStreams).reduce((function(t,n){var o=e.elementaryStreams[n];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return a.warn("Could not parse fragment "+e.sn+" "+n+" duration reliably ("+u+")"),t||!1;var l=i?0:Pt(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(_.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(o.message),this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=oi,this.hls.trigger(_.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(Kr);function ci(){return self.SourceBuffer||self.WebKitSourceBuffer}function fi(){if(!Ce())return!1;var e=ci();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function vi(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var pi=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=ke(this.cachedData,e),this.cachedData=null);var r,i=W(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?X(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&g(o))&&(this.basePTS=gi(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(e,n)){var l=this.appendFrame(a,e,n);l?(this.frameIndex++,this.lastPTS=l.sample.pts,r=n+=l.length):n=u}else Y(e,n)?(i=W(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===u&&r!==u){var d=j(e,r);this.cachedData?this.cachedData=ke(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:vi(),id3Track:s,textTrack:vi()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:vi(),id3Track:this._id3Track,textTrack:vi()}},t.destroy=function(){},e}(),gi=function(e,t,r){return g(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)};function mi(e,t){return 255===e[t]&&240==(246&e[t+1])}function yi(e,t){return 1&e[t+1]?7:9}function _i(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function bi(e,t){return t+1<e.length&&mi(e,t)}function Ei(e,t){if(bi(e,t)){var r=yi(e,t);if(t+r>=e.length)return!1;var i=_i(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||bi(e,n)}return!1}function Ti(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,u=navigator.userAgent.toLowerCase(),l=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&t[r+2])>>>6);var h=(60&t[r+2])>>>2;if(!(h>d.length-1))return s=(1&t[r+2])<<2,s|=(192&t[r+3])>>>6,x.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+h),/firefox/i.test(u)?h>=6?(n=5,o=new Array(4),a=h-3):(n=2,o=new Array(2),a=h):-1!==u.indexOf("android")?(n=2,o=new Array(2),a=h):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&h>=6?a=h-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(h>=6&&1===s||/vivaldi/i.test(u))||!i&&1===s)&&(n=2,o=new Array(2)),a=h)),o[0]=n<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[h],channelCount:s,codec:"mp4a.40."+n,manifestCodec:l};var c=new Error("invalid ADTS sampling index:"+h);e.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,r,i,n);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,x.log("parsed codec:"+e.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Si(e){return 9216e4/e}function Li(e,t,r,i,n){var a,s=i+n*Si(e.samplerate),o=function(e,t){var r=yi(e,t);if(t+r<=e.length){var i=_i(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var u=o.frameLength,l=o.headerLength,d=l+u,h=Math.max(0,r+d-t.length);h?(a=new Uint8Array(d-l)).set(t.subarray(r+l,t.length),0):a=t.subarray(r+l,r+d);var c={unit:a,pts:s};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var ki=null,wi=[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],xi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ai=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ri=[0,1,1,4];function Di(e,t,r,i,n){if(!(r+24>t.length)){var a=Ci(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Ci(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*wi[14*(3===r?3-i:3===i?3:4)+n-1],l=xi[3*(3===r?0:2===r?1:2)+a],d=3===o?1:2,h=Ai[r][i],c=Ri[i],f=8*h*c,v=Math.floor(h*u/l+s)*c;if(null===ki){var p=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ki=p?parseInt(p[1]):0}return!!ki&&ki<=87&&2===i&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:v,samplesPerFrame:f}}}function Pi(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Oi(e,t){return t+1<e.length&&Pi(e,t)}function Ii(e,t){if(t+1<e.length&&Pi(e,t)){var r=Ci(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||Oi(e,n)}return!1}var Fi=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(Ii(e,r))return!1;for(var i=e.length;r<i;r++)if(Ei(e,r))return x.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&mi(e,t)&&_i(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){Ti(e,this.observer,t,r,e.manifestCodec);var i=Li(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},t}(pi),Mi=/\/emsg[-/]ID3/i,Bi=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=this.videoTrack=vi("video",1),a=this.audioTrack=vi("audio",1),s=this.txtTrack=vi("text",1);if(this.id3Track=vi("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=ye(e);if(o.video){var u=o.video,l=u.id,d=u.timescale,h=u.codec;n.id=l,n.timescale=s.timescale=d,n.codec=h}if(o.audio){var c=o.audio,f=c.id,v=c.timescale,p=c.codec;a.id=f,a.timescale=v,a.codec=p}s.id=le.text,n.sampleDuration=0,n.duration=a.duration=i}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=ce(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=ke(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=ge(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=j(e,0,i.byteOffset-8),t.remainder=j(e,i.byteOffset-8),t}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return n.samples=we(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=we(e,t),{videoTrack:t,audioTrack:vi(),id3Track:i,textTrack:vi()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=ge(e.samples,["emsg"]);i&&i.forEach((function(e){var i=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,u=0,l=0;if(0===t){for(;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1,n=ce(e,12),a=ce(e,16),o=ce(e,20),u=ce(e,24),l=28}else if(1===t){n=ce(e,l+=4);var d=ce(e,l+=4),h=ce(e,l+=4);for(l+=4,s=Math.pow(2,32)*d+h,m(s)||(s=Number.MAX_SAFE_INTEGER,x.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ce(e,l),u=ce(e,l+=4),l+=4;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(Mi.test(i.schemeIdUri)){var n=g(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:pt,duration:a})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),Ni=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}},t.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&x.log(e.pts+"/"+e.dts+":"+e.debug)},e}(),Ui=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),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)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&x.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),u=this.readBits.bind(this),l=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var p=o();if(u(5),h(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var g=l();if(3===g&&h(1),f(),f(),h(1),d())for(t=3!==g?8:12,r=0;r<t;r++)d()&&v(r<6?16:64)}f();var m=l();if(0===m)l();else if(1===m)for(h(1),c(),c(),e=l(),r=0;r<e;r++)c();f(),h(1);var y=l(),_=l(),b=u(1);0===b&&h(1),h(1),d()&&(i=l(),n=l(),a=l(),s=l());var E=[1,1];if(d()&&d())switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-b)*(_+1)*16-(b?2:4)*(a+s),pixelRatio:E}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),Gi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.parseAVCPES=function(e,t,r,i,n){var a,s=this,o=this.parseAVCNALu(e,r.data),u=this.VideoSample,l=!1;r.data=null,u&&o.length&&!e.audFound&&(this.pushAccessUnit(u,e),u=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),o.forEach((function(i){var o;switch(i.type){case 1:var d=!1;a=!0;var h,c=i.data;if(l&&c.length>4){var f=new Ui(c).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(d=!0)}d&&null!=(h=u)&&h.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.frame=!0,u.key=d;break;case 5:a=!0,null!=(o=u)&&o.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:a=!0,Ae(i.data,1,r.pts,t.samples);break;case 7:var v,p;a=!0,l=!0;var g=i.data,m=new Ui(g).readSPS();if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(p=e.pixelRatio)?void 0:p[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[g],e.duration=n;for(var y=g.subarray(1,4),_="avc1.",b=0;b<3;b++){var E=y[b].toString(16);E.length<2&&(E="0"+E),_+=E}e.codec=_}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,u&&s.pushAccessUnit(u,e),u=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&a&&u.units.push(i)})),i&&u&&(this.pushAccessUnit(u,e),this.VideoSample=null)},r.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],u=0,l=-1,d=0;for(-1===a&&(l=0,d=31&t[0],a=0,u=1);u<n;)if(r=t[u++],a)if(1!==a)if(r)if(1===r){if(i=u-a-1,l>=0){var h={data:t.subarray(l,i),type:d};o.push(h)}else{var c=this.getLastNalUnit(e.samples);c&&(s&&u<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),i>0&&(c.data=ke(c.data,t.subarray(0,i)),c.state=0))}u<n?(l=u,d=31&t[u],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(l>=0&&a>=0){var f={data:t.subarray(l,n),type:d,state:a};o.push(f)}if(0===o.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=ke(v.data,t))}return e.naluState=a,o},t}(Ni),Vi=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new $r(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,r){var i=this,n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,n){var a=this,s=Re(n.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){n.data=a.getAvcDecryptedUnit(s,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}},e}(),ji=188,Hi=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Gi}e.probe=function(t){var r=e.syncOffset(t);return r>0&&x.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-ji)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=ji){if(71!==e[o]||t-o!==ji&&71!==e[o+ji]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-ji)+1),n||(n=0===Ki(e,o)),n&&s>1&&(0===a&&s>2||o+ji>r))return a}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:le[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=s.pid,h=s.pesData,c=o.pid,f=u.pid,v=o.pesData,p=u.pesData,g=null,m=this.pmtParsed,y=this._pmtId,_=t.length;if(this.remainderData&&(_=(t=ke(this.remainderData,t)).length,this.remainderData=null),_<ji&&!n)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};var b=Math.max(0,e.syncOffset(t));(_-=(_-b)%ji)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,_,t.buffer.byteLength-_));for(var E=0,T=b;T<_;T+=ji)if(71===t[T]){var S=!!(64&t[T+1]),L=Ki(t,T),k=void 0;if((48&t[T+3])>>4>1){if((k=T+5+t[T+4])===T+ji)continue}else k=T+4;switch(L){case d:S&&(h&&(a=Xi(h))&&this.videoParser.parseAVCPES(s,l,a,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(k,T+ji)),h.size+=T+ji-k);break;case c:if(S){if(v&&(a=Xi(v)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}v={data:[],size:0}}v&&(v.data.push(t.subarray(k,T+ji)),v.size+=T+ji-k);break;case f:S&&(p&&(a=Xi(p))&&this.parseID3PES(u,a),p={data:[],size:0}),p&&(p.data.push(t.subarray(k,T+ji)),p.size+=T+ji-k);break;case 0:S&&(k+=t[k]+1),y=this._pmtId=zi(t,k);break;case y:S&&(k+=t[k]+1);var w=Wi(t,k,this.typeSupported,i,this.observer);(d=w.videoPid)>0&&(s.pid=d,s.segmentCodec=w.segmentVideoCodec),(c=w.audioPid)>0&&(o.pid=c,o.segmentCodec=w.segmentAudioCodec),(f=w.id3Pid)>0&&(u.pid=f),null===g||m||(x.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+g+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),g=null,T=b-188),m=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=L}}else E++;E>0&&qi(this.observer,new Error("Found "+E+" TS packet/s that do not start with 0x47")),s.pesData=h,o.pesData=v,u.pesData=p;var A={audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};return n&&this.extractRemainingSamples(A),A},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,u=n.pesData;if(s&&(t=Xi(s))?(this.videoParser.parseAVCPES(i,a,t,!0,this._duration),i.pesData=null):i.pesData=s,o&&(t=Xi(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&x.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;u&&(t=Xi(u))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=u},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Vi(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var r,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var u=s.missing,l=s.sample.unit.byteLength;if(-1===u)o=ke(s.sample.unit,o);else{var d=l-u;s.sample.unit.set(o.subarray(0,u),d),e.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r<i-1&&!bi(o,r);r++);if(r!==a){var h,c=r<i-1;if(h=c?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",qi(this.observer,new Error(h),c),!c)return}if(Ti(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!s)return void x.warn("[tsdemuxer]: AAC PES unknown PTS");var f=Si(e.samplerate);n=s.sample.pts+f}for(var v,p=0;r<i;){if(r+=(v=Li(e,o,r,n,p)).length,v.missing){this.aacOverFlow=v;break}for(p++;r<i-1&&!bi(o,r);r++);}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,n=0,a=0,s=t.pts;if(void 0!==s)for(;a<i;)if(Oi(r,a)){var o=Di(e,r,a,s,n);if(!o)break;a+=o.length,n++}else a++;else x.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=o({},t,{type:this._videoTrack?pt:ft,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function Ki(e,t){return((31&e[t+1])<<8)+e[t+2]}function zi(e,t){return(31&e[t+10])<<8|e[t+11]}function Wi(e,t,r,i,n){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var o=Ki(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Yi("ADTS AAC");break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Yi("H.264");break}case 27:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):x.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Yi("AC-3");break}case 129:x.warn("AC-3 in M2TS support not included in build");break;case 6:if(-1===a.audioPid&&u>0)for(var l=t+5,d=u;d>2;){106===e[l]&&x.warn("AC-3 in M2TS support not included in build");var h=e[l+1]+2;l+=h,d-=h}break;case 194:case 135:return qi(n,new Error("Unsupported EC-3 in M2TS found")),a;case 36:return qi(n,new Error("Unsupported HEVC in M2TS found")),a}t+=u+5}return a}function qi(e,t,r){x.warn("parsing error: "+t.message),e.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Yi(e){x.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Xi(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=ke(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var u=t[7];192&u&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&u?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(x.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var l=(i=t[8])+9;if(e.size<=l)return null;e.size-=l;for(var d=new Uint8Array(e.size),h=0,c=o.length;h<c;h++){var f=(t=o[h]).byteLength;if(l){if(l>f){l-=f;continue}t=t.subarray(l),f-=l,l=0}d.set(t,s),s+=f}return r&&(r-=i+3),{data:d,pts:n,dts:a,len:r}}return null}var Qi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==X(t)&&function(e,t){var r=0,i=5;t+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),u=8-o;a[0]=4278190080>>>24+u<<u,n[0]=(s[0]&a[0])>>u,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r}(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(Ii(e,r))return x.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return Pi(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return Di(e,t,r,this.basePTS,this.frameIndex)},t}(pi),Ji=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}(),Zi=Math.pow(2,32)-1,$i=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},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]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,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 s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,u,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=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))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+1)),a=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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=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))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),u=t.width,l=t.height,d=t.pixelRatio[0],h=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,u>>8&255,255&u,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,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,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=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]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(Zi+1)),o=Math.floor(i%(Zi+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,o>>24,o>>16&255,o>>8&255,255&o,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,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(Zi+1)),s=Math.floor(r%(Zi+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,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=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]))},e.trun=function(t,r){var i,n,a,s,o,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(r+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=(n=l[i]).duration,s=n.size,o=n.flags,u=n.cts,c.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*i);return e.box(e.types.trun,c)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t);return ke(e.FTYP,r)},e}();$i.types=void 0,$i.HDLR_TYPES=void 0,$i.STTS=void 0,$i.STSC=void 0,$i.STCO=void 0,$i.STSZ=void 0,$i.VMHD=void 0,$i.SMHD=void 0,$i.STSD=void 0,$i.FTYP=void 0,$i.DINF=void 0;function en(e,t){return void 0===t&&(t=!1),function(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}(e,1e3,1/9e4,t)}var tn=null,rn=null,nn=function(){function e(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===tn){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tn=n?parseInt(n[1]):0}if(null===rn){var a=navigator.userAgent.match(/Safari\/(\d+)/i);rn=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){x.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){x.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){x.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,an(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&x.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var u,l,d,h,c,f,v=n,p=n,g=e.pid>-1,m=t.pid>-1,y=t.samples.length,_=e.samples.length>0,b=s&&y>0||y>1;if((!g||_)&&(!m||b)||this.ISGenerated||s){if(this.ISGenerated){var E,T,S,L,k=this.videoTrackConfig;!k||t.width===k.width&&t.height===k.height&&(null==(E=t.pixelRatio)?void 0:E[0])===(null==(T=k.pixelRatio)?void 0:T[0])&&(null==(S=t.pixelRatio)?void 0:S[1])===(null==(L=k.pixelRatio)?void 0:L[1])||this.resetInitSegment()}else d=this.generateIS(e,t,n,a);var w,A=this.isVideoContiguous,R=-1;if(b&&(R=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,R>0){x.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var D=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(R),t.dropped+=R,w=p+=(t.samples[0].pts-D)/t.inputTimeScale}else-1===R&&(x.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(_&&b){var C=this.getVideoStartPts(t.samples),P=(an(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,P),p+=Math.max(0,-P)}if(_){if(e.samplerate||(x.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,a)),l=this.remuxAudio(e,v,this.isAudioContiguous,a,m||b||o===st?p:void 0),b){var O=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(x.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,a)),u=this.remuxVideo(t,p,A,O)}}else b&&(u=this.remuxVideo(t,p,A,0));u&&(u.firstKeyFrame=R,u.independent=-1!==R,u.firstKeyFramePTS=w)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=sn(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=on(i,n,this._initPTS))),{audio:l,video:u,initSegment:d,independent:f,text:h,id3:c}},t.generateIS=function(e,t,r,i){var n,a,s,o=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||i,f="audio/mp4";if(c&&(n=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(f="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):$i.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(s=e.inputTimeScale,h&&s===h.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:$i.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(s=t.inputTimeScale,h&&s===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=Math.round(s*r);a=Math.min(a,an(u[0].dts,v)-p),n=Math.min(n,v-p)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:d,initPTS:n,timescale:s}},t.remuxVideo=function(e,t,r,i){var n,a,s=e.inputTimeScale,u=e.samples,l=[],d=u.length,h=this._initPTS,c=this.nextAvcDts,f=8,v=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;if(!r||null===c){var y=t*s,T=u[0].pts-an(u[0].dts,u[0].pts);tn&&null!==c&&Math.abs(y-T-c)<15e3?r=!0:c=y-T}for(var S=h.baseTime*s/h.timescale,L=0;L<d;L++){var k=u[L];k.pts=an(k.pts-S,c),k.dts=an(k.dts-S,c),k.dts<u[L>0?L-1:L].dts&&(m=!0)}m&&u.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=u[0].dts;var w=u[u.length-1].dts-n,A=w?Math.round(w/(d-1)):v||e.inputTimeScale/30;if(r){var R=n-c,D=R>A,C=R<-1;if((D||C)&&(D?x.warn("AVC: "+en(R,!0)+" ms ("+R+"dts) hole between fragments detected at "+t.toFixed(3)):x.warn("AVC: "+en(-R,!0)+" ms ("+R+"dts) overlapping between fragments detected at "+t.toFixed(3)),!C||c>=u[0].pts||tn)){n=c;var P=u[0].pts-R;if(D)u[0].dts=n,u[0].pts=P;else for(var O=0;O<u.length&&!(u[O].dts>P);O++)u[O].dts-=R,u[O].pts-=R;x.log("Video: Initial PTS/DTS adjusted: "+en(P,!0)+"/"+en(n,!0)+", delta: "+en(R,!0)+" ms")}}for(var I=0,F=0,M=n=Math.max(0,n),B=0;B<d;B++){for(var N=u[B],U=N.units,G=U.length,V=0,j=0;j<G;j++)V+=U[j].data.length;F+=V,I+=G,N.length=V,N.dts<M?(N.dts=M,M+=A/4|0||1):M=N.dts,p=Math.min(N.pts,p),g=Math.max(N.pts,g)}a=u[d-1].dts;var H,K=F+4*I+8;try{H=new Uint8Array(K)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:b.MUX_ERROR,details:E.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:K,reason:"fail allocating video mdat "+K})}var z=new DataView(H.buffer);z.setUint32(0,K),H.set($i.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,J=0;J<d;J++){for(var Z=u[J],$=Z.units,ee=0,te=0,re=$.length;te<re;te++){var ie=$[te],ne=ie.data,ae=ie.data.byteLength;z.setUint32(f,ae),f+=4,H.set(ne,f),f+=ae,ee+=4+ae}var se=void 0;if(J<d-1)v=u[J+1].dts-Z.dts,se=u[J+1].pts-Z.pts;else{var oe=this.config,ue=J>0?Z.dts-u[J-1].dts:A;if(se=J>0?Z.pts-u[J-1].pts:A,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var le=Math.floor(oe.maxBufferHole*s),de=(i?p+i*s:this.nextAudioPts)-Z.pts;de>le?((v=de-ue)<0?v=ue:W=!0,x.log("[mp4-remuxer]: It is approximately "+de/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=ue}else v=ue}var he=Math.round(Z.pts-Z.dts);q=Math.min(q,v),X=Math.max(X,v),Y=Math.min(Y,se),Q=Math.max(Q,se),l.push(new un(Z.key,v,ee,he))}if(l.length)if(tn){if(tn<70){var ce=l[0].flags;ce.dependsOn=2,ce.isNonSync=0}}else if(rn&&Q-Y<X-q&&A/X<.025&&0===l[0].cts){x.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,ve=0,pe=l.length;ve<pe;ve++){var ge=fe+l[ve].duration,me=fe+l[ve].cts;if(ve<pe-1){var ye=ge+l[ve+1].cts;l[ve].duration=ye-me}else l[ve].duration=ve?l[ve-1].duration:A;l[ve].cts=0,fe=ge}}v=W||!v?A:v,this.nextAvcDts=c=a+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var _e={data1:$i.moof(e.sequenceNumber++,n,o({},e,{samples:l})),data2:H,startPTS:p/s,endPTS:(g+v)/s,startDTS:n/s,endDTS:c/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_e},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},t.remuxAudio=function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),u=this.getSamplesPerFrame(e),l=u*s,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],f=void 0!==n,v=e.samples,p=h?0:8,g=this.nextAudioPts||-1,m=t*a,y=d.baseTime*a/d.timescale;if(this.isAudioContiguous=r=r||v.length&&g>0&&(i&&Math.abs(m-g)<9e3||Math.abs(an(v[0].pts-y,m)-g)<20*l),v.forEach((function(e){e.pts=an(e.pts-y,m)})),!r||g<0){if(v=v.filter((function(e){return e.pts>=0})),!v.length)return;g=0===n?0:i&&!f?Math.max(0,m):v[0].pts}if("aac"===e.segmentCodec)for(var T=this.config.maxAudioFramesDrift,S=0,L=g;S<v.length;S++){var k=v[S],w=k.pts,A=w-L,R=Math.abs(1e3*A/a);if(A<=-T*l&&f)0===S&&(x.warn("Audio frame @ "+(w/a).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*A/a)+" ms."),this.nextAudioPts=g=L=w);else if(A>=T*l&&R<1e4&&f){var D=Math.round(A/l);(L=w-D*l)<0&&(D--,L+=l),0===S&&(this.nextAudioPts=g=L),x.warn("[mp4-remuxer]: Injecting "+D+" audio frame @ "+(L/a).toFixed(3)+"s due to "+Math.round(1e3*A/a)+" ms gap.");for(var C=0;C<D;C++){var P=Math.max(L,0),O=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);O||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),O=k.unit.subarray()),v.splice(S,0,{unit:O,pts:P}),L+=l,S++}}k.pts=L,L+=l}for(var I,F=null,M=null,B=0,N=v.length;N--;)B+=v[N].unit.byteLength;for(var U=0,G=v.length;U<G;U++){var V=v[U],j=V.unit,H=V.pts;if(null!==M)c[U-1].duration=Math.round((H-M)/s);else{if(r&&"aac"===e.segmentCodec&&(H=g),F=H,!(B>0))return;B+=p;try{I=new Uint8Array(B)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:b.MUX_ERROR,details:E.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:B,reason:"fail allocating audio mdat "+B})}h||(new DataView(I.buffer).setUint32(0,B),I.set($i.types.mdat,4))}I.set(j,p);var K=j.byteLength;p+=K,c.push(new un(!0,u,K,0)),M=H}var z=c.length;if(z){var W=c[c.length-1];this.nextAudioPts=g=M+s*W.duration;var q=h?new Uint8Array(0):$i.moof(e.sequenceNumber++,F/s,o({},e,{samples:c}));e.samples=[];var Y=F/a,X=g/a,Q={data1:q,data2:I,startPTS:Y,endPTS:X,startDTS:Y,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,Q}},t.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,o=this._initDTS,u=9e4*o.baseTime/o.timescale,l=(null!==s?s:i.startDTS*n)+u,d=i.endDTS*n+u,h=1024*a,c=Math.ceil((d-l)/h),f=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),f){for(var v=[],p=0;p<c;p++){var g=l+p*h;v.push({unit:f,pts:g,dts:g})}return e.samples=v,this.remuxAudio(e,t,r,!1)}x.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function an(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function sn(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=an(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=an(o.dts-i.baseTime*a/i.timescale,t*a)/a}var u=e.samples;return e.samples=[],{samples:u}}}function on(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=an(s.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var un=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},ln=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Se(e,i)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=ye(e);i.audio&&(t=dn(i.audio,I)),i.video&&(r=dn(i.video,F));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:x.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,i,n,a){var s,o,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};g(l)||(l=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return d;var c={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return x.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=ge(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],u=ge(o,["tfhd"])[0],l=t[ce(u,4)];if(l){var d=l.default,h=ce(u,0)|(null==d?void 0:d.flags),c=null==d?void 0:d.duration;8&h&&(c=ce(u,2&h?12:8));for(var f=l.timescale||9e4,v=ge(o,["trun"]),p=0;p<v.length;p++)!(r=Le(v[p]))&&c&&(r=c*ce(v[p],4)),l.type===F?i+=r/f:l.type===I&&(n+=r/f)}}if(0===i&&0===n){for(var m=1/0,y=0,_=0,b=ge(e,["sidx"]),E=0;E<b.length;E++){var T=me(b[E]);if(null!=T&&T.references){m=Math.min(m,T.earliestPresentationTime/T.timescale);var S=T.references.reduce((function(e,t){return e+t.info.duration||0}),0);_=(y=Math.max(y,S+T.earliestPresentationTime/T.timescale))-m}}if(_&&g(_))return _}return i||n}(h,f),p=function(e,t){return ge(t,["moof","traf"]).reduce((function(t,r){var i=ge(r,["tfdt"])[0],n=i[0],a=ge(r,["tfhd"]).reduce((function(t,r){var a=ce(r,4),s=e[a];if(s){var o=ce(i,4);if(1===n){if(o===oe)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=oe+1,o+=ce(i,8)}var u=o/(s.timescale||9e4);if(g(u)&&(null===t||u<t))return u}return t}),null);return null!==a&&g(a)&&(null===t||a<t)?a:t}),null)}(f,h),m=null===p?n:p;(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(u,m,n,v)||c.timescale!==u.timescale&&a)&&(c.initPTS=m-n,u&&1===u.timescale&&x.warn("Adjusting initPTS by "+(c.initPTS-u.baseTime)),this.initPTS=u={baseTime:c.initPTS,timescale:1});var y=e?m-u.baseTime/u.timescale:l,_=y+v;(function(e,t,r){ge(t,["moof","traf"]).forEach((function(t){ge(t,["tfhd"]).forEach((function(i){var n=ce(i,4),a=e[n];if(a){var s=a.timescale||9e4;ge(t,["tfdt"]).forEach((function(e){var t=e[0],i=r*s;if(i){var n=ce(e,4);if(0===t)n-=i,pe(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=ce(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(oe+1)),o=Math.floor(n%(oe+1));pe(e,4,a),pe(e,8,o)}}}))}}))}))})(f,h,u.baseTime/u.timescale),v>0?this.lastEndTime=_:(x.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var b=!!f.audio,E=!!f.video,T="";b&&(T+="audio"),E&&(T+="video");var S={data1:h,startPTS:y,startDTS:y,endPTS:_,endDTS:_,type:T,hasAudio:b,hasVideo:E,nb:1,dropped:0};return d.audio="audio"===S.type?S:void 0,d.video="audio"!==S.type?S:void 0,d.initSegment=c,d.id3=sn(r,n,u,u),i.samples.length&&(d.text=on(i,n,u)),d},e}();function dn(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===I){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return Ge(r,!1);var i="mp4a.40.5";return x.info('Parsed audio codec "'+r+'" or audio object type not handled. Using "'+i+'"'),i}return x.warn('Unhandled video codec "'+r+'"'),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}var hn,cn="undefined"!=typeof self?self:void 0;try{hn=self.performance.now.bind(self.performance)}catch(e){x.debug("Unable to use Performance API on this environment"),hn=null==cn?void 0:cn.Date.now}var fn=[{demux:Bi,remux:ln},{demux:Hi,remux:nn},{demux:Fi,remux:nn},{demux:Qi,remux:nn}],vn=function(){function e(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=hn();var s=new Uint8Array(e),o=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var l=i||o,d=l.contiguous,h=l.discontinuity,c=l.trackSwitch,f=l.accurateTimeOffset,v=l.timeOffset,p=l.initSegmentChange,g=u.audioCodec,m=u.videoCodec,y=u.defaultInitPts,T=u.duration,S=u.initSegmentData,L=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(L&&"AES-128"===L.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,L.key.buffer,L.iv.buffer).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var w=k.softwareDecrypt(s,L.key.buffer,L.iv.buffer);if(r.part>-1&&(w=k.flush()),!w)return a.executeEnd=hn(),pn(r);s=new Uint8Array(w)}var A=this.needsProbing(h,c);if(A){var R=this.configureTransmuxer(s);if(R)return x.warn("[transmuxer] "+R.message),this.observer.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:R,reason:R.message}),a.executeEnd=hn(),pn(r)}(h||c||p||A)&&this.resetInitSegment(S,g,m,T,t),(h||p||A)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var D=this.transmux(s,L,v,f,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,a.executeEnd=hn(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=hn();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(i){var u=i.flush();u&&s.push(this.push(u,null,e))}var l=this.demuxer,d=this.remuxer;if(!l||!d)return r.executeEnd=hn(),[pn(e)];var h=l.flush(o);return gn(h)?h.then((function(r){return t.flushRemux(s,r,e),s})):(this.flushRemux(s,h,e),s)},t.flushRemux=function(e,t,r){var i=t.audioTrack,n=t.videoTrack,a=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,u=o.accurateTimeOffset,l=o.timeOffset;x.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,n,a,s,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=hn()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,u=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,u,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=fn.length;s<o;s++){var u;if(null!=(u=fn[s].demux)&&u.probe(e)){t=fn[s];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,d=this.remuxer,h=t.remux,c=t.demux;d&&d instanceof h||(this.remuxer=new h(i,r,n,a)),l&&l instanceof c||(this.demuxer=new c(i,r,n),this.probe=c.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new $r(this.config)),e},e}();var pn=function(e){return{remuxResult:{},chunkMeta:e}};function gn(e){return"then"in e&&e.then instanceof Function}var mn=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null},yn=function(e,t,r,i,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a},_n={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){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,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(_n);var bn=f(_n.exports);function En(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&Tn(i,a),s&&Tn(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function Tn(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function Sn(e,t,r){t.reduce((function(t,r){return En(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}void 0!==r&&r&&function(e){var t=new bn,r=function(t,r){e.postMessage({event:t,data:r})};t.on(_.FRAG_DECRYPTED,r),t.on(_.ERROR,r),e.addEventListener("message",(function(i){var n=i.data;switch(n.cmd){case"init":var a=JSON.parse(n.config);e.transmuxer=new vn(t,n.typeSupported,a,"",n.id),w(a.debug,n.id),function(){var e=function(e){x[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in x)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(n.config);break;case"demux":var s=e.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);gn(s)?(e.transmuxer.async=!0,s.then((function(t){En(e,t)})).catch((function(e){r(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,En(e,s));break;case"flush":var o=n.chunkMeta,u=e.transmuxer.flush(o);gn(u)||e.transmuxer.async?(gn(u)||(u=Promise.resolve(u)),u.then((function(t){Sn(e,t,o)})).catch((function(e){r(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):Sn(e,u,o)}}))}(self);var Ln=function(){function e(e,r,i,n){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var s=e.config;this.hls=e,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var o=function(e,t){(t=t||{}).frag=a.frag,t.id=a.id,e===_.ERROR&&(a.error=t.error),a.hls.trigger(e,t)};this.observer=new bn,this.observer.on(_.FRAG_DECRYPTED,o),this.observer.on(_.ERROR,o);var u,l,d,h,c=Ce(s.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},f={mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath,1))try{s.workerPath?(x.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(x.log('injecting Web Worker for "'+r+'"'),this.workerContext=(u=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),l=self.URL.createObjectURL(u),{worker:new self.Worker(l),objectURL:l})),this.onwmsg=function(e){return a.onWorkerMessage(e)};var v=this.workerContext.worker;v.addEventListener("message",this.onwmsg),v.onerror=function(e){var t=new Error(e.message+" ("+e.filename+":"+e.lineno+")");s.enableWorker=!1,x.warn('Error in "'+r+'" Web Worker, fallback to inline'),a.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},v.postMessage({cmd:"init",typeSupported:f,vendor:"",id:r,config:JSON.stringify(s)})}catch(e){x.warn('Error setting up "'+r+'" Web Worker, fallback to inline',e),this.resetWorker(),this.error=null,this.transmuxer=new vn(this.observer,f,s,"",r)}else this.transmuxer=new vn(this.observer,f,s,"",r)}var r=e.prototype;return r.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},r.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},r.push=function(e,t,r,i,n,a,s,o,u,l){var d,h,c=this;u.transmuxing.start=self.performance.now();var f=this.transmuxer,v=a?a.start:n.start,p=n.decryptdata,g=this.frag,m=!(g&&n.cc===g.cc),y=!(g&&u.level===g.level),_=g?u.sn-g.sn:-1,b=this.part?u.part-this.part.index:-1,E=0===_&&u.id>1&&u.id===(null==g?void 0:g.stats.chunkCount),T=!y&&(1===_||0===_&&(1===b||E&&b<=0)),S=self.performance.now();(y||_||0===n.stats.parsing.start)&&(n.stats.parsing.start=S),!a||!b&&T||(a.stats.parsing.start=S);var L=!(g&&(null==(d=n.initSegment)?void 0:d.url)===(null==(h=g.initSegment)?void 0:h.url)),k=new yn(m,T,o,y,v,L);if(!T||m||L){x.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+m+"\n trackSwitch: "+y+"\n contiguous: "+T+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+L);var w=new mn(r,i,t,s,l);this.configureTransmuxer(w)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:u,state:k},e instanceof ArrayBuffer?[e]:[]);else if(f){var A=f.push(e,p,u,k);gn(A)?(f.async=!0,A.then((function(e){c.handleTransmuxComplete(e)})).catch((function(e){c.transmuxerError(e,u,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(A))}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);gn(i)||r.async?(gn(i)||(i=Promise.resolve(i)),i.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data;if(null!=t&&t.event){var r=this.hls;if(this.hls)switch(t.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":x[t.data.logType]&&x[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}else x.warn("worker message received with no "+(t?"event name":"data"))},r.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),kn=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,i=this.media,n=this.stalled;if(null!==i){var a=i.currentTime,s=i.seeking,o=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,a===e)if(u||o)this.stalled=null;else if(i.paused&&!s||i.ended||0===i.playbackRate||!ur.getBuffered(i).length)this.nudgeRetry=0;else{var l=ur.bufferInfo(i,a,0),d=l.nextStart||0;if(s){var h=l.len>2,c=!d||t&&t.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(h||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var f;if(!(l.len>0||d))return;var v=Math.max(d,l.start||0)-a,p=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,g=(null==p||null==(f=p.details)?void 0:f.live)?2*p.details.targetduration:2,m=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=g||m))return void(i.paused||this._trySkipBufferHole(m))}var y=self.performance.now();if(null!==n){var _=y-n;if(s||!(_>=250)||(this._reportStall(l),this.media)){var b=ur.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(b,_)}}else this.stalled=y}else if(this.moved=!0,s||(this.nudgeRetry=0),null!==n){if(this.stallReported){var E=self.performance.now()-n;x.warn("playback not stuck anymore @"+a+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(x.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");x.warn(i.message),t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=ur.bufferInfo(i,n,0),s=n<a.start?a.start:a.nextStart;if(s){var o=a.len<=t.maxBufferHole,u=a.len>0&&a.len<1&&i.readyState<3,l=s-n;if(l>0&&(o||u)){if(l>t.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===n){var c=d.getAppendedFrag(0,at);c&&s<c.end&&(h=!0)}if(!h){var f=e||d.getAppendedFrag(n,at);if(f){for(var v=!1,p=f.end;p<s;){var g=d.getPartialFragment(p);if(!g){v=!0;break}p+=g.duration}if(v)return 0}}}var m=Math.max(s+.05,n+.1);if(x.warn("skipping hole, adjusting currentTime from "+n+" to "+m),this.moved=!0,this.stalled=null,i.currentTime=m,e&&!e.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+m);r.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:e})}return m}}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a=n+(i+1)*e.nudgeOffset,s=new Error("Nudging 'currentTime' from "+n+" to "+a);x.warn(s.message),r.currentTime=a,t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges");x.error(o.message),t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},e}(),wn=function(e){function t(t,r,i){var n;return(n=e.call(this,t,r,i,"[stream-controller]",at)||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(_.ERROR,this.onError,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(_.ERROR,this.onError,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=ri,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=ti},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case di:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=ri;break}if(this.hls.nextLoadLevel!==this.level){this.state=ri;break}break;case ai:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,u=this.level,l=null==o?void 0:o[u];this.resetStartWhenNotLoaded(l||null),this.state=ri}}this.state===ri&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=e.nextLoadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(_.BUFFER_EOS,u),void(this.state=ui)}e.loadLevel!==n&&-1===e.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=e.nextLoadLevel=n;var l=a.details;if(!l||this.state===di||l.live&&this.levelLastLoaded!==a)return this.level=n,void(this.state=di);var d=s.len,h=this.getMaxBufferLength(a.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&"initSegment"!==f.sn&&this.fragmentTracker.getState(f)!==Ir){var v,p=(null!=(v=this.backtrackFragment)?v:f).sn-l.startSN,g=l.fragments[p-1];g&&f.cc===g.cc&&(f=g,this.fragmentTracker.removeFragment(g))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,c)){if(!f.gap){var m=this.audioOnly&&!this.altAudio?I:F,y=(m===F?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,m,at)}f=this.getNextFragmentLoopLoading(f,l,s,at,h)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,a,c))}}}}},r.loadFragment=function(t,r,i){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Cr||n===Or?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,at)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var u=this.getBufferedFrag(t.currentTime+r);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ii:case ni:case ai:case si:case oi:this.state=ri}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new kn(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;g(t)&&this.log("Media seeked to "+t.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(_.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},r.onManifestParsed=function(e,t){var r,i,n=!1,a=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(n=n||-1!==t.indexOf("mp4a.40.2"),a=a||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!("function"==typeof(null==(i=ci())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===ri){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=di)}},r.onLevelLoaded=function(e,t){var r,i=this.levels,n=t.level,a=t.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],u=this.fragCurrent;!u||this.state!==ni&&this.state!==ai||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var l=0;if(a.live||null!=(r=o.details)&&r.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;l=this.alignPlaylists(a,o.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(o.details=a,this.levelLastLoaded=o,this.hls.trigger(_.LEVEL_UPDATED,{details:a,level:n}),this.state===di){if(this.waitForCdnTuneIn(a))return;this.state=ri}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,l),this.tick()}else this.warn("Levels were reset while loading level "+n)},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var u=s.videoCodec,l=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,h=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new Ln(this.hls,at,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,v=-1!==f,p=new zr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,v),g=this.initPTS[r.cc];c.push(n,d,h,u,r,i,o.totalduration,l,p,g)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(_.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},r.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var u=n[s];u&&(this.videoBuffer=u.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===at){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===oi&&(this.state=ri));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(e,t){var r;if(t.fatal)this.state=li;else switch(t.details){case E.FRAG_GAP:case E.FRAG_PARSING_ERROR:case E.FRAG_DECRYPT_ERROR:case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(at,t);break;case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:case E.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==di||(null==(r=t.context)?void 0:r.type)!==rt||(this.state=ri);break;case E.BUFFER_APPEND_ERROR:case E.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===E.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case E.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!ur.getBuffered(e).length){var r=this.state!==ri?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=ri,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==I||this.audioOnly&&!this.altAudio){var i=(r===F?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,at),this.tick()}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=ur.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},r._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(i){var n=r.hls;if(i&&!r.fragContextChanged(e)){t.fragmentError=0,r.state=ri,r.startFragRequested=!1,r.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(_.FRAG_LOADED,i),e.bitrateTest=!1}}))},r._handleTransmuxComplete=function(e){var t,r="main",i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,u=s.part,l=s.level,d=n.video,h=n.text,c=n.id3,f=n.initSegment,v=l.details,p=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=si,f){if(null!=f&&f.tracks){var m=o.initSegment||o;this._bufferInitSegment(l,f.tracks,m,a),i.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:f.tracks})}var y=f.initPTS,b=f.timescale;g(y)&&(this.initPTS[o.cc]={baseTime:y,timescale:b},i.trigger(_.INIT_PTS_FOUND,{frag:o,id:r,initPTS:y,timescale:b}))}if(d&&v&&"initSegment"!==o.sn){var E=v.fragments[o.sn-1-v.startSN],T=o.sn===v.startSN,S=!E||o.cc>E.cc;if(!1!==n.independent){var L=d.startPTS,k=d.endPTS,w=d.startDTS,x=d.endDTS;if(u)u.elementaryStreams[d.type]={startPTS:L,endPTS:k,startDTS:w,endDTS:x};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!S&&(this.couldBacktrack=!0),d.dropped&&d.independent){var A=this.getMainFwdBufferInfo(),R=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,D=d.firstKeyFramePTS?d.firstKeyFramePTS:L;if(!T&&R<D-this.config.maxBufferHole&&!S)return void this.backtrack(o);S&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,k,o.start,x,!0)}else T&&L>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,L,k,w,x),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,u,a,T||S)}else{if(!T&&!S)return void this.backtrack(o);o.gap=!0}}if(p){var C=p.startPTS,P=p.endPTS,O=p.startDTS,F=p.endDTS;u&&(u.elementaryStreams[I]={startPTS:C,endPTS:P,startDTS:O,endDTS:F}),o.setElementaryStreamInfo(I,C,P,O,F),this.bufferFragmentData(p,o,u,a)}if(v&&null!=c&&null!=(t=c.samples)&&t.length){var M={id:r,frag:o,details:v,samples:c.samples};i.trigger(_.FRAG_PARSING_METADATA,M)}if(v&&h){var B={id:r,frag:o,details:v,samples:h.samples};i.trigger(_.FRAG_PARSING_USERDATA,B)}}}else this.resetWhenMissingContext(a)},r._bufferInitSegment=function(e,t,r,i){var n=this;if(this.state===si){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a=t.audio,s=t.video,o=t.audiovideo;if(a){var u=e.audioCodec,l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),e.audioCodec&&e.audioCodec!==u&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+u+'"'),a.levelCodec=u,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]")}s&&(s.levelCodec=e.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(_.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(_.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tickImmediate()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,at)},r.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ri},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(ur.isBuffered(e,r)?t=this.getAppendedFrag(r):ur.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n||(this.fragPlaying=t,this.hls.trigger(_.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(_.LEVEL_SWITCHED,{level:n}))}}},s(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&g(t)&&g(r.programDateTime)){var i=r.programDateTime+1e3*(t-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(hi),xn=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new bn,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,w(t.debug||!1,"Hls instance");var r=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=xr(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var i=("level"===e?"playlist":e)+"LoadPolicy",a=void 0===t[i],s=[];n.forEach((function(n){var o=e+"Loading"+n,u=t[o];if(void 0!==u&&a){s.push(o);var l=r[i].default;switch(t[i]={default:l},n){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}})),s.length&&x.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(t[i]))})),i(i({},r),t)}(e.DefaultConfig,t);this.userConfig=t,r.progressive&&Ar(r);var n=r.abrController,a=r.bufferController,s=r.capLevelController,o=r.errorController,u=r.fpsController,l=new o(this),d=this.abrController=new n(this),h=this.bufferController=new a(this),c=this.capLevelController=new s(this),f=new u(this),v=new dt(this),p=new bt(this),g=r.contentSteeringController,m=g?new g(this):null,y=this.levelController=new Rr(this,m),b=new Fr(this),E=new Hr(this.config),T=this.streamController=new wn(this,b,E);c.setStreamController(T),f.setStreamController(T);var S=[v,y,T];m&&S.splice(1,0,m),this.networkControllers=S;var L=[d,h,c,f,p,b];this.audioTrackController=this.createController(r.audioTrackController,S);var k=r.audioStreamController;k&&S.push(new k(this,b,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,S);var A=r.subtitleStreamController;A&&S.push(new A(this,b,E)),this.createController(r.timelineController,L),E.emeController=this.emeController=this.createController(r.emeController,L),this.cmcdController=this.createController(r.cmcdController,L),this.latencyController=this.createController(Et,L),this.coreComponents=L,S.push(l);var R=l.onErrorOut;"function"==typeof R&&this.on(_.ERROR,R,l)}e.isMSESupported=function(){return fi()},e.isSupported=function(){return function(){if(!fi())return!1;var e=Ce();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(Fe(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(Fe(t,"audio"))})))}()},e.getMediaSource=function(){return Ce()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(x.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===_.ERROR;this.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){x.log("destroy"),this.trigger(_.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){x.log("attachMedia"),this._media=e,this.trigger(_.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){x.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=p.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,x.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),x.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){x.log("stopLoad"),this.started=!1,this.networkControllers.forEach((function(e){e.stopLoad()}))},t.resumeBuffering=function(){this.started&&this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.startLoad(-1)}))},t.pauseBuffering=function(){this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.stopLoad()}))},t.swapAudioCodec=function(){x.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){x.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null},s(e,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){x.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){x.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){x.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){x.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){x.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(x.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return Tt.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{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:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{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:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return _}},{key:"ErrorTypes",get:function(){return b}},{key:"ErrorDetails",get:function(){return E}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:wr},set:function(t){e.defaultConfig=t}}]),e}();return xn.defaultConfig=void 0,xn}()}(!1)},21:(e,t,r)=>{r.d(t,{c:()=>n.a});var i=r(539),n=r.n(i)}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};function n(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 a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(){s=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var c={};function f(){}function v(){}function p(){}var g={};l(g,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(x([])));y&&y!==t&&r.call(y,a)&&(g=y);var _=p.prototype=f.prototype=Object.create(g);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,a,s,o){var u=h(e[i],e,a);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===c)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=h(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),c;var n=h(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function x(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:A}}function A(){return{value:void 0,done:!0}}return v.prototype=p,i(_,"constructor",{value:p,configurable:!0}),i(p,"constructor",{value:v,configurable:!0}),v.displayName=l(p,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(E.prototype),l(E.prototype,o,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new E(d(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),l(_,u,"Generator"),l(_,a,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=x,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function o(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){o(a,i,n,s,u,"next",e)}function u(e){o(a,i,n,s,u,"throw",e)}s(void 0)}))}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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,g(i.key),i)}}function h(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}r.d(i,{N:()=>or,c:()=>ur.c});var m=r(228),y=r.n(m);function _(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 b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){A(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(){E=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof c?t:c,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function c(){}function f(){}function v(){}var p={};u(p,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(x([])));m&&m!==t&&r.call(m,a)&&(p=m);var y=v.prototype=c.prototype=Object.create(p);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=d(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var n=d(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function x(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:A}}function A(){return{value:void 0,done:!0}}return f.prototype=v,i(y,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:f,configurable:!0}),f.displayName=u(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},_(b.prototype),u(b.prototype,s,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new b(l(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(y),u(y,o,"Generator"),u(y,a,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=x,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function T(e){return(T="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})(e)}function S(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function L(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){S(a,i,n,s,o,"next",e)}function o(e){S(a,i,n,s,o,"throw",e)}s(void 0)}))}}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(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,U(i.key),i)}}function x(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function A(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&C(e,t)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function P(){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}}function O(e,t,r){return(O=P()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&C(n,r.prototype),n}).apply(null,arguments)}function I(e){var t="function"==typeof Map?new Map:void 0;return I=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;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,i)}function i(){return O(e,arguments,D(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),C(i,e)},I(e)}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e){var t=P();return function(){var r,i=D(e);if(t){var n=D(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return F(e)}(this,r)}}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=D(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},B.apply(this,arguments)}function N(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}function U(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var G={DEBUG:1,LOG:2,WARN:3,ERROR:4},V=["Boolean","Number","String","Undefined","Null","Date","Object"],j=function(){function e(t,r){k(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return x(e,[{key:"debug",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.DEBUG].concat(i)),e.disabled||(t=console).debug.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"log",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.LOG].concat(i)),e.disabled||(t=console).log.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"warn",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.WARN].concat(i)),e.disabled||(t=console).warn.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"error",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.ERROR].concat(i)),e.disabled||(t=console).error.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];var a=i.map((function(e){return z(e)}));t="[".concat(H(),"]")+this._prefix+JSON.stringify(a)}catch(e){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function H(){return(new Date).toLocaleString()}function K(e){if("object"!==T(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function z(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==T(e))return e;var n=Object.prototype.toString.call(e).slice(8,-1);if(!V.includes(n))return n;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?i[a]=K(e[a]):"object"===T(e[a])?i[a]=z(e[a],t,r+1):i[a]=e[a]);return i}}A(j,"disabled",!0);var W,q="core.ttfb",Y="core.metadataparsed",X="core.sei",Q="core.flvscriptdata",J="core.demuxedtrack",Z="core.streamexception",$="real_time_speed",ee="network",te="network_timeout",re="demux",ie="remux",ne="media",ae="other",se="FLV",oe="FMP4",ue="MSE_ADD_SB",le="MSE_APPEND_BUFFER",de="MSE_OTHER",he="MSE_FULL",ce="MSE_CHANGE_TYPE",fe=(A(W={},"manifest",{HLS:1100,DASH:1200}),A(W,ee,2100),A(W,te,2101),A(W,"network_forbidden",2103),A(W,"network_notfound",2104),A(W,"network_range_not_satisfiable",2116),A(W,re,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),A(W,ie,{FMP4:4100,MP4:4200}),A(W,ne,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),A(W,"drm",{LICENSE:7100,CUSTOM_LICENSE:7200}),A(W,ae,8e3),A(W,"runtime",{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),W),ve=function(){R(t,I(Error));var e=M(t);function t(r,i,n,a,s){var o;return k(this,t),(o=e.call(this,s||(null==n?void 0:n.message))).errorType=r===te?ee:r,o.originError=n,o.ext=a,o.errorCode=fe[r][i]||fe[r],o.errorMessage=o.message,o.errorCode||(o.errorType=ae,o.errorCode=fe[o.errorType]),o}return x(t,null,[{key:"create",value:function(e,r,i,n,a){return e instanceof t?e:(e instanceof Error&&(i=e,e=""),e||(e=ae),new t(e,r,i,n,a))}},{key:"network",value:function(e){var r;return new t(null!=e&&e.isTimeout?te:ee,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(r=e.response)||void 0===r?void 0:r.status})}}]),t}(),pe=function(){function e(){k(this,e)}return x(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(e){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],i=0,n=e.length;i<n;i++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(i)-o<=t){var u=e.end(i);u>o&&(s[1]=u)}else r.push([e.start(i),e.end(i)])}else r.push([e.start(i),e.end(i)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var n=0,a=0,s=0,o=0,u=0,l=0,d=0,h=e.buffers(t,i),c=0,f=h.length;c<f;c++){var v=h[c];if(r+i>=v[0]&&r<=v[1])n=v[0],a=v[1],s=c;else{if(r+i<v[0]){o=v[0],u=v[1];break}r+i>v[1]&&(l=v[0],d=v[1])}}return{start:n,end:a,index:s,buffers:h,nextStart:o,nextEnd:u,prevStart:l,prevEnd:d,currentTime:r,behind:r-n,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(h)}}},{key:"isBuffered",value:function(t,r){if(t){var i=e.get(t);if(null!=i&&i.length)for(var n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}return!1}}]),e}();function ge(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var ye="fetch",_e="arraybuffer",be="text",Ee=function(){R(t,I(Error));var e=M(t);function t(r,i,n,a){var s;return k(this,t),A(F(s=e.call(this,a)),"retryCount",0),A(F(s),"isTimeout",!1),A(F(s),"loaderType",ye),A(F(s),"startTime",0),A(F(s),"endTime",0),A(F(s),"options",{}),s.url=r,s.request=i,s.response=n,s}return x(t)}(),Te=Object.prototype.toString;function Se(e){if("[object Object]"!==Te.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Le(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function ke(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function we(e,t){if(e){if(!t)return e;var r,i=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===Te.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===T(e)}(t)&&(t=JSON.stringify(t)),"".concat(ke(e),"=").concat(ke(t))})).join("&")})).filter(Boolean).join("&");if(i){var n=e.indexOf("#");-1!==n&&(e=e.slice(0,n)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function xe(e,t,r,i,n,a,s,o,u,l,d){return n=null!=n?parseFloat(n):null,i=parseInt(i||"0",10),Number.isNaN(i)&&(i=0),{data:e,done:t,options:{range:u,vid:l,index:o,contentLength:i,age:n,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:d},response:r}}function Ae(e,t){return Math.round(8*e*1e3/t/1024)}var Re=2097152,De=function(){R(r,y());var e,t=M(r);function r(){var e;return k(this,r),A(F(e=t.call(this)),"_abortController",null),A(F(e),"_timeoutTimer",null),A(F(e),"_reader",null),A(F(e),"_response",null),A(F(e),"_aborted",!1),A(F(e),"_index",-1),A(F(e),"_range",null),A(F(e),"_receivedLength",0),A(F(e),"_running",!1),A(F(e),"_logger",null),A(F(e),"_vid",""),A(F(e),"_onProcessMinLen",0),A(F(e),"_onCancel",null),A(F(e),"_priOptions",null),e}return x(r,[{key:"load",value:function(e){var t,r=this,i=e.url,n=e.vid,a=e.timeout,s=e.responseType,o=e.onProgress,u=e.index,l=e.onTimeout,d=e.onCancel,h=e.range,c=e.transformResponse,f=e.request,v=e.params,p=e.logger,g=e.method,m=e.headers,y=e.body,_=e.mode,b=e.credentials,T=e.cache,S=e.redirect,k=e.referrer,w=e.referrerPolicy,x=e.onProcessMinLen,A=e.priOptions;this._logger=p,this._aborted=!1,this._onProcessMinLen=x,this._onCancel=d,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=h||[0,0],this._vid=n||i,this._priOptions=A||{};var R={method:g,headers:m,body:y,mode:_,credentials:b,cache:T,redirect:S,referrer:k,referrerPolicy:w,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},D=!1;clearTimeout(this._timeoutTimer),i=we(i,v);var C=Le(h);C&&(m=f?f.headers:R.headers=R.headers||(Headers?new Headers:{}),Headers&&m instanceof Headers?m.append("Range",C):m.Range=C),a&&(this._timeoutTimer=setTimeout((function(){if(D=!0,r.cancel(),l){var e=new Ee(i,R,null,"timeout");e.isTimeout=!0,l(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var P=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",h),new Promise((function(e,t){fetch(f||i,f?void 0:R).then(function(){var n=L(E().mark((function n(a){var l,d,f,v;return E().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){n.next=4;break}return n.abrupt("return");case 4:if(c&&(a=c(a,i)||a),a.ok){n.next=7;break}throw new Ee(i,R,a,"bad network response");case 7:if(l=Date.now(),s!==be){n.next=15;break}return n.next=11,a.text();case 11:d=n.sent,r._running=!1,n.next=37;break;case 15:if("json"!==s){n.next=22;break}return n.next=18,a.json();case 18:d=n.sent,r._running=!1,n.next=37;break;case 22:if(!o){n.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,o,P,l),n.abrupt("return");case 29:return n.next=31,a.arrayBuffer();case 31:d=n.sent,d=new Uint8Array(d),r._running=!1,f=Date.now()-P,v=Ae(d.byteLength,f),r.emit($,{speed:v,len:d.byteLength,time:f,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",h),e(xe(d,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),P,l,u,h,r._vid,r._priOptions));case 39:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){var n;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!D||((e=e instanceof Ee?e:new Ee(i,R,null,null===(n=e)||void 0===n?void 0:n.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=D,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(e=L(E().mark((function e(){return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return e.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,i){var n=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new Ee(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Re),this._writeIdx=0);var s,o,u,l=this._reader=e.body.getReader(),d=function(){var a=L(E().mark((function a(){var h,c,f,v,p,g,m,y;return E().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return o=Date.now(),a.prev=1,a.next=4,l.read();case 4:s=a.sent,u=Date.now(),a.next=13;break;case 8:return a.prev=8,a.t0=a.catch(1),u=Date.now(),n._aborted||(n._running=!1,a.t0.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n.reject(a.t0)),a.abrupt("return");case 13:if(c=(null===(h=n._range)||void 0===h?void 0:h.length)>0?n._range[0]:0,f=c+n._receivedLength,!n._aborted){a.next=19;break}return n._running=!1,t(void 0,!1,{range:[f,f],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),a.abrupt("return");case 19:v=s.value?s.value.byteLength:0,n._receivedLength+=v,n._logger.debug("【fetchLoader,onProgress call】,task,",n._range,", start,",f,", end,",c+n._receivedLength,", done,",s.done),n._onProcessMinLen>0?n._writeIdx+v>=n._onProcessMinLen||s.done?((p=new Uint8Array(n._writeIdx+v)).set(n._cache.slice(0,n._writeIdx),0),v>0&&p.set(s.value,n._writeIdx),n._writeIdx=0,n._logger.debug("【fetchLoader,onProgress enough】,done,",s.done,",len,",p.byteLength,", writeIdx,",n._writeIdx)):v>0&&n._writeIdx+v<Re?(n._cache.set(s.value,n._writeIdx),n._writeIdx+=v,n._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",n._writeIdx)):v>0&&(g=new Uint8Array(n._writeIdx+v+2048),n._logger.debug("【fetchLoader,onProgress extra start】,size,",n._writeIdx+v+2048,", datalen,",v,", writeIdx,",n._writeIdx),g.set(n._cache.slice(0,n._writeIdx),0),v>0&&g.set(s.value,n._writeIdx),n._writeIdx+=v,delete n._cache,n._cache=g,n._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",n._writeIdx)):p=s.value,(p&&p.byteLength>0||s.done)&&t(p,s.done,{range:[n._range[0]+n._receivedLength-(p?p.byteLength:0),n._range[0]+n._receivedLength],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),s.done?(m=Date.now()-r,y=Ae(n._receivedLength,m),n.emit($,{speed:y,len:n._receivedLength,time:m,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions}),n._running=!1,n._logger.debug("[fetchLoader onProgress end],task,",n._range,",done,",s.done),n.resolve(xe(s,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,i,n._index,n._range,n._vid,n._priOptions))):d();case 25:case"end":return a.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();d()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),r}(),Ce=function(){R(t,y());var e=M(t);function t(){var r;return k(this,t),A(F(r=e.call(this)),"_xhr",null),A(F(r),"_aborted",!1),A(F(r),"_timeoutTimer",null),A(F(r),"_range",null),A(F(r),"_receivedLength",0),A(F(r),"_url",null),A(F(r),"_onProgress",null),A(F(r),"_index",-1),A(F(r),"_headers",null),A(F(r),"_currentChunkSizeKB",384),A(F(r),"_timeout",null),A(F(r),"_xhr",null),A(F(r),"_withCredentials",null),A(F(r),"_startTime",-1),A(F(r),"_loadCompleteResolve",null),A(F(r),"_loadCompleteReject",null),A(F(r),"_runing",!1),A(F(r),"_logger",!1),A(F(r),"_vid",""),A(F(r),"_responseType",void 0),A(F(r),"_credentials",void 0),A(F(r),"_method",void 0),A(F(r),"_transformResponse",void 0),A(F(r),"_firstRtt",void 0),A(F(r),"_onCancel",null),A(F(r),"_priOptions",null),r}return x(t,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=we(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof Ee?e:new Ee(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===_e&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,i=this._range[1];t<this._range[1]-r&&(i=r+t),e=[r,i],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,i,n;t._running=!1;var a=new Ee(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.status)+",statusText,"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new Ee(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var i=this._headers||{},n=Le(e);n&&(i.Range=n),i&&Object.keys(i).forEach((function(e){r.setRequestHeader(e,i[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var i=new Ee(this._url,null,b(b({},e.target.response),{},{status:r}),"bad response,status:"+r);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var n,a=null,s=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===_e){var u,l=new Uint8Array(e.target.response);if(n=o+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=Ae(this._receivedLength,d);this.emit($,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[n,o+this._receivedLength],priOptions:this._priOptions})}a=l,s=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",n,"end ",o+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",s)}else s=!0,a=e.target.response;var c={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(c=this._transformResponse(c,this._url)||c),this._onProgress&&this._onProgress(a,s,{index:this._index,vid:this._vid,range:[n,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},c),s?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(xe(this._onProgress?null:a,s,c,c.headers["content-length"],c.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,B(D(t.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(i.s();!(t=i.n()).done;){var n=t.value.split(": ");r[n[0].toLowerCase()]=n.slice(1).join(": ")}}catch(e){i.e(e)}finally{i.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),t}();function Pe(){var e,t,r=new Promise((function(r,i){e=r,t=i}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function Oe(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var Ie=["retry","retryDelay","onRetryError","transformError"],Fe=function(){function e(t,r){k(this,e),this.promise=Pe(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new j("Loader")),this._loaderType=t,this._loader=t===ye&&"undefined"!=typeof fetch?new De:new Ce,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return x(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,i=t.retryDelay,n=t.onRetryError,a=t.transformError,s=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(t,Ie),o=function(){var t=L(E().mark((function t(){var u,l,d;return E().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(s);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,a&&(l=a(l)||l),n&&e._retryCount>0&&n(l,e._retryCount,{index:s.index,vid:s.vid,range:s.range,priOptions:s.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",s.range),e._retryTimer=setTimeout(o,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=L(E().mark((function e(){return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}(),Me=function(){R(r,y());var e,t=M(r);function r(e){var i;return k(this,r),A(F(i=t.call(this,e)),"type",ye),A(F(i),"_queue",[]),A(F(i),"_alive",[]),A(F(i),"_currentTask",null),A(F(i),"_finnalUrl",""),A(F(i),"_config",void 0),i._config=function(e){return b({loaderType:ye,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:be,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),"xhr"!==i._config.loaderType&&De.isSupported()||(i.type="xhr"),i.log=e.logger,i}return x(r,[{key:"isFetch",value:function(){return this.type===ye}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&Se(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&Se(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var i=new Fe(this.type,r);return i.loader.on($,(function(e){t.emit($,e)})),this._queue.push(i),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),i.promise}},{key:"cancel",value:(e=L(E().mark((function e(){var t;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,me();case 8:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return De.isSupported()}}]),r}(),Be=function(){function e(t){var r=this;k(this,e),A(this,"_seiSet",new Set),this.emitter=t,t.on(X,(function(e){e&&r._seiSet.add(e)}))}return x(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var i=e-.2,n=e+.2,a=[];this._seiSet.forEach((function(e){e.time>=i&&e.time<=n&&a.push(e)})),a.forEach((function(e){r._seiSet.delete(e),r.emitter.emit("core.seiintime",e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),Ne=function(){function e(t){k(this,e),A(this,"_chunkSpeed",0),A(this,"_chunkCache",[]),A(this,"_speeds",[]),A(this,"_totalSize",0),A(this,"_totalCost",0),this._opts=t||{}}return x(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,i;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var n=(null===(i=this._opts)||void 0===i?void 0:i.chunkCountForSpeed)||50;this._chunkCache.length>n&&(this._chunkCache=this._chunkCache.slice(-n))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),Ue=function(){function e(t){k(this,e),A(this,"encodeType",""),A(this,"audioCodec",""),A(this,"videoCodec",""),A(this,"domain",""),A(this,"fps",0),A(this,"bitrate",0),A(this,"width",0),A(this,"height",0),A(this,"samplerate",0),A(this,"channelCount",0),A(this,"gop",0),A(this,"_bitsAccumulateSize",0),A(this,"_bitsAccumulateDuration",0),A(this,"_startGopId",-1),this._timescale=t}return x(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,i=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;i&&i>0&&i<100&&(this.fps=i)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ge=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;k(this,e),A(this,"_core",null),A(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new Ue(r),this._bindEvents()}return x(e,[{key:"getStats",value:function(){var e,t,r,i,n,a,s,o,u,l,d,h=(null===(e=this._core)||void 0===e?void 0:e.media)||{},c=h.currentTime,f=void 0===c?0:c,v=h.decodeFps,p=void 0===v?0:v;return b(b({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(i=this._core)||void 0===i||null===(n=i.speedInfo)||void 0===n?void 0:n.call(i).avgSpeed)||0,totalReceivedByte:(null===(a=this._core)||void 0===a||null===(s=a.speedInfo)||void 0===s?void 0:s.call(a).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:f,bufferEnd:(null===(l=this._core)||void 0===l||null===(d=l.bufferInfo())||void 0===d?void 0:d.remaining)||0,decodeFps:p})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(J,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Q,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Y,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(q,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new Ue(this._timescale)}}]),e}(),Ve=function(){function e(){k(this,e),A(this,"_prevCurrentTime",0)}return x(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var n=e.currentTime,a=0;if(this._prevCurrentTime===n){var s=pe.info(pe.get(e),n);if(!s.buffers.length)return;r&&s.nextStart||s.nextStart&&s.nextStart-n<t?a=s.nextStart+.1:s.end&&s.end-n>i&&!e.seeking&&(a=n+.1)}this._prevCurrentTime=n,a&&n!==a&&(e.currentTime=a)}}}]),e}(),je="undefined"!=typeof window;function He(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return je?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(e){}}function Ke(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var ze="updateDuration",We=function(){function e(t,r){var i=this;k(this,e),A(this,"media",null),A(this,"mediaSource",null),A(this,"_openPromise",Pe()),A(this,"_queue",Object.create(null)),A(this,"_sourceBuffer",Object.create(null)),A(this,"_mseFullFlag",{}),A(this,"_st",0),A(this,"_opst",0),A(this,"_logger",null),A(this,"_config",null),A(this,"_url",null),A(this,"_onStartStreaming",(function(){i._logger.debug("startstreaming")})),A(this,"_onEndStreaming",(function(){i._logger.debug("endstreaming")})),A(this,"_onSBUpdateEnd",(function(e){var t=i._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==ze&&t.shift(),r){var n,a,s=Oe()-i._opst;i._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),function(e){try{return JSON.stringify(e)}catch(e){return""}}(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(n=i._sourceBuffer[e])||void 0===n?void 0:n.buffered)),s,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:s});var o=null===(a=r.context)||void 0===a?void 0:a.callback;o&&"function"==typeof o&&o(r.context),i._startQueue(e)}}})),A(this,"_onSBUpdateError",(function(e,t){var r=i._queue[e];if(r){var n=r[0];n&&(i._logger.error("UpdateError",e,n.opName,n.context),n.promise.reject(new ve(ne,le,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new j("MSE"),this._config.openLog&&j.enable()}var t,r,i;return x(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var i=e._queue[r];Array.isArray(i)&&(t||(t=i.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!Ke(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var i=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{i=Math.max(t.bufferEnd(e)||0,i)}catch(e){}})),e<i)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),ze,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var i=Oe()-e._st;e._logger.debug("sourceopen",i),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:i})})),this._openPromise=Pe()}return this._openPromise}},{key:"bindMedia",value:(i=L(E().mark((function e(t){var r,i,n,a,s=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=He(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new r,n=Ke(i),this._st=Oe(),a=function e(){var r=Oe()-s._st;s._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",a),n&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=n,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(r=L(E().mark((function e(){var t,r,i,n=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=n._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,r&&i)try{t.endOfStream()}catch(e){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(n._sourceBuffer[e])}catch(e){}})),Ke(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(e){}this.media=null}this.mediaSource=null,this._openPromise=Pe(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(e){throw new ve(ne,ue,e)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,i=this._sourceBuffer[e];return this.mediaSource&&i&&i.mimeType!==t?"function"!=typeof i.changeType?Promise.reject(new ve(ne,ce,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{i.changeType(t)}catch(e){throw new ve(ne,ce,e)}i.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var i=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var n;i.mediaSource&&!i.media.error&&(i._logger.debug("MSE APPEND START",r),i._opst=Oe(),null===(n=i._sourceBuffer[e])||void 0===n||n.appendBuffer(t))}),"appendBuffer",r):Promise.resolve()}},{key:"remove",value:function(e,t,r,i){var n=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(n.mediaSource&&!n.media.error){var a=n._sourceBuffer[e];t>=r||!a?n._onSBUpdateEnd(e):(n._opst=Oe(),n._logger.debug("MSE REMOVE START",e,t,r,i),a.remove(t,r))}}),"removeBuffer",i,a)}},{key:"clearBuffer",value:function(e,t){var r,i=this;return Object.keys(this._sourceBuffer).forEach((function(n){r=i.remove(n,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var i=t._sourceBuffer[r];e=t.remove(r,0,pe.end(pe.get(i)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var i=this._queue[e];if(t&&i)this._queue[e]=[];else if(i&&i[e]&&!(i.length<5)){var n=[];i.forEach((function(e){e.context&&e.context.isinit&&n.push(e)})),this._queue[e]=i.slice(0,2),n.length>0&&(r=this._queue[e]).push.apply(r,n)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return pe.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return pe.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return pe.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,i,n){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:Pe(),opName:r,context:i};return n?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=L(E().mark((function e(t,r,i){var n,a,s=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((n=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],n.forEach((function(e){var t=s._queue[e],n=Pe();a.push(n),t.push({exec:function(){n.resolve()},promise:n,opName:r,context:i}),1===t.length&&s._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{n.forEach((function(e){var t=s._queue[e],r=s._sourceBuffer[e];null==t||t.shift(),r&&r.updating||s._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,i){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(i){i&&i.message&&i.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,r.context&&"object"===T(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new ve(ne,he,i))):(this._logger.error(i),r.promise.reject(i.constructor===ve?i:new ve(ne,de,i)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var i=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),i._sourceBuffer[e].timestampOffset=t,i._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=He();if(!t)return!1;try{return t.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ye(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,nt(i.key),i)}}function Xe(e,t,r){return t&&Ye(e.prototype,t),r&&Ye(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Qe(e,t,r){return(t=nt(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$e(e,t)}function Ze(e){return(Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t){return($e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t=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}}();return function(){var r,i=Ze(e);if(t){var n=Ze(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function tt(e){return function(e){if(Array.isArray(e))return it(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rt(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rt(e,t){if(e){if("string"==typeof e)return it(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?it(e,t):void 0}}function it(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}function nt(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}A(We,"VIDEO","video"),A(We,"AUDIO","audio");var at=function(){function e(t){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return Xe(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(at,"disabled",!0);var st="video",ot="hevc",ut="aac",lt="g7110a",dt="g7110m",ht="opus",ct="LARGE_AV_SHIFT",ft="LARGE_VIDEO_GAP",vt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",pt="LARGE_AUDIO_GAP",gt="AUDIO_FILLED",mt="AUDIO_DROPPED",yt=function(){function e(){qe(this,e),Qe(this,"id",1),Qe(this,"type",st),Qe(this,"codecType","avc"),Qe(this,"pid",-1),Qe(this,"hvcC",void 0),Qe(this,"codec",""),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"sequenceNumber",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"baseDts",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"pps",[]),Qe(this,"sps",[]),Qe(this,"vps",[]),Qe(this,"fpsNum",0),Qe(this,"fpsDen",0),Qe(this,"sarRatio",[]),Qe(this,"width",0),Qe(this,"height",0),Qe(this,"nalUnitSize",4),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"isVideo",!0),Qe(this,"lastKeyFrameDts",0),Qe(this,"kid",null),Qe(this,"pssh",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),_t=function(){function e(){qe(this,e),Qe(this,"id",2),Qe(this,"type","audio"),Qe(this,"codecType",ut),Qe(this,"pid",-1),Qe(this,"codec",""),Qe(this,"sequenceNumber",0),Qe(this,"sampleDuration",0),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"baseDts",0),Qe(this,"sampleSize",16),Qe(this,"sampleRate",0),Qe(this,"channelCount",0),Qe(this,"objectType",0),Qe(this,"sampleRateIndex",0),Qe(this,"config",[]),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"kid",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!(!(this.sampleRate&&this.channelCount&&this.codec)||this.codecType!==ut&&this.codecType!==lt&&this.codecType!==dt&&this.codecType!==ht)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),bt=function(){function e(t,r,i){qe(this,e),Qe(this,"flag",{}),Qe(this,"keyframe",!1),Qe(this,"gopId",0),Qe(this,"duration",0),Qe(this,"size",0),Qe(this,"units",[]),Qe(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,i&&(this.units=i)}return Xe(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),Et=Xe((function e(t,r,i,n){qe(this,e),Qe(this,"duration",1024),Qe(this,"flag",{dependsOn:2,isNonSyncSample:0}),Qe(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=n,i&&(this.duration=i)})),Tt=Xe((function e(t,r){qe(this,e),Qe(this,"time",0),this.data=t,this.originPts=this.pts=r})),St=function(){Je(t,Tt);var e=et(t);function t(){return qe(this,t),e.apply(this,arguments)}return Xe(t)}(),Lt=function(){Je(t,Tt);var e=et(t);function t(){return qe(this,t),e.apply(this,arguments)}return Xe(t)}(),kt=function(){function e(){qe(this,e),Qe(this,"id",3),Qe(this,"type","metadata"),Qe(this,"timescale",0),Qe(this,"flvScriptSamples",[]),Qe(this,"seiSamples",[])}return Xe(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),wt="undefined"!=typeof window,xt=wt&&navigator.userAgent.toLocaleLowerCase(),At=wt&&/^((?!chrome|android).)*safari/.test(xt),Rt=wt&&xt.includes("firefox"),Dt=wt&&xt.includes("android"),Ct=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var i=t.length,n=0;n+2<i&&(255!==t[n]||240!=(246&t[n+1]));)n++;if(!(n>=i)){var a=n,s=[],o=(60&t[n+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var l,d,h=1+((192&t[n+2])>>>6),c=(1&t[n+2])<<2|(192&t[n+3])>>>6,f=e._getConfig(o,c,h),v=f.config,p=f.codec,g=0,m=e.getFrameDuration(u);n+7<i;)if(255===t[n]&&240==(246&t[n+1])){if(!(d=(3&t[n+3])<<11|t[n+4]<<3|(224&t[n+5])>>5)||i-n<d)break;l=2*(1&~t[n+1]),s.push({pts:r+g*m,data:t.subarray(n+7+l,n+d)}),g++,n+=d}else n++;return{skip:a,remaining:n>=i?void 0:t.subarray(n),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:h,channelCount:c,codec:p,config:v,originCodec:"mp4a.40.".concat(h)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,i=(7&t[0])<<1|t[1]>>>7,n=(120&t[1])>>>3,a=e.FREQ[i];if(a){var s=e._getConfig(i,n,r);return{samplingFrequencyIndex:i,sampleRate:a,objectType:r,channelCount:n,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}},{key:"_getConfig",value:function(e,t,r){var i,n,a=[];return Rt?e>=6?(i=5,n=e-3):(i=2,n=e):Dt?(i=2,n=e):(i=2===r||5===r?r:5,n=e,e>=6?n=e-3:1===t&&(i=2,n=e)),a[0]=i<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===i&&(a[1]|=(14&n)>>1,a[2]=(1&n)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(i)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();Qe(Ct,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Pt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),r="",i=0;i<8;i++)r+=String.fromCodePoint(e[i]);if("OpusHead"!==r)throw new Error("Invalid Opus MagicSignature");var n=e[9];console.log("Pre-skip",e[10],e[11]);var a=t.getUint32(12,!0),s=t.getInt16(16,!0);if(a)return{outputGain:s,sampleRate:a,channelCount:n,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}]),e}(),Ot=5e3,It=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=i,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return Xe(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var n=this.videoTrack,a=this.audioTrack;if(!r&&i||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!i&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,n),!i&&t&&(this._audioNextPts=this._videoNextDts=t),this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist())&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(n),this.metadataTrack.exist()){var s=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s}))}n.samples.length&&(n.baseMediaDecodeTime=n.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var i;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)i=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var n=e.samples[0],a=e.samples[r.length-1];i=Math.floor((a.dts-n.dts)/(r.length-1))}else i=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u,l=r.length,d=0,h=r[0],c=this._videoNextDts-h.dts;if(Math.abs(c)>200)Math.abs(h.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3&&(this._lastVideoExceptionChunkFirstDtsDot=h.dts,e.warnings.push({type:vt,nextDts:this._videoNextDts,firstSampleDts:h.dts,nextSampleDts:null===(u=r[1])||void 0===u?void 0:u.dts,sampleDuration:c})),this._videoTimestampBreak>=5?(this._videoNextDts=h.dts,this._videoTimestampBreak=0):(h.dts+=c,h.pts+=c,this.audioTrack.exist()||(this._videoTimestampBreak=1));for(var f=0;f<l;f++){var v=r[f].dts,p=r[f+1];((d=f<l-1?p.dts-v:s?s.dts-v:i)>1e3||d<0)&&(this._videoTimestampBreak++,Math.abs(v-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=v,e.warnings.push({type:ft,time:v/e.timescale,dts:v,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:d,refSampleDuration:i})),d=i),r[f].duration=d,this._videoNextDts+=d,this._lastVideoDuration=d}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,i=t.samples;if(!r.length&&!i.length)return!1;var n=1/0,a=1/0;r.length&&(e.baseDts=n=r[0].pts),i.length&&(t.baseDts=a=i[0].dts),this._baseDts=Math.min(n,a);var s=a-n;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:ct,videoBaseDts:a,audioBasePts:n,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){if(!e.sampleDuration)switch(e.codecType){case ut:e.sampleDuration=Ct.getFrameDuration(e.timescale,r);break;case ht:e.sampleDuration=Pt.getFrameDuration(e.samples,r);break;case lt:case dt:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var i=e.sampleDuration,n=e.codecType===ht?20:e.codecType===ut?1024:i*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],l=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,l=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&l>=3*i&&l<=1e3&&!At){var d=this._getSilentFrame(e)||t[0].data.subarray(),h=Math.floor(l/i);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Ot&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:gt,pts:u.pts,originPts:u.originPts,count:h,nextPts:o,refSampleDuration:i}));for(var c=0;c<h;c++){var f=new Et(Math.floor(this._audioNextPts+i)-Math.floor(this._audioNextPts),d,n);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=i,s++}s--}else if(l<=-3*i&&l>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Ot&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:mt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:i})),t.splice(s,1),s--;else{if(Math.abs(l)>1e3&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Ot&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:pt,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:l,refSampleDuration:i}))),e.codecType===ht){var v=t[t.length-1];v&&(v.duration=u.pts-v.pts)}else u.dts=u.pts=o,u.duration=n;this._audioNextPts+=i}}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,i=e.sampleRate,n=e.samples[0];if(n)return 2*n.data.byteLength/r/(t/8)/i*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===ut?Ct.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}();function Ft(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function Mt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Bt(e){for(var t,r="avc1.",i=0;i<3;i++)(t=e[i].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function Nt(e){if(!Array.isArray(e)){for(var t=[],r="",i=0;i<e.length;i++)i%2&&(r=e[i-1]+e[i],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}Math.pow(2,32);var Ut=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,i=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((i=2+ ++r)>=t)return[];for(var n=[];i<t;)switch(e[i]){case 0:if(0!==e[i-1]){i+=2;break}if(0!==e[i-2]){i++;break}r!==i-2&&n.push(e.subarray(r,i-2));do{i++}while(1!==e[i]&&i<t);i=(r=i+1)+2;break;case 1:if(0!==e[i-1]||0!==e[i-2]){i+=3;break}r!==i-2&&n.push(e.subarray(r,i-2)),i=(r=i+1)+2;break;default:i+=3}return r<t&&n.push(e.subarray(r)),n}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,i=e.length,n=[],a=0;a+t<i;)if(r=Mt(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>i)break;n.push(e.subarray(a,a+r)),a+=r}return n}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,i=t?2:1,n=0,a=0,s="";255===e[i];)n+=255,i++;for(n+=e[i++];255===e[i];)a+=255,i++;if(a+=e[i++],5===n&&r>i+16)for(var o=0;o<16;o++)s+=e[i].toString(16),i++;return{payload:e.subarray(i,i+a),type:n,size:a,uuid:s}}},{key:"removeEPB",value:function(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(!r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}}]),e}(),Gt=function(){function e(t){if(qe(this,e),Qe(this,"_bytesAvailable",void 0),Qe(this,"_bitsAvailable",0),Qe(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return Xe(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return 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;for(e=0;e<this._bitsAvailable;++e)if(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:"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:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Vt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,i,n=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],l=0;l<u;l++)if(i=t[o]<<8|t[o+1],o+=2,i){var d=t.subarray(o,o+i);o+=i,a.push(d),r||(r=e.parseSPS(Ut.removeEPB(d)))}var h,c=t[o];o++;for(var f=0;f<c;f++)h=t[o]<<8|t[o+1],o+=2,h&&(s.push(t.subarray(o,o+h)),o+=h);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:n}}}},{key:"parseSPS",value:function(e){var t=new Gt(e);t.readUByte();var r=t.readUByte(),i=t.readUByte(),n=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var l=t.readUEG();if(0===l)t.readUEG();else if(1===l){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var d=t.readUEG(),h=0;h<d;h++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var c=t.readUEG(),f=t.readUEG(),v=t.readBits(1);0===v&&t.skipBits(1),t.skipBits(1);var p,g,m,y,_,b=0,E=0,T=0,S=0;if(t.readBool()&&(b=t.readUEG(),E=t.readUEG(),T=t.readUEG(),S=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:p=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var L=t.readBits(32),k=t.readBits(32);g=t.readBool(),_=(m=k)/(y=2*L)}}return{codec:Bt(e.subarray(1,4)),profileIdc:r,profileCompatibility:i,levelIdc:n,chromaFormat:a,width:Math.ceil(16*(c+1)-2*(b+E)),height:(2-v)*(f+1)*16-(v?2:4)*(T+S),sarRatio:p,fpsNum:m,fpsDen:y,fps:_,fixedFrame:g}}}]),e}(),jt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var i,n,a,s,o,u=1+(3&t[21]),l=[],d=[],h=[],c=23,f=t[22],v=0;v<f;v++){a=63&t[c],s=t[c+1]<<8|t[c+2],c+=3;for(var p=0;p<s;p++)if(o=t[c]<<8|t[c+1],c+=2,o){switch(a){case 32:var g=t.subarray(c,c+o);i||(i=e.parseVPS(Ut.removeEPB(g),r)),h.push(g);break;case 33:var m=t.subarray(c,c+o);n||(n=e.parseSPS(Ut.removeEPB(m),r)),l.push(m);break;case 34:d.push(t.subarray(c,c+o))}c+=o}}return{hvcC:r,sps:n,spsArr:l,ppsArr:d,vpsArr:h,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var i=new Gt(t);i.readUByte(),i.readUByte(),i.readBits(12);var n=i.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,n+1),i.readBits(17),e._parseProfileTierLevel(i,n,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var i=new Gt(t);i.readUByte(),i.readUByte(),i.readBits(4);var n=i.readBits(3);r.numTemporalLayers=Math.max(n+1,r.numTemporalLayers||0),r.temporalIdNested=i.readBits(1),e._parseProfileTierLevel(i,n,r),i.readUEG();var a=r.chromaFormatIdc=i.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=i.readBits(1));var u,l,d,h,c=i.readUEG(),f=i.readUEG(),v=i.readBits(1);return 1===v&&(u=i.readUEG(),l=i.readUEG(),d=i.readUEG(),h=i.readUEG()),r.bitDepthLumaMinus8=i.readUEG(),r.bitDepthChromaMinus8=i.readUEG(),1===v&&(c-=(1!==a&&2!==a||0!==o?1:2)*(l+u),f-=(1===a&&0===o?2:1)*(h+d)),{codec:"hev1.1.6.L93.B0",width:c,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var i=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),i),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var n=e.readBits(8);i<r.generalTierFlag?r.generalLevelIdc=n:r.generalLevelIdc=Math.max(n,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==s[u]&&e.readBits(8)}}]),e}(),Ht=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"decode",value:function(t){for(var r=[],i=t,n=0,a=t.length;n<a;)if(i[n]<128)r.push(String.fromCharCode(i[n])),++n;else{if(i[n]<192);else if(i[n]<224){if(e._checkContinuation(i,n,1)){var s=(31&i[n])<<6|63&i[n+1];if(s>=128){r.push(String.fromCharCode(65535&s)),n+=2;continue}}}else if(i[n]<240){if(e._checkContinuation(i,n,2)){var o=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),n+=3;continue}}}else if(i[n]<248&&e._checkContinuation(i,n,3)){var u=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),n+=4;continue}}r.push(String.fromCharCode(65533)),++n}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var i=e;if(t+r<i.length){for(;r--;)if(128!=(192&i[++t]))return!1;return!0}return!1}}]),e}(),Kt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},i=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),n=e._parseValue(new DataView(t.buffer,t.byteOffset+i.size,t.byteLength-i.size));return r[i.data]=n.data,r}}},{key:"_parseValue",value:function(t){var r,i=t.byteLength,n=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),n+=8;break;case 1:r=!!t.getUint8(1),n+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n));r=s.data,n+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(i-4))&&(o=3);n<i-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-o)),l=u.size,d=u.data;if(u.isEnd)break;r[d.name]=d.value,n+=l}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 8:r={},n+=4;var h=0;for(9==(16777215&t.getUint32(i-4))&&(h=3);n<i-8;){var c=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-h)),f=c.size,v=c.data;if(c.isEnd)break;r[v.name]=v.value,n+=f}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 9:r=void 0,n=1,a=!0;break;case 10:r=[];var p=t.getUint32(1);n+=4;for(var g=0;g<p;g++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n)),y=m.data,_=m.size;r.push(y),n+=_}break;case 11:var b=t.getFloat64(n)+6e4*t.getInt16(n+8);r=new Date(b),n+=10;break;case 12:var E=t.getUint32(1);n+=4,r="",E>0&&(r=Ht.decode(new Uint8Array(t.buffer,t.byteOffset+n,E))),n+=E;break;default:n=i}return{data:r,size:n,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Ht.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),i=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:i.data},size:r.size+i.size,isEnd:i.isEnd}}}}]),e}(),zt=new at("FlvDemuxer"),Wt=function(){function e(t,r,i){qe(this,e),Qe(this,"_headerParsed",!1),Qe(this,"_remainingData",null),Qe(this,"_gopId",0),Qe(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new yt,this.audioTrack=r||new _t,this.metadataTrack=i||new kt,this._fixer=new It(this.videoTrack,this.audioTrack,this.metadataTrack)}return Xe(e,[{key:"demux",value:function(t){var r,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3?arguments[3]:void 0,s=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!i&&n||(this._remainingData=null),i&&(this._headerParsed=!1),i?(o.reset(),s.reset(),u.reset()):(o.samples=[],s.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],s.warnings=[],this._remainingData&&(t=Ft(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:s,metadataTrack:u};var l=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");s.present=(4&t[4])>>>2!=0,o.present=!!(1&t[4]),this._headerParsed=!0,l=Mt(t,5)+4}for(var d,h,c,f,v,p=t.length;l+15<p&&(d=t[l],!(l+15+(h=t[l+1]<<16|t[l+2]<<8|t[l+3])>p));)c=(t[l+7]<<24>>>0)+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6],l+=11,f=t.subarray(l,l+h),8===d?this._parseAudio(f,c):9===d?(a&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,c)):18===d?this._parseScript(f,c):zt.warn("Invalid tag type: ".concat(d)),(v=Mt(t,l+=h))!==11+h&&zt.warn("Invalid PrevTagSize ".concat(v," (").concat(11+h,")")),l+=4;l<p&&(this._remainingData=t.subarray(l)),s.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,s.timescale=s.codecType===ht?1e3:s.sampleRate||0,!s.exist()&&s.hasSample()&&s.reset(),!o.exist()&&o.hasSample()&&o.reset();var g=u.flvScriptSamples[u.flvScriptSamples.length-1],m=null==g||null===(r=g.data)||void 0===r?void 0:r.onMetaData;return m&&(null!=o&&o.exist()&&(m.hasOwnProperty("duration")&&(o.duration=1e3*m.duration),m.hasOwnProperty("width")&&m.hasOwnProperty("height")&&(o.width=m.width,o.height=m.height)),null!=s&&s.exist()&&m.hasOwnProperty("duration")&&(s.duration=1e3*m.duration)),{videoTrack:o,audioTrack:s,metadataTrack:u}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,i,n){return this.demux(e,t,r,n),this.fix(i,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var i=(240&t[0])>>>4,n=this.audioTrack;if(10!==i&&7!==i&&8!==i&&13!==i)return zt.warn("Unsupported sound format: ".concat(i)),void n.reset();if(10!==i&&13!==i){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];n.sampleRate=e.AUDIO_RATE[a],n.sampleSize=s?16:8,n.channelCount=o+1}switch(i){case 7:case 8:this._parseG711(t,r,i);break;case 10:this._parseAac(t,r);break;case 13:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,i=e[1];switch(r.codecType=ht,i){case 0:var n=Pt.parseHeaderPackets(e.subarray(2));n?(r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.config=n.config,r.sampleDuration=Pt.getFrameDuration([],r.timescale)):(r.reset(),zt.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var a=new Et(t,e.subarray(2),r.sampleDuration);r.samples.push(a);break;default:zt.warn("Unknown OpusPacketType: ".concat(i))}}},{key:"_parseG711",value:function(e,t,r){var i=this.audioTrack;i.codecType=7===r?lt:dt,i.sampleRate=8e3,i.codec=i.codecType,i.samples.push(new Et(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=ut,0===e[1]){var i=Ct.parseAudioSpecificConfig(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.objectType=i.objectType,r.sampleRateIndex=i.samplingFrequencyIndex):(r.reset(),zt.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Et(t,e.subarray(2)))}else zt.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var i=(240&e[0])>>>4,n=15&e[0],a=this.videoTrack;if(7!==n&&12!==n)return a.reset(),void zt.warn("Unsupported codecId: ".concat(n));var s=12===n;a.codecType=s?ot:"avc";var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var l=e.subarray(5),d=s?jt.parseHEVCDecoderConfigurationRecord(l):Vt.parseAVCDecoderConfigurationRecord(l);if(d){var h=d.hvcC,c=d.sps,f=d.ppsArr,v=d.spsArr,p=d.vpsArr,g=d.nalUnitSize;h&&(a.hvcC=a.hvcC||h),c&&(a.codec=c.codec,a.width=c.width,a.height=c.height,a.sarRatio=c.sarRatio,a.fpsNum=c.fpsNum,a.fpsDen=c.fpsDen),v.length&&(a.sps=v),f.length&&(a.pps=f),p&&p.length&&(a.vps=p),g&&(a.nalUnitSize=g)}else zt.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Ut.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var y=new bt(t+u,t,m);if(this.seamlessLoadingSwitching&&t<a.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===i&&(y.setToKeyframe(),a.lastKeyFrameDts=t),a.samples.push(y),m.forEach((function(e){var i=s?e[0]>>>1&63:31&e[0];switch(i){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==i||s&&5===i)break;y.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==i||s&&6===i)break;r.metadataTrack.seiSamples.push(new Lt(Ut.parseSEI(Ut.removeEPB(e),s),t+u))}})),y.keyframe&&this._gopId++,y.gopId=this._gopId}else zt.warn("Cannot parse NALUs",e)}else 2===o||zt.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new St(Kt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Mt(e,5)>=9}}]),e}();Qe(Wt,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var qt=function(){function e(){qe(this,e),this.buffer=new Uint8Array(0)}return Xe(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach((function(t){t?e.buffer=function(e){for(var t=0,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];i.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return i.forEach((function(e){a.set(e,s),s+=e.length})),a}(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),Yt=Math.pow(2,32)-1,Xt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"box",value: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];var n=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(n);a[0]=n>>24&255,a[1]=n>>16&255,a[2]=n>>8&255,a[3]=255&n,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===st&&e.codecType===ot}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Ft(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Nt(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(tt(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(tt(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,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,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===ht?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,i=t.enca.sampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>8&255,255&i,0,0]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,n,a,s)}},{key:"encv",value:function(t){var r,i,n=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],l=t.sarRatio[1],d=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,s>>8&255,255&s,o>>8&255,255&o,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]),h=new Uint8Array((r=(i=[1,n[1],n[2],n[3],255,225,n.length>>>8&255,255&n.length]).concat.apply(i,tt(n)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,tt(a))),c=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),v=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,l>>24,l>>16&255,l>>8&255,255&l]);return e.box(e.types.encv,d,e.box(e.types.avcC,h),e.box(e.types.btrt,c),f,e.box(e.types.pasp,v))}},{key:"schi",value:function(t){var r=new Uint8Array([]),i=e.tenc(t);return e.box(e.types.schi,r,i)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Nt(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),i=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),n=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,i),e.box(e.types.schm,n),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===ot,i=r?e.types.hvc1:e.types.avc1,n=r?e.hvcC(t):e.avcC(t),a=[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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),n];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[i].concat(a))}},{key:"avcC",value:function(t){var r,i,n,a=[],s=[];return t.sps.forEach((function(e){n=e.byteLength,a.push(n>>>8&255),a.push(255&n),a.push.apply(a,tt(e))})),t.pps.forEach((function(e){n=e.byteLength,s.push(n>>>8&255),s.push(255&n),s.push.apply(s,tt(e))})),e.box(e.types.avcC,new Uint8Array((r=(i=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(i,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var i,n=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,l=(n.length&&1)+(a.length&&1)+(s.length&&1);i=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,l];var d=function(e){var t;i.push(e.length>>8,e.length),(t=i).push.apply(t,tt(e))};n.length&&(i.push(160,0,n.length),n.forEach(d)),a.length&&(i.push(161,0,a.length),a.forEach(d)),s.length&&(i.push(162,0,s.length),s.forEach(d))}else i=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(i))}},{key:"pasp",value:function(t){var r,i,n=(i=2,function(e){if(Array.isArray(e))return e}(r=t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);u=!0);}catch(e){l=!0,n=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(r,i)||rt(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=n[0],s=n[1];return e.box(e.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]))}},{key:"mp4a",value:function(t){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,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=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,t.sampleRate>>8&255,255&t.sampleRate,0,0]),i=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,i)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(tt(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(tt(t.map((function(t){return e.traf(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:"traf",value:function(t){var r=e.tfhd(t.id),i=e.tfdt(t,t.baseMediaDecodeTime),n=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){n+=8,e.subsamples&&e.subsamples.length&&(n+=2,n+=6*e.subsamples.length)})),t.videoSencLength=n,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,i,a,s,o,u)}if(t.isAudioEncryption){var l=e.sbgp(),d=e.saiz(t),h=e.saio(t),c=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,i,l,d,h,c,f)}var v=e.sbgp(),p=e.trun1(t);return e.box(e.types.traf,r,i,v,p)}if(t.isVideo){var g=e.trun1(t);return e.box(e.types.traf,r,i,g)}var m=e.sbgp(),y=e.saiz(t),_=e.saio(t),b=e.senc(t),E=e.trun1(t);return e.box(e.types.traf,r,i,m,y,_,b,E)}var T=e.sdtp(t);return e.box(e.types.traf,r,i,T,e.trun(t.samples,T.byteLength+76))}},{key:"sdtp",value:function(t){var r=new qt;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new qt,i=qt.writeUint32(t.samples.length),n=null;if(t.isVideo){var a=t.videoSencLength;n=qt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(n=qt.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),n=qt.writeUint32(s)}return t.samples.forEach((function(e){r.write(qt.writeUint32(e.duration)),r.write(qt.writeUint32(e.size)),r.write(qt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(qt.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),i,n,r.buffer)}},{key:"senc",value:function(t){var r=new qt,i=t.samples.length,n=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||n*i,r.write(qt.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(qt.writeUint32(i)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(qt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(qt.writeUint16(e.BytesOfClearData)),r.write(qt.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var i=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,i)}},{key:"saiz",value:function(t){var r=t.samples.length,i=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,i)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var i=Math.floor(r/(Yt+1)),n=Math.floor(r%(Yt+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var i=t.length,n=12+16*i;r+=8+n;var a=new Uint8Array(n);a.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);for(var s=0;s<i;s++){var o=t[s],u=o.duration,l=o.size,d=o.flag,h=void 0===d?{}:d,c=o.cts,f=void 0===c?0:c;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|(null===h.dependsOn||void 0===h.dependsOn?1:h.dependsOn),h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|(null===h.isNonSyncSample||void 0===h.isNonSyncSample?1:h.isNonSyncSample),61440&h.degradationPriority,15&h.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(tt(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,i=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&i.push(e.stss(r.stss)),r.ctts.length&&i.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(i))}},{key:"stts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.stts,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsc",value:function(t){var r=t.length,i=new Uint8Array(12*r),n=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;i.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],n),n+=12})),e.box(e.types.stsc,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsz",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stsz,Ft(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stco",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stco,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stss",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stss,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"ctts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.ctts,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,i=t.samples[0].duration,n=i*t.samples.length,a=t.samples[0].sampleOffset*i,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,l=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){l+=8,e.subsamples&&e.subsamples.length&&(l+=2,l+=6*e.subsamples.length)})),t.videoSencLength=l,o=s+141+16*t.samples.length+l,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var d=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,n>>24&255,n>>16&255,n>>8&255,255&n,144,0,0,0]);return e.box(e.types.sidx,d)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();Qe(Xt,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),Qe(Xt,"HDLR_TYPES",{video: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]),audio: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])}),Qe(Xt,"FTYPAVC1",Xt.box(Xt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),Qe(Xt,"FTYPHEV1",Xt.box(Xt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),Qe(Xt,"DINF",Xt.box(Xt.types.dinf,Xt.box(Xt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),Qe(Xt,"VMHD",Xt.box(Xt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),Qe(Xt,"SMHD",Xt.box(Xt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),Qe(Xt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),Qe(Xt,"STTS",Xt.box(Xt.types.stts,Xt.StblTable)),Qe(Xt,"STSC",Xt.box(Xt.types.stsc,Xt.StblTable)),Qe(Xt,"STSZ",Xt.box(Xt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),Qe(Xt,"STCO",Xt.box(Xt.types.stco,Xt.StblTable));var Qt=function(){function e(t,r){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return Xe(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).debug.apply(t,[this._prefix].concat(i))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).log.apply(t,[this._prefix].concat(i))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).error.apply(t,[this._prefix].concat(i))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(Qt,"disabled",!0);var Jt=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r;var n=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=n&&Number(n[1])<50,this.log=new Qt("FMP4Remuxer",!i||!i.openLog||!i.openLog)}return Xe(e,[{key:"remux",value:function(){var e,t,r,i,n,a=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,l=o.exist(),d=u.exist(),h=[];return a&&(s&&s.initMerge?(l&&h.push(this.videoTrack),d&&h.push(this.audioTrack),r=Xt.initSegment(h)):(l&&(e=Xt.initSegment([this.videoTrack])),d&&(t=Xt.initSegment([this.audioTrack])))),l&&o.hasSample()&&(i=this._remuxVideo()),d&&u.hasSample()&&(n=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:i,audioSegment:n}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),i=0;r?t.forEach((function(e){i+=e.data.byteLength})):t.forEach((function(e){i+=e.units.reduce((function(e,t){return e+t.byteLength}),0),i+=4*e.units.length}));var n=new Uint8Array(i);if(r)for(var a,s=0,o=t.length,u=0;s<o;s++)a=t[s],n.set(a.data,u),a.size=a.data.byteLength,u+=a.size;else for(var l,d=new DataView(n.buffer),h=function(e,r){r=t[c];var i=0;r.units.forEach((function(t){d.setUint32(e,t.byteLength),e+=4,n.set(t,e),e+=t.byteLength,i+=4+t.byteLength})),r.size=i,v=e,l=r},c=0,f=t.length,v=0;c<f;c++)h(v,l);var p=Xt.mdat(n);return Ft(Xt.moof([e]),p)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=Xt.mdat(t);return Ft(Xt.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Zt=function(){function e(){l(this,e),c(this,"_ttfb",0),c(this,"_demuxStart",0),c(this,"_demuxEnd",0),c(this,"_demuxCost",0),c(this,"_remuxStart",0),c(this,"_remuxEnd",0),c(this,"_remuxCost",0),c(this,"_appendStart",0),c(this,"_appendEnd",0),c(this,"_appendCost",0)}return h(e,[{key:"set",value:function(e,t){this["_".concat(e)]=t}},{key:"start",value:function(e){this["_".concat(e,"Start")]=Date.now()}},{key:"end",value:function(e){this["_".concat(e,"End")]=Date.now(),this["_".concat(e,"Cost")]=this["_".concat(e,"Cost")]+(this["_".concat(e,"End")]-this["_".concat(e,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),e}(),$t="demux",er="remux",tr="append",rr=new j("BufferService"),ir=function(){function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this,e),c(this,"flv",null),c(this,"_demuxer",new Wt),c(this,"_remuxer",null),c(this,"_mse",null),c(this,"_softVideo",null),c(this,"_sourceCreated",!1),c(this,"_needInitSegment",!0),c(this,"_discontinuity",!0),c(this,"_contiguous",!1),c(this,"_initSegmentId",""),c(this,"_cachedBuffer",null),c(this,"_demuxStartTime",0),c(this,"_opts",null),this.flv=t,this._opts=i,r?this._softVideo=r:(this._remuxer=new Jt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new We(null,{preferMMS:"boolean"==typeof i.preferMMS?i.preferMMS:!!i.perferMMS}),this._mse.bindMedia(t.media))}var t,r,i,n,o,d;return h(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:We.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:(d=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:(o=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit("core.buffereos");case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"updateDuration",value:(n=u(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return rr.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:(i=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"appendBuffer",value:(r=u(s().mark((function e(t){var r,i,n,a,o,u,l,d,h,c,f,v,p,g,m,y,_,b=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!1,this._cachedBuffer&&(t=ge(this._cachedBuffer,t),this._cachedBuffer=null),i=this._demuxer,t&&t.length&&i){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,this.flv._transferCost.start($t),i.demuxAndFix(t,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end($t),e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(5),new ve(re,se,e.t0);case 15:if(n=i.videoTrack,a=i.audioTrack,o=i.metadataTrack,!this.seamlessLoadingSwitch){e.next=25;break}if(!((u=n.samples.findIndex((function(e){return e.originDts===n.lastKeyFrameDts})))>=0)){e.next=25;break}return n.samples.splice(u),e.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,t=null,r=!0;case 25:if(l=n.exist(),d=a.exist(),this._opts.onlyAudio&&(l=!1,n.present=!1),this._opts.onlyVideo&&(d=!1,a.present=!1),!(!l&&n.present||!d&&a.present)){e.next=42;break}if(h=0,(c=l?n:d?a:void 0)&&c.samples.length&&(h=(c.samples[c.samples.length-1].originPts-c.samples[0].originPts)/c.timescale*1e3),!(h>this._opts.analyzeDuration)){e.next=40;break}rr.warn("analyze duration exceeded, ".concat(h,"ms"),c),n.present=l,a.present=d,this.flv.emit("core.analyzedurationexceeded",{duration:h}),e.next=42;break;case 40:return this._cachedBuffer=t,e.abrupt("return");case 42:if(f=n.type,v=a.type,this._fireEvents(n,a,o),r||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),p=this._mse,g=function(){var e,t;null!==(e=b.flv)&&void 0!==e&&e.emit&&(null===(t=b.flv)||void 0===t||t.emit("core.appendbuffer",{}))},this.flv.emit(J,{videoTrack:n}),(m="".concat(n.codec,"/").concat(n.width,"/").concat(n.height,"/").concat(a.codec,"/").concat(a.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=m,this._emitMetaParsedEvent(n,a)),!p){e.next=81;break}if(this._sourceCreated){e.next=59;break}return e.next=55,p.open();case 55:l&&(rr.log("codec: video/mp4;codecs=".concat(n.codec)),p.createSource(f,"video/mp4;codecs=".concat(n.codec))),d&&(rr.log("codec: audio/mp4;codecs=".concat(a.codec)),p.createSource(v,"audio/mp4;codecs=".concat(a.codec))),this._sourceCreated=!0,this.flv.emit("core.sourcebuffercreated");case 59:e.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(n.duration=this._opts.durationForMSELowLatencyOff*n.timescale,a.duration=this._opts.durationForMSELowLatencyOff*d.timescale),this.flv._transferCost.start(er),y=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(er),e.next=69;break;case 66:throw e.prev=66,e.t1=e.catch(59),new ve(ie,oe,e.t1);case 69:if(!this._needInitSegment||y.videoInitSegment||y.audioInitSegment){e.next=71;break}return e.abrupt("return");case 71:return this._needInitSegment=!1,_=[],y.videoInitSegment&&_.push(p.append(f,y.videoInitSegment)),y.audioInitSegment&&_.push(p.append(v,y.audioInitSegment)),y.videoSegment&&_.push(p.append(f,y.videoSegment)),y.audioSegment&&_.push(p.append(v,y.audioSegment)),this.flv._transferCost.start(tr),e.abrupt("return",Promise.all(_).then(g).then((function(){b.flv._transferCost.end(tr),g()})));case 81:this._softVideo&&(this._softVideo.appendBuffer(n,a),g());case 82:case"end":return e.stop()}}),e,this,[[5,12],[59,66]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=u(s().mark((function e(t){var r,i,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(i=r.currentTime,!((n=i-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(pe.start(pe.get(r))+1>=n)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,n).then((function(){return a.flv.emit("core.removebuffer",{removeEnd:n})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(Y,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(Y,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),rr.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i=this;rr.debug("videoTrack samples count: ".concat(e.samples.length,", audioTrack samples count: ").concat(t.samples.length)),r.flvScriptSamples.forEach((function(e){i.flv.emit(Q,e),rr.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&i.flv.emit("core.keyframe",{pts:e.originPts})})),e.warnings.forEach((function(e){var t;switch(e.type){case ct:t="LARGE_AV_FIRST_FRAME_GAP_DETECT";break;case ft:t="LARGE_VIDEO_DTS_GAP_DETECT";break;case vt:t="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),rr.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case pt:t="LARGE_AUDIO_DTS_GAP_DETECT";break;case gt:t="AUDIO_GAP_DETECT";break;case mt:t="AUDIO_OVERLAP_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),rr.warn("audio exception",e)})),r.seiSamples.forEach((function(e){i.flv.emit(X,a(a({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function nr(e,t){var r=0,i=e.length-1,n=0,a=0,s=i;for(t<e[0]&&(r=0,a=s+1);a<=s;){if((n=a+Math.floor((s-a)/2))===i||t>=e[n]&&t<e[n+1]){r=n;break}e[n]<t?a=n+1:s=n-1}return r}var ar=new j("flv"),sr=.1,or=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(b,y());var e,t,r,i,n,o,d,g,m,_=(g=b,m=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}}(),function(){var e,t=f(g);if(m){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}(this,e)});function b(e){var t,r;return l(this,b),c(p(t=_.call(this)),"media",null),c(p(t),"_loading",!1),c(p(t),"_opts",null),c(p(t),"_bufferService",null),c(p(t),"_gapService",null),c(p(t),"_stats",null),c(p(t),"_mediaLoader",null),c(p(t),"_maxChunkWaitTimer",null),c(p(t),"_tickTimer",null),c(p(t),"_tickInterval",500),c(p(t),"_urlSwitching",!1),c(p(t),"_seamlessSwitching",!1),c(p(t),"_disconnectRetryCount",0),c(p(t),"_preLoadEndPoint",0),c(p(t),"_keyframes",null),c(p(t),"_acceptRanges",!0),c(p(t),"_onProgress",function(){var e=u(s().mark((function e(r,i,n,a){var o,u,l,d,h,c,f,v,p,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.startTime,u=n.endTime,l=n.st,d=n.firstByteTime,t._loading=!i,t._firstProgressEmit){e.next=13;break}if(t.media){e.next=6;break}return null===(h=t._mediaLoader)||void 0===h||h.cancel(),e.abrupt("return");case 6:c=a.headers,f=l?d-l:u-o,t.emit(q,{url:t._opts.url,responseUrl:a.url,elapsed:f}),t.emit("core.loadresponseheaders",{headers:c}),t._transferCost.set("ttfb",f),t._acceptRanges=!(null==c||!c.get("Accept-Ranges"))||!(null==c||!c.get("Content-Range")),t._firstProgressEmit=!0;case 13:if(t._bufferService){e.next=15;break}return e.abrupt("return");case 15:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=17,e.next=20,t._bufferService.appendBuffer(r);case 20:null===(v=t._bufferService)||void 0===v||v.evictBuffer(t._opts.bufferBehind),e.next=33;break;case 23:if(e.prev=23,e.t0=e.catch(17),t.isLive||!t._bufferService.isFull()){e.next=32;break}return e.next=28,t._mediaLoader.cancel();case 28:return t._loading=!1,p=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(p)/2,e.abrupt("return");case 32:return e.abrupt("return",t._emitError(ve.create(e.t0)));case 33:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit("core.switchurlsuccess",{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!i||t.media.seeking){e.next=40;break}return t.emit("core.loadcomplete"),ar.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),e.abrupt("return");case 40:if(t.isLive){e.next=42;break}return e.abrupt("return");case 42:(g=t._opts.maxReaderInterval)&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){if(t._disconnectRetryCount)return t._disconnectRetryCount--,void t.load();ar.debug("onMaxChunkWait",g),t._end()}),g));case 44:case"end":return e.stop()}}),e,null,[[17,23]])})));return function(t,r,i,n){return e.apply(this,arguments)}}()),c(p(t),"_onRetryError",(function(e,r){ar.debug("load retry",e,r),t.emit("core.loadretry",{error:ve.network(e),retryTime:r})})),c(p(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),ar.debug("end stream")})),c(p(t),"_resetDisconnectCount",(function(){t._disconnectRetryCount=t._opts.disconnectRetryCount})),c(p(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=p(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=pe.end(pe.get(e));if(!(r<sr)&&e.readyState){var i=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)&&e.currentTime)t._gapService&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService&&i.enableStartGapJump)return void((t._opts.mseLowLatency||!1===t._opts.mseLowLatency&&t.bufferInfo(.3).nextStart)&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3));i.isLive&&4===e.readyState&&r-e.currentTime>i.disconnectTime&&t.disconnect()}}}})),c(p(t),"_onPlay",(function(){var e,r,i=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);if(t.isLive)!t._loading&&i&&t.replay(void 0,!0);else{var n=t.bufferInfo();(n.start||n.nextStart)>sr&&t._tick()}})),c(p(t),"_onLoadeddata",(function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),c(p(t),"_onSeeking",u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return e.stop()}}),e)})))),c(p(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var i=pe.end(pe.get(t.media));i-r>=e.maxLatency&&(t.media.currentTime=i-e.targetLatency,t.emit("core.chaseframe",{currentTime:t.media.currentTime,latency:e.targetLatency}))}t._seiService.throw(r,!0),e.isLive||!t.seekable||t._loading||t._checkPreload()}})),c(p(t),"_onWaiting",(function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())})),c(p(t),"_onBufferUpdate",(function(){if(!t._opts.isLive){var e=t.bufferInfo(),r=e.end,i=e.nextEnd;Math.abs((r||i)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}})),c(p(t),"_checkPreload",u(s().mark((function e(){var r,i,n,a,o,u,l,d,h,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.bufferInfo(),i=r.remaining,n=void 0===i?0:i,a=t._opts,o=t._keyframes.filepositions,u=t._keyframes.times,l=t.media.currentTime,!(n<a.preloadTime)){e.next=19;break}if(d=nr(t._keyframes.times,l+n+sr),(h=nr(t._keyframes.times,l+n+t._opts.preloadTime))===d&&(h=d+1),t._preLoadEndPoint!==h){e.next=11;break}return e.abrupt("return");case 11:if(null!=(c=o[d])){e.next=14;break}return e.abrupt("return");case 14:return e.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[c,o[h]]),t._preLoadEndPoint=h,t._bufferService.unContiguous(u[d]);case 19:case"end":return e.stop()}}),e)})))),c(p(t),"_onFlvScriptData",(function(e){var r,i,n,a,s=null===(r=e.data)||void 0===r||null===(i=r.onMetaData)||void 0===i?void 0:i.keyframes,o=null===(n=e.data)||void 0===n||null===(a=n.onMetaData)||void 0===a?void 0:a.duration;s&&(t._keyframes=s),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=a({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new Me(a(a({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._disconnectRetryCount=t._opts.disconnectRetryCount,t._transferCost=new Zt,t._bufferService=new ir(p(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new Be(p(t)),t._bandwidthService=new Ne({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new Ge(p(t)),t._opts.softDecode||(t._gapService=new Ve),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.media.addEventListener("progress",t._onBufferUpdate),t.media.addEventListener("waiting",t._onWaiting),t.on(Q,t._onFlvScriptData),t}return h(b,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:sr;return pe.info(pe.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(d=u(s().mark((function e(t){var r,i=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],this._bufferService){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._reset(r);case 5:this._loadData(t,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"replay",value:(o=u(s().mark((function e(){var t,r,i=this,n=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:this._opts.seamlesslyReload,r=n.length>1?n[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(this._resetDisconnectCount(),!t){e.next=11;break}return e.next=8,this._clear();case 8:setTimeout((function(){i._seamlessSwitching=!0,i._loadData(i._opts.url),i._bufferService.seamlessSwitch()})),e.next=13;break;case 11:return e.next=13,this.load();case 13:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 14:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"disconnect",value:function(){var e;return ar.debug("disconnect!"),null===(e=this._bufferService)||void 0===e||e.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:(n=u(s().mark((function e(t,r){var i=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(this._resetDisconnectCount(),!this._loading||!r){e.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var e=u(s().mark((function e(r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i._clear();case 2:i._bufferService.seamlessLoadingSwitching=!0,i._urlSwitching=!0,i._seamlessSwitching=!0,i._bufferService.seamlessSwitch(),i._loadData(t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return");case 6:if(r&&this._opts.isLive){e.next=11;break}return e.next=9,this.load(t);case 9:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 11:return e.next=13,this._clear();case 13:setTimeout((function(){i._urlSwitching=!0,i._seamlessSwitching=!0,i._loadData(t),i._bufferService.seamlessSwitch()}));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"destroy",value:(i=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),e.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];ar.table(e),ar.error(e),ar.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit("core.switchurlfailed",e)),this.emit("error",e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(r=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_loadData",value:(t=u(s().mark((function e(t,r){var i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),i=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(i=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=i,this.emit("core.loadstart",{url:i,seamlessSwitching:this._seamlessSwitching}),ar.debug("load data, loading:",this._loading,i),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:i,range:r});case 15:e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(12),this._loading=!1,e.abrupt("return",this._emitError(ve.network(e.t0),!1));case 21:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,r){return t.apply(this,arguments)})},{key:"_clear",value:(e=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:We.isSupported()}},{key:"enableLogger",value:function(){j.enable(),at.enable()}},{key:"disableLogger",value:function(){j.disable(),at.disable()}}]),b}();try{localStorage.getItem("xgd")?or.enableLogger():or.disableLogger()}catch(e){}var ur=r(21),lr=i.N,dr=i.c;export{lr as Flv,dr as Hls};
|