lemon-mse 0.3.7 → 0.3.9

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/index.js CHANGED
@@ -1,37 +1,33 @@
1
- (function (g, f) {var hasExports = typeof exports === 'object';if (typeof define === "function" && define.amd) {define([], f);} else if (typeof module === "object" && module.exports) {module.exports = f();} else {var m = hasExports ? f() : f();var root = hasExports ? exports : g;for(var i in m) root[i] = m[i];}}(typeof self !== 'undefined' ? self : typeof globalThis !== 'undefined' ? globalThis : this, () => {var exports = {};var module = { exports };
2
- "use strict";var cf=Object.create;var ai=Object.defineProperty;var vf=Object.getOwnPropertyDescriptor;var pf=Object.getOwnPropertyNames;var mf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var Za=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports),yf=(c,g)=>{for(var n in g)ai(c,n,{get:g[n],enumerable:!0})},es=(c,g,n,l)=>{if(g&&typeof g=="object"||typeof g=="function")for(let f of pf(g))!gf.call(c,f)&&f!==n&&ai(c,f,{get:()=>g[f],enumerable:!(l=vf(g,f))||l.enumerable});return c};var gr=(c,g,n)=>(n=c!=null?cf(mf(c)):{},es(g||!c||!c.__esModule?ai(n,"default",{value:c,enumerable:!0}):n,c)),Ef=c=>es(ai({},"__esModule",{value:!0}),c);var _r=Za((nh,Xi)=>{"use strict";var xf=Object.prototype.hasOwnProperty,pt="~";function Rr(){}Object.create&&(Rr.prototype=Object.create(null),new Rr().__proto__||(pt=!1));function bf(c,g,n){this.fn=c,this.context=g,this.once=n||!1}function os(c,g,n,l,f){if(typeof n!="function")throw new TypeError("The listener must be a function");var v=new bf(n,l||c,f),E=pt?pt+g:g;return c._events[E]?c._events[E].fn?c._events[E]=[c._events[E],v]:c._events[E].push(v):(c._events[E]=v,c._eventsCount++),c}function oi(c,g){--c._eventsCount===0?c._events=new Rr:delete c._events[g]}function ht(){this._events=new Rr,this._eventsCount=0}ht.prototype.eventNames=function(){var g=[],n,l;if(this._eventsCount===0)return g;for(l in n=this._events)xf.call(n,l)&&g.push(pt?l.slice(1):l);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(n)):g};ht.prototype.listeners=function(g){var n=pt?pt+g:g,l=this._events[n];if(!l)return[];if(l.fn)return[l.fn];for(var f=0,v=l.length,E=new Array(v);f<v;f++)E[f]=l[f].fn;return E};ht.prototype.listenerCount=function(g){var n=pt?pt+g:g,l=this._events[n];return l?l.fn?1:l.length:0};ht.prototype.emit=function(g,n,l,f,v,E){var _=pt?pt+g:g;if(!this._events[_])return!1;var S=this._events[_],C=arguments.length,I,P;if(S.fn){switch(S.once&&this.removeListener(g,S.fn,void 0,!0),C){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,n),!0;case 3:return S.fn.call(S.context,n,l),!0;case 4:return S.fn.call(S.context,n,l,f),!0;case 5:return S.fn.call(S.context,n,l,f,v),!0;case 6:return S.fn.call(S.context,n,l,f,v,E),!0}for(P=1,I=new Array(C-1);P<C;P++)I[P-1]=arguments[P];S.fn.apply(S.context,I)}else{var H=S.length,W;for(P=0;P<H;P++)switch(S[P].once&&this.removeListener(g,S[P].fn,void 0,!0),C){case 1:S[P].fn.call(S[P].context);break;case 2:S[P].fn.call(S[P].context,n);break;case 3:S[P].fn.call(S[P].context,n,l);break;case 4:S[P].fn.call(S[P].context,n,l,f);break;default:if(!I)for(W=1,I=new Array(C-1);W<C;W++)I[W-1]=arguments[W];S[P].fn.apply(S[P].context,I)}}return!0};ht.prototype.on=function(g,n,l){return os(this,g,n,l,!1)};ht.prototype.once=function(g,n,l){return os(this,g,n,l,!0)};ht.prototype.removeListener=function(g,n,l,f){var v=pt?pt+g:g;if(!this._events[v])return this;if(!n)return oi(this,v),this;var E=this._events[v];if(E.fn)E.fn===n&&(!f||E.once)&&(!l||E.context===l)&&oi(this,v);else{for(var _=0,S=[],C=E.length;_<C;_++)(E[_].fn!==n||f&&!E[_].once||l&&E[_].context!==l)&&S.push(E[_]);S.length?this._events[v]=S.length===1?S[0]:S:oi(this,v)}return this};ht.prototype.removeAllListeners=function(g){var n;return g?(n=pt?pt+g:g,this._events[n]&&oi(this,n)):(this._events=new Rr,this._eventsCount=0),this};ht.prototype.off=ht.prototype.removeListener;ht.prototype.addListener=ht.prototype.on;ht.prefixed=pt;ht.EventEmitter=ht;typeof Xi<"u"&&(Xi.exports=ht)});var so=Za((ao,_n)=>{(function c(g){(function(n,l){typeof ao=="object"&&typeof _n<"u"?_n.exports=l():typeof define=="function"&&define.amd?define(l):(n=typeof globalThis<"u"?globalThis:n||self,n.Hls=l())})(this,function(){"use strict";function n(s,a){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(s);a&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})),i.push.apply(i,e)}return i}function l(s){for(var a=1;a<arguments.length;a++){var i=arguments[a]!=null?arguments[a]:{};a%2?n(Object(i),!0).forEach(function(e){S(s,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(i,e))})}return s}function f(s,a){if(typeof s!="object"||!s)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var e=i.call(s,a||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function v(s){var a=f(s,"string");return typeof a=="symbol"?a:String(a)}function E(s,a){for(var i=0;i<a.length;i++){var e=a[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,v(e.key),e)}}function _(s,a,i){return a&&E(s.prototype,a),i&&E(s,i),Object.defineProperty(s,"prototype",{writable:!1}),s}function S(s,a,i){return a=v(a),a in s?Object.defineProperty(s,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[a]=i,s}function C(){return C=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(s[e]=i[e])}return s},C.apply(this,arguments)}function I(s,a){s.prototype=Object.create(a.prototype),s.prototype.constructor=s,H(s,a)}function P(s){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},P(s)}function H(s,a){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(s,a)}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Y(s,a,i){return W()?Y=Reflect.construct.bind():Y=function(t,r,o){var u=[null];u.push.apply(u,r);var h=Function.bind.apply(t,u),d=new h;return o&&H(d,o.prototype),d},Y.apply(null,arguments)}function ee(s){try{return Function.toString.call(s).indexOf("[native code]")!==-1}catch{return typeof s=="function"}}function J(s){var a=typeof Map=="function"?new Map:void 0;return J=function(e){if(e===null||!ee(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(e))return a.get(e);a.set(e,t)}function t(){return Y(e,arguments,P(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),H(t,e)},J(s)}function ae(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function se(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _e={exports:{}};(function(s,a){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(h,d,m){if(m=m||{},h=h.trim(),d=d.trim(),!d){if(!m.alwaysNormalize)return h;var p=u.parseURL(h);if(!p)throw new Error("Error trying to parse base URL.");return p.path=u.normalizePath(p.path),u.buildURLFromParts(p)}var y=u.parseURL(d);if(!y)throw new Error("Error trying to parse relative URL.");if(y.scheme)return m.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var T=u.parseURL(h);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var x=t.exec(T.path);T.netLoc=x[1],T.path=x[2]}T.netLoc&&!T.path&&(T.path="/");var b={scheme:T.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(b.netLoc=T.netLoc,y.path[0]!=="/"))if(!y.path)b.path=T.path,y.params||(b.params=T.params,y.query||(b.query=T.query));else{var L=T.path,A=L.substring(0,L.lastIndexOf("/")+1)+y.path;b.path=u.normalizePath(A)}return b.path===null&&(b.path=m.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(b)},parseURL:function(h){var d=e.exec(h);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(h){for(h=h.split("").reverse().join("").replace(r,"");h.length!==(h=h.replace(o,"")).length;);return h.split("").reverse().join("")},buildURLFromParts:function(h){return h.scheme+h.netLoc+h.path+h.params+h.query+h.fragment}};s.exports=u})()})(_e);var oe=_e.exports,j=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},ue=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=Ve},Ve=Number.MAX_SAFE_INTEGER||9007199254740991,R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s}({}),le=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),G=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),He=function(){},F={trace:He,debug:He,log:He,warn:He,info:He,error:He},O=F;function B(s){var a=self.console[s];return a?a.bind(self.console,"["+s+"] >"):He}function re(s){for(var a=arguments.length,i=new Array(a>1?a-1:0),e=1;e<a;e++)i[e-1]=arguments[e];i.forEach(function(t){O[t]=s[t]?s[t].bind(s):B(t)})}function X(s,a){if(typeof console=="object"&&s===!0||typeof s=="object"){re(s,"debug","log","info","warn","error");try{O.log('Debug logs enabled for "'+a+'" in hls.js version 1.5.17')}catch{O=F}}else O=F}var k=O,ge=/^(\d+)x(\d+)$/,De=/(.+?)=(".*?"|.*?)(?:,|$)/g,pe=function(){function s(i){typeof i=="string"&&(i=s.parseAttrList(i)),C(this,i)}var a=s.prototype;return a.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),o=0;o<t.length/2;o++)r[o]=parseInt(t.slice(o*2,o*2+2),16);return r}else return null},a.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.decimalFloatingPoint=function(e){return parseFloat(this[e])},a.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},a.enumeratedString=function(e){return this[e]},a.bool=function(e){return this[e]==="YES"},a.decimalResolution=function(e){var t=ge.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={},o='"';for(De.lastIndex=0;(t=De.exec(e))!==null;){var u=t[2];u.indexOf(o)===0&&u.lastIndexOf(o)===u.length-1&&(u=u.slice(1,-1));var h=t[1].trim();r[h]=u}return r},_(s,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),s}();function Ne(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Qe(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var ke=function(){function s(a,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(a,t)&&a[t]!==e[t]){k.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+a.ID+'"'),this._badValueForSameId=t;break}a=C(new pe({}),e,a)}if(this.attr=a,this._startDate=new Date(a["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);j(r.getTime())&&(this._endDate=r)}}return _(s,[{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 i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(j(i))return i}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&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),$t=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}},Pe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},hr=function(){function s(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[Pe.AUDIO]=null,e[Pe.VIDEO]=null,e[Pe.AUDIOVIDEO]=null,e),this.baseurl=i}var a=s.prototype;return a.setByteRange=function(e,t){var r=e.split("@",2),o;r.length===1?o=t?.byteRangeEndOffset||0:o=parseInt(r[1]),this._byteRange=[o,parseInt(r[0])+o]},_(s,[{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=oe.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),s}(),dr=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new $t,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=a.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,o,u,h,d){d===void 0&&(d=!1);var m=this.elementaryStreams,p=m[t];if(!p){m[t]={startPTS:r,endPTS:o,startDTS:u,endDTS:h,partial:d};return}p.startPTS=Math.min(p.startPTS,r),p.endPTS=Math.max(p.endPTS,o),p.startDTS=Math.min(p.startDTS,u),p.endDTS=Math.max(p.endDTS,h)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Pe.AUDIO]=null,t[Pe.VIDEO]=null,t[Pe.AUDIOVIDEO]=null},_(a,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var o=Object.keys(this.levelkeys);if(o.length===1)return this._decryptdata=this.levelkeys[o[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!j(this.programDateTime))return null;var t=j(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),o=r.length;if(o>1||o===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),a}(hr),Tn=function(s){I(a,s);function a(i,e,t,r,o){var u;u=s.call(this,t)||this,u.fragOffset=0,u.duration=0,u.gap=!1,u.independent=!1,u.relurl=void 0,u.fragment=void 0,u.index=void 0,u.stats=new $t,u.duration=i.decimalFloatingPoint("DURATION"),u.gap=i.bool("GAP"),u.independent=i.bool("INDEPENDENT"),u.relurl=i.enumeratedString("URI"),u.fragment=e,u.index=r;var h=i.enumeratedString("BYTERANGE");return h&&u.setByteRange(h,o),o&&(u.fragOffset=o.fragOffset+o.duration),u}return _(a,[{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)}}]),a}(hr),Je=10,oo=function(){function s(i){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=i}var a=s.prototype;return a.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}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||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},_(s,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||Je}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&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(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}(),uo=void 0,lo=se(uo);function nr(s,a,i){return Uint8Array.prototype.slice?s.slice(a,i):new Uint8Array(Array.prototype.slice.call(s,a,i))}var gi=function(a,i){return i+10<=a.length&&a[i]===73&&a[i+1]===68&&a[i+2]===51&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},xn=function(a,i){return i+10<=a.length&&a[i]===51&&a[i+1]===68&&a[i+2]===73&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},Nr=function(a,i){for(var e=i,t=0;gi(a,i);){t+=10;var r=Ur(a,i+6);t+=r,xn(a,i+10)&&(t+=10),i+=t}if(t>0)return a.subarray(e,e+t)},Ur=function(a,i){var e=0;return e=(a[i]&127)<<21,e|=(a[i+1]&127)<<14,e|=(a[i+2]&127)<<7,e|=a[i+3]&127,e},fo=function(a,i){return gi(a,i)&&Ur(a,i+6)+10<=a.length-i},bn=function(a){for(var i=An(a),e=0;e<i.length;e++){var t=i[e];if(Ln(t))return go(t)}},Ln=function(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"},ho=function(a){var i=String.fromCharCode(a[0],a[1],a[2],a[3]),e=Ur(a,4),t=10;return{type:i,size:e,data:a.subarray(t,t+e)}},An=function(a){for(var i=0,e=[];gi(a,i);){var t=Ur(a,i+6);i+=10;for(var r=i+t;i+8<r;){var o=ho(a.subarray(i)),u=co(o);u&&e.push(u),i+=o.size+10}xn(a,i)&&(i+=10)}return e},co=function(a){return a.type==="PRIV"?vo(a):a.type[0]==="W"?mo(a):po(a)},vo=function(a){if(!(a.size<2)){var i=Qt(a.data,!0),e=new Uint8Array(a.data.subarray(i.length+1));return{key:a.type,info:i,data:e.buffer}}},po=function(a){if(!(a.size<2)){if(a.type==="TXXX"){var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data.subarray(1));return{key:a.type,data:r}}},mo=function(a){if(a.type==="WXXX"){if(a.size<2)return;var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data);return{key:a.type,data:r}},go=function(a){if(a.data.byteLength===8){var i=new Uint8Array(a.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Qt=function(a,i){i===void 0&&(i=!1);var e=yo();if(e){var t=e.decode(a);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var o=a.length,u,h,d,m="",p=0;p<o;){if(u=a[p++],u===0&&i)return m;if(u===0||u===3)continue;switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:m+=String.fromCharCode(u);break;case 12:case 13:h=a[p++],m+=String.fromCharCode((u&31)<<6|h&63);break;case 14:h=a[p++],d=a[p++],m+=String.fromCharCode((u&15)<<12|(h&63)<<6|(d&63)<<0);break}}return m},yi;function yo(){if(!navigator.userAgent.includes("PlayStation 4"))return!yi&&typeof self.TextDecoder<"u"&&(yi=new self.TextDecoder("utf-8")),yi}var Rn={hexDump:function(a){for(var i="",e=0;e<a.length;e++){var t=a[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},Br=Math.pow(2,32)-1,Eo=[].push,Cn={video:1,audio:2,id3:3,text:4};function nt(s){return String.fromCharCode.apply(null,s)}function Dn(s,a){var i=s[a]<<8|s[a+1];return i<0?65536+i:i}function ve(s,a){var i=In(s,a);return i<0?4294967296+i:i}function wn(s,a){var i=ve(s,a);return i*=Math.pow(2,32),i+=ve(s,a+4),i}function In(s,a){return s[a]<<24|s[a+1]<<16|s[a+2]<<8|s[a+3]}function Ei(s,a,i){s[a]=i>>24,s[a+1]=i>>16&255,s[a+2]=i>>8&255,s[a+3]=i&255}function _o(s){for(var a=s.byteLength,i=0;i<a;){var e=ve(s,i);if(e>8&&s[i+4]===109&&s[i+5]===111&&s[i+6]===111&&s[i+7]===102)return!0;i=e>1?i+e:a}return!1}function be(s,a){var i=[];if(!a.length)return i;for(var e=s.byteLength,t=0;t<e;){var r=ve(s,t),o=nt(s.subarray(t+4,t+8)),u=r>1?t+r:e;if(o===a[0])if(a.length===1)i.push(s.subarray(t+8,u));else{var h=be(s.subarray(t+8,u),a.slice(1));h.length&&Eo.apply(i,h)}t=u}return i}function So(s){var a=[],i=s[0],e=8,t=ve(s,e);e+=4;var r=0,o=0;i===0?(r=ve(s,e),o=ve(s,e+4),e+=8):(r=wn(s,e),o=wn(s,e+8),e+=16),e+=2;var u=s.length+o,h=Dn(s,e);e+=2;for(var d=0;d<h;d++){var m=e,p=ve(s,m);m+=4;var y=p&2147483647,T=(p&2147483648)>>>31;if(T===1)return k.warn("SIDX has hierarchical references (not supported)"),null;var x=ve(s,m);m+=4,a.push({referenceSize:y,subsegmentDuration:x,info:{duration:x/t,start:u,end:u+y-1}}),u+=y,m+=4,e=m}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:h,references:a}}function Pn(s){for(var a=[],i=be(s,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=be(t,["tkhd"])[0];if(r){var o=r[0],u=ve(r,o===0?12:20),h=be(t,["mdia","mdhd"])[0];if(h){o=h[0];var d=ve(h,o===0?12:20),m=be(t,["mdia","hdlr"])[0];if(m){var p=nt(m.subarray(8,12)),y={soun:Pe.AUDIO,vide:Pe.VIDEO}[p];if(y){var T=be(t,["mdia","minf","stbl","stsd"])[0],x=To(T);a[u]={timescale:d,type:y},a[y]=l({timescale:d,id:u},x)}}}}}var b=be(s,["moov","mvex","trex"]);return b.forEach(function(L){var A=ve(L,4),D=a[A];D&&(D.default={duration:ve(L,12),flags:ve(L,20)})}),a}function To(s){var a=s.subarray(8),i=a.subarray(86),e=nt(a.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var o=be(a,[e])[0],u=o.subarray(e==="enca"?28:78),h=be(u,["sinf"]);h.forEach(function(yt){var ft=be(yt,["schm"])[0];if(ft){var st=nt(ft.subarray(4,8));if(st==="cbcs"||st==="cenc"){var or=be(yt,["frma"])[0];or&&(t=nt(or))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var d=be(i,["avcC"])[0];t+="."+Gr(d[1])+Gr(d[2])+Gr(d[3]);break}case"mp4a":{var m=be(a,[e])[0],p=be(m.subarray(28),["esds"])[0];if(p&&p.length>12){var y=4;if(p[y++]!==3)break;y=_i(p,y),y+=2;var T=p[y++];if(T&128&&(y+=2),T&64&&(y+=p[y++]),p[y++]!==4)break;y=_i(p,y);var x=p[y++];if(x===64)t+="."+Gr(x);else break;if(y+=12,p[y++]!==5)break;y=_i(p,y);var b=p[y++],L=(b&248)>>3;L===31&&(L+=1+((b&7)<<3)+((p[y]&224)>>5)),t+="."+L}break}case"hvc1":case"hev1":{var A=be(i,["hvcC"])[0],D=A[1],w=["","A","B","C"][D>>6],N=D&31,U=ve(A,2),$=(D&32)>>5?"H":"L",V=A[12],M=A.subarray(6,12);t+="."+w+N,t+="."+U.toString(16).toUpperCase(),t+="."+$+V;for(var K="",z=M.length;z--;){var te=M[z];if(te||K){var Z=te.toString(16).toUpperCase();K="."+Z+K}}t+=K;break}case"dvh1":case"dvhe":{var ie=be(i,["dvcC"])[0],he=ie[2]>>1&127,fe=ie[2]<<5&32|ie[3]>>3&31;t+="."+Ut(he)+"."+Ut(fe);break}case"vp09":{var Le=be(i,["vpcC"])[0],Ee=Le[4],we=Le[5],Ae=Le[6]>>4&15;t+="."+Ut(Ee)+"."+Ut(we)+"."+Ut(Ae);break}case"av01":{var ye=be(i,["av1C"])[0],je=ye[1]>>>5,Fe=ye[1]&31,qe=ye[2]>>>7?"H":"M",Xe=(ye[2]&64)>>6,Ze=(ye[2]&32)>>5,ze=je===2&&Xe?Ze?12:10:Xe?10:8,Ue=(ye[2]&16)>>4,jt=(ye[2]&8)>>3,_t=(ye[2]&4)>>2,$e=ye[2]&3,ct=1,vt=1,et=1,Ke=0;t+="."+je+"."+Ut(Fe)+qe+"."+Ut(ze)+"."+Ue+"."+jt+_t+$e+"."+Ut(ct)+"."+Ut(vt)+"."+Ut(et)+"."+Ke;break}}return{codec:t,encrypted:r}}function _i(s,a){for(var i=a+5;s[a++]&128&&a<i;);return a}function Gr(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Ut(s){return(s<10?"0":"")+s}function xo(s,a){if(!s||!a)return s;var i=a.keyId;if(i&&a.isCommonEncryption){var e=be(s,["moov","trak"]);e.forEach(function(t){var r=be(t,["mdia","minf","stbl","stsd"])[0],o=r.subarray(8),u=be(o,["enca"]),h=u.length>0;h||(u=be(o,["encv"])),u.forEach(function(d){var m=h?d.subarray(28):d.subarray(78),p=be(m,["sinf"]);p.forEach(function(y){var T=bo(y);if(T){var x=T.subarray(8,24);x.some(function(b){return b!==0})||(k.log("[eme] Patching keyId in 'enc"+(h?"a":"v")+">sinf>>tenc' box: "+Rn.hexDump(x)+" -> "+Rn.hexDump(i)),T.set(i,8))}})})})}return s}function bo(s){var a=be(s,["schm"])[0];if(a){var i=nt(a.subarray(4,8));if(i==="cbcs"||i==="cenc")return be(s,["schi","tenc"])[0]}return null}function Lo(s,a){return be(a,["moof","traf"]).reduce(function(i,e){var t=be(e,["tfdt"])[0],r=t[0],o=be(e,["tfhd"]).reduce(function(u,h){var d=ve(h,4),m=s[d];if(m){var p=ve(t,4);if(r===1){if(p===Br)return k.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),u;p*=Br+1,p+=ve(t,8)}var y=m.timescale||9e4,T=p/y;if(j(T)&&(u===null||T<u))return T}return u},null);return o!==null&&j(o)&&(i===null||o<i)?o:i},null)}function Ao(s,a){for(var i=0,e=0,t=0,r=be(s,["moof","traf"]),o=0;o<r.length;o++){var u=r[o],h=be(u,["tfhd"])[0],d=ve(h,4),m=a[d];if(m){var p=m.default,y=ve(h,0)|p?.flags,T=p?.duration;y&8&&(y&2?T=ve(h,12):T=ve(h,8));for(var x=m.timescale||9e4,b=be(u,["trun"]),L=0;L<b.length;L++){if(i=Ro(b[L]),!i&&T){var A=ve(b[L],4);i=T*A}m.type===Pe.VIDEO?e+=i/x:m.type===Pe.AUDIO&&(t+=i/x)}}}if(e===0&&t===0){for(var D=1/0,w=0,N=0,U=be(s,["sidx"]),$=0;$<U.length;$++){var V=So(U[$]);if(V!=null&&V.references){D=Math.min(D,V.earliestPresentationTime/V.timescale);var M=V.references.reduce(function(K,z){return K+z.info.duration||0},0);w=Math.max(w,M+V.earliestPresentationTime/V.timescale),N=w-D}}if(N&&j(N))return N}return e||t}function Ro(s){var a=ve(s,0),i=8;a&1&&(i+=4),a&4&&(i+=4);for(var e=0,t=ve(s,4),r=0;r<t;r++){if(a&256){var o=ve(s,i);e+=o,i+=4}a&512&&(i+=4),a&1024&&(i+=4),a&2048&&(i+=4)}return e}function Co(s,a,i){be(a,["moof","traf"]).forEach(function(e){be(e,["tfhd"]).forEach(function(t){var r=ve(t,4),o=s[r];if(o){var u=o.timescale||9e4;be(e,["tfdt"]).forEach(function(h){var d=h[0],m=i*u;if(m){var p=ve(h,4);if(d===0)p-=m,p=Math.max(p,0),Ei(h,4,p);else{p*=Math.pow(2,32),p+=ve(h,8),p-=m,p=Math.max(p,0);var y=Math.floor(p/(Br+1)),T=Math.floor(p%(Br+1));Ei(h,4,y),Ei(h,8,T)}}})}})})}function Do(s){var a={valid:null,remainder:null},i=be(s,["moof"]);if(i.length<2)return a.remainder=s,a;var e=i[i.length-1];return a.valid=nr(s,0,e.byteOffset-8),a.remainder=nr(s,e.byteOffset-8),a}function At(s,a){var i=new Uint8Array(s.length+a.length);return i.set(s),i.set(a,s.length),i}function kn(s,a){var i=[],e=a.samples,t=a.timescale,r=a.id,o=!1,u=be(e,["moof"]);return u.map(function(h){var d=h.byteOffset-8,m=be(h,["traf"]);m.map(function(p){var y=be(p,["tfdt"]).map(function(T){var x=T[0],b=ve(T,4);return x===1&&(b*=Math.pow(2,32),b+=ve(T,8)),b/t})[0];return y!==void 0&&(s=y),be(p,["tfhd"]).map(function(T){var x=ve(T,4),b=ve(T,0)&16777215,L=(b&1)!==0,A=(b&2)!==0,D=(b&8)!==0,w=0,N=(b&16)!==0,U=0,$=(b&32)!==0,V=8;x===r&&(L&&(V+=8),A&&(V+=4),D&&(w=ve(T,V),V+=4),N&&(U=ve(T,V),V+=4),$&&(V+=4),a.type==="video"&&(o=wo(a.codec)),be(p,["trun"]).map(function(M){var K=M[0],z=ve(M,0)&16777215,te=(z&1)!==0,Z=0,ie=(z&4)!==0,he=(z&256)!==0,fe=0,Le=(z&512)!==0,Ee=0,we=(z&1024)!==0,Ae=(z&2048)!==0,ye=0,je=ve(M,4),Fe=8;te&&(Z=ve(M,Fe),Fe+=4),ie&&(Fe+=4);for(var qe=Z+d,Xe=0;Xe<je;Xe++){if(he?(fe=ve(M,Fe),Fe+=4):fe=w,Le?(Ee=ve(M,Fe),Fe+=4):Ee=U,we&&(Fe+=4),Ae&&(K===0?ye=ve(M,Fe):ye=In(M,Fe),Fe+=4),a.type===Pe.VIDEO)for(var Ze=0;Ze<Ee;){var ze=ve(e,qe);if(qe+=4,Io(o,e[qe])){var Ue=e.subarray(qe,qe+ze);On(Ue,o?2:1,s+ye/t,i)}qe+=ze,Ze+=ze+4}s+=fe/t}}))})})}),i}function wo(s){if(!s)return!1;var a=s.indexOf("."),i=a<0?s:s.substring(0,a);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function Io(s,a){if(s){var i=a>>1&63;return i===39||i===40}else{var e=a&31;return e===6}}function On(s,a,i,e){var t=Mn(s),r=0;r+=a;for(var o=0,u=0,h=0;r<t.length;){o=0;do{if(r>=t.length)break;h=t[r++],o+=h}while(h===255);u=0;do{if(r>=t.length)break;h=t[r++],u+=h}while(h===255);var d=t.length-r,m=r;if(u<d)r+=u;else if(u>d){k.error("Malformed SEI payload. "+u+" is too small, only "+d+" bytes left to parse.");break}if(o===4){var p=t[m++];if(p===181){var y=Dn(t,m);if(m+=2,y===49){var T=ve(t,m);if(m+=4,T===1195456820){var x=t[m++];if(x===3){var b=t[m++],L=31&b,A=64&b,D=A?2+L*3:0,w=new Uint8Array(D);if(A){w[0]=b;for(var N=1;N<D;N++)w[N]=t[m++]}e.push({type:x,payloadType:o,pts:i,bytes:w})}}}}}else if(o===5&&u>16){for(var U=[],$=0;$<16;$++){var V=t[m++].toString(16);U.push(V.length==1?"0"+V:V),($===3||$===5||$===7||$===9)&&U.push("-")}for(var M=u-16,K=new Uint8Array(M),z=0;z<M;z++)K[z]=t[m++];e.push({payloadType:o,pts:i,uuid:U.join(""),userData:Qt(K),userDataBytes:K})}}}function Mn(s){for(var a=s.byteLength,i=[],e=1;e<a-2;)s[e]===0&&s[e+1]===0&&s[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return s;var t=a-i.length,r=new Uint8Array(t),o=0;for(e=0;e<t;o++,e++)o===i[0]&&(o++,i.shift()),r[e]=s[o];return r}function Po(s){var a=s[0],i="",e="",t=0,r=0,o=0,u=0,h=0,d=0;if(a===0){for(;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1,t=ve(s,12),r=ve(s,16),u=ve(s,20),h=ve(s,24),d=28}else if(a===1){d+=4,t=ve(s,d),d+=4;var m=ve(s,d);d+=4;var p=ve(s,d);for(d+=4,o=Math.pow(2,32)*m+p,ue(o)||(o=Number.MAX_SAFE_INTEGER,k.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=ve(s,d),d+=4,h=ve(s,d),d+=4;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1}var y=s.subarray(d,s.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:o,presentationTimeDelta:r,eventDuration:u,id:h,payload:y}}var ko=function(){s.clearKeyUriToKeyIdMap=function(){};function s(i,e,t,r,o){r===void 0&&(r=[1]),o===void 0&&(o=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=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=o,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var a=s.prototype;return a.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},a.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&k.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=Oo(e),r=new s(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},s}();function Oo(s){for(var a=new Uint8Array(16),i=12;i<16;i++)a[i]=s>>8*(15-i)&255;return a}function ar(s){if(s===void 0&&(s=!0),!(typeof self>"u")){var a=(s||!self.MediaSource)&&self.ManagedMediaSource;return a||self.MediaSource||self.WebKitMediaSource}}function Mo(s){return typeof self<"u"&&s===self.ManagedMediaSource}var Vr={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 Fo(s,a){var i=Vr[a];return!!i&&!!i[s.slice(0,4)]}function Si(s,a,i){return i===void 0&&(i=!0),!s.split(",").some(function(e){return!Fn(e,a,i)})}function Fn(s,a,i){var e;i===void 0&&(i=!0);var t=ar(i);return(e=t?.isTypeSupported(Ti(s,a)))!=null?e:!1}function Ti(s,a){return a+'/mp4;codecs="'+s+'"'}function Nn(s){if(s){var a=s.substring(0,4);return Vr.video[a]}return 2}function Hr(s){return s.split(",").reduce(function(a,i){var e=Vr.video[i];return e?(e*2+a)/(a?3:2):(Vr.audio[i]+a)/(a?2:1)},0)}var xi={};function No(s,a){if(a===void 0&&(a=!0),xi[s])return xi[s];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[s],e=0;e<i.length;e++)if(Fn(i[e],"audio",a))return xi[s]=i[e],i[e];return s}var Uo=/flac|opus/i;function Kr(s,a){return a===void 0&&(a=!0),s.replace(Uo,function(i){return No(i.toLowerCase(),a)})}function Un(s,a){return s&&s!=="mp4a"?s:a&&a.split(",")[0]}function Bo(s){for(var a=s.split(","),i=0;i<a.length;i++){var e=a[i].split(".");if(e.length>2){var t=e.shift()+".";t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),a[i]=t}}return a.join(",")}var Bn=/#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,Gn=/#EXT-X-MEDIA:(.*)/g,Go=/^#EXT(?:INF|-X-TARGETDURATION):/m,Vn=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"),Vo=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("|")),Lr=function(){function s(){}return s.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},s.resolve=function(i,e){return oe.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},s.isMediaPlaylist=function(i){return Go.test(i)},s.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},o=[];Bn.lastIndex=0;for(var u;(u=Bn.exec(i))!=null;)if(u[1]){var h,d=new pe(u[1]),m=u[2],p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:s.resolve(m,e)},y=d.decimalResolution("RESOLUTION");y&&(p.width=y.width,p.height=y.height),Ho(d.CODECS,p),(h=p.unknownCodecs)!=null&&h.length||o.push(p),r.levels.push(p)}else if(u[3]){var T=u[3],x=u[4];switch(T){case"SESSION-DATA":{var b=new pe(x),L=b["DATA-ID"];L&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[L]=b);break}case"SESSION-KEY":{var A=Hn(x,e);A.encrypted&&A.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(A)):k.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+x+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var D=new pe(x);r.contentSteering={uri:s.resolve(D["SERVER-URI"],e),pathwayId:D["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Kn(x);break}}}var w=o.length>0&&o.length<r.levels.length;return r.levels=w?o:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(i,e,t){var r,o={},u=t.levels,h={AUDIO:u.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),SUBTITLES:u.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),"CLOSED-CAPTIONS":[]},d=0;for(Gn.lastIndex=0;(r=Gn.exec(i))!==null;){var m=new pe(r[1]),p=m.TYPE;if(p){var y=h[p],T=o[p]||[];o[p]=T;var x=m.LANGUAGE,b=m["ASSOC-LANGUAGE"],L=m.CHANNELS,A=m.CHARACTERISTICS,D=m["INSTREAM-ID"],w={attrs:m,bitrate:0,id:d++,groupId:m["GROUP-ID"]||"",name:m.NAME||x||"",type:p,default:m.bool("DEFAULT"),autoselect:m.bool("AUTOSELECT"),forced:m.bool("FORCED"),lang:x,url:m.URI?s.resolve(m.URI,e):""};if(b&&(w.assocLang=b),L&&(w.channels=L),A&&(w.characteristics=A),D&&(w.instreamId=D),y!=null&&y.length){var N=s.findGroup(y,w.groupId)||y[0];Wn(w,N,"audioCodec"),Wn(w,N,"textCodec")}T.push(w)}}return o},s.parseLevelPlaylist=function(i,e,t,r,o,u){var h=new oo(e),d=h.fragments,m=null,p=0,y=0,T=0,x=0,b=null,L=new dr(r,e),A,D,w,N=-1,U=!1,$=null;for(Vn.lastIndex=0,h.m3u8=i,h.hasVariableRefs=!1;(A=Vn.exec(i))!==null;){U&&(U=!1,L=new dr(r,e),L.start=T,L.sn=p,L.cc=x,L.level=t,m&&(L.initSegment=m,L.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null,$&&(L.setByteRange($),$=null)));var V=A[1];if(V){L.duration=parseFloat(V);var M=(" "+A[2]).slice(1);L.title=M||null,L.tagList.push(M?["INF",V,M]:["INF",V])}else if(A[3]){if(j(L.duration)){L.start=T,w&&Yn(L,w,h),L.sn=p,L.level=t,L.cc=x,d.push(L);var K=(" "+A[3]).slice(1);L.relurl=K,jn(L,b),b=L,T+=L.duration,p++,y=0,U=!0}}else if(A[4]){var z=(" "+A[4]).slice(1);b?L.setByteRange(z,b):L.setByteRange(z)}else if(A[5])L.rawProgramDateTime=(" "+A[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),N===-1&&(N=d.length);else{if(A=A[0].match(Vo),!A){k.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<A.length&&!(typeof A[D]<"u");D++);var te=(" "+A[D]).slice(1),Z=(" "+A[D+1]).slice(1),ie=A[D+2]?(" "+A[D+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":h.type=Z.toUpperCase();break;case"MEDIA-SEQUENCE":p=h.startSN=parseInt(Z);break;case"SKIP":{var he=new pe(Z),fe=he.decimalInteger("SKIPPED-SEGMENTS");if(j(fe)){h.skippedSegments=fe;for(var Le=fe;Le--;)d.unshift(null);p+=fe}var Ee=he.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ee&&(h.recentlyRemovedDateranges=Ee.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(Z),1);break;case"VERSION":h.version=parseInt(Z);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(Z||ie)&&L.tagList.push(ie?[Z,ie]:[Z]);break;case"DISCONTINUITY":x++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([te]);break;case"BITRATE":L.tagList.push([te,Z]);break;case"DATERANGE":{var we=new pe(Z),Ae=new ke(we,h.dateRanges[we.ID]);Ae.isValid||h.skippedSegments?h.dateRanges[Ae.id]=Ae:k.warn('Ignoring invalid DATERANGE tag: "'+Z+'"'),L.tagList.push(["EXT-X-DATERANGE",Z]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":x=parseInt(Z);break;case"KEY":{var ye=Hn(Z,e);if(ye.isSupported()){if(ye.method==="NONE"){w=void 0;break}w||(w={}),w[ye.keyFormat]&&(w=C({},w)),w[ye.keyFormat]=ye}else k.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Z+'"');break}case"START":h.startTimeOffset=Kn(Z);break;case"MAP":{var je=new pe(Z);if(L.duration){var Fe=new dr(r,e);zn(Fe,je,t,w),m=Fe,L.initSegment=m,m.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=m.rawProgramDateTime)}else{var qe=L.byteRangeEndOffset;if(qe){var Xe=L.byteRangeStartOffset;$=qe-Xe+"@"+Xe}else $=null;zn(L,je,t,w),m=L,U=!0}break}case"SERVER-CONTROL":{var Ze=new pe(Z);h.canBlockReload=Ze.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=Ze.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&Ze.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=Ze.optionalFloat("PART-HOLD-BACK",0),h.holdBack=Ze.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ze=new pe(Z);h.partTarget=ze.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ue=h.partList;Ue||(Ue=h.partList=[]);var jt=y>0?Ue[Ue.length-1]:void 0,_t=y++,$e=new pe(Z),ct=new Tn($e,L,e,_t,jt);Ue.push(ct),L.duration+=ct.duration;break}case"PRELOAD-HINT":{var vt=new pe(Z);h.preloadHint=vt;break}case"RENDITION-REPORT":{var et=new pe(Z);h.renditionReports=h.renditionReports||[],h.renditionReports.push(et);break}default:k.warn("line parsed but not handled: "+A);break}}}b&&!b.relurl?(d.pop(),T-=b.duration,h.partList&&(h.fragmentHint=b)):h.partList&&(jn(L,b),L.cc=x,h.fragmentHint=L,w&&Yn(L,w,h));var Ke=d.length,yt=d[0],ft=d[Ke-1];if(T+=h.skippedSegments*h.targetduration,T>0&&Ke&&ft){h.averagetargetduration=T/Ke;var st=ft.sn;h.endSN=st!=="initSegment"?st:0,h.live||(ft.endList=!0),yt&&(h.startCC=yt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(T+=h.fragmentHint.duration),h.totalduration=T,h.endCC=x,N>0&&Ko(d,N),h},s}();function Hn(s,a,i){var e,t,r=new pe(s),o=(e=r.METHOD)!=null?e:"",u=r.URI,h=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,m=(t=r.KEYFORMAT)!=null?t:"identity";u&&r.IV&&!h&&k.error("Invalid IV: "+r.IV);var p=u?Lr.resolve(u,a):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new ko(o,p,m,y,h)}function Kn(s){var a=new pe(s),i=a.decimalFloatingPoint("TIME-OFFSET");return j(i)?i:null}function Ho(s,a){var i=(s||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return Fo(r,e)});t.length&&(a[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),a.unknownCodecs=i}function Wn(s,a,i){var e=a[i];e&&(s[i]=e)}function Ko(s,a){for(var i=s[a],e=a;e--;){var t=s[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function jn(s,a){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):a!=null&&a.programDateTime&&(s.programDateTime=a.endProgramDateTime),j(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function zn(s,a,i,e){s.relurl=a.URI,a.BYTERANGE&&s.setByteRange(a.BYTERANGE),s.level=i,s.sn="initSegment",e&&(s.levelkeys=e),s.initSegment=null}function Yn(s,a,i){s.levelkeys=a;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==a)&&Object.keys(a).some(function(t){return a[t].isCommonEncryption})&&e.push(s)}var Oe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Me={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function qn(s){var a=s.type;switch(a){case Oe.AUDIO_TRACK:return Me.AUDIO;case Oe.SUBTITLE_TRACK:return Me.SUBTITLE;default:return Me.MAIN}}function bi(s,a){var i=s.url;return(i===void 0||i.indexOf("data:")===0)&&(i=a.url),i}var Wo=function(){function s(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var a=s.prototype;return a.startLoad=function(e){},a.stopLoad=function(){this.destroyInternalLoaders()},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,o=t.loader,u=r||o,h=new u(t);return this.loaders[e.type]=h,h},a.getInternalLoader=function(e){return this.loaders[e.type]},a.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},a.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},a.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},a.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Oe.MANIFEST,url:r,deliveryDirectives:null})},a.onLevelLoading=function(e,t){var r=t.id,o=t.level,u=t.pathwayId,h=t.url,d=t.deliveryDirectives;this.load({id:r,level:o,pathwayId:u,responseType:"text",type:Oe.LEVEL,url:h,deliveryDirectives:d})},a.onAudioTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.AUDIO_TRACK,url:u,deliveryDirectives:h})},a.onSubtitleTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.SUBTITLE_TRACK,url:u,deliveryDirectives:h})},a.load=function(e){var t,r=this,o=this.hls.config,u=this.getInternalLoader(e);if(u){var h=u.context;if(h&&h.url===e.url&&h.level===e.level){k.trace("[playlist-loader]: playlist request ongoing");return}k.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}var d;if(e.type===Oe.MANIFEST?d=o.manifestLoadPolicy.default:d=C({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){var m;if(e.type===Oe.LEVEL&&e.level!==null?m=this.hls.levels[e.level].details:e.type===Oe.AUDIO_TRACK&&e.id!==null?m=this.hls.audioTracks[e.id].details:e.type===Oe.SUBTITLE_TRACK&&e.id!==null&&(m=this.hls.subtitleTracks[e.id].details),m){var p=m.partTarget,y=m.targetduration;if(p&&y){var T=Math.max(p*3,y*.8)*1e3;d=C({},d,{maxTimeToFirstByteMs:Math.min(T,d.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(T,d.maxTimeToFirstByteMs)})}}}var x=d.errorRetry||d.timeoutRetry||{},b={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:x.maxNumRetry||0,retryDelay:x.retryDelayMs||0,maxRetryDelay:x.maxRetryDelayMs||0},L={onSuccess:function(D,w,N,U){var $=r.getInternalLoader(N);r.resetInternalLoader(N.type);var V=D.data;if(V.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(D,N,new Error("no EXTM3U delimiter"),U||null,w);return}w.parsing.start=performance.now(),Lr.isMediaPlaylist(V)?r.handleTrackOrLevelPlaylist(D,w,N,U||null,$):r.handleMasterPlaylist(D,w,N,U)},onError:function(D,w,N,U){r.handleNetworkError(w,N,!1,D,U)},onTimeout:function(D,w,N){r.handleNetworkError(w,N,!0,void 0,D)}};u.load(e,b,L)},a.handleMasterPlaylist=function(e,t,r,o){var u=this.hls,h=e.data,d=bi(e,r),m=Lr.parseMasterPlaylist(h,d);if(m.playlistParsingError){this.handleManifestParsingError(e,r,m.playlistParsingError,o,t);return}var p=m.contentSteering,y=m.levels,T=m.sessionData,x=m.sessionKeys,b=m.startTimeOffset,L=m.variableList;this.variableList=L;var A=Lr.parseMasterPlaylistMedia(h,d,m),D=A.AUDIO,w=D===void 0?[]:D,N=A.SUBTITLES,U=A["CLOSED-CAPTIONS"];if(w.length){var $=w.some(function(V){return!V.url});!$&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(k.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new pe({}),bitrate:0,url:""}))}u.trigger(R.MANIFEST_LOADED,{levels:y,audioTracks:w,subtitles:N,captions:U,contentSteering:p,url:d,stats:t,networkDetails:o,sessionData:T,sessionKeys:x,startTimeOffset:b,variableList:L})},a.handleTrackOrLevelPlaylist=function(e,t,r,o,u){var h=this.hls,d=r.id,m=r.level,p=r.type,y=bi(e,r),T=0,x=j(m)?m:j(d)?d:0,b=qn(r),L=Lr.parseLevelPlaylist(e.data,y,x,b,T,this.variableList);if(p===Oe.MANIFEST){var A={attrs:new pe({}),bitrate:0,details:L,name:"",url:y};h.trigger(R.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:y,stats:t,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=L,this.handlePlaylistLoaded(L,e,t,r,o,u)},a.handleManifestParsingError=function(e,t,r,o,u){this.hls.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.MANIFEST_PARSING_ERROR,fatal:t.type===Oe.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:o,stats:u})},a.handleNetworkError=function(e,t,r,o,u){r===void 0&&(r=!1);var h="A network "+(r?"timeout":"error"+(o?" (status "+o.code+")":""))+" occurred while loading "+e.type;e.type===Oe.LEVEL?h+=": "+e.level+" id: "+e.id:(e.type===Oe.AUDIO_TRACK||e.type===Oe.SUBTITLE_TRACK)&&(h+=" id: "+e.id+' group-id: "'+e.groupId+'"');var d=new Error(h);k.warn("[playlist-loader]: "+h);var m=G.UNKNOWN,p=!1,y=this.getInternalLoader(e);switch(e.type){case Oe.MANIFEST:m=r?G.MANIFEST_LOAD_TIMEOUT:G.MANIFEST_LOAD_ERROR,p=!0;break;case Oe.LEVEL:m=r?G.LEVEL_LOAD_TIMEOUT:G.LEVEL_LOAD_ERROR,p=!1;break;case Oe.AUDIO_TRACK:m=r?G.AUDIO_TRACK_LOAD_TIMEOUT:G.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Oe.SUBTITLE_TRACK:m=r?G.SUBTITLE_TRACK_LOAD_TIMEOUT:G.SUBTITLE_LOAD_ERROR,p=!1;break}y&&this.resetInternalLoader(e.type);var T={type:le.NETWORK_ERROR,details:m,fatal:p,url:e.url,loader:y,context:e,error:d,networkDetails:t,stats:u};if(o){var x=t?.url||e.url;T.response=l({url:x,data:void 0},o)}this.hls.trigger(R.ERROR,T)},a.handlePlaylistLoaded=function(e,t,r,o,u,h){var d=this.hls,m=o.type,p=o.level,y=o.id,T=o.groupId,x=o.deliveryDirectives,b=bi(t,o),L=qn(o),A=typeof o.level=="number"&&L===Me.MAIN?p:void 0;if(!e.fragments.length){var D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:D,reason:D.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var w=e.playlistParsingError;if(w){d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:w,reason:w.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}switch(e.live&&h&&(h.getCacheAge&&(e.ageHeader=h.getCacheAge()||0),(!h.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),m){case Oe.MANIFEST:case Oe.LEVEL:d.trigger(R.LEVEL_LOADED,{details:e,level:A||0,id:y||0,stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break}},s}();function jo(s,a){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=s,a.dispatchEvent(i)}function zo(s){var a=s.mode;if(a==="disabled"&&(s.mode="hidden"),s.cues)for(var i=s.cues.length;i--;)s.removeCue(s.cues[i]);a==="disabled"&&(s.mode=a)}function Yo(s,a,i,e){var t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var r=Xo(s.cues,a,i),o=0;o<r.length;o++)(!e||e(r[o]))&&s.removeCue(r[o]);t==="disabled"&&(s.mode=t)}function qo(s,a){if(a<s[0].startTime)return 0;var i=s.length-1;if(a>s[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(a<s[r].startTime)t=r-1;else if(a>s[r].startTime&&e<i)e=r+1;else return r}return s[e].startTime-a<a-s[t].startTime?e:t}function Xo(s,a,i){var e=[],t=qo(s,a);if(t>-1)for(var r=t,o=s.length;r<o;r++){var u=s[r];if(u.startTime>=a&&u.endTime<=i)e.push(u);else if(u.startTime>i)return e}return e}var Rt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},$o=.25;function Li(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Xn(s,a,i,e,t){var r=new s(a,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new s(a,i,JSON.stringify(t?l({type:t},e):e))}return r}var Wr=function(){var s=Li();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Ai(s,a){return s.getTime()/1e3-a}function Qo(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Jo=function(){function s(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var a=s.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(e,t){this.media=t.media},a.onMediaDetaching=function(){this.id3Track&&(zo(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},a.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return jo(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,o=r.enableEmsgMetadataCues,u=r.enableID3MetadataCues;if(!(!o&&!u)){var h=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var d=Li();if(d)for(var m=0;m<h.length;m++){var p=h[m].type;if(!(p===Rt.emsg&&!o||!u)){var y=An(h[m].data);if(y){var T=h[m].pts,x=T+h[m].duration;x>Wr&&(x=Wr);var b=x-T;b<=0&&(x=T+$o);for(var L=0;L<y.length;L++){var A=y[L];if(!Ln(A)){this.updateId3CueEnds(T,p);var D=Xn(d,T,x,A,p);D&&this.id3Track.addCue(D)}}}}}}}},a.updateId3CueEnds=function(e,t){var r,o=(r=this.id3Track)==null?void 0:r.cues;if(o)for(var u=o.length;u--;){var h=o[u];h.type===t&&h.startTime<e&&h.endTime===Wr&&(h.endTime=e)}},a.onBufferFlushing=function(e,t){var r=t.startOffset,o=t.endOffset,u=t.type,h=this.id3Track,d=this.hls;if(d){var m=d.config,p=m.enableEmsgMetadataCues,y=m.enableID3MetadataCues;if(h&&(p||y)){var T;u==="audio"?T=function(b){return b.type===Rt.audioId3&&y}:u==="video"?T=function(b){return b.type===Rt.emsg&&p}:T=function(b){return b.type===Rt.audioId3&&y||b.type===Rt.emsg&&p},Yo(h,r,o,T)}}},a.onLevelUpdated=function(e,t){var r=this,o=t.details;if(!(!this.media||!o.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,h=this.id3Track,d=o.dateRanges,m=Object.keys(d);if(h)for(var p=Object.keys(u).filter(function(w){return!m.includes(w)}),y=function(){var N=p[T];Object.keys(u[N].cues).forEach(function(U){h.removeCue(u[N].cues[U])}),delete u[N]},T=p.length;T--;)y();var x=o.fragments[o.fragments.length-1];if(!(m.length===0||!j(x?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var b=x.programDateTime/1e3-x.start,L=Li(),A=function(){var N=m[D],U=d[N],$=Ai(U.startDate,b),V=u[N],M=V?.cues||{},K=V?.durationKnown||!1,z=Wr,te=U.endDate;if(te)z=Ai(te,b),K=!0;else if(U.endOnNext&&!K){var Z=m.reduce(function(Ae,ye){if(ye!==U.id){var je=d[ye];if(je.class===U.class&&je.startDate>U.startDate&&(!Ae||U.startDate<Ae.startDate))return je}return Ae},null);Z&&(z=Ai(Z.startDate,b),K=!0)}for(var ie=Object.keys(U.attr),he=0;he<ie.length;he++){var fe=ie[he];if(Ne(fe)){var Le=M[fe];if(Le)K&&!V.durationKnown&&(Le.endTime=z);else if(L){var Ee=U.attr[fe];Qe(fe)&&(Ee=Qo(Ee));var we=Xn(L,$,z,{key:fe,data:Ee},Rt.dateRange);we&&(we.id=N,r.id3Track.addCue(we),M[fe]=we)}}}u[N]={cues:M,dateRange:U,durationKnown:K}},D=0;D<m.length;D++)A()}}},s}(),Zo=function(){function s(i){var e=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 e.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var a=s.prototype;return a.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)},a.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},a.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},a.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},a.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)},a.onError=function(e,t){var r;t.details===G.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&k.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},a.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var o=this.config,u=o.lowLatencyMode,h=o.maxLiveSyncPlaybackRate;if(!(!u||h===1||!t.live)){var d=this.targetLatency;if(d!==null){var m=r-d,p=Math.min(this.maxLatency,d+t.targetduration),y=m<p;if(y&&m>.05&&this.forwardBufferLength>1){var T=Math.min(2,Math.max(1,h)),x=Math.round(2/(1+Math.exp(-.75*m-this.edgeStalled))*20)/20;e.playbackRate=Math.min(T,Math.max(1,x))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},a.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},a.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},_(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,o=e.targetduration,u=this.config,h=u.liveSyncDuration,d=u.liveSyncDurationCount,m=u.lowLatencyMode,p=this.hls.userConfig,y=m&&r||t;(p.liveSyncDuration||p.liveSyncDurationCount||y===0)&&(y=h!==void 0?h:d*o);var T=o,x=1;return y+Math.min(this.stallCount*x,T)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var o=r.edge,u=e-t-this.edgeStalled,h=o-r.totalduration,d=o-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(h,u),d)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;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}}]),s}(),Ri=["NONE","TYPE-0","TYPE-1",null];function eu(s){return Ri.indexOf(s)>-1}var jr=["SDR","PQ","HLG"];function tu(s){return!!s&&jr.indexOf(s)>-1}var zr={No:"",Yes:"YES",v2:"v2"};function $n(s){var a=s.canSkipUntil,i=s.canSkipDateRanges,e=s.age,t=e<a/2;return a&&t?i?zr.v2:zr.Yes:zr.No}var Qn=function(){function s(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var a=s.prototype;return a.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},s}(),Ci=function(){function s(i){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=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var a=s.prototype;return a.hasAudioGroup=function(e){return Jn(this._audioGroups,e)},a.hasSubtitleGroup=function(e){return Jn(this._subtitleGroups,e)},a.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var o=this._subtitleGroups;o||(o=this._subtitleGroups=[]),o.indexOf(t)===-1&&o.push(t)}}},a.addFallback=function(){},_(s,[{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(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),s}();function Jn(s,a){return!a||!s?!1:s.indexOf(a)!==-1}function Di(s,a){var i=a.startPTS;if(j(i)){var e=0,t;a.sn>s.sn?(e=i-s.start,t=s):(e=s.start-i,t=a),t.duration!==e&&(t.duration=e)}else if(a.sn>s.sn){var r=s.cc===a.cc;r&&s.minEndPTS?a.start=s.start+(s.minEndPTS-s.start):a.start=s.start+s.duration}else a.start=Math.max(s.start-a.duration,0)}function Zn(s,a,i,e,t,r){var o=e-i;o<=0&&(k.warn("Fragment should have a positive duration",a),e=i+a.duration,r=t+a.duration);var u=i,h=e,d=a.startPTS,m=a.endPTS;if(j(d)){var p=Math.abs(d-i);j(a.deltaPTS)?a.deltaPTS=Math.max(p,a.deltaPTS):a.deltaPTS=p,u=Math.max(i,d),i=Math.min(i,d),t=Math.min(t,a.startDTS),h=Math.min(e,m),e=Math.max(e,m),r=Math.max(r,a.endDTS)}var y=i-a.start;a.start!==0&&(a.start=i),a.duration=e-a.start,a.startPTS=i,a.maxStartPTS=u,a.startDTS=t,a.endPTS=e,a.minEndPTS=h,a.endDTS=r;var T=a.sn;if(!s||T<s.startSN||T>s.endSN)return 0;var x,b=T-s.startSN,L=s.fragments;for(L[b]=a,x=b;x>0;x--)Di(L[x],L[x-1]);for(x=b;x<L.length-1;x++)Di(L[x],L[x+1]);return s.fragmentHint&&Di(L[L.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,y}function ru(s,a){for(var i=null,e=s.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var o=0,u;if(au(s,a,function(x,b){x.relurl&&(o=x.cc-b.cc),j(x.startPTS)&&j(x.endPTS)&&(b.start=b.startPTS=x.startPTS,b.startDTS=x.startDTS,b.maxStartPTS=x.maxStartPTS,b.endPTS=x.endPTS,b.endDTS=x.endDTS,b.minEndPTS=x.minEndPTS,b.duration=x.endPTS-x.startPTS,b.duration&&(u=b),a.PTSKnown=a.alignedSliding=!0),b.elementaryStreams=x.elementaryStreams,b.loader=x.loader,b.stats=x.stats,x.initSegment&&(b.initSegment=x.initSegment,i=x.initSegment)}),i){var h=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;h.forEach(function(x){var b;x&&(!x.initSegment||x.initSegment.relurl===((b=i)==null?void 0:b.relurl))&&(x.initSegment=i)})}if(a.skippedSegments)if(a.deltaUpdateFailed=a.fragments.some(function(x){return!x}),a.deltaUpdateFailed){k.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=a.skippedSegments;d--;)a.fragments.shift();a.startSN=a.fragments[0].sn,a.startCC=a.fragments[0].cc}else a.canSkipDateRanges&&(a.dateRanges=iu(s.dateRanges,a.dateRanges,a.recentlyRemovedDateranges));var m=a.fragments;if(o){k.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<m.length;p++)m[p].cc+=o}a.skippedSegments&&(a.startCC=a.fragments[0].cc),nu(s.partList,a.partList,function(x,b){b.elementaryStreams=x.elementaryStreams,b.stats=x.stats}),u?Zn(a,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):ea(s,a),m.length&&(a.totalduration=a.edge-m[0].start),a.driftStartTime=s.driftStartTime,a.driftStart=s.driftStart;var y=a.advancedDateTime;if(a.advanced&&y){var T=a.edge;a.driftStart||(a.driftStartTime=y,a.driftStart=T),a.driftEndTime=y,a.driftEnd=T}else a.driftEndTime=s.driftEndTime,a.driftEnd=s.driftEnd,a.advancedDateTime=s.advancedDateTime}function iu(s,a,i){var e=C({},s);return i&&i.forEach(function(t){delete e[t]}),Object.keys(a).forEach(function(t){var r=new ke(a[t].attr,e[t]);r.isValid?e[t]=r:k.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(a[t].attr)+'"')}),e}function nu(s,a,i){if(s&&a)for(var e=0,t=0,r=s.length;t<=r;t++){var o=s[t],u=a[t+e];o&&u&&o.index===u.index&&o.fragment.sn===u.fragment.sn?i(o,u):e--}}function au(s,a,i){for(var e=a.skippedSegments,t=Math.max(s.startSN,a.startSN)-a.startSN,r=(s.fragmentHint?1:0)+(e?a.endSN:Math.min(s.endSN,a.endSN))-a.startSN,o=a.startSN-s.startSN,u=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,h=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,d=t;d<=r;d++){var m=h[o+d],p=u[d];e&&!p&&d<e&&(p=a.fragments[d]=m),m&&p&&i(m,p)}}function ea(s,a){var i=a.startSN+a.skippedSegments-s.startSN,e=s.fragments;i<0||i>=e.length||su(a,e[i].start)}function su(s,a){if(a){for(var i=s.fragments,e=s.skippedSegments;e<i.length;e++)i[e].start+=a;s.fragmentHint&&(s.fragmentHint.start+=a)}}function ou(s,a){a===void 0&&(a=1/0);var i=1e3*s.targetduration;if(s.updated){var e=s.fragments,t=4;if(e.length&&i*t>a){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function uu(s,a,i){if(!(s!=null&&s.details))return null;var e=s.details,t=e.fragments[a-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===a)?t:a<e.startSN&&i&&i.sn===a?i:null}function ta(s,a,i){var e;return s!=null&&s.details?ra((e=s.details)==null?void 0:e.partList,a,i):null}function ra(s,a,i){if(s)for(var e=s.length;e--;){var t=s[e];if(t.index===i&&t.fragment.sn===a)return t}return null}function ia(s){s.forEach(function(a,i){var e=a.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function Yr(s){switch(s.details){case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_TIMEOUT:case G.LEVEL_LOAD_TIMEOUT:case G.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function na(s,a){var i=Yr(a);return s.default[(i?"timeout":"error")+"Retry"]}function wi(s,a){var i=s.backoff==="linear"?1:Math.pow(2,a);return Math.min(i*s.retryDelayMs,s.maxRetryDelayMs)}function aa(s){return l(l({},s),{errorRetry:null,timeoutRetry:null})}function qr(s,a,i,e){if(!s)return!1;var t=e?.code,r=a<s.maxNumRetry&&(lu(t)||!!i);return s.shouldRetry?s.shouldRetry(s,a,i,e,r):r}function lu(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}var sa={search:function(a,i){for(var e=0,t=a.length-1,r=null,o=null;e<=t;){r=(e+t)/2|0,o=a[r];var u=i(o);if(u>0)e=r+1;else if(u<0)t=r-1;else return o}return null}};function fu(s,a,i){if(a===null||!Array.isArray(s)||!s.length||!j(a))return null;var e=s[0].programDateTime;if(a<(e||0))return null;var t=s[s.length-1].endProgramDateTime;if(a>=(t||0))return null;i=i||0;for(var r=0;r<s.length;++r){var o=s[r];if(du(a,i,o))return o}return null}function oa(s,a,i,e,t){i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=.005);var r=null;if(s){r=a[s.sn-a[0].sn+1]||null;var o=s.endDTS-i;o>0&&o<15e-7&&(i+=15e-7)}else i===0&&a[0].start===0&&(r=a[0]);if(r&&((!s||s.level===r.level)&&ua(i,e,r)===0||hu(r,s,Math.min(t,e))))return r;var u=sa.search(a,ua.bind(null,i,e));return u&&(u!==s||!r)?u:r}function hu(s,a,i){if(a&&a.start===0&&a.level<s.level&&(a.endPTS||0)>0){var e=a.tagList.reduce(function(t,r){return r[0]==="INF"&&(t+=parseFloat(r[1])),t},i);return s.start<=e}return!1}function ua(s,a,i){if(s===void 0&&(s=0),a===void 0&&(a=0),i.start<=s&&i.start+i.duration>s)return 0;var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=s?1:i.start-e>s&&i.start?-1:0}function du(s,a,i){var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>s}function cu(s,a){return sa.search(s,function(i){return i.cc<a?1:i.cc>a?-1:0})}var ot={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ct={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},vu=function(){function s(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=k.log.bind(k,"[info]:"),this.warn=k.warn.bind(k,"[warning]:"),this.error=k.error.bind(k,"[error]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))},a.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},a.startLoad=function(e){},a.stopLoad=function(){this.playlistError=0},a.getVariantLevelIndex=function(e){return e?.type===Me.MAIN?e.level:this.hls.loadLevel},a.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},a.onLevelUpdated=function(){this.playlistError=0},a.onError=function(e,t){var r,o;if(!t.fatal){var u=this.hls,h=t.context;switch(t.details){case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case G.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ot.DoNothing,flags:Ct.None};return}case G.FRAG_GAP:case G.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ot.SendAlternateToPenaltyBox;return}case G.LEVEL_EMPTY_ERROR:case G.LEVEL_PARSING_ERROR:{var d,m,p=t.parent===Me.MAIN?t.level:u.loadLevel;t.details===G.LEVEL_EMPTY_ERROR&&((d=t.context)!=null&&(m=d.levelDetails)!=null&&m.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,p):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p))}return;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:typeof h?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,h.level));return;case G.AUDIO_TRACK_LOAD_ERROR:case G.AUDIO_TRACK_LOAD_TIMEOUT:case G.SUBTITLE_LOAD_ERROR:case G.SUBTITLE_TRACK_LOAD_TIMEOUT:if(h){var y=u.levels[u.loadLevel];if(y&&(h.type===Oe.AUDIO_TRACK&&y.hasAudioGroup(h.groupId)||h.type===Oe.SUBTITLE_TRACK&&y.hasSubtitleGroup(h.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u.loadLevel),t.errorAction.action=ot.SendAlternateToPenaltyBox,t.errorAction.flags=Ct.MoveAllAlternatesMatchingHost;return}}return;case G.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var T=u.levels[u.loadLevel],x=T?.attrs["HDCP-LEVEL"];x?t.errorAction={action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHDCP,hdcpLevel:x}:this.keySystemError(t)}return;case G.BUFFER_ADD_CODEC_ERROR:case G.REMUX_ALLOC_ERROR:case G.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:u.loadLevel);return;case G.INTERNAL_EXCEPTION:case G.BUFFER_APPENDING_ERROR:case G.BUFFER_FULL_ERROR:case G.LEVEL_SWITCH_ERROR:case G.BUFFER_STALLED_ERROR:case G.BUFFER_SEEK_OVER_HOLE:case G.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ot.DoNothing,flags:Ct.None};return}t.type===le.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},a.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},a.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,o=na(r.config.playlistLoadPolicy,e),u=this.playlistError++,h=qr(o,u,Yr(e),e.response);if(h)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:o,retryCount:u};var d=this.getLevelSwitchAction(e,t);return o&&(d.retryConfig=o,d.retryCount=u),d},a.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),o=t.levels[r],u=t.config,h=u.fragLoadPolicy,d=u.keyLoadPolicy,m=na(e.details.startsWith("key")?d:h,e),p=t.levels.reduce(function(x,b){return x+b.fragmentError},0);if(o){e.details!==G.FRAG_GAP&&o.fragmentError++;var y=qr(m,p,Yr(e),e.response);if(y)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:m,retryCount:p}}var T=this.getLevelSwitchAction(e,r);return m&&(T.retryConfig=m,T.retryCount=p),T},a.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var o=this.hls.levels[t];if(o){var u,h,d=e.details;o.loadError++,d===G.BUFFER_APPEND_ERROR&&o.fragmentError++;var m=-1,p=r.levels,y=r.loadLevel,T=r.minAutoLevel,x=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var b=(u=e.frag)==null?void 0:u.type,L=b===Me.AUDIO&&d===G.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),A=L&&p.some(function(z){var te=z.audioCodec;return o.audioCodec!==te}),D=e.sourceBufferName==="video"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),w=D&&p.some(function(z){var te=z.codecSet,Z=z.audioCodec;return o.codecSet!==te&&o.audioCodec===Z}),N=(h=e.context)!=null?h:{},U=N.type,$=N.groupId,V=function(){var te=(K+y)%p.length;if(te!==y&&te>=T&&te<=x&&p[te].loadError===0){var Z,ie,he=p[te];if(d===G.FRAG_GAP&&b===Me.MAIN&&e.frag){var fe=p[te].details;if(fe){var Le=oa(e.frag,fe.fragments,e.frag.start);if(Le!=null&&Le.gap)return 0}}else{if(U===Oe.AUDIO_TRACK&&he.hasAudioGroup($)||U===Oe.SUBTITLE_TRACK&&he.hasSubtitleGroup($))return 0;if(b===Me.AUDIO&&(Z=o.audioGroups)!=null&&Z.some(function(Ee){return he.hasAudioGroup(Ee)})||b===Me.SUBTITLE&&(ie=o.subtitleGroups)!=null&&ie.some(function(Ee){return he.hasSubtitleGroup(Ee)})||A&&o.audioCodec===he.audioCodec||!A&&o.audioCodec!==he.audioCodec||w&&o.codecSet===he.codecSet)return 0}return m=te,1}},M,K=p.length;K--&&(M=V(),!(M!==0&&M===1)););if(m>-1&&r.loadLevel!==m)return e.levelRetry=!0,this.playlistError=0,{action:ot.SendAlternateToPenaltyBox,flags:Ct.None,nextAutoLevel:m}}return{action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHost}},a.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ot.DoNothing:break;case ot.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==G.FRAG_GAP?t.fatal=!0:/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());break}if(t.fatal){this.hls.stopLoad();return}},a.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var o=r.flags,u=r.hdcpLevel,h=r.nextAutoLevel;switch(o){case Ct.None:this.switchLevel(e,h);break;case Ct.MoveAllAlternatesMatchingHDCP:u&&(t.maxHdcpLevel=Ri[Ri.indexOf(u)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,h)}},a.switchLevel=function(e,t){t!==void 0&&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)},s}(),pu=function(){function s(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=k.log.bind(k,e+":"),this.warn=k.warn.bind(k,e+":"),this.hls=i}var a=s.prototype;return a.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},a.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},a.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},a.stopLoad=function(){this.canLoad=!1,this.clearTimer()},a.switchParams=function(e,t,r){var o=t?.renditionReports;if(o){for(var u=-1,h=0;h<o.length;h++){var d=o[h],m=void 0;try{m=new self.URL(d.URI,t.url).href}catch(L){k.warn("Could not construct new URL for Rendition Report: "+L),m=d.URI||""}if(m===e){u=h;break}else m===e.substring(0,m.length)&&(u=h)}if(u!==-1){var p=o[u],y=parseInt(p["LAST-MSN"])||t?.lastPartSn,T=parseInt(p["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var x=Math.min(t.age-t.partTarget,t.targetduration);T>=0&&x>t.partTarget&&(T+=1)}var b=r&&$n(r);return new Qn(y,T>=0?T:void 0,b)}}},a.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},a.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},a.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},a.playlistLoaded=function(e,t,r){var o=this,u=t.details,h=t.stats,d=self.performance.now(),m=h.loading.first?Math.max(0,d-h.loading.first):0;if(u.advancedDateTime=Date.now()-m,u.live||r!=null&&r.live){if(u.reloaded(r),r&&this.log("live playlist "+e+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:u.updated?"UPDATED":"MISSED")),r&&u.fragments.length>0&&ru(r,u),!this.canLoad||!u.live)return;var p,y=void 0,T=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var x=this.hls.config.lowLatencyMode,b=u.lastPartSn,L=u.endSN,A=u.lastPartIndex,D=A!==-1,w=b===L,N=x?0:A;D?(y=w?L+1:b,T=w?N:A+1):y=L+1;var U=u.age,$=U+u.ageHeader,V=Math.min($-u.partTarget,u.targetduration*1.5);if(V>0){if(r&&V>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+V+" with playlist age: "+u.age),V=0;else{var M=Math.floor(V/u.targetduration);if(y+=M,T!==void 0){var K=Math.round(V%u.targetduration/u.partTarget);T+=K}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+U.toFixed(2)+"s goal: "+V+" skip sn "+M+" to part "+T)}u.tuneInGoal=V}if(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T),x||!w){this.loadPlaylist(p);return}}else(u.canBlockReload||u.canSkipUntil)&&(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T));var z=this.hls.mainForwardBufferInfo,te=z?z.end-z.len:0,Z=(u.edge-te)*1e3,ie=ou(u,Z);u.updated&&d>this.requestScheduled+ie&&(this.requestScheduled=h.loading.start),y!==void 0&&u.canBlockReload?this.requestScheduled=h.loading.first+ie-(u.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+ie<d?this.requestScheduled=d:this.requestScheduled-d<=0&&(this.requestScheduled+=ie);var he=this.requestScheduled-d;he=Math.max(0,he),this.log("reload live playlist "+e+" in "+Math.round(he)+" ms"),this.timer=self.setTimeout(function(){return o.loadPlaylist(p)},he)}else this.clearTimer()},a.getDeliveryDirectives=function(e,t,r,o){var u=$n(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,o=t.part,u=zr.No),new Qn(r,o,u)},a.checkRetry=function(e){var t=this,r=e.details,o=Yr(e),u=e.errorAction,h=u||{},d=h.action,m=h.retryCount,p=m===void 0?0:m,y=h.retryConfig,T=!!u&&!!y&&(d===ot.RetryRequest||!u.resolved&&d===ot.SendAlternateToPenaltyBox);if(T){var x;if(this.requestScheduled=-1,p>=y.maxNumRetry)return!1;if(o&&(x=e.context)!=null&&x.deliveryDirectives)this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var b=wi(y,p);this.timer=self.setTimeout(function(){return t.loadPlaylist()},b),this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" in '+b+"ms")}e.levelRetry=!0,u.resolved=!0}return T},s}(),cr=function(){function s(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var a=s.prototype;return a.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},a.getTotalWeight=function(){return this.totalWeight_},a.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),mu=function(){function s(i,e,t,r){r===void 0&&(r=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_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new cr(i),this.fast_=new cr(e),this.defaultTTFB_=r,this.ttfb_=new cr(i)}var a=s.prototype;return a.update=function(e,t){var r=this.slow_,o=this.fast_,u=this.ttfb_;r.halfLife!==e&&(this.slow_=new cr(e,r.getEstimate(),r.getTotalWeight())),o.halfLife!==t&&(this.fast_=new cr(t,o.getEstimate(),o.getTotalWeight())),u.halfLife!==e&&(this.ttfb_=new cr(e,u.getEstimate(),u.getTotalWeight()))},a.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,o=e/1e3,u=r/o;this.fast_.sample(o,u),this.slow_.sample(o,u)},a.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))},a.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},a.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},a.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},a.destroy=function(){},s}();function gu(){if(typeof matchMedia=="function"){var s=matchMedia("(dynamic-range: high)"),a=matchMedia("bad query");if(s.media!==a.media)return s.matches===!0}return!1}function yu(s,a){var i=!1,e=[];return s&&(i=s!=="SDR",e=[s]),a&&(e=a.allowedVideoRanges||jr.slice(0),i=a.preferHDR!==void 0?a.preferHDR:gu(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function Eu(s,a,i,e,t){for(var r=Object.keys(s),o=e?.channels,u=e?.audioCodec,h=o&&parseInt(o)===2,d=!0,m=!1,p=1/0,y=1/0,T=1/0,x=0,b=[],L=yu(a,t),A=L.preferHDR,D=L.allowedVideoRanges,w=function(){var K=s[r[N]];d=K.channels[2]>0,p=Math.min(p,K.minHeight),y=Math.min(y,K.minFramerate),T=Math.min(T,K.minBitrate);var z=D.filter(function(te){return K.videoRanges[te]>0});z.length>0&&(m=!0,b=z)},N=r.length;N--;)w();p=j(p)?p:0,y=j(y)?y:0;var U=Math.max(1080,p),$=Math.max(30,y);T=j(T)?T:i,i=Math.max(T,i),m||(a=void 0,b=[]);var V=r.reduce(function(M,K){var z=s[K];if(K===M)return M;if(z.minBitrate>i)return Ht(K,"min bitrate of "+z.minBitrate+" > current estimate of "+i),M;if(!z.hasDefaultAudio)return Ht(K,"no renditions with default or auto-select sound found"),M;if(u&&K.indexOf(u.substring(0,4))%5!==0)return Ht(K,'audio codec preference "'+u+'" not found'),M;if(o&&!h){if(!z.channels[o])return Ht(K,"no renditions with "+o+" channel sound found (channels options: "+Object.keys(z.channels)+")"),M}else if((!u||h)&&d&&z.channels[2]===0)return Ht(K,"no renditions with stereo sound found"),M;return z.minHeight>U?(Ht(K,"min resolution of "+z.minHeight+" > maximum of "+U),M):z.minFramerate>$?(Ht(K,"min framerate of "+z.minFramerate+" > maximum of "+$),M):b.some(function(te){return z.videoRanges[te]>0})?z.maxScore<x?(Ht(K,"max score of "+z.maxScore+" < selected max of "+x),M):M&&(Hr(K)>=Hr(M)||z.fragmentError>s[M].fragmentError)?M:(x=z.maxScore,K):(Ht(K,"no variants with VIDEO-RANGE of "+JSON.stringify(b)+" found"),M)},void 0);return{codecSet:V,videoRanges:b,preferHDR:A,minFramerate:y,minBitrate:T}}function Ht(s,a){k.log('[abr] start candidates with "'+s+'" ignored because '+a)}function _u(s){return s.reduce(function(a,i){var e=a.groups[i.groupId];e||(e=a.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(a.hasDefaultAudio=!0),e.hasAutoSelect&&(a.hasAutoSelectAudio=!0),a},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Su(s,a,i,e){return s.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var o=r.audioGroups,u=t[r.codecSet];u||(t[r.codecSet]=u={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),u.minBitrate=Math.min(u.minBitrate,r.bitrate);var h=Math.min(r.height,r.width);return u.minHeight=Math.min(u.minHeight,h),u.minFramerate=Math.min(u.minFramerate,r.frameRate),u.maxScore=Math.max(u.maxScore,r.score),u.fragmentError+=r.fragmentError,u.videoRanges[r.videoRange]=(u.videoRanges[r.videoRange]||0)+1,t},{})}var Tu=function(){function s(i){var e=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 t=e.fragCurrent,r=e.partCurrent,o=e.hls,u=o.autoLevelEnabled,h=o.media;if(!(!t||!h)){var d=performance.now(),m=r?r.stats:t.stats,p=r?r.duration:t.duration,y=d-m.loading.start,T=o.minAutoLevel;if(m.aborted||m.loaded&&m.loaded===m.total||t.level<=T){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!u||h.paused||!h.playbackRate||!h.readyState)){var x=o.mainForwardBufferInfo;if(x!==null){var b=e.bwEstimator.getEstimateTTFB(),L=Math.abs(h.playbackRate);if(!(y<=Math.max(b,1e3*(p/(L*2))))){var A=x.len/L,D=m.loading.first?m.loading.first-m.loading.start:-1,w=m.loaded&&D>-1,N=e.getBwEstimate(),U=o.levels,$=U[t.level],V=m.total||Math.max(m.loaded,Math.round(p*$.averageBitrate/8)),M=w?y-D:y;M<1&&w&&(M=Math.min(y,m.loaded*8/N));var K=w?m.loaded*1e3/M:0,z=K?(V-m.loaded)/K:V*8/N+b/1e3;if(!(z<=A)){var te=K?K*8:N,Z=Number.POSITIVE_INFINITY,ie;for(ie=t.level-1;ie>T;ie--){var he=U[ie].maxBitrate;if(Z=e.getTimeToLoadFrag(b/1e3,te,p*he,!U[ie].details),Z<A)break}if(!(Z>=z)&&!(Z>p*10)){o.nextLoadLevel=o.nextAutoLevel=ie,w?e.bwEstimator.sample(y-Math.min(b,D),m.loaded):e.bwEstimator.sampleTTFB(y);var fe=U[ie].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>fe&&e.resetEstimator(fe),e.clearTimer(),k.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
3
- Time to underbuffer: `+A.toFixed(3)+` s
4
- Estimated load time for current fragment: `+z.toFixed(3)+` s
5
- Estimated load time for down switch fragment: `+Z.toFixed(3)+` s
6
- TTFB estimate: `+(D|0)+` ms
7
- Current BW estimate: `+(j(N)?N|0:"Unknown")+` bps
8
- New BW estimate: `+(e.getBwEstimate()|0)+` bps
9
- Switching to level `+ie+" @ "+(fe|0)+" bps"),o.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:m})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var a=s.prototype;return a.resetEstimator=function(e){e&&(k.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},a.initEstimator=function(){var e=this.hls.config;return new mu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(R.ERROR,this.onError,this))},a.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},a.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},a.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},a.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},a.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var o;this.fragCurrent=r,this.partCurrent=(o=t.part)!=null?o:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},a.onLevelSwitching=function(e,t){this.clearTimer()},a.onError=function(e,t){if(!t.fatal)switch(t.details){case G.BUFFER_ADD_CODEC_ERROR:case G.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case G.FRAG_LOAD_TIMEOUT:{var r=t.frag,o=this.fragCurrent,u=this.partCurrent;if(r&&o&&r.sn===o.sn&&r.level===o.level){var h=performance.now(),d=u?u.stats:r.stats,m=h-d.loading.start,p=d.loading.first?d.loading.first-d.loading.start:-1,y=d.loaded&&p>-1;if(y){var T=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(m-Math.min(T,p),d.loaded)}else this.bwEstimator.sampleTTFB(m)}break}}},a.getTimeToLoadFrag=function(e,t,r,o){var u=e+r/t,h=o?this.lastLevelLoadSec:0;return u+h},a.onLevelLoaded=function(e,t){var r=this.hls.config,o=t.stats.loading,u=o.end-o.start;j(u)&&(this.lastLevelLoadSec=u/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part,u=o?o.stats:r.stats;if(r.type===Me.MAIN&&this.bwEstimator.sampleTTFB(u.loading.first-u.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var h=o?o.duration:r.duration,d=this.hls.levels[r.level],m=(d.loaded?d.loaded.bytes:0)+u.loaded,p=(d.loaded?d.loaded.duration:0)+h;d.loaded={bytes:m,duration:p},d.realBitrate=Math.round(8*m/p)}if(r.bitrateTest){var y={stats:u,frag:r,part:o,id:r.type};this.onFragBuffered(R.FRAG_BUFFERED,y),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},a.onFragBuffered=function(e,t){var r=t.frag,o=t.part,u=o!=null&&o.stats.loaded?o.stats:r.stats;if(!u.aborted&&!this.ignoreFragment(r)){var h=u.parsing.end-u.loading.start-Math.min(u.loading.first-u.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(h,u.loaded),u.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=h/1e3:this.bitrateTestDelay=0}},a.ignoreFragment=function(e){return e.type!==Me.MAIN||e.sn==="initSegment"},a.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},a.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},a.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,o=r.maxAutoLevel,u=r.config,h=r.minAutoLevel,d=t?t.duration:e?e.duration:0,m=this.getBwEstimate(),p=this.getStarvationDelay(),y=u.abrBandWidthFactor,T=u.abrBandWidthUpFactor;if(p){var x=this.findBestLevel(m,h,o,p,0,y,T);if(x>=0)return x}var b=d?Math.min(d,u.maxStarvationDelay):u.maxStarvationDelay;if(!p){var L=this.bitrateTestDelay;if(L){var A=d?Math.min(d,u.maxLoadingDelay):u.maxLoadingDelay;b=A-L,k.info("[abr] bitrate test took "+Math.round(1e3*L)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),y=T=1}}var D=this.findBestLevel(m,h,o,p,b,y,T);if(k.info("[abr] "+(p?"rebuffering expected":"buffer is empty")+", optimal quality level "+D),D>-1)return D;var w=r.levels[h],N=r.levels[r.loadLevel];return w?.bitrate<N?.bitrate?h:r.loadLevel},a.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,o=e.mainForwardBufferInfo;return(o?o.len:0)/r},a.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},a.findBestLevel=function(e,t,r,o,u,h,d){var m,p=this,y=o+u,T=this.lastLoadedFragLevel,x=T===-1?this.hls.firstLevel:T,b=this.fragCurrent,L=this.partCurrent,A=this.hls,D=A.levels,w=A.allAudioTracks,N=A.loadLevel,U=A.config;if(D.length===1)return 0;var $=D[x],V=!!($!=null&&(m=$.details)!=null&&m.live),M=N===-1||T===-1,K,z="SDR",te=$?.frameRate||0,Z=U.audioPreference,ie=U.videoPreference,he=this.audioTracksByGroup||(this.audioTracksByGroup=_u(w));if(M){if(this.firstSelection!==-1)return this.firstSelection;var fe=this.codecTiers||(this.codecTiers=Su(D,he,t,r)),Le=Eu(fe,z,e,Z,ie),Ee=Le.codecSet,we=Le.videoRanges,Ae=Le.minFramerate,ye=Le.minBitrate,je=Le.preferHDR;K=Ee,z=je?we[we.length-1]:we[0],te=Ae,e=Math.max(e,ye),k.log("[abr] picked start tier "+JSON.stringify(Le))}else K=$?.codecSet,z=$?.videoRange;for(var Fe=L?L.duration:b?b.duration:0,qe=this.bwEstimator.getEstimateTTFB()/1e3,Xe=[],Ze=function(){var _t,$e=D[Ue],ct=Ue>x;if(!$e)return 0;if(K&&$e.codecSet!==K||z&&$e.videoRange!==z||ct&&te>$e.frameRate||!ct&&te>0&&te<$e.frameRate||$e.supportedResult&&!((_t=$e.supportedResult.decodingInfoResults)!=null&&_t[0].smooth))return Xe.push(Ue),0;var vt=$e.details,et=(L?vt?.partTarget:vt?.averagetargetduration)||Fe,Ke;ct?Ke=d*e:Ke=h*e;var yt=Fe&&o>=Fe*2&&u===0?D[Ue].averageBitrate:D[Ue].maxBitrate,ft=p.getTimeToLoadFrag(qe,Ke,yt*et,vt===void 0),st=Ke>=yt&&(Ue===T||$e.loadError===0&&$e.fragmentError===0)&&(ft<=qe||!j(ft)||V&&!p.bitrateTestDelay||ft<y);if(st){var or=p.forcedAutoLevel;return Ue!==N&&(or===-1||or!==N)&&(Xe.length&&k.trace("[abr] Skipped level(s) "+Xe.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+D[Xe[0]].codecs+'" '+D[Xe[0]].videoRange+'; not compatible with "'+$.codecs+'" '+z),k.info("[abr] switch candidate:"+x+"->"+Ue+" adjustedbw("+Math.round(Ke)+")-bitrate="+Math.round(Ke-yt)+" ttfb:"+qe.toFixed(1)+" avgDuration:"+et.toFixed(1)+" maxFetchDuration:"+y.toFixed(1)+" fetchDuration:"+ft.toFixed(1)+" firstSelection:"+M+" codecSet:"+K+" videoRange:"+z+" hls.loadLevel:"+N)),M&&(p.firstSelection=Ue),{v:Ue}}},ze,Ue=r;Ue>=t;Ue--)if(ze=Ze(),ze!==0&&ze)return ze.v;return-1},_(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,o=this.getBwEstimate(),u=this.hls.config.maxStarvationDelay,h=this.findBestLevel(o,r,t,0,u,1,1);if(h>-1)return h;var d=this.hls.firstLevel,m=Math.min(Math.max(d,r),t);return k.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+d+" clamped to "+m),m}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),o=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!o||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var u=r&&o?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var h=this.hls.levels;if(h.length>Math.max(e,u)&&h[e].loadError<=h[u].loadError)return e}return this._nextAutoLevel=u,this.nextAutoLevelKey=this.getAutoLevelKey(),u},set:function(e){var t=this.hls,r=t.maxAutoLevel,o=t.minAutoLevel,u=Math.min(Math.max(e,o),r);this._nextAutoLevel!==u&&(this.nextAutoLevelKey="",this._nextAutoLevel=u)}}]),s}(),xu={length:0,start:function(){return 0},end:function(){return 0}},rt=function(){function s(){}return s.isBuffered=function(i,e){try{if(i){for(var t=s.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(i,e,t){try{if(i){var r=s.getBuffered(i),o=[],u;for(u=0;u<r.length;u++)o.push({start:r.start(u),end:r.end(u)});return this.bufferedInfo(o,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(L,A){var D=L.start-A.start;return D||A.end-L.end});var r=[];if(t)for(var o=0;o<i.length;o++){var u=r.length;if(u){var h=r[u-1].end;i[o].start-h<t?i[o].end>h&&(r[u-1].end=i[o].end):r.push(i[o])}else r.push(i[o])}else r=i;for(var d=0,m,p=e,y=e,T=0;T<r.length;T++){var x=r[T].start,b=r[T].end;if(e+t>=x&&e<b)p=x,y=b,d=y-e;else if(e+t<x){m=x;break}}return{len:d,start:p||0,end:y||0,nextStart:m}},s.getBuffered=function(i){try{return i.buffered}catch(e){return k.log("failed to get media.buffered",e),xu}},s}(),bu=function(){function s(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var a=s.prototype;return a.append=function(e,t,r){var o=this.queues[t];o.push(e),o.length===1&&!r&&this.executeNext(t)},a.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},a.appendBlocker=function(e){var t,r=new Promise(function(u){t=u}),o={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(o,e),r},a.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(u){k.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+u),r.onError(u);var o=this.buffers[e];o!=null&&o.updating||this.shiftAndExecuteNext(e)}}},a.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},a.current=function(e){return this.queues[e][0]},s}(),la=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Lu=function(){function s(i){var e=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(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,o=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(R.MEDIA_ATTACHED,{media:r,mediaSource:o})),o&&o.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,o=e._objectUrl;r!==o&&k.error("Media element src was set while attaching MediaSource ("+o+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=Mo(ar(i.config.preferManagedMediaSource)),this.log=k.log.bind(k,t),this.warn=k.warn.bind(k,t),this.error=k.error.bind(k,t),this._initSourceBuffer(),this.registerListeners()}var a=s.prototype;return a.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},a.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},a.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)},a._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new bu(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},a.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},a.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},a.onMediaAttaching=function(e,t){var r=this.media=t.media,o=ar(this.appendSource);if(r&&o){var u,h=this.mediaSource=new o;this.log("created media source: "+((u=h.constructor)==null?void 0:u.name)),h.addEventListener("sourceopen",this._onMediaSourceOpen),h.addEventListener("sourceended",this._onMediaSourceEnded),h.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(h.addEventListener("startstreaming",this._onStartStreaming),h.addEventListener("endstreaming",this._onEndStreaming));var d=this._objectUrl=self.URL.createObjectURL(h);if(this.appendSource)try{r.removeAttribute("src");var m=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||m&&h instanceof m,fa(r),Au(r,d),r.load()}catch{r.src=d}else r.src=d;r.addEventListener("emptied",this._onMediaEmptied)}},a.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(o){this.warn("onMediaDetaching: "+o.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&&fa(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(R.MEDIA_DETACHED,void 0)},a.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},a.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(o){this.warn("onBufferReset "+e,o)}},a.onBufferCodecs=function(e,t){var r=this,o=this.getSourceBufferTypes().length,u=Object.keys(t);if(u.forEach(function(d){if(o){var m=r.tracks[d];if(m&&typeof m.buffer.changeType=="function"){var p,y=t[d],T=y.id,x=y.codec,b=y.levelCodec,L=y.container,A=y.metadata,D=Un(m.codec,m.levelCodec),w=D?.replace(la,"$1"),N=Un(x,b),U=(p=N)==null?void 0:p.replace(la,"$1");if(N&&w!==U){d.slice(0,5)==="audio"&&(N=Kr(N,r.appendSource));var $=L+";codecs="+N;r.appendChangeType(d,$),r.log("switching codec "+D+" to "+N),r.tracks[d]={buffer:m.buffer,codec:x,container:L,levelCodec:b,metadata:A,id:T}}}}else r.pendingTracks[d]=t[d]}),!o){var h=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==h&&(this.log(h+" bufferCodec event(s) expected "+u.join(",")),this.bufferCodecEventsExpected=h),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},a.appendChangeType=function(e,t){var r=this,o=this.operationQueue,u={execute:function(){var d=r.sourceBuffer[e];d&&(r.log("changing "+e+" sourceBuffer type to "+t),d.changeType(t)),o.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(d){r.warn("Failed to change "+e+" SourceBuffer type",d)}};o.append(u,e,!!this.pendingTracks[e])},a.onBufferAppending=function(e,t){var r=this,o=this.hls,u=this.operationQueue,h=this.tracks,d=t.data,m=t.type,p=t.frag,y=t.part,T=t.chunkMeta,x=T.buffering[m],b=self.performance.now();x.start=b;var L=p.stats.buffering,A=y?y.stats.buffering:null;L.start===0&&(L.start=b),A&&A.start===0&&(A.start=b);var D=h.audio,w=!1;m==="audio"&&D?.container==="audio/mpeg"&&(w=!this.lastMpegAudioChunk||T.id===1||this.lastMpegAudioChunk.sn!==T.sn,this.lastMpegAudioChunk=T);var N=p.start,U={execute:function(){if(x.executeStart=self.performance.now(),w){var V=r.sourceBuffer[m];if(V){var M=N-V.timestampOffset;Math.abs(M)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+N+" (delta: "+M+") sn: "+p.sn+")"),V.timestampOffset=N)}}r.appendExecutor(d,m)},onStart:function(){},onComplete:function(){var V=self.performance.now();x.executeEnd=x.end=V,L.first===0&&(L.first=V),A&&A.first===0&&(A.first=V);var M=r.sourceBuffer,K={};for(var z in M)K[z]=rt.getBuffered(M[z]);r.appendErrors[m]=0,m==="audio"||m==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(R.BUFFER_APPENDED,{type:m,frag:p,part:y,chunkMeta:T,parent:p.type,timeRanges:K})},onError:function(V){var M={type:le.MEDIA_ERROR,parent:p.type,details:G.BUFFER_APPEND_ERROR,sourceBufferName:m,frag:p,part:y,chunkMeta:T,error:V,err:V,fatal:!1};if(V.code===DOMException.QUOTA_EXCEEDED_ERR)M.details=G.BUFFER_FULL_ERROR;else{var K=++r.appendErrors[m];M.details=G.BUFFER_APPEND_ERROR,r.warn("Failed "+K+"/"+o.config.appendErrorMaxRetry+' times to append segment in "'+m+'" sourceBuffer'),K>=o.config.appendErrorMaxRetry&&(M.fatal=!0)}o.trigger(R.ERROR,M)}};u.append(U,m,!!this.pendingTracks[m])},a.onBufferFlushing=function(e,t){var r=this,o=this.operationQueue,u=function(d){return{execute:r.removeExecutor.bind(r,d,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(R.BUFFER_FLUSHED,{type:d})},onError:function(p){r.warn("Failed to remove from "+d+" SourceBuffer",p)}}};t.type?o.append(u(t.type),t.type):this.getSourceBufferTypes().forEach(function(h){o.append(u(h),h)})},a.onFragParsed=function(e,t){var r=this,o=t.frag,u=t.part,h=[],d=u?u.elementaryStreams:o.elementaryStreams;d[Pe.AUDIOVIDEO]?h.push("audiovideo"):(d[Pe.AUDIO]&&h.push("audio"),d[Pe.VIDEO]&&h.push("video"));var m=function(){var y=self.performance.now();o.stats.buffering.end=y,u&&(u.stats.buffering.end=y);var T=u?u.stats:o.stats;r.hls.trigger(R.FRAG_BUFFERED,{frag:o,part:u,stats:T,id:o.type})};h.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(m,h)},a.onFragChanged=function(e,t){this.trimBuffers()},a.onBufferEos=function(e,t){var r=this,o=this.getSourceBufferTypes().reduce(function(u,h){var d=r.sourceBuffer[h];return d&&(!t.type||t.type===h)&&(d.ending=!0,d.ended||(d.ended=!0,r.log(h+" sourceBuffer now EOS"))),u&&!!(!d||d.ended)},!0);o&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(h){var d=r.sourceBuffer[h];d&&(d.ending=!1)});var u=r.mediaSource;if(!u||u.readyState!=="open"){u&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+u.readyState);return}r.log("Calling mediaSource.endOfStream()"),u.endOfStream()}))},a.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())},a.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var o=this.getSourceBufferTypes();if(o.length){var u=e.config,h=r.currentTime,d=t.levelTargetDuration,m=t.live&&u.liveBackBufferLength!==null?u.liveBackBufferLength:u.backBufferLength;if(j(m)&&m>0){var p=Math.max(m,d),y=Math.floor(h/d)*d-p;this.flushBackBuffer(h,d,y)}if(j(u.frontBufferFlushThreshold)&&u.frontBufferFlushThreshold>0){var T=Math.max(u.maxBufferLength,u.frontBufferFlushThreshold),x=Math.max(T,d),b=Math.floor(h/d)*d+x;this.flushFrontBuffer(h,d,b)}}}},a.flushBackBuffer=function(e,t,r){var o=this,u=this.details,h=this.sourceBuffer,d=this.getSourceBufferTypes();d.forEach(function(m){var p=h[m];if(p){var y=rt.getBuffered(p);if(y.length>0&&r>y.start(0)){if(o.hls.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:r}),u!=null&&u.live)o.hls.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(p.ended&&y.end(y.length-1)-e<t*2){o.log("Cannot flush "+m+" back buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:m})}}})},a.flushFrontBuffer=function(e,t,r){var o=this,u=this.sourceBuffer,h=this.getSourceBufferTypes();h.forEach(function(d){var m=u[d];if(m){var p=rt.getBuffered(m),y=p.length;if(y<2)return;var T=p.start(y-1),x=p.end(y-1);if(r>T||e>=T&&e<=x)return;if(m.ended&&e-x<2*t){o.log("Cannot flush "+d+" front buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:T,endOffset:1/0,type:d})}})},a.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,o=this.mediaSource,u=e.fragments[0].start+e.totalduration,h=r.duration,d=j(o.duration)?o.duration:0;e.live&&t.config.liveDurationInfinity?(o.duration=1/0,this.updateSeekableRange(e)):(u>d&&u>h||!j(h))&&(this.log("Updating Media Source duration to "+u.toFixed(3)),o.duration=u)}},a.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,o=r.length;if(o&&e.live&&t!=null&&t.setLiveSeekableRange){var u=Math.max(0,r[0].start),h=Math.max(u,u+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+u+"-"+h+"."),t.setLiveSeekableRange(u,h)}},a.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,o=Object.keys(r).length;if(o&&(!e||o===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),u.forEach(function(d){t.executeNext(d)});else{var h=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:h,reason:h.message})}}},a.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var u=function(m){if(!r[m]){var p,y=e[m];if(!y)throw Error("source buffer exists for track "+m+", however track does not");var T=((p=y.levelCodec)==null?void 0:p.indexOf(","))===-1?y.levelCodec:y.codec;T&&m.slice(0,5)==="audio"&&(T=Kr(T,t.appendSource));var x=y.container+";codecs="+T;t.log("creating sourceBuffer("+x+")");try{var b=r[m]=o.addSourceBuffer(x),L=m;t.addBufferListener(L,"updatestart",t._onSBUpdateStart),t.addBufferListener(L,"updateend",t._onSBUpdateEnd),t.addBufferListener(L,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(L,"bufferedchange",function(A,D){var w=D.removedRanges;w!=null&&w.length&&t.hls.trigger(R.BUFFER_FLUSHED,{type:m})}),t.tracks[m]={buffer:b,codec:T,container:y.container,levelCodec:y.levelCodec,metadata:y.metadata,id:y.id}}catch(A){t.error("error while trying to add sourceBuffer: "+A.message),t.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:A,sourceBufferName:m,mimeType:x})}}};for(var h in e)u(h)},a._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},a._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,o=r.current(e);o.onComplete(),r.shiftAndExecuteNext(e)},a._onSBUpdateError=function(e,t){var r,o=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+o,t),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:o,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(o)},a.removeExecutor=function(e,t,r){var o=this.media,u=this.mediaSource,h=this.operationQueue,d=this.sourceBuffer,m=d[e];if(!o||!u||!m){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(e);return}var p=j(o.duration)?o.duration:1/0,y=j(u.duration)?u.duration:1/0,T=Math.max(0,t),x=Math.min(r,p,y);x>T&&(!m.ending||m.ended)?(m.ended=!1,this.log("Removing ["+T+","+x+"] from the "+e+" SourceBuffer"),m.remove(T,x)):h.shiftAndExecuteNext(e)},a.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},a.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var o=this.operationQueue,u=t.map(function(h){return o.appendBlocker(h)});Promise.all(u).then(function(){e(),t.forEach(function(h){var d=r.sourceBuffer[h];d!=null&&d.updating||o.shiftAndExecuteNext(h)})})},a.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},a.addBufferListener=function(e,t,r){var o=this.sourceBuffer[e];if(o){var u=r.bind(this,e);this.listeners[e].push({event:t,listener:u}),o.addEventListener(t,u)}},a.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},_(s,[{key:"mediaSrc",get:function(){var e,t,r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r?.src}}]),s}();function fa(s){var a=s.querySelectorAll("source");[].slice.call(a).forEach(function(i){s.removeChild(i)})}function Au(s,a){var i=self.document.createElement("source");i.type="video/mp4",i.src=a,s.appendChild(i)}var Ru=function(){function s(i){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=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var e=this.hls;e.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var e=this.hls;e.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.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})},a.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},a.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onLevelsUpdated=function(e,t){this.timer&&j(this.autoLevelCapping)&&this.detectPlayerSize()},a.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&k.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}}},a.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var o=r.filter(function(u,h){return t.isLevelAllowed(u)&&h<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.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},a.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var o=function(y,T){return T?y.width!==T.width||y.height!==T.height:!0},u=e.length-1,h=Math.max(t,r),d=0;d<e.length;d+=1){var m=e[d];if((m.width>=h||m.height>=h)&&o(m,e[d+1])){u=d;break}}return u},_(s,[{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{}return e}}]),s}(),Cu=function(){function s(i){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=i,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},a.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var o=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},a.checkFPS=function(e,t,r){var o=performance.now();if(t){if(this.lastTime){var u=o-this.lastTime,h=r-this.lastDroppedFrames,d=t-this.lastDecodedFrames,m=1e3*h/u,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:h,currentDecoded:d,totalDroppedFrames:r}),m>0&&h>p.config.fpsDroppedMonitoringThreshold*d){var y=p.currentLevel;k.warn("drop FPS ratio greater than max allowed value for currentLevel: "+y),y>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=y)&&(y=y-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:y,droppedLevel:p.currentLevel}),p.autoLevelCapping=y,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},a.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)},s}(),Du=3e5,wu=function(){function s(i){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=i,this.log=k.log.bind(k,"[content-steering]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.ERROR,this.onError,this))},a.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},a.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},a.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},a.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},a.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},a.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},a.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},a.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},a.onError=function(e,t){var r=t.errorAction;if(r?.action===ot.SendAlternateToPenaltyBox&&r.flags===Ct.MoveAllAlternatesMatchingHost){var o=this.levels,u=this.pathwayPriority,h=this.pathwayId;if(t.context){var d=t.context,m=d.groupId,p=d.pathwayId,y=d.type;m&&o?h=this.getPathwayForGroupId(m,y,h):p&&(h=p)}h in this.penalizedPathways||(this.penalizedPathways[h]=performance.now()),!u&&o&&(u=o.reduce(function(T,x){return T.indexOf(x.pathwayId)===-1&&T.push(x.pathwayId),T},[])),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==h),r.resolved||k.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+h+" levels: "+(o&&o.length)+" priorities: "+JSON.stringify(u)+" penalized: "+JSON.stringify(this.penalizedPathways))}},a.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){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},a.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},a.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,o=performance.now();Object.keys(r).forEach(function(y){o-r[y]>Du&&delete r[y]});for(var u=0;u<e.length;u++){var h=e[u];if(!(h in r)){if(h===this.pathwayId)return;var d=this.hls.nextLoadLevel,m=this.hls.levels[d];if(t=this.getLevelsForPathway(h),t.length>0){this.log('Setting Pathway to "'+h+'"'),this.pathwayId=h,ia(t),this.hls.trigger(R.LEVELS_UPDATED,{levels:t});var p=this.hls.levels[d];m&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==m.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==m.bitrate&&this.log("Unstable Pathways change from bitrate "+m.bitrate+" to "+p.bitrate),this.hls.nextLoadLevel=d);break}}}},a.getPathwayForGroupId=function(e,t,r){for(var o=this.getLevelsForPathway(r).concat(this.levels||[]),u=0;u<o.length;u++)if(t===Oe.AUDIO_TRACK&&o[u].hasAudioGroup(e)||t===Oe.SUBTITLE_TRACK&&o[u].hasSubtitleGroup(e))return o[u].pathwayId;return r},a.clonePathways=function(e){var t=this,r=this.levels;if(r){var o={},u={};e.forEach(function(h){var d=h.ID,m=h["BASE-ID"],p=h["URI-REPLACEMENT"];if(!r.some(function(T){return T.pathwayId===d})){var y=t.getLevelsForPathway(m).map(function(T){var x=new pe(T.attrs);x["PATHWAY-ID"]=d;var b=x.AUDIO&&x.AUDIO+"_clone_"+d,L=x.SUBTITLES&&x.SUBTITLES+"_clone_"+d;b&&(o[x.AUDIO]=b,x.AUDIO=b),L&&(u[x.SUBTITLES]=L,x.SUBTITLES=L);var A=da(T.uri,x["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",p),D=new Ci({attrs:x,audioCodec:T.audioCodec,bitrate:T.bitrate,height:T.height,name:T.name,url:A,videoCodec:T.videoCodec,width:T.width});if(T.audioGroups)for(var w=1;w<T.audioGroups.length;w++)D.addGroupId("audio",T.audioGroups[w]+"_clone_"+d);if(T.subtitleGroups)for(var N=1;N<T.subtitleGroups.length;N++)D.addGroupId("text",T.subtitleGroups[N]+"_clone_"+d);return D});r.push.apply(r,y),ha(t.audioTracks,o,p,d),ha(t.subtitleTracks,u,p,d)}})}},a.loadSteeringManifest=function(e){var t=this,r=this.hls.config,o=r.loader;this.loader&&this.loader.destroy(),this.loader=new o(r);var u;try{u=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(u.protocol!=="data:"){var h=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;u.searchParams.set("_HLS_pathway",this.pathwayId),u.searchParams.set("_HLS_throughput",""+h)}var d={responseType:"json",url:u.href},m=r.steeringManifestLoadPolicy.default,p=m.errorRetry||m.timeoutRetry||{},y={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:p.maxNumRetry||0,retryDelay:p.retryDelayMs||0,maxRetryDelay:p.maxRetryDelayMs||0},T={onSuccess:function(b,L,A,D){t.log('Loaded steering manifest: "'+u+'"');var w=b.data;if(w.VERSION!==1){t.log("Steering VERSION "+w.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=w.TTL;var N=w["RELOAD-URI"],U=w["PATHWAY-CLONES"],$=w["PATHWAY-PRIORITY"];if(N)try{t.uri=new self.URL(N,u).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+N);return}t.scheduleRefresh(t.uri||A.url),U&&t.clonePathways(U);var V={steeringManifest:w,url:u.toString()};t.hls.trigger(R.STEERING_MANIFEST_LOADED,V),$&&t.updatePathwayPriority($)},onError:function(b,L,A,D){if(t.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+L.url+")"),t.stopLoad(),b.code===410){t.enabled=!1,t.log("Steering manifest "+L.url+" no longer available");return}var w=t.timeToLoad*1e3;if(b.code===429){var N=t.loader;if(typeof N?.getResponseHeader=="function"){var U=N.getResponseHeader("Retry-After");U&&(w=parseFloat(U)*1e3)}t.log("Steering manifest "+L.url+" rate limited");return}t.scheduleRefresh(t.uri||L.url,w)},onTimeout:function(b,L,A){t.log("Timeout loading steering manifest ("+L.url+")"),t.scheduleRefresh(t.uri||L.url)}};this.log("Requesting steering manifest: "+u),this.loader.load(d,y,T)},a.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var o,u=(o=r.hls)==null?void 0:o.media;if(u&&!u.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},s}();function ha(s,a,i,e){s&&Object.keys(a).forEach(function(t){var r=s.filter(function(o){return o.groupId===t}).map(function(o){var u=C({},o);return u.details=void 0,u.attrs=new pe(u.attrs),u.url=u.attrs.URI=da(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),u.groupId=u.attrs["GROUP-ID"]=a[t],u.attrs["PATHWAY-ID"]=e,u});s.push.apply(s,r)})}function da(s,a,i,e){var t=e.HOST,r=e.PARAMS,o=e[i],u;a&&(u=o?.[a],u&&(s=u));var h=new self.URL(s);return t&&!u&&(h.host=t),r&&Object.keys(r).sort().forEach(function(d){d&&h.searchParams.set(d,r[d])}),h.href}var Iu=/^age:\s*[\d.]+\s*$/im,ca=function(){function s(i){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=i&&i.xhrSetup||null,this.stats=new $t,this.retryDelay=0}var a=s.prototype;return a.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},a.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},a.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()},a.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var o=this.loader=new self.XMLHttpRequest,u=this.stats;u.loading.first=0,u.loaded=0,u.aborted=!1;var h=this.xhrSetup;h?Promise.resolve().then(function(){if(!(e.loader!==o||e.stats.aborted))return h(o,r.url)}).catch(function(d){if(!(e.loader!==o||e.stats.aborted))return o.open("GET",r.url,!0),h(o,r.url)}).then(function(){e.loader!==o||e.stats.aborted||e.openAndSendXhr(o,r,t)}).catch(function(d){e.callbacks.onError({code:o.status,text:d.message},r,o,u)}):this.openAndSendXhr(o,r,t)}},a.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var o=t.headers,u=r.loadPolicy,h=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;if(o)for(var m in o)e.setRequestHeader(m,o[m]);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=h&&j(h)?h:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},a.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var o=t.readyState,u=this.config;if(!r.aborted&&o>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),u.timeout!==u.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),u.timeout=u.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),u.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var h=t.status,d=t.responseType!=="text";if(h>=200&&h<300&&(d&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var m=d?t.response:t.responseText,p=t.responseType==="arraybuffer"?m.byteLength:m.length;if(r.loaded=r.total=p,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var y=this.callbacks.onProgress;if(y&&y(r,e,m,t),!this.callbacks)return;var T={url:t.responseURL,data:m,code:h};this.callbacks.onSuccess(T,r,e,t)}else{var x=u.loadPolicy.errorRetry,b=r.retry,L={url:e.url,data:void 0,code:h};qr(x,b,!1,L)?this.retry(x):(k.error(h+" while loading "+e.url),this.callbacks.onError({code:h,text:t.statusText},e,t,r))}}}},a.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(qr(e,t,!0))this.retry(e);else{var r;k.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}},a.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=wi(e,r.retry),r.retry++,k.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+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)},a.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},a.getCacheAge=function(){var e=null;if(this.loader&&Iu.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),Pu=function(){function s(){this.chunks=[],this.dataLength=0}var a=s.prototype;return a.push=function(e){this.chunks.push(e),this.dataLength+=e.length},a.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=ku(e,t);else return new Uint8Array(0);return this.reset(),r},a.reset=function(){this.chunks.length=0,this.dataLength=0},s}();function ku(s,a){for(var i=new Uint8Array(a),e=0,t=0;t<s.length;t++){var r=s[t];i.set(r,e),e+=r.length}return i}function Ou(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Mu=/(\d+)-(\d+)\/(\d+)/,va=function(){function s(i){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=i.fetchSetup||Bu,this.controller=new self.AbortController,this.stats=new $t}var a=s.prototype;return a.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},a.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(e,t,r){var o=this,u=this.stats;if(u.loading.start)throw new Error("Loader can only be used once.");u.loading.start=self.performance.now();var h=Fu(e,this.controller.signal),d=r.onProgress,m=e.responseType==="arraybuffer",p=m?"byteLength":"length",y=t.loadPolicy,T=y.maxTimeToFirstByteMs,x=y.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,h),self.clearTimeout(this.requestTimeout),t.timeout=T&&j(T)?T:x,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},t.timeout),self.fetch(this.request).then(function(b){o.response=o.loader=b;var L=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(o.requestTimeout),t.timeout=x,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},x-(L-u.loading.start)),!b.ok){var A=b.status,D=b.statusText;throw new Gu(D||"fetch, bad network response",A,b)}return u.loading.first=L,u.total=Uu(b.headers)||u.total,d&&j(t.highWaterMark)?o.loadProgressively(b,u,e,t.highWaterMark,d):m?b.arrayBuffer():e.responseType==="json"?b.json():b.text()}).then(function(b){var L=o.response;if(!L)throw new Error("loader destroyed");self.clearTimeout(o.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var A=b[p];A&&(u.loaded=u.total=A);var D={url:L.url,data:b,code:L.status};d&&!j(t.highWaterMark)&&d(u,e,b,L),r.onSuccess(D,u,e,L)}).catch(function(b){if(self.clearTimeout(o.requestTimeout),!u.aborted){var L=b&&b.code||0,A=b?b.message:null;r.onError({code:L,text:A},e,b?b.details:null,u)}})},a.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},a.loadProgressively=function(e,t,r,o,u){o===void 0&&(o=0);var h=new Pu,d=e.body.getReader(),m=function p(){return d.read().then(function(y){if(y.done)return h.dataLength&&u(t,r,h.flush(),e),Promise.resolve(new ArrayBuffer(0));var T=y.value,x=T.length;return t.loaded+=x,x<o||h.dataLength?(h.push(T),h.dataLength>=o&&u(t,r,h.flush(),e)):u(t,r,T,e),p()}).catch(function(){return Promise.reject()})};return m()},s}();function Fu(s,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(C({},s.headers))};return s.rangeEnd&&i.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),i}function Nu(s){var a=Mu.exec(s);if(a)return parseInt(a[2])-parseInt(a[1])+1}function Uu(s){var a=s.get("Content-Range");if(a){var i=Nu(a);if(j(i))return i}var e=s.get("Content-Length");if(e)return parseInt(e)}function Bu(s,a){return new self.Request(s.url,a)}var Gu=function(s){I(a,s);function a(i,e,t){var r;return r=s.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return a}(J(Error)),Vu={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},pa=l(l({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:60*1e3*1e3,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:ca,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Tu,bufferController:Lu,capLevelController:Ru,errorController:vu,fpsController:Cu,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:Vu},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},Hu()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:wu});function Hu(){return{cueHandler:lo,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Ku(s,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=Ii(s),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var o=(r==="level"?"playlist":r)+"LoadPolicy",u=a[o]===void 0,h=[];t.forEach(function(d){var m=r+"Loading"+d,p=a[m];if(p!==void 0&&u){h.push(m);var y=i[o].default;switch(a[o]={default:y},d){case"TimeOut":y.maxLoadTimeMs=p,y.maxTimeToFirstByteMs=p;break;case"MaxRetry":y.errorRetry.maxNumRetry=p,y.timeoutRetry.maxNumRetry=p;break;case"RetryDelay":y.errorRetry.retryDelayMs=p,y.timeoutRetry.retryDelayMs=p;break;case"MaxRetryTimeout":y.errorRetry.maxRetryDelayMs=p,y.timeoutRetry.maxRetryDelayMs=p;break}}}),h.length&&k.warn('hls.js config: "'+h.join('", "')+'" setting(s) are deprecated, use "'+o+'": '+JSON.stringify(a[o]))}),l(l({},i),a)}function Ii(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ii):Object.keys(s).reduce(function(a,i){return a[i]=Ii(s[i]),a},{}):s}function Wu(s){var a=s.loader;if(a!==va&&a!==ca)k.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var i=Ou();i&&(s.loader=va,s.progressive=!0,s.enableSoftwareAES=!0,k.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Pi,ju=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),s.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var o=this.hls.config.preferManagedMediaSource,u=[],h={},d={},m=!1,p=!1,y=!1;r.levels.forEach(function(T){var x,b,L=T.attrs,A=T.audioCodec,D=T.videoCodec;((x=A)==null?void 0:x.indexOf("mp4a.40.34"))!==-1&&(Pi||(Pi=/chrome|firefox/i.test(navigator.userAgent)),Pi&&(T.audioCodec=A=void 0)),A&&(T.audioCodec=A=Kr(A,o)),((b=D)==null?void 0:b.indexOf("avc1"))===0&&(D=T.videoCodec=Bo(D));var w=T.width,N=T.height,U=T.unknownCodecs;if(m||(m=!!(w&&N)),p||(p=!!D),y||(y=!!A),!(U!=null&&U.length||A&&!Si(A,"audio",o)||D&&!Si(D,"video",o))){var $=L.CODECS,V=L["FRAME-RATE"],M=L["HDCP-LEVEL"],K=L["PATHWAY-ID"],z=L.RESOLUTION,te=L["VIDEO-RANGE"],Z=(K||".")+"-",ie=""+Z+T.bitrate+"-"+z+"-"+V+"-"+$+"-"+te+"-"+M;if(h[ie])if(h[ie].uri!==T.url&&!T.attrs["PATHWAY-ID"]){var fe=d[ie]+=1;T.attrs["PATHWAY-ID"]=new Array(fe+1).join(".");var Le=new Ci(T);h[ie]=Le,u.push(Le)}else h[ie].addGroupId("audio",L.AUDIO),h[ie].addGroupId("text",L.SUBTITLES);else{var he=new Ci(T);h[ie]=he,d[ie]=1,u.push(he)}}}),this.filterAndSortMediaOptions(u,r,m,p,y)},i.filterAndSortMediaOptions=function(t,r,o,u,h){var d=this,m=[],p=[],y=t;if((o||u)&&h&&(y=y.filter(function(M){var K=M.videoCodec,z=M.videoRange,te=M.width,Z=M.height;return(!!K||!!(te&&Z))&&tu(z)})),y.length===0){Promise.resolve().then(function(){if(d.hls){r.levels.length&&d.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var M=new Error("no level with compatible codecs found in manifest");d.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:M,reason:M.message})}});return}if(r.audioTracks){var T=this.hls.config.preferManagedMediaSource;m=r.audioTracks.filter(function(M){return!M.audioCodec||Si(M.audioCodec,"audio",T)}),ma(m)}r.subtitles&&(p=r.subtitles,ma(p));var x=y.slice(0);y.sort(function(M,K){if(M.attrs["HDCP-LEVEL"]!==K.attrs["HDCP-LEVEL"])return(M.attrs["HDCP-LEVEL"]||"")>(K.attrs["HDCP-LEVEL"]||"")?1:-1;if(o&&M.height!==K.height)return M.height-K.height;if(M.frameRate!==K.frameRate)return M.frameRate-K.frameRate;if(M.videoRange!==K.videoRange)return jr.indexOf(M.videoRange)-jr.indexOf(K.videoRange);if(M.videoCodec!==K.videoCodec){var z=Nn(M.videoCodec),te=Nn(K.videoCodec);if(z!==te)return te-z}if(M.uri===K.uri&&M.codecSet!==K.codecSet){var Z=Hr(M.codecSet),ie=Hr(K.codecSet);if(Z!==ie)return ie-Z}return M.averageBitrate!==K.averageBitrate?M.averageBitrate-K.averageBitrate:0});var b=x[0];if(this.steering&&(y=this.steering.filterParsedLevels(y),y.length!==x.length)){for(var L=0;L<x.length;L++)if(x[L].pathwayId===y[0].pathwayId){b=x[L];break}}this._levels=y;for(var A=0;A<y.length;A++)if(y[A]===b){var D;this._firstLevel=A;var w=b.bitrate,N=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+w),((D=this.hls.userConfig)==null?void 0:D.abrEwmaDefaultEstimate)===void 0){var U=Math.min(w,this.hls.config.abrEwmaDefaultEstimateMax);U>N&&N===pa.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=U)}break}var $=h&&!u,V={levels:y,audioTracks:m,subtitleTracks:p,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:h,video:u,altAudio:!$&&m.some(function(M){return!!M.url})};this.hls.trigger(R.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Oe.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var o=r.frag;if(o!==void 0&&o.type===Me.MAIN){var u=o.elementaryStreams;if(!Object.keys(u).some(function(d){return!!u[d]}))return;var h=this._levels[o.level];h!=null&&h.loadError&&(this.log("Resetting level error count of "+h.loadError+" on frag buffered"),h.loadError=0)}},i.onLevelLoaded=function(t,r){var o,u=r.level,h=r.details,d=this._levels[u];if(!d){var m;this.warn("Invalid level index "+u),(m=r.deliveryDirectives)!=null&&m.skip&&(h.deltaUpdateFailed=!0);return}u===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(u,r,d.details)):(o=r.deliveryDirectives)!=null&&o.skip&&(h.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,o=this.currentLevel;if(o&&this.shouldLoadPlaylist(o)){var u=o.uri;if(t)try{u=t.addDirectives(u)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var h=o.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(h?" Pathway "+h:"")+" "+u),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:u,level:r,pathwayId:o.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,o,u=this._levels.filter(function(h,d){return d!==t?!0:(r.steering&&r.steering.removeLevel(h),h===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,h.details&&h.details.fragments.forEach(function(m){return m.level=-1})),!1)});ia(u),this._levels=u,this.currentLevelIndex>-1&&(o=this.currentLevel)!=null&&o.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(R.LEVELS_UPDATED,{levels:u})},i.onLevelsUpdated=function(t,r){var o=r.levels;this._levels=o},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,o=t.maxAutoLevel,u=t.maxHdcpLevel;this._maxAutoLevel!==o&&(this._maxAutoLevel=o,this.hls.trigger(R.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:o,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:u}))},_(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var o=new Error("invalid level idx"),u=t<0;if(this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.LEVEL_SWITCH_ERROR,level:t,fatal:u,error:o,reason:o.message}),u)return;t=Math.min(t,r.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,m=d?d.attrs["PATHWAY-ID"]:void 0,p=r[t],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=p,!(h===t&&p.details&&d&&m===y)){this.log("Switching to level "+t+" ("+(p.height?p.height+"p ":"")+(p.videoRange?p.videoRange+" ":"")+(p.codecSet?p.codecSet+" ":"")+"@"+p.bitrate+")"+(y?" with Pathway "+y:"")+" from level "+h+(m?" with Pathway "+m:""));var T={level:t,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(R.LEVEL_SWITCHING,T);var x=p.details;if(!x||x.live){var b=this.switchParams(p.uri,d?.details,x);this.loadPlaylist(b)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),a}(pu);function ma(s){var a={};s.forEach(function(i){var e=i.groupId||"";i.id=a[e]=a[e]||0,a[e]++})}var gt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},zu=function(){function s(i){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=i,this._registerListeners()}var a=s.prototype;return a._registerListeners=function(){var e=this.hls;e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)},a.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},a.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var o=r.length;o--;){var u=r[o];if(!u)break;var h=u.end;if(u.start<=e&&h!==null&&e<=h)return u}return this.getBufferedFrag(e,t)},a.getBufferedFrag=function(e,t){for(var r=this.fragments,o=Object.keys(r),u=o.length;u--;){var h=r[o[u]];if(h?.body.type===t&&h.buffered){var d=h.body;if(d.start<=e&&e<=d.end)return d}}return null},a.detectEvictedFragments=function(e,t,r,o){var u=this;this.timeRanges&&(this.timeRanges[e]=t);var h=o?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(d){var m=u.fragments[d];if(m&&!(h>=m.body.sn)){if(!m.buffered&&!m.loaded){m.body.type===r&&u.removeFragment(m.body);return}var p=m.range[e];p&&p.time.some(function(y){var T=!u.isTimeBuffered(y.startPTS,y.endPTS,t);return T&&u.removeFragment(m.body),T})}})},a.detectPartialFragments=function(e){var t=this,r=this.timeRanges,o=e.frag,u=e.part;if(!(!r||o.sn==="initSegment")){var h=vr(o),d=this.fragments[h];if(!(!d||d.buffered&&o.gap)){var m=!o.relurl;if(Object.keys(r).forEach(function(y){var T=o.elementaryStreams[y];if(T){var x=r[y],b=m||T.partial===!0;d.range[y]=t.getBufferedTimes(o,u,b,x)}}),d.loaded=null,Object.keys(d.range).length){d.buffered=!0;var p=d.body.endList=o.endList||d.body.endList;p&&(this.endListFragments[d.body.type]=d),Xr(d)||this.removeParts(o.sn-1,o.type)}else this.removeFragment(d.body)}}},a.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(o){return o.fragment.sn>=e}))},a.fragBuffered=function(e,t){var r=vr(e),o=this.fragments[r];!o&&t&&(o=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)},a.getBufferedTimes=function(e,t,r,o){for(var u={time:[],partial:r},h=e.start,d=e.end,m=e.minEndPTS||d,p=e.maxStartPTS||h,y=0;y<o.length;y++){var T=o.start(y)-this.bufferPadding,x=o.end(y)+this.bufferPadding;if(p>=T&&m<=x){u.time.push({startPTS:Math.max(h,o.start(y)),endPTS:Math.min(d,o.end(y))});break}else if(h<x&&d>T){var b=Math.max(h,o.start(y)),L=Math.min(d,o.end(y));L>b&&(u.partial=!0,u.time.push({startPTS:b,endPTS:L}))}else if(d<=T)break}return u},a.getPartialFragment=function(e){var t=null,r,o,u,h=0,d=this.bufferPadding,m=this.fragments;return Object.keys(m).forEach(function(p){var y=m[p];y&&Xr(y)&&(o=y.body.start-d,u=y.body.end+d,e>=o&&e<=u&&(r=Math.min(e-o,u-e),h<=r&&(t=y.body,h=r)))}),t},a.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||Xr(t))},a.getState=function(e){var t=vr(e),r=this.fragments[t];return r?r.buffered?Xr(r)?gt.PARTIAL:gt.OK:gt.APPENDING:gt.NOT_LOADED},a.isTimeBuffered=function(e,t,r){for(var o,u,h=0;h<r.length;h++){if(o=r.start(h)-this.bufferPadding,u=r.end(h)+this.bufferPadding,e>=o&&t<=u)return!0;if(t<=o)return!1}return!1},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var u=o?null:t,h=vr(r);this.fragments[h]={body:r,appendedPTS:null,loaded:u,buffered:!1,range:Object.create(null)}}},a.onBufferAppended=function(e,t){var r=this,o=t.frag,u=t.part,h=t.timeRanges;if(o.sn!=="initSegment"){var d=o.type;if(u){var m=this.activePartLists[d];m||(this.activePartLists[d]=m=[]),m.push(u)}this.timeRanges=h,Object.keys(h).forEach(function(p){var y=h[p];r.detectEvictedFragments(p,y,d,u)})}},a.onFragBuffered=function(e,t){this.detectPartialFragments(t)},a.hasFragment=function(e){var t=vr(e);return!!this.fragments[t]},a.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},a.removeFragmentsInRange=function(e,t,r,o,u){var h=this;o&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var m=h.fragments[d];if(m){var p=m.body;p.type!==r||o&&!p.gap||p.start<t&&p.end>e&&(m.buffered||u)&&h.removeFragment(p)}})},a.removeFragment=function(e){var t=vr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var o=e.sn;this.activePartLists[e.type]=r.filter(function(u){return u.fragment.sn!==o})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},a.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function Xr(s){var a,i,e;return s.buffered&&(s.body.gap||((a=s.range.video)==null?void 0:a.partial)||((i=s.range.audio)==null?void 0:i.partial)||((e=s.range.audiovideo)==null?void 0:e.partial))}function vr(s){return s.type+"_"+s.level+"_"+s.sn}var ga=Math.pow(2,17),Yu=function(){function s(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var a=s.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(e,t){var r=this,o=e.url;if(!o)return Promise.reject(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(o?"part list":"url")),networkDetails:null}));this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(L){return L[0]==="GAP"})){p(Ea(e));return}else e.gap=!1;var y=r.loader=e.loader=h?new h(u):new d(u),T=ya(e),x=aa(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ga};e.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){r.resetLoader(e,y);var U=A.data;w.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),m({frag:e,part:null,payload:U,networkDetails:N})},onError:function(A,D,w,N){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:l({url:o,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))},onProgress:function(A,D,w,N){t&&t({frag:e,part:null,payload:w,networkDetails:N})}})})},a.loadPart=function(e,t,r){var o=this;this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(o.loader&&o.loader.destroy(),e.gap||t.gap){p(Ea(e,t));return}var y=o.loader=e.loader=h?new h(u):new d(u),T=ya(e,t),x=aa(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ga};t.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){o.resetLoader(e,y),o.updateStatsFromPart(e,t);var U={frag:e,part:t,payload:A.data,networkDetails:N};r(U),m(U)},onError:function(A,D,w,N){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:l({url:T.url,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){e.stats.aborted=t.stats.aborted,o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))}})})},a.updateStatsFromPart=function(e,t){var r=e.stats,o=t.stats,u=o.total;if(r.loaded+=o.loaded,u){var h=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/u),h),m=h-d,p=m*Math.round(r.loaded/d);r.total=r.loaded+p}else r.total=Math.max(r.loaded,r.total);var y=r.loading,T=o.loading;y.start?y.first+=T.first-T.start:(y.start=T.start,y.first=T.first),y.end=T.end},a.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function ya(s,a){a===void 0&&(a=null);var i=a||s,e={frag:s,part:a,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(j(t)&&j(r)){var o,u=t,h=r;if(s.sn==="initSegment"&&((o=s.decryptdata)==null?void 0:o.method)==="AES-128"){var d=r-t;d%16&&(h=r+(16-d%16)),t!==0&&(e.resetIV=!0,u=t-16)}e.rangeStart=u,e.rangeEnd=h}return e}function Ea(s,a){var i=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),e={type:le.MEDIA_ERROR,details:G.FRAG_GAP,fatal:!1,frag:s,error:i,networkDetails:null};return a&&(e.part=a),(a||s).stats.aborted=!0,new Kt(e)}var Kt=function(s){I(a,s);function a(i){var e;return e=s.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return a}(J(Error)),qu=function(){function s(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var a=s.prototype;return a.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var o;if(e&&e!==((o=r.context)==null?void 0:o.frag.type))return;r.abort()}}},a.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},a.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},a.createKeyLoadError=function(e,t,r,o,u){return t===void 0&&(t=G.KEY_LOAD_ERROR),new Kt({type:le.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:u,error:r,networkDetails:o})},a.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var o=e.sn,u=e.cc,h=function(){var p=t[d];if(u<=p.cc&&(o==="initSegment"||p.sn==="initSegment"||o<p.sn))return r.emeController.selectKeySystemFormat(p).then(function(y){p.setKeyFormat(y)}),1},d=0;d<t.length&&!h();d++);},a.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)},a.loadInternal=function(e,t){var r,o;t&&e.setKeyFormat(t);var u=e.decryptdata;if(!u){var h=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,G.KEY_LOAD_ERROR,h))}var d=u.uri;if(!d)return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+d+'"')));var m=this.keyUriToKeyInfo[d];if((r=m)!=null&&r.decryptdata.key)return u.key=m.decryptdata.key,Promise.resolve({frag:e,keyInfo:m});if((o=m)!=null&&o.keyLoadPromise){var p;switch((p=m.mediaKeySessionContext)==null?void 0:p.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return m.keyLoadPromise.then(function(y){return u.key=y.keyInfo.decryptdata.key,{frag:e,keyInfo:m}})}}switch(m=this.keyUriToKeyInfo[d]={decryptdata:u,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},u.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return u.keyFormat==="identity"?this.loadKeyHTTP(m,e):this.loadKeyEME(m,e);case"AES-128":return this.loadKeyHTTP(m,e);default:return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+u.method+'"')))}},a.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var o=this.emeController.loadKey(r);if(o)return(e.keyLoadPromise=o.then(function(u){return e.mediaKeySessionContext=u,r})).catch(function(u){throw e.keyLoadPromise=null,u})}return Promise.resolve(r)},a.loadKeyHTTP=function(e,t){var r=this,o=this.config,u=o.loader,h=new u(o);return t.keyLoader=e.loader=h,e.keyLoadPromise=new Promise(function(d,m){var p={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},y=o.keyLoadPolicy.default,T={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},x={onSuccess:function(L,A,D,w){var N=D.frag,U=D.keyInfo,$=D.url;if(!N.decryptdata||U!==r.keyUriToKeyInfo[$])return m(r.createKeyLoadError(N,G.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));U.decryptdata.key=N.decryptdata.key=new Uint8Array(L.data),N.keyLoader=null,U.loader=null,d({frag:N,keyInfo:U})},onError:function(L,A,D,w){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_ERROR,new Error("HTTP Error "+L.code+" loading key "+L.text),D,l({url:p.url,data:void 0},L)))},onTimeout:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),D))},onAbort:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.INTERNAL_ABORTED,new Error("key loading aborted"),D))}};h.load(p,T,x)})},a.resetLoader=function(e){var t=e.frag,r=e.keyInfo,o=e.url,u=r.loader;t.keyLoader===u&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[o],u&&u.destroy()},s}(),Xu=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var a=s.prototype;return a.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},a.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},a.onHandlerDestroyed=function(){},a.hasInterval=function(){return!!this._tickInterval},a.hasNextTick=function(){return!!this._tickTimer},a.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},a.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},a.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},a.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},a.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},a.doTick=function(){},s}(),_a=function(a,i,e,t,r,o){t===void 0&&(t=0),r===void 0&&(r=-1),o===void 0&&(o=!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=$r(),this.buffering={audio:$r(),video:$r(),audiovideo:$r()},this.level=a,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=o};function $r(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Qr(s,a){for(var i=0,e=s.length;i<e;i++){var t;if(((t=s[i])==null?void 0:t.cc)===a)return s[i]}return null}function $u(s,a,i){return!!(a&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function Qu(s,a){var i=s.fragments,e=a.fragments;if(!e.length||!i.length){k.log("No fragments to align");return}var t=Qr(i,e[0].cc);if(!t||t&&!t.startPTS){k.log("No frag in previous level to align on");return}return t}function Sa(s,a){if(s){var i=s.start+a;s.start=s.startPTS=i,s.endPTS=i+s.duration}}function Ta(s,a){for(var i=a.fragments,e=0,t=i.length;e<t;e++)Sa(i[e],s);a.fragmentHint&&Sa(a.fragmentHint,s),a.alignedSliding=!0}function Ju(s,a,i){a&&(Zu(s,i,a),!i.alignedSliding&&a&&el(i,a),!i.alignedSliding&&a&&!i.skippedSegments&&ea(a,i))}function Zu(s,a,i){if($u(s,i,a)){var e=Qu(i,a);e&&j(e.start)&&(k.log("Adjusting PTS using last level due to CC increase within current level "+a.url),Ta(e.start,a))}}function el(s,a){if(!(!s.hasProgramDateTime||!a.hasProgramDateTime)){var i=s.fragments,e=a.fragments;if(!(!i.length||!e.length)){var t,r,o=Math.min(a.endCC,s.endCC);a.startCC<o&&s.startCC<o&&(t=Qr(e,o),r=Qr(i,o)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=Qr(i,t.cc)||i[Math.floor(i.length/2)]);var u=t.programDateTime,h=r.programDateTime;if(!(!u||!h)){var d=(h-u)/1e3-(r.start-t.start);Ta(d,s)}}}}var tl=function(){function s(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var a=s.prototype;return a.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},s}(),rl=function(){function s(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var a=s.prototype;return a.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}();function il(s){var a=s.byteLength,i=a&&new DataView(s.buffer).getUint8(a-1);return i?nr(s,0,a-i):s}var nl=function(){function s(){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 a=s.prototype;return a.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),o=0;o<4;o++)r[o]=t.getUint32(o*4);return r},a.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,o=r[0],u=r[1],h=r[2],d=r[3],m=this.invSubMix,p=m[0],y=m[1],T=m[2],x=m[3],b=new Uint32Array(256),L=0,A=0,D=0;for(D=0;D<256;D++)D<128?b[D]=D<<1:b[D]=D<<1^283;for(D=0;D<256;D++){var w=A^A<<1^A<<2^A<<3^A<<4;w=w>>>8^w&255^99,e[L]=w,t[w]=L;var N=b[L],U=b[N],$=b[U],V=b[w]*257^w*16843008;o[L]=V<<24|V>>>8,u[L]=V<<16|V>>>16,h[L]=V<<8|V>>>24,d[L]=V,V=$*16843009^U*65537^N*257^L*16843008,p[w]=V<<24|V>>>8,y[w]=V<<16|V>>>16,T[w]=V<<8|V>>>24,x[w]=V,L?(L=N^b[b[b[$^N]]],A^=b[b[A]]):L=A=1}},a.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,o=0;o<t.length&&r;)r=t[o]===this.key[o],o++;if(!r){this.key=t;var u=this.keySize=t.length;if(u!==4&&u!==6&&u!==8)throw new Error("Invalid aes key size="+u);var h=this.ksRows=(u+6+1)*4,d,m,p=this.keySchedule=new Uint32Array(h),y=this.invKeySchedule=new Uint32Array(h),T=this.sBox,x=this.rcon,b=this.invSubMix,L=b[0],A=b[1],D=b[2],w=b[3],N,U;for(d=0;d<h;d++){if(d<u){N=p[d]=t[d];continue}U=N,d%u===0?(U=U<<8|U>>>24,U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255],U^=x[d/u|0]<<24):u>6&&d%u===4&&(U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255]),p[d]=N=(p[d-u]^U)>>>0}for(m=0;m<h;m++)d=h-m,m&3?U=p[d]:U=p[d-4],m<4||d<=4?y[m]=U:y[m]=L[T[U>>>24]]^A[T[U>>>16&255]]^D[T[U>>>8&255]]^w[T[U&255]],y[m]=y[m]>>>0}},a.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},a.decrypt=function(e,t,r){for(var o=this.keySize+6,u=this.invKeySchedule,h=this.invSBox,d=this.invSubMix,m=d[0],p=d[1],y=d[2],T=d[3],x=this.uint8ArrayToUint32Array_(r),b=x[0],L=x[1],A=x[2],D=x[3],w=new Int32Array(e),N=new Int32Array(w.length),U,$,V,M,K,z,te,Z,ie,he,fe,Le,Ee,we,Ae=this.networkToHostOrderSwap;t<w.length;){for(ie=Ae(w[t]),he=Ae(w[t+1]),fe=Ae(w[t+2]),Le=Ae(w[t+3]),K=ie^u[0],z=Le^u[1],te=fe^u[2],Z=he^u[3],Ee=4,we=1;we<o;we++)U=m[K>>>24]^p[z>>16&255]^y[te>>8&255]^T[Z&255]^u[Ee],$=m[z>>>24]^p[te>>16&255]^y[Z>>8&255]^T[K&255]^u[Ee+1],V=m[te>>>24]^p[Z>>16&255]^y[K>>8&255]^T[z&255]^u[Ee+2],M=m[Z>>>24]^p[K>>16&255]^y[z>>8&255]^T[te&255]^u[Ee+3],K=U,z=$,te=V,Z=M,Ee=Ee+4;U=h[K>>>24]<<24^h[z>>16&255]<<16^h[te>>8&255]<<8^h[Z&255]^u[Ee],$=h[z>>>24]<<24^h[te>>16&255]<<16^h[Z>>8&255]<<8^h[K&255]^u[Ee+1],V=h[te>>>24]<<24^h[Z>>16&255]<<16^h[K>>8&255]<<8^h[z&255]^u[Ee+2],M=h[Z>>>24]<<24^h[K>>16&255]<<16^h[z>>8&255]<<8^h[te&255]^u[Ee+3],N[t]=Ae(U^b),N[t+1]=Ae(M^L),N[t+2]=Ae(V^A),N[t+3]=Ae($^D),b=ie,L=he,A=fe,D=Le,t=t+4}return N.buffer},s}(),al=16,ki=function(){function s(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,o=r===void 0?!0: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=i.enableSoftwareAES,this.removePKCS7Padding=o,o)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var a=s.prototype;return a.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},a.isSync=function(){return this.useSoftware},a.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?il(r):r},a.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},a.decrypt=function(e,t,r){var o=this;return this.useSoftware?new Promise(function(u,h){o.softwareDecrypt(new Uint8Array(e),t,r);var d=o.flush();d?u(d.buffer):h(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},a.softwareDecrypt=function(e,t,r){var o=this.currentIV,u=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(e=At(h,e),this.remainderData=null);var d=this.getValidChunk(e);if(!d.length)return null;o&&(r=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new nl),m.expandKey(t);var p=u;return this.currentResult=m.decrypt(d.buffer,0,r),this.currentIV=nr(d,-16).buffer,p||null},a.webCryptoDecrypt=function(e,t,r){var o=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new rl(this.subtle,t)}return this.fastAesKey.expandKey().then(function(u){if(!o.subtle)return Promise.reject(new Error("web crypto not initialized"));o.logOnce("WebCrypto AES decrypt");var h=new tl(o.subtle,new Uint8Array(r));return h.decrypt(e.buffer,u)}).catch(function(u){return k.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+u.name+": "+u.message),o.onWebCryptoError(e,t,r)})},a.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var o=this.flush();if(o)return o.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},a.getValidChunk=function(e){var t=e,r=e.length-e.length%al;return r!==e.length&&(t=nr(e,0,r),this.remainderData=nr(e,r)),t},a.logOnce=function(e){this.logEnabled&&(k.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),sl={toString:function(a){for(var i="",e=a.length,t=0;t<e;t++)i+="["+a.start(t).toFixed(3)+"-"+a.end(t).toFixed(3)+"]";return i}},ne={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ol=function(s){I(a,s);function a(e,t,r,o,u){var h;return h=s.call(this)||this,h.hls=void 0,h.fragPrevious=null,h.fragCurrent=null,h.fragmentTracker=void 0,h.transmuxer=null,h._state=ne.STOPPED,h.playlistType=void 0,h.media=null,h.mediaBuffer=null,h.config=void 0,h.bitrateTest=!1,h.lastCurrentTime=0,h.nextLoadPosition=0,h.startPosition=0,h.startTimeOffset=null,h.loadedmetadata=!1,h.retryDate=0,h.levels=null,h.fragmentLoader=void 0,h.keyLoader=void 0,h.levelLastLoaded=null,h.startFragRequested=!1,h.decrypter=void 0,h.initPTS=[],h.onvseeking=null,h.onvended=null,h.logPrefix="",h.log=void 0,h.warn=void 0,h.playlistType=u,h.logPrefix=o,h.log=k.log.bind(k,o+":"),h.warn=k.warn.bind(k,o+":"),h.hls=e,h.fragmentLoader=new Yu(e.config),h.keyLoader=r,h.fragmentTracker=t,h.config=e.config,h.decrypter=new ki(e.config),e.on(R.MANIFEST_LOADED,h.onManifestLoaded,ae(h)),h}var i=a.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ne.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var o=r.partList;if(o!=null&&o.length){var u=o[o.length-1],h=rt.isBuffered(this.media,u.start+u.duration/2);return h}var d=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var o=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),o.addEventListener("seeking",this.onvseeking),o.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===ne.STOPPED&&this.startLoad(u.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,o=this.media,u=this.mediaBuffer,h=this.state,d=o?o.currentTime:0,m=rt.bufferInfo(u||o,d,t.maxBufferHole);if(this.log("media seeking to "+(j(d)?d.toFixed(3):d)+", state: "+h),this.state===ne.ENDED)this.resetLoadingState();else if(r){var p=t.maxFragLookUpTolerance,y=r.start-p,T=r.start+r.duration+p;if(!m.len||T<m.start||y>m.end){var x=d>T;(d<y||x)&&(x&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}o&&(this.fragmentTracker.removeFragmentsInRange(d,1/0,this.playlistType,!0),this.lastCurrentTime=d),!this.loadedmetadata&&!m.len&&(this.nextLoadPosition=this.startPosition=d),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),s.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=ne.STOPPED,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,s.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,o){this._loadFragForPlayback(t,r,o)},i._loadFragForPlayback=function(t,r,o){var u=this,h=function(m){if(u.fragContextChanged(t)){u.warn("Fragment "+t.sn+(m.part?" p: "+m.part.index:"")+" of level "+t.level+" was dropped during download."),u.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,u._handleFragmentLoadProgress(m)};this._doFragLoad(t,r,o,h).then(function(d){if(d){var m=u.state;if(u.fragContextChanged(t)){(m===ne.FRAG_LOADING||!u.fragCurrent&&m===ne.PARSING)&&(u.fragmentTracker.removeFragment(t),u.state=ne.IDLE);return}"payload"in d&&(u.log("Loaded fragment "+t.sn+" of level "+t.level),u.hls.trigger(R.FRAG_LOADED,d)),u._handleFragmentLoadComplete(d)}}).catch(function(d){u.state===ne.STOPPED||u.state===ne.ERROR||(u.warn("Frag error: "+(d?.message||d)),u.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,o=this.fragmentTracker,u=o.getState(t);if(u===gt.APPENDING){var h=t.type,d=this.getFwdBufferInfo(this.mediaBuffer,h),m=Math.max(t.duration,d?d.len:this.config.maxBufferLength),p=this.backtrackFragment,y=p?t.sn-p.sn:0;(y===1||this.reduceMaxBufferLength(m,t.duration))&&o.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?o.removeAllFragments():o.hasParts(t.type)&&(o.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),o.getState(t)===gt.PARTIAL&&o.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,o){if(o===void 0&&(o=null),!!(t-r)){var u={startOffset:t,endOffset:r,type:o};this.hls.trigger(R.BUFFER_FLUSHING,u)}},i._loadInitSegment=function(t,r){var o=this;this._doFragLoad(t,r).then(function(u){if(!u||o.fragContextChanged(t)||!o.levels)throw new Error("init load aborted");return u}).then(function(u){var h=o.hls,d=u.payload,m=t.decryptdata;if(d&&d.byteLength>0&&m!=null&&m.key&&m.iv&&m.method==="AES-128"){var p=self.performance.now();return o.decrypter.decrypt(new Uint8Array(d),m.key.buffer,m.iv.buffer).catch(function(y){throw h.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_DECRYPT_ERROR,fatal:!1,error:y,reason:y.message,frag:t}),y}).then(function(y){var T=self.performance.now();return h.trigger(R.FRAG_DECRYPTED,{frag:t,payload:y,stats:{tstart:p,tdecrypt:T}}),u.payload=y,o.completeInitSegmentLoad(u)})}return o.completeInitSegmentLoad(u)}).catch(function(u){o.state===ne.STOPPED||o.state===ne.ERROR||(o.warn(u),o.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var o=t.frag.stats;this.state=ne.IDLE,t.frag.data=new Uint8Array(t.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var o,u,h,d,m=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===Me.MAIN?"level":"track")+" "+t.level+" (frag:["+((o=t.startPTS)!=null?o:NaN).toFixed(3)+"-"+((u=t.endPTS)!=null?u:NaN).toFixed(3)+"] > buffer:"+(m?sl.toString(rt.getBuffered(m)):"(detached)")+")"),t.sn!=="initSegment"){var p;if(t.type!==Me.SUBTITLE){var y=t.elementaryStreams;if(!Object.keys(y).some(function(x){return!!y[x]})){this.state=ne.IDLE;return}}var T=(p=this.levels)==null?void 0:p[t.level];T!=null&&T.fragmentError&&(this.log("Resetting level fragment error count of "+T.fragmentError+" on frag buffered"),T.fragmentError=0)}this.state=ne.IDLE,m&&(!this.loadedmetadata&&t.type==Me.MAIN&&m.buffered.length&&((h=this.fragCurrent)==null?void 0:h.sn)===((d=this.fragPrevious)==null?void 0:d.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var o=t.frag,u=t.part,h=t.partsLoaded,d=!h||h.length===0||h.some(function(p){return!p}),m=new _a(o.level,o.sn,o.stats.chunkCount+1,0,u?u.index:-1,!d);r.flush(m)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,o,u){var h,d=this;o===void 0&&(o=null);var m=r?.details;if(!this.levels||!m)throw new Error("frag load aborted, missing level"+(m?"":" detail")+"s");var p=null;if(t.encrypted&&!((h=t.decryptdata)!=null&&h.key)?(this.log("Loading key for "+t.sn+" of ["+m.startSN+"-"+m.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=ne.KEY_LOADING,this.fragCurrent=t,p=this.keyLoader.load(t).then(function(D){if(!d.fragContextChanged(D.frag))return d.hls.trigger(R.KEY_LOADED,D),d.state===ne.KEY_LOADING&&(d.state=ne.IDLE),D}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&m.encryptedFragments.length&&this.keyLoader.loadClear(t,m.encryptedFragments),o=Math.max(t.start,o||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var y=m.partList;if(y&&u){o>t.end&&m.fragmentHint&&(t=m.fragmentHint);var T=this.getNextPart(y,t,o);if(T>-1){var x=y[T];this.log("Loading part sn: "+t.sn+" p: "+x.index+" cc: "+t.cc+" of playlist ["+m.startSN+"-"+m.endSN+"] parts [0-"+T+"-"+(y.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),this.nextLoadPosition=x.start+x.duration,this.state=ne.FRAG_LOADING;var b;return p?b=p.then(function(D){return!D||d.fragContextChanged(D.frag)?null:d.doFragPartsLoad(t,x,r,u)}).catch(function(D){return d.handleFragLoadError(D)}):b=this.doFragPartsLoad(t,x,r,u).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:x,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}else if(!t.url||this.loadedEndOfParts(y,o))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(m?"of ["+m.startSN+"-"+m.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),j(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ne.FRAG_LOADING;var L=this.config.progressive,A;return L&&p?A=p.then(function(D){return!D||d.fragContextChanged(D?.frag)?null:d.fragmentLoader.load(t,u)}).catch(function(D){return d.handleFragLoadError(D)}):A=Promise.all([this.fragmentLoader.load(t,L?u:void 0),p]).then(function(D){var w=D[0];return!L&&w&&u&&u(w),w}).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):A},i.doFragPartsLoad=function(t,r,o,u){var h=this;return new Promise(function(d,m){var p,y=[],T=(p=o.details)==null?void 0:p.partList,x=function b(L){h.fragmentLoader.loadPart(t,L,u).then(function(A){y[L.index]=A;var D=A.part;h.hls.trigger(R.FRAG_LOADED,A);var w=ta(o,t.sn,L.index+1)||ra(T,t.sn,L.index+1);if(w)b(w);else return d({frag:t,part:D,partsLoaded:y})}).catch(m)};x(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===G.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(R.ERROR,r)}else this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==ne.PARSING){!this.fragCurrent&&this.state!==ne.STOPPED&&this.state!==ne.ERROR&&(this.state=ne.IDLE);return}var o=r.frag,u=r.part,h=r.level,d=self.performance.now();o.stats.parsing.end=d,u&&(u.stats.parsing.end=d),this.updateLevelTiming(o,u,h,t.partial)},i.getCurrentContext=function(t){var r=this.levels,o=this.fragCurrent,u=t.level,h=t.sn,d=t.part;if(!(r!=null&&r[u]))return this.warn("Levels object was unset while buffering fragment "+h+" of level "+u+". The current chunk will not be buffered."),null;var m=r[u],p=d>-1?ta(m,h,d):null,y=p?p.fragment:uu(m,h,o);return y?(o&&o!==y&&(y.stats=o.stats),{frag:y,part:p,level:m}):null},i.bufferFragmentData=function(t,r,o,u,h){var d;if(!(!t||this.state!==ne.PARSING)){var m=t.data1,p=t.data2,y=m;if(m&&p&&(y=At(m,p)),!!((d=y)!=null&&d.length)){var T={type:t.type,frag:r,part:o,chunkMeta:u,parent:r.type,data:y};if(this.hls.trigger(R.BUFFER_APPENDING,T),t.dropped&&t.independent&&!o){if(h)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!rt.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var o=r.currentTime,u=rt.bufferInfo(r,o,0),h=t.duration,d=Math.min(this.config.maxFragLookUpTolerance*2,h*.25),m=Math.max(Math.min(t.start-d,u.end-d),o+d);t.start-m>d&&this.flushMainBuffer(m,t.start)}},i.getFwdBufferInfo=function(t,r){var o=this.getLoadPosition();return j(o)?this.getFwdBufferInfoAtPos(t,o,r):null},i.getFwdBufferInfoAtPos=function(t,r,o){var u=this.config.maxBufferHole,h=rt.bufferInfo(t,r,u);if(h.len===0&&h.nextStart!==void 0){var d=this.fragmentTracker.getBufferedFrag(r,o);if(d&&h.nextStart<d.end)return rt.bufferInfo(t,r,Math.max(h.nextStart,u))}return h},i.getMaxBufferLength=function(t){var r=this.config,o;return t?o=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):o=r.maxBufferLength,Math.min(o,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t,r){var o=this.config,u=Math.max(Math.min(t-r,o.maxBufferLength),r),h=Math.max(t-r*3,o.maxMaxBufferLength/2,u);return h>=u?(o.maxMaxBufferLength=h,this.warn("Reduce max buffer length to "+h+"s"),!0):!1},i.getAppendedFrag=function(t,r){var o=this.fragmentTracker.getAppendedFrag(t,Me.MAIN);return o&&"fragment"in o?o.fragment:o},i.getNextFragment=function(t,r){var o=r.fragments,u=o.length;if(!u)return null;var h=this.config,d=o[0].start,m;if(r.live){var p=h.initialLiveManifestSize;if(u<p)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+p+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<d)&&(m=this.getInitialLiveFragment(r,o),this.startPosition=this.nextLoadPosition=m?this.hls.liveSyncPosition||m.start:t)}else t<=d&&(m=o[0]);if(!m){var y=h.lowLatencyMode?r.partEnd:r.fragmentEnd;m=this.getFragmentAtPosition(t,y,r)}return this.mapToInitFragWhenRequired(m)},i.isLoopLoading=function(t,r){var o=this.fragmentTracker.getState(t);return(o===gt.OK||o===gt.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,o,u,h){var d=t.gap,m=this.getNextFragment(this.nextLoadPosition,r);if(m===null)return m;if(t=m,d&&t&&!t.gap&&o.nextStart){var p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,o.nextStart,u);if(p!==null&&o.len+p.len>=h)return this.log('buffer full after gaps in "'+u+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,o){for(var u=-1,h=!1,d=!0,m=0,p=t.length;m<p;m++){var y=t[m];if(d=d&&!y.independent,u>-1&&o<y.start)break;var T=y.loaded;T?u=-1:(h||y.independent||d)&&y.fragment===r&&(u=m),h=T}return u},i.loadedEndOfParts=function(t,r){var o=t[t.length-1];return o&&r>o.start&&o.loaded},i.getInitialLiveFragment=function(t,r){var o=this.fragPrevious,u=null;if(o){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+o.programDateTime),u=fu(r,o.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var h=o.sn+1;if(h>=t.startSN&&h<=t.endSN){var d=r[h-t.startSN];o.cc===d.cc&&(u=d,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=cu(r,o.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?t.fragmentEnd:t.edge,t))}return u},i.getFragmentAtPosition=function(t,r,o){var u=this.config,h=this.fragPrevious,d=o.fragments,m=o.endSN,p=o.fragmentHint,y=u.maxFragLookUpTolerance,T=o.partList,x=!!(u.lowLatencyMode&&T!=null&&T.length&&p);x&&p&&!this.bitrateTest&&(d=d.concat(p),m=p.sn);var b;if(t<r){var L=t>r-y?0:y;b=oa(h,d,t,L)}else b=d[d.length-1];if(b){var A=b.sn-o.startSN,D=this.fragmentTracker.getState(b);if((D===gt.OK||D===gt.PARTIAL&&b.gap)&&(h=b),h&&b.sn===h.sn&&(!x||T[0].fragment.sn>b.sn)){var w=h&&b.level===h.level;if(w){var N=d[A+1];b.sn<m&&this.fragmentTracker.getState(N)!==gt.OK?b=N:b=null}}}return b},i.synchronizeToLiveEdge=function(t){var r=this.config,o=this.media;if(o){var u=this.hls.liveSyncPosition,h=o.currentTime,d=t.fragments[0].start,m=t.edge,p=h>=d-r.maxFragLookUpTolerance&&h<=m;if(u!==null&&o.duration>u&&(h<u||!p)){var y=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!p&&o.readyState<4||h<m-y)&&(this.loadedmetadata||(this.nextLoadPosition=u),o.readyState&&(this.warn("Playback: "+h.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),o.currentTime=u))}}},i.alignPlaylists=function(t,r,o){var u=t.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var h=t.fragments[0].start,d=!r,m=t.alignedSliding&&j(h);if(d||!m&&!h){var p=this.fragPrevious;Ju(p,o,t);var y=t.fragments[0].start;return this.log("Live playlist sliding: "+y.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(p?p.sn:"na")+" fragments: "+u),y}return h},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var o=this.startPosition;if(o<r&&(o=-1),o===-1||this.lastCurrentTime===-1){var u=this.startTimeOffset!==null,h=u?this.startTimeOffset:t.startTimeOffset;h!==null&&j(h)?(o=r+h,h<0&&(o+=t.totalduration),o=Math.min(Math.max(r,o),r+t.totalduration),this.log("Start time offset "+h+" found in "+(u?"multivariant":"media")+" playlist, adjust startPosition to "+o),this.startPosition=o):t.live?o=this.hls.liveSyncPosition||r:this.startPosition=o=0,this.lastCurrentTime=o}this.nextLoadPosition=o},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==ne.FRAG_LOADING_WAITING_RETRY)&&(this.state=ne.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var o=this.getCurrentContext(r.chunkMeta);o&&(r.frag=o.frag)}var u=r.frag;if(!(!u||u.type!==t||!this.levels)){if(this.fragContextChanged(u)){var h;this.warn("Frag load error must match current frag to retry "+u.url+" > "+((h=this.fragCurrent)==null?void 0:h.url));return}var d=r.details===G.FRAG_GAP;d&&this.fragmentTracker.fragBuffered(u,!0);var m=r.errorAction,p=m||{},y=p.action,T=p.retryCount,x=T===void 0?0:T,b=p.retryConfig;if(m&&y===ot.RetryRequest&&b){this.resetStartWhenNotLoaded(this.levelLastLoaded);var L=wi(b,x);this.warn("Fragment "+u.sn+" of "+t+" "+u.level+" errored with "+r.details+", retrying loading "+(x+1)+"/"+b.maxNumRetry+" in "+L+"ms"),m.resolved=!0,this.retryDate=self.performance.now()+L,this.state=ne.FRAG_LOADING_WAITING_RETRY}else if(b&&m)if(this.resetFragmentErrors(t),x<b.maxNumRetry)!d&&y!==ot.RemoveAlternatePermanently&&(m.resolved=!0);else{k.warn(r.details+" reached or exceeded max retry ("+x+")");return}else m?.action===ot.SendAlternateToPenaltyBox?this.state=ne.WAITING_LEVEL:this.state=ne.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===ne.PARSING||this.state===ne.PARSED){var r=t.frag,o=t.parent,u=this.getFwdBufferInfo(this.mediaBuffer,o),h=u&&u.len>.5;h&&this.reduceMaxBufferLength(u.len,r?.duration||10);var d=!h;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+o+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),d}return!1},i.resetFragmentErrors=function(t){t===Me.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.afterBufferFlushed=function(t,r,o){if(t){var u=rt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,u,o),this.state===ne.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ne.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,o,u){var h=this,d,m=o.details;if(!m){this.warn("level.details undefined");return}var p=Object.keys(t.elementaryStreams).reduce(function(T,x){var b=t.elementaryStreams[x];if(b){var L=b.endPTS-b.startPTS;if(L<=0)return h.warn("Could not parse fragment "+t.sn+" "+x+" duration reliably ("+L+")"),T||!1;var A=u?0:Zn(m,t,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return h.hls.trigger(R.LEVEL_PTS_UPDATED,{details:m,level:o,drift:A,type:x,frag:t,start:b.startPTS,end:b.endPTS}),!0}return T},!1);if(!p&&((d=this.transmuxer)==null?void 0:d.error)===null){var y=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(o.fragmentError===0&&(o.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(y.message),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+o.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=ne.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},_(a,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),a}(Xu);function xa(){return self.SourceBuffer||self.WebKitSourceBuffer}function ba(){var s=ar();if(!s)return!1;var a=xa();return!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function"}function ul(){if(!ba())return!1;var s=ar();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(a){return s.isTypeSupported(Ti(a,"video"))})||["mp4a.40.2","fLaC"].some(function(a){return s.isTypeSupported(Ti(a,"audio"))}))}function ll(){var s,a=xa();return typeof(a==null||(s=a.prototype)==null?void 0:s.changeType)=="function"}function Bt(s,a){return s===void 0&&(s=""),a===void 0&&(a=9e4),{type:s,id:-1,pid:-1,inputTimeScale:a,sequenceNumber:-1,samples:[],dropped:0}}var La=function(){function s(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},a.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},a.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},a.canParse=function(e,t){return!1},a.appendFrame=function(e,t,r){},a.demux=function(e,t){this.cachedData&&(e=At(this.cachedData,e),this.cachedData=null);var r=Nr(e,0),o=r?r.length:0,u,h=this._audioTrack,d=this._id3Track,m=r?bn(r):void 0,p=e.length;for((this.basePTS===null||this.frameIndex===0&&j(m))&&(this.basePTS=fl(m,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY});o<p;){if(this.canParse(e,o)){var y=this.appendFrame(h,e,o);y?(this.frameIndex++,this.lastPTS=y.sample.pts,o+=y.length,u=o):o=p}else fo(e,o)?(r=Nr(e,o),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY}),o+=r.length,u=o):o++;if(o===p&&u!==p){var T=nr(e,u);this.cachedData?this.cachedData=At(this.cachedData,T):this.cachedData=T}}return{audioTrack:h,videoTrack:Bt(),id3Track:d,textTrack:Bt()}},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},a.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bt(),id3Track:this._id3Track,textTrack:Bt()}},a.destroy=function(){},s}(),fl=function(a,i,e){if(j(a))return a*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function hl(s,a,i,e){var t,r,o,u,h=navigator.userAgent.toLowerCase(),d=e,m=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((a[i+2]&192)>>>6)+1;var p=(a[i+2]&60)>>>2;if(p>m.length-1){var y=new Error("invalid ADTS sampling index:"+p);s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message});return}return o=(a[i+2]&1)<<2,o|=(a[i+3]&192)>>>6,k.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+p),/firefox/i.test(h)?p>=6?(t=5,u=new Array(4),r=p-3):(t=2,u=new Array(2),r=p):h.indexOf("android")!==-1?(t=2,u=new Array(2),r=p):(t=5,u=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&p>=6?r=p-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(p>=6&&o===1||/vivaldi/i.test(h))||!e&&o===1)&&(t=2,u=new Array(2)),r=p)),u[0]=t<<3,u[0]|=(p&14)>>1,u[1]|=(p&1)<<7,u[1]|=o<<3,t===5&&(u[1]|=(r&14)>>1,u[2]=(r&1)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:m[p],channelCount:o,codec:"mp4a.40."+t,manifestCodec:d}}function Aa(s,a){return s[a]===255&&(s[a+1]&246)===240}function Ra(s,a){return s[a+1]&1?7:9}function Oi(s,a){return(s[a+3]&3)<<11|s[a+4]<<3|(s[a+5]&224)>>>5}function dl(s,a){return a+5<s.length}function Jr(s,a){return a+1<s.length&&Aa(s,a)}function cl(s,a){return dl(s,a)&&Aa(s,a)&&Oi(s,a)<=s.length-a}function vl(s,a){if(Jr(s,a)){var i=Ra(s,a);if(a+i>=s.length)return!1;var e=Oi(s,a);if(e<=i)return!1;var t=a+e;return t===s.length||Jr(s,t)}return!1}function Ca(s,a,i,e,t){if(!s.samplerate){var r=hl(a,i,e,t);if(!r)return;s.config=r.config,s.samplerate=r.samplerate,s.channelCount=r.channelCount,s.codec=r.codec,s.manifestCodec=r.manifestCodec,k.log("parsed codec:"+s.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function Da(s){return 1024*9e4/s}function pl(s,a){var i=Ra(s,a);if(a+i<=s.length){var e=Oi(s,a)-i;if(e>0)return{headerLength:i,frameLength:e}}}function wa(s,a,i,e,t){var r=Da(s.samplerate),o=e+t*r,u=pl(a,i),h;if(u){var d=u.frameLength,m=u.headerLength,p=m+d,y=Math.max(0,i+p-a.length);y?(h=new Uint8Array(p-m),h.set(a.subarray(i+m,a.length),0)):h=a.subarray(i+m,i+p);var T={unit:h,pts:o};return y||s.samples.push(T),{sample:T,length:p,missing:y}}var x=a.length-i;h=new Uint8Array(x),h.set(a.subarray(i,a.length),0);var b={unit:h,pts:o};return{sample:b,length:x,missing:-1}}var Zr=null,ml=[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],gl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],yl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],El=[0,1,1,4];function Ia(s,a,i,e,t){if(!(i+24>a.length)){var r=Pa(a,i);if(r&&i+r.frameLength<=a.length){var o=r.samplesPerFrame*9e4/r.sampleRate,u=e+t*o,h={unit:a.subarray(i,i+r.frameLength),pts:u,dts:u};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(h),{sample:h,length:r.frameLength,missing:0}}}}function Pa(s,a){var i=s[a+1]>>3&3,e=s[a+1]>>1&3,t=s[a+2]>>4&15,r=s[a+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var o=s[a+2]>>1&1,u=s[a+3]>>6,h=i===3?3-e:e===3?3:4,d=ml[h*14+t-1]*1e3,m=i===3?0:i===2?1:2,p=gl[m*3+r],y=u===3?1:2,T=yl[i][e],x=El[e],b=T*8*x,L=Math.floor(T*d/p+o)*x;if(Zr===null){var A=navigator.userAgent||"",D=A.match(/Chrome\/(\d+)/i);Zr=D?parseInt(D[1]):0}var w=!!Zr&&Zr<=87;return w&&e===2&&d>=224e3&&u===0&&(s[a+3]=s[a+3]|128),{sampleRate:p,channelCount:y,frameLength:L,samplesPerFrame:b}}}function Mi(s,a){return s[a]===255&&(s[a+1]&224)===224&&(s[a+1]&6)!==0}function ka(s,a){return a+1<s.length&&Mi(s,a)}function _l(s,a){var i=4;return Mi(s,a)&&i<=s.length-a}function Oa(s,a){if(a+1<s.length&&Mi(s,a)){var i=4,e=Pa(s,a),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=a+t;return r===s.length||ka(s,r)}return!1}var Sl=function(s){I(a,s);function a(e,t){var r;return r=s.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(Oa(t,o))return!1;for(var u=t.length;o<u;o++)if(vl(t,o))return k.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return cl(t,r)},i.appendFrame=function(t,r,o){Ca(t,this.observer,r,o,t.manifestCodec);var u=wa(t,r,o,this.basePTS,this.frameIndex);if(u&&u.missing===0)return u},a}(La),Tl=/\/emsg[-/]ID3/i,xl=function(){function s(i,e){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=e}var a=s.prototype;return a.resetTimeStamp=function(){},a.resetInitSegment=function(e,t,r,o){var u=this.videoTrack=Bt("video",1),h=this.audioTrack=Bt("audio",1),d=this.txtTrack=Bt("text",1);if(this.id3Track=Bt("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var m=Pn(e);if(m.video){var p=m.video,y=p.id,T=p.timescale,x=p.codec;u.id=y,u.timescale=d.timescale=T,u.codec=x}if(m.audio){var b=m.audio,L=b.id,A=b.timescale,D=b.codec;h.id=L,h.timescale=A,h.codec=D}d.id=Cn.text,u.sampleDuration=0,u.duration=h.duration=o}},a.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return _o(e)},a.demux=function(e,t){this.timeOffset=t;var r=e,o=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=At(this.remainderData,e));var h=Do(r);this.remainderData=h.remainder,o.samples=h.valid||new Uint8Array}else o.samples=r;var d=this.extractID3Track(o,t);return u.samples=kn(t,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},a.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var o=this.extractID3Track(t,this.timeOffset);return r.samples=kn(e,t),{videoTrack:t,audioTrack:Bt(),id3Track:o,textTrack:Bt()}},a.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var o=be(e.samples,["emsg"]);o&&o.forEach(function(u){var h=Po(u);if(Tl.test(h.schemeIdUri)){var d=j(h.presentationTime)?h.presentationTime/h.timeScale:t+h.presentationTimeDelta/h.timeScale,m=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;m<=.001&&(m=Number.POSITIVE_INFINITY);var p=h.payload;r.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Rt.emsg,duration:m})}})}return r},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},a.destroy=function(){},s}(),bl=function(a,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),o=new Uint32Array(1),u=new Uint8Array(1);t>0;){u[0]=a[i];var h=Math.min(t,8),d=8-h;o[0]=4278190080>>>24+d<<d,r[0]=(u[0]&o[0])>>d,e=e?e<<h|r[0]:r[0],i+=1,t-=h}return e},Ll=function(){function s(){this.VideoSample=null}var a=s.prototype;return a.createVideoSample=function(e,t,r,o){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:o,length:0}},a.getLastNalUnit=function(e){var t,r=this.VideoSample,o;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var u=r.units;o=u[u.length-1]}return o},a.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,o=r.length;if(o){var u=r[o-1];e.pts=u.pts,e.dts=u.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&k.log(e.pts+"/"+e.dts+":"+e.debug)},s}(),Ma=function(){function s(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var a=s.prototype;return a.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,o=new Uint8Array(4),u=Math.min(4,t);if(u===0)throw new Error("no bytes available");o.set(e.subarray(r,r+u)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=u*8,this.bytesAvailable-=u},a.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},a.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&k.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},a.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()},a.skipUEG=function(){this.skipBits(1+this.skipLZ())},a.skipEG=function(){this.skipBits(1+this.skipLZ())},a.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},a.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},a.readBoolean=function(){return this.readBits(1)===1},a.readUByte=function(){return this.readBits(8)},a.readUShort=function(){return this.readBits(16)},a.readUInt=function(){return this.readBits(32)},a.skipScalingList=function(e){for(var t=8,r=8,o,u=0;u<e;u++)r!==0&&(o=this.readEG(),r=(t+o+256)%256),t=r===0?t:r},a.readSPS=function(){var e=0,t=0,r=0,o=0,u,h,d,m=this.readUByte.bind(this),p=this.readBits.bind(this),y=this.readUEG.bind(this),T=this.readBoolean.bind(this),x=this.skipBits.bind(this),b=this.skipEG.bind(this),L=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);m();var D=m();if(p(5),x(3),m(),L(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){var w=y();if(w===3&&x(1),L(),L(),x(1),T())for(h=w!==3?8:12,d=0;d<h;d++)T()&&(d<6?A(16):A(64))}L();var N=y();if(N===0)y();else if(N===1)for(x(1),b(),b(),u=y(),d=0;d<u;d++)b();L(),x(1);var U=y(),$=y(),V=p(1);V===0&&x(1),x(1),T()&&(e=y(),t=y(),r=y(),o=y());var M=[1,1];if(T()&&T()){var K=m();switch(K){case 1:M=[1,1];break;case 2:M=[12,11];break;case 3:M=[10,11];break;case 4:M=[16,11];break;case 5:M=[40,33];break;case 6:M=[24,11];break;case 7:M=[20,11];break;case 8:M=[32,11];break;case 9:M=[80,33];break;case 10:M=[18,11];break;case 11:M=[15,11];break;case 12:M=[64,33];break;case 13:M=[160,99];break;case 14:M=[4,3];break;case 15:M=[3,2];break;case 16:M=[2,1];break;case 255:{M=[m()<<8|m(),m()<<8|m()];break}}}return{width:Math.ceil((U+1)*16-e*2-t*2),height:(2-V)*($+1)*16-(V?2:4)*(r+o),pixelRatio:M}},a.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Al=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.parseAVCPES=function(t,r,o,u,h){var d=this,m=this.parseAVCNALu(t,o.data),p=this.VideoSample,y,T=!1;o.data=null,p&&m.length&&!t.audFound&&(this.pushAccessUnit(p,t),p=this.VideoSample=this.createVideoSample(!1,o.pts,o.dts,"")),m.forEach(function(x){var b;switch(x.type){case 1:{var L=!1;y=!0;var A=x.data;if(T&&A.length>4){var D=new Ma(A).readSliceType();(D===2||D===4||D===7||D===9)&&(L=!0)}if(L){var w;(w=p)!=null&&w.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null)}p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.frame=!0,p.key=L;break}case 5:y=!0,(b=p)!=null&&b.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null),p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.key=!0,p.frame=!0;break;case 6:{y=!0,On(x.data,1,o.pts,r.samples);break}case 7:{var N,U;y=!0,T=!0;var $=x.data,V=new Ma($),M=V.readSPS();if(!t.sps||t.width!==M.width||t.height!==M.height||((N=t.pixelRatio)==null?void 0:N[0])!==M.pixelRatio[0]||((U=t.pixelRatio)==null?void 0:U[1])!==M.pixelRatio[1]){t.width=M.width,t.height=M.height,t.pixelRatio=M.pixelRatio,t.sps=[$],t.duration=h;for(var K=$.subarray(1,4),z="avc1.",te=0;te<3;te++){var Z=K[te].toString(16);Z.length<2&&(Z="0"+Z),z+=Z}t.codec=z}break}case 8:y=!0,t.pps=[x.data];break;case 9:y=!0,t.audFound=!0,p&&d.pushAccessUnit(p,t),p=d.VideoSample=d.createVideoSample(!1,o.pts,o.dts,"");break;case 12:y=!0;break;default:y=!1,p&&(p.debug+="unknown NAL "+x.type+" ");break}if(p&&y){var ie=p.units;ie.push(x)}}),u&&p&&(this.pushAccessUnit(p,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var o=r.byteLength,u=t.naluState||0,h=u,d=[],m=0,p,y,T,x=-1,b=0;for(u===-1&&(x=0,b=r[0]&31,u=0,m=1);m<o;){if(p=r[m++],!u){u=p?0:1;continue}if(u===1){u=p?0:2;continue}if(!p)u=3;else if(p===1){if(y=m-u-1,x>=0){var L={data:r.subarray(x,y),type:b};d.push(L)}else{var A=this.getLastNalUnit(t.samples);A&&(h&&m<=4-h&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-h)),y>0&&(A.data=At(A.data,r.subarray(0,y)),A.state=0))}m<o?(T=r[m]&31,x=m,b=T,u=0):u=-1}else u=0}if(x>=0&&u>=0){var D={data:r.subarray(x,o),type:b,state:u};d.push(D)}if(d.length===0){var w=this.getLastNalUnit(t.samples);w&&(w.data=At(w.data,r))}return t.naluState=u,d},a}(Ll),Rl=function(){function s(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new ki(e,{removePKCS7Padding:!1})}var a=s.prototype;return a.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},a.decryptAacSample=function(e,t,r){var o=this,u=e[t].unit;if(!(u.length<=16)){var h=u.subarray(16,u.length-u.length%16),d=h.buffer.slice(h.byteOffset,h.byteOffset+h.length);this.decryptBuffer(d).then(function(m){var p=new Uint8Array(m);u.set(p,16),o.decrypter.isSync()||o.decryptAacSamples(e,t+1,r)})}},a.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},a.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)r.set(e.subarray(u,u+16),o);return r},a.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)e.set(r.subarray(o,o+16),u);return e},a.decryptAvcSample=function(e,t,r,o,u){var h=this,d=Mn(u.data),m=this.getAvcEncryptedData(d);this.decryptBuffer(m.buffer).then(function(p){u.data=h.getAvcDecryptedUnit(d,p),h.decrypter.isSync()||h.decryptAvcSamples(e,t,r+1,o)})},a.decryptAvcSamples=function(e,t,r,o){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){o();return}for(var u=e[t].units;!(r>=u.length);r++){var h=u[r];if(!(h.data.length<=48||h.type!==1&&h.type!==5)&&(this.decryptAvcSample(e,t,r,o,h),!this.decrypter.isSync()))return}}},s}(),at=188,Cl=function(){function s(i,e,t){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=i,this.config=e,this.typeSupported=t,this.videoParser=new Al}s.probe=function(e){var t=s.syncOffset(e);return t>0&&k.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(at*5,t-at)+1,o=0;o<r;){for(var u=!1,h=-1,d=0,m=o;m<t;m+=at)if(e[m]===71&&(t-m===at||e[m+at]===71)){if(d++,h===-1&&(h=m,h!==0&&(r=Math.min(h+at*99,e.length-at)+1)),u||(u=Fi(e,m)===0),u&&d>1&&(h===0&&d>2||m+at>r))return h}else{if(d)return-1;break}o++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Cn[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",o),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=o},a.resetTimeStamp=function(){},a.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},a.demux=function(e,t,r,o){r===void 0&&(r=!1),o===void 0&&(o=!1),r||(this.sampleAes=null);var u,h=this._videoTrack,d=this._audioTrack,m=this._id3Track,p=this._txtTrack,y=h.pid,T=h.pesData,x=d.pid,b=m.pid,L=d.pesData,A=m.pesData,D=null,w=this.pmtParsed,N=this._pmtId,U=e.length;if(this.remainderData&&(e=At(this.remainderData,e),U=e.length,this.remainderData=null),U<at&&!o)return this.remainderData=e,{audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};var $=Math.max(0,s.syncOffset(e));U-=(U-$)%at,U<e.byteLength&&!o&&(this.remainderData=new Uint8Array(e.buffer,U,e.buffer.byteLength-U));for(var V=0,M=$;M<U;M+=at)if(e[M]===71){var K=!!(e[M+1]&64),z=Fi(e,M),te=(e[M+3]&48)>>4,Z=void 0;if(te>1){if(Z=M+5+e[M+4],Z===M+at)continue}else Z=M+4;switch(z){case y:K&&(T&&(u=pr(T))&&this.videoParser.parseAVCPES(h,p,u,!1,this._duration),T={data:[],size:0}),T&&(T.data.push(e.subarray(Z,M+at)),T.size+=M+at-Z);break;case x:if(K){if(L&&(u=pr(L)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}L={data:[],size:0}}L&&(L.data.push(e.subarray(Z,M+at)),L.size+=M+at-Z);break;case b:K&&(A&&(u=pr(A))&&this.parseID3PES(m,u),A={data:[],size:0}),A&&(A.data.push(e.subarray(Z,M+at)),A.size+=M+at-Z);break;case 0:K&&(Z+=e[Z]+1),N=this._pmtId=Dl(e,Z);break;case N:{K&&(Z+=e[Z]+1);var ie=wl(e,Z,this.typeSupported,r,this.observer);y=ie.videoPid,y>0&&(h.pid=y,h.segmentCodec=ie.segmentVideoCodec),x=ie.audioPid,x>0&&(d.pid=x,d.segmentCodec=ie.segmentAudioCodec),b=ie.id3Pid,b>0&&(m.pid=b),D!==null&&!w&&(k.warn("MPEG-TS PMT found at "+M+" after unknown PID '"+D+"'. Backtracking to sync byte @"+$+" to parse all TS packets."),D=null,M=$-188),w=this.pmtParsed=!0;break}case 17:case 8191:break;default:D=z;break}}else V++;V>0&&ei(this.observer,new Error("Found "+V+" TS packet/s that do not start with 0x47")),h.pesData=T,d.pesData=L,m.pesData=A;var he={audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};return o&&this.extractRemainingSamples(he),he},a.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},a.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,o=e.id3Track,u=e.textTrack,h=r.pesData,d=t.pesData,m=o.pesData,p;if(h&&(p=pr(h))?(this.videoParser.parseAVCPES(r,u,p,!0,this._duration),r.pesData=null):r.pesData=h,d&&(p=pr(d))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,p);break;case"mp3":this.parseMPEGPES(t,p);break}t.pesData=null}else d!=null&&d.size&&k.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=d;m&&(p=pr(m))?(this.parseID3PES(o,p),o.pesData=null):o.pesData=m},a.demuxSampleAes=function(e,t,r){var o=this.demux(e,r,!0,!this.config.progressive),u=this.sampleAes=new Rl(this.observer,this.config,t);return this.decrypt(o,u)},a.decrypt=function(e,t){return new Promise(function(r){var o=e.audioTrack,u=e.videoTrack;o.samples&&o.segmentCodec==="aac"?t.decryptAacSamples(o.samples,0,function(){u.samples?t.decryptAvcSamples(u.samples,0,0,function(){r(e)}):r(e)}):u.samples&&t.decryptAvcSamples(u.samples,0,0,function(){r(e)})})},a.destroy=function(){this._duration=0},a.parseAACPES=function(e,t){var r=0,o=this.aacOverFlow,u=t.data;if(o){this.aacOverFlow=null;var h=o.missing,d=o.sample.unit.byteLength;if(h===-1)u=At(o.sample.unit,u);else{var m=d-h;o.sample.unit.set(u.subarray(0,h),m),e.samples.push(o.sample),r=o.missing}}var p,y;for(p=r,y=u.length;p<y-1&&!Jr(u,p);p++);if(p!==r){var T,x=p<y-1;if(x?T="AAC PES did not start with ADTS header,offset:"+p:T="No ADTS header found in AAC PES",ei(this.observer,new Error(T),x),!x)return}Ca(e,this.observer,u,p,this.audioCodec);var b;if(t.pts!==void 0)b=t.pts;else if(o){var L=Da(e.samplerate);b=o.sample.pts+L}else{k.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var A=0,D;p<y;)if(D=wa(e,u,p,b,A),p+=D.length,D.missing){this.aacOverFlow=D;break}else for(A++;p<y-1&&!Jr(u,p);p++);},a.parseMPEGPES=function(e,t){var r=t.data,o=r.length,u=0,h=0,d=t.pts;if(d===void 0){k.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;h<o;)if(ka(r,h)){var m=Ia(e,r,h,d,u);if(m)h+=m.length,u++;else break}else h++},a.parseAC3PES=function(e,t){},a.parseID3PES=function(e,t){if(t.pts===void 0){k.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=C({},t,{type:this._videoTrack?Rt.emsg:Rt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},s}();function Fi(s,a){return((s[a+1]&31)<<8)+s[a+2]}function Dl(s,a){return(s[a+10]&31)<<8|s[a+11]}function wl(s,a,i,e,t){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[a+1]&15)<<8|s[a+2],u=a+3+o-4,h=(s[a+10]&15)<<8|s[a+11];for(a+=12+h;a<u;){var d=Fi(s,a),m=(s[a+3]&15)<<8|s[a+4];switch(s[a]){case 207:if(!e){Ni("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=d);break;case 21:r.id3Pid===-1&&(r.id3Pid=d);break;case 219:if(!e){Ni("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=d,r.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?k.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=d,r.segmentAudioCodec="mp3");break;case 193:if(!e){Ni("AC-3");break}case 129:k.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&m>0)for(var p=a+5,y=m;y>2;){var T=s[p];switch(T){case 106:k.warn("AC-3 in M2TS support not included in build");break}var x=s[p+1]+2;p+=x,y-=x}break;case 194:case 135:return ei(t,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return ei(t,new Error("Unsupported HEVC in M2TS found")),r}a+=m+5}return r}function ei(s,a,i){k.warn("parsing error: "+a.message),s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:a,reason:a.message})}function Ni(s){k.log(s+" with AES-128-CBC encryption found in unencrypted stream")}function pr(s){var a=0,i,e,t,r,o,u=s.data;if(!s||s.size===0)return null;for(;u[0].length<19&&u.length>1;)u[0]=At(u[0],u[1]),u.splice(1,1);i=u[0];var h=(i[0]<<16)+(i[1]<<8)+i[2];if(h===1){if(e=(i[4]<<8)+i[5],e&&e>s.size-6)return null;var d=i[7];d&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,d&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-o>60*9e4&&(k.warn(Math.round((r-o)/9e4)+"s delta between PTS and DTS, align them"),r=o)):o=r),t=i[8];var m=t+9;if(s.size<=m)return null;s.size-=m;for(var p=new Uint8Array(s.size),y=0,T=u.length;y<T;y++){i=u[y];var x=i.byteLength;if(m)if(m>x){m-=x;continue}else i=i.subarray(m),x-=m,m=0;p.set(i,a),a+=x}return e&&(e-=t+3),{data:p,pts:r,dts:o,len:e}}return null}var Il=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(r&&t[o]===11&&t[o+1]===119&&bn(r)!==void 0&&bl(t,o)<=16)return!1;for(var u=t.length;o<u;o++)if(Oa(t,o))return k.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return _l(t,r)},i.appendFrame=function(t,r,o){if(this.basePTS!==null)return Ia(t,r,o,this.basePTS,this.frameIndex)},a}(La),Fa=function(){function s(){}return s.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)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(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)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(e===2)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(e===3)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]);break}},s}(),Jt=Math.pow(2,32)-1,ut=function(){function s(){}return s.init=function(){s.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:[]};var i;for(i in s.types)s.types.hasOwnProperty(i)&&(s.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=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]),t=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]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=o,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,u,d,u,h),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];for(var u=r.length,h=u;u--;)e+=r[u].byteLength;var d=new Uint8Array(e);for(d[0]=e>>24&255,d[1]=e>>16&255,d[2]=e>>8&255,d[3]=e&255,d.set(i,4),u=0,e=8;u<h;u++)d.set(r[u],e),e+=r[u].byteLength;return d},s.hdlr=function(i){return s.box(s.types.hdlr,s.HDLR_TYPES[i])},s.mdat=function(i){return s.box(s.types.mdat,i)},s.mdhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},s.mdia=function(i){return s.box(s.types.mdia,s.mdhd(i.timescale,i.duration),s.hdlr(i.type),s.minf(i))},s.mfhd=function(i){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},s.minf=function(i){return i.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(i)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(i))},s.moof=function(i,e,t){return s.box(s.types.moof,s.mfhd(i),s.traf(t,e))},s.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trak(i[e]);return s.box.apply(null,[s.types.moov,s.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(s.mvex(i)))},s.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trex(i[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,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 s.box(s.types.mvhd,o)},s.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,o;for(r=0;r<e.length;r++)o=e[r].flags,t[r+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return s.box(s.types.sdtp,t)},s.stbl=function(i){return s.box(s.types.stbl,s.stsd(i),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(i){var e=[],t=[],r,o,u;for(r=0;r<i.sps.length;r++)o=i.sps[r],u=o.byteLength,e.push(u>>>8&255),e.push(u&255),e=e.concat(Array.prototype.slice.call(o));for(r=0;r<i.pps.length;r++)o=i.pps[r],u=o.byteLength,t.push(u>>>8&255),t.push(u&255),t=t.concat(Array.prototype.slice.call(o));var h=s.box(s.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),d=i.width,m=i.height,p=i.pixelRatio[0],y=i.pixelRatio[1];return s.box(s.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,d>>8&255,d&255,m>>8&255,m&255,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,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&255])))},s.esds=function(i){var e=i.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(i.config).concat([6,1,2]))},s.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},s.mp4a=function(i){return s.box(s.types.mp4a,s.audioStsd(i),s.box(s.types.esds,s.esds(i)))},s.mp3=function(i){return s.box(s.types[".mp3"],s.audioStsd(i))},s.ac3=function(i){return s.box(s.types["ac-3"],s.audioStsd(i),s.box(s.types.dac3,i.config))},s.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(i)):i.segmentCodec==="ac3"?s.box(s.types.stsd,s.STSD,s.ac3(i)):s.box(s.types.stsd,s.STSD,s.mp4a(i)):s.box(s.types.stsd,s.STSD,s.avc1(i))},s.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,o=i.height,u=Math.floor(t/(Jt+1)),h=Math.floor(t%(Jt+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,h>>24,h>>16&255,h>>8&255,h&255,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,r>>8&255,r&255,0,0,o>>8&255,o&255,0,0]))},s.traf=function(i,e){var t=s.sdtp(i),r=i.id,o=Math.floor(e/(Jt+1)),u=Math.floor(e%(Jt+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255])),s.trun(i,t.length+16+20+8+16+8+8),t)},s.trak=function(i){return i.duration=i.duration||4294967295,s.box(s.types.trak,s.tkhd(i),s.mdia(i))},s.trex=function(i){var e=i.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(i,e){var t=i.samples||[],r=t.length,o=12+16*r,u=new Uint8Array(o),h,d,m,p,y,T;for(e+=8+o,u.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),h=0;h<r;h++)d=t[h],m=d.duration,p=d.size,y=d.flags,T=d.cts,u.set([m>>>24&255,m>>>16&255,m>>>8&255,m&255,p>>>24&255,p>>>16&255,p>>>8&255,p&255,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.paddingValue<<1|y.isNonSync,y.degradPrio&61440,y.degradPrio&15,T>>>24&255,T>>>16&255,T>>>8&255,T&255],12+16*h);return s.box(s.types.trun,u)},s.initSegment=function(i){s.types||s.init();var e=s.moov(i),t=At(s.FTYP,e);return t},s}();ut.types=void 0,ut.HDLR_TYPES=void 0,ut.STTS=void 0,ut.STSC=void 0,ut.STCO=void 0,ut.STSZ=void 0,ut.VMHD=void 0,ut.SMHD=void 0,ut.STSD=void 0,ut.FTYP=void 0,ut.DINF=void 0;var Pl=9e4;function kl(s,a,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=s*a*i;return e?Math.round(t):t}function Ar(s,a){return a===void 0&&(a=!1),kl(s,1e3,1/Pl,a)}var Ol=10*1e3,Na=1024,Ml=1152,Fl=1536,mr=null,Ui=null,Bi=function(){function s(i,e,t,r){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=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,mr===null){var o=navigator.userAgent||"",u=o.match(/Chrome\/(\d+)/i);mr=u?parseInt(u[1]):0}if(Ui===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);Ui=h?parseInt(h[1]):0}}var a=s.prototype;return a.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},a.resetTimeStamp=function(e){k.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},a.resetNextTimestamp=function(){k.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},a.resetInitSegment=function(){k.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},a.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(o,u){var h=u.pts-o;return h<-4294967296?(t=!0,Dt(o,u.pts)):h>0?o:u.pts},e[0].pts);return t&&k.debug("PTS rollover detected"),r},a.remux=function(e,t,r,o,u,h,d,m){var p,y,T,x,b,L,A=u,D=u,w=e.pid>-1,N=t.pid>-1,U=t.samples.length,$=e.samples.length>0,V=d&&U>0||U>1,M=(!w||$)&&(!N||V)||this.ISGenerated||d;if(M){if(this.ISGenerated){var K,z,te,Z,ie=this.videoTrackConfig;ie&&(t.width!==ie.width||t.height!==ie.height||((K=t.pixelRatio)==null?void 0:K[0])!==((z=ie.pixelRatio)==null?void 0:z[0])||((te=t.pixelRatio)==null?void 0:te[1])!==((Z=ie.pixelRatio)==null?void 0:Z[1]))&&this.resetInitSegment()}else T=this.generateIS(e,t,u,h);var he=this.isVideoContiguous,fe=-1,Le;if(V&&(fe=Nl(t.samples),!he&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,fe>0){k.warn("[mp4-remuxer]: Dropped "+fe+" out of "+U+" video samples due to a missing keyframe");var Ee=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(fe),t.dropped+=fe,D+=(t.samples[0].pts-Ee)/t.inputTimeScale,Le=D}else fe===-1&&(k.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),L=!1);if(this.ISGenerated){if($&&V){var we=this.getVideoStartPts(t.samples),Ae=Dt(e.samples[0].pts,we)-we,ye=Ae/t.inputTimeScale;A+=Math.max(0,ye),D+=Math.max(0,-ye)}if($){if(e.samplerate||(k.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),T=this.generateIS(e,t,u,h)),y=this.remuxAudio(e,A,this.isAudioContiguous,h,N||V||m===Me.AUDIO?D:void 0),V){var je=y?y.endPTS-y.startPTS:0;t.inputTimeScale||(k.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),T=this.generateIS(e,t,u,h)),p=this.remuxVideo(t,D,he,je)}}else V&&(p=this.remuxVideo(t,D,he,0));p&&(p.firstKeyFrame=fe,p.independent=fe!==-1,p.firstKeyFramePTS=Le)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(b=Ua(r,u,this._initPTS,this._initDTS)),o.samples.length&&(x=Ba(o,u,this._initPTS))),{audio:y,video:p,initSegment:T,independent:L,text:x,id3:b}},a.generateIS=function(e,t,r,o){var u=e.samples,h=t.samples,d=this.typeSupported,m={},p=this._initPTS,y=!p||o,T="audio/mp4",x,b,L;if(y&&(x=b=1/0),e.config&&u.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(T="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}m.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):ut.initSegment([e]),metadata:{channelCount:e.channelCount}},y&&(L=e.inputTimeScale,!p||L!==p.timescale?x=b=u[0].pts-Math.round(L*r):y=!1)}if(t.sps&&t.pps&&h.length){if(t.timescale=t.inputTimeScale,m.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ut.initSegment([t]),metadata:{width:t.width,height:t.height}},y)if(L=t.inputTimeScale,!p||L!==p.timescale){var A=this.getVideoStartPts(h),D=Math.round(L*r);b=Math.min(b,Dt(h[0].dts,A)-D),x=Math.min(x,A-D)}else y=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(m).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:x,timescale:L},this._initDTS={baseTime:b,timescale:L}):x=L=void 0,{tracks:m,initPTS:x,timescale:L}},a.remuxVideo=function(e,t,r,o){var u=e.inputTimeScale,h=e.samples,d=[],m=h.length,p=this._initPTS,y=this.nextAvcDts,T=8,x=this.videoSampleDuration,b,L,A=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,w=!1;if(!r||y===null){var N=t*u,U=h[0].pts-Dt(h[0].dts,h[0].pts);mr&&y!==null&&Math.abs(N-U-y)<15e3?r=!0:y=N-U}for(var $=p.baseTime*u/p.timescale,V=0;V<m;V++){var M=h[V];M.pts=Dt(M.pts-$,y),M.dts=Dt(M.dts-$,y),M.dts<h[V>0?V-1:V].dts&&(w=!0)}w&&h.sort(function(ni,Ja){var hf=ni.dts-Ja.dts,df=ni.pts-Ja.pts;return hf||df}),b=h[0].dts,L=h[h.length-1].dts;var K=L-b,z=K?Math.round(K/(m-1)):x||e.inputTimeScale/30;if(r){var te=b-y,Z=te>z,ie=te<-1;if((Z||ie)&&(Z?k.warn("AVC: "+Ar(te,!0)+" ms ("+te+"dts) hole between fragments detected at "+t.toFixed(3)):k.warn("AVC: "+Ar(-te,!0)+" ms ("+te+"dts) overlapping between fragments detected at "+t.toFixed(3)),!ie||y>=h[0].pts||mr)){b=y;var he=h[0].pts-te;if(Z)h[0].dts=b,h[0].pts=he;else for(var fe=0;fe<h.length&&!(h[fe].dts>he);fe++)h[fe].dts-=te,h[fe].pts-=te;k.log("Video: Initial PTS/DTS adjusted: "+Ar(he,!0)+"/"+Ar(b,!0)+", delta: "+Ar(te,!0)+" ms")}}b=Math.max(0,b);for(var Le=0,Ee=0,we=b,Ae=0;Ae<m;Ae++){for(var ye=h[Ae],je=ye.units,Fe=je.length,qe=0,Xe=0;Xe<Fe;Xe++)qe+=je[Xe].data.length;Ee+=qe,Le+=Fe,ye.length=qe,ye.dts<we?(ye.dts=we,we+=z/4|0||1):we=ye.dts,A=Math.min(ye.pts,A),D=Math.max(ye.pts,D)}L=h[m-1].dts;var Ze=Ee+4*Le+8,ze;try{ze=new Uint8Array(Ze)}catch(ni){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:ni,bytes:Ze,reason:"fail allocating video mdat "+Ze});return}var Ue=new DataView(ze.buffer);Ue.setUint32(0,Ze),ze.set(ut.types.mdat,4);for(var jt=!1,_t=Number.POSITIVE_INFINITY,$e=Number.POSITIVE_INFINITY,ct=Number.NEGATIVE_INFINITY,vt=Number.NEGATIVE_INFINITY,et=0;et<m;et++){for(var Ke=h[et],yt=Ke.units,ft=0,st=0,or=yt.length;st<or;st++){var Ya=yt[st],rf=Ya.data,ji=Ya.data.byteLength;Ue.setUint32(T,ji),T+=4,ze.set(rf,T),T+=ji,ft+=4+ji}var ri=void 0;if(et<m-1)x=h[et+1].dts-Ke.dts,ri=h[et+1].pts-Ke.pts;else{var qa=this.config,ii=et>0?Ke.dts-h[et-1].dts:z;if(ri=et>0?Ke.pts-h[et-1].pts:z,qa.stretchShortVideoTrack&&this.nextAudioPts!==null){var nf=Math.floor(qa.maxBufferHole*u),zi=(o?A+o*u:this.nextAudioPts)-Ke.pts;zi>nf?(x=zi-ii,x<0?x=ii:jt=!0,k.log("[mp4-remuxer]: It is approximately "+zi/90+" ms to the next segment; using duration "+x/90+" ms for the last video frame.")):x=ii}else x=ii}var af=Math.round(Ke.pts-Ke.dts);_t=Math.min(_t,x),ct=Math.max(ct,x),$e=Math.min($e,ri),vt=Math.max(vt,ri),d.push(new Ga(Ke.key,x,ft,af))}if(d.length){if(mr){if(mr<70){var Xa=d[0].flags;Xa.dependsOn=2,Xa.isNonSync=0}}else if(Ui&&vt-$e<ct-_t&&z/ct<.025&&d[0].cts===0){k.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Yi=b,wt=0,$a=d.length;wt<$a;wt++){var Qa=Yi+d[wt].duration,sf=Yi+d[wt].cts;if(wt<$a-1){var of=Qa+d[wt+1].cts;d[wt].duration=of-sf}else d[wt].duration=wt?d[wt-1].duration:z;d[wt].cts=0,Yi=Qa}}}x=jt||!x?z:x,this.nextAvcDts=y=L+x,this.videoSampleDuration=x,this.isVideoContiguous=!0;var uf=ut.moof(e.sequenceNumber++,b,C({},e,{samples:d})),lf="video",ff={data1:uf,data2:ze,startPTS:A/u,endPTS:(D+x)/u,startDTS:b/u,endDTS:y/u,type:lf,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ff},a.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return Ml;case"ac3":return Fl;default:return Na}},a.remuxAudio=function(e,t,r,o,u){var h=e.inputTimeScale,d=e.samplerate?e.samplerate:h,m=h/d,p=this.getSamplesPerFrame(e),y=p*m,T=this._initPTS,x=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],L=u!==void 0,A=e.samples,D=x?0:8,w=this.nextAudioPts||-1,N=t*h,U=T.baseTime*h/T.timescale;if(this.isAudioContiguous=r=r||A.length&&w>0&&(o&&Math.abs(N-w)<9e3||Math.abs(Dt(A[0].pts-U,N)-w)<20*y),A.forEach(function(st){st.pts=Dt(st.pts-U,N)}),!r||w<0){if(A=A.filter(function(st){return st.pts>=0}),!A.length)return;u===0?w=0:o&&!L?w=Math.max(0,N):w=A[0].pts}if(e.segmentCodec==="aac")for(var $=this.config.maxAudioFramesDrift,V=0,M=w;V<A.length;V++){var K=A[V],z=K.pts,te=z-M,Z=Math.abs(1e3*te/h);if(te<=-$*y&&L)V===0&&(k.warn("Audio frame @ "+(z/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/h)+" ms."),this.nextAudioPts=w=M=z);else if(te>=$*y&&Z<Ol&&L){var ie=Math.round(te/y);M=z-ie*y,M<0&&(ie--,M+=y),V===0&&(this.nextAudioPts=w=M),k.warn("[mp4-remuxer]: Injecting "+ie+" audio frame @ "+(M/h).toFixed(3)+"s due to "+Math.round(1e3*te/h)+" ms gap.");for(var he=0;he<ie;he++){var fe=Math.max(M,0),Le=Fa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Le||(k.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=K.unit.subarray()),A.splice(V,0,{unit:Le,pts:fe}),M+=y,V++}}K.pts=M,M+=y}for(var Ee=null,we=null,Ae,ye=0,je=A.length;je--;)ye+=A[je].unit.byteLength;for(var Fe=0,qe=A.length;Fe<qe;Fe++){var Xe=A[Fe],Ze=Xe.unit,ze=Xe.pts;if(we!==null){var Ue=b[Fe-1];Ue.duration=Math.round((ze-we)/m)}else if(r&&e.segmentCodec==="aac"&&(ze=w),Ee=ze,ye>0){ye+=D;try{Ae=new Uint8Array(ye)}catch(st){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:st,bytes:ye,reason:"fail allocating audio mdat "+ye});return}if(!x){var jt=new DataView(Ae.buffer);jt.setUint32(0,ye),Ae.set(ut.types.mdat,4)}}else return;Ae.set(Ze,D);var _t=Ze.byteLength;D+=_t,b.push(new Ga(!0,p,_t,0)),we=ze}var $e=b.length;if($e){var ct=b[b.length-1];this.nextAudioPts=w=we+m*ct.duration;var vt=x?new Uint8Array(0):ut.moof(e.sequenceNumber++,Ee/m,C({},e,{samples:b}));e.samples=[];var et=Ee/h,Ke=w/h,yt="audio",ft={data1:vt,data2:Ae,startPTS:et,endPTS:Ke,startDTS:et,endDTS:Ke,type:yt,hasAudio:!0,hasVideo:!1,nb:$e};return this.isAudioContiguous=!0,ft}},a.remuxEmptyAudio=function(e,t,r,o){var u=e.inputTimeScale,h=e.samplerate?e.samplerate:u,d=u/h,m=this.nextAudioPts,p=this._initDTS,y=p.baseTime*9e4/p.timescale,T=(m!==null?m:o.startDTS*u)+y,x=o.endDTS*u+y,b=d*Na,L=Math.ceil((x-T)/b),A=Fa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(k.warn("[mp4-remuxer]: remux empty Audio"),!A){k.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var D=[],w=0;w<L;w++){var N=T+w*b;D.push({unit:A,pts:N,dts:N})}return e.samples=D,this.remuxAudio(e,t,r,!1)},s}();function Dt(s,a){var i;if(a===null)return s;for(a<s?i=-8589934592:i=8589934592;Math.abs(s-a)>4294967296;)s+=i;return s}function Nl(s){for(var a=0;a<s.length;a++)if(s[a].key)return a;return-1}function Ua(s,a,i,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,o=0;o<t;o++){var u=s.samples[o];u.pts=Dt(u.pts-i.baseTime*r/i.timescale,a*r)/r,u.dts=Dt(u.dts-e.baseTime*r/e.timescale,a*r)/r}var h=s.samples;return s.samples=[],{samples:h}}}function Ba(s,a,i){var e=s.samples.length;if(e){for(var t=s.inputTimeScale,r=0;r<e;r++){var o=s.samples[r];o.pts=Dt(o.pts-i.baseTime*t/i.timescale,a*t)/t}s.samples.sort(function(h,d){return h.pts-d.pts});var u=s.samples;return s.samples=[],{samples:u}}}var Ga=function(a,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}},Ul=function(){function s(){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 a=s.prototype;return a.destroy=function(){},a.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},a.resetNextTimestamp=function(){this.lastEndTime=null},a.resetInitSegment=function(e,t,r,o){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(xo(e,o)),this.emitInitSegment=!0},a.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var o=this.initData=Pn(e);o.audio&&(t=Va(o.audio,Pe.AUDIO)),o.video&&(r=Va(o.video,Pe.VIDEO));var u={};o.audio&&o.video?u.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:o.audio?u.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:o.video?u.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:k.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=u},a.remux=function(e,t,r,o,u,h){var d,m,p=this.initPTS,y=this.lastEndTime,T={audio:void 0,video:void 0,text:o,id3:r,initSegment:void 0};j(y)||(y=this.lastEndTime=u||0);var x=t.samples;if(!(x!=null&&x.length))return T;var b={initPTS:void 0,timescale:1},L=this.initData;if((d=L)!=null&&d.length||(this.generateInitSegment(x),L=this.initData),!((m=L)!=null&&m.length))return k.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);var A=Ao(x,L),D=Lo(L,x),w=D===null?u:D;(Bl(p,w,u,A)||b.timescale!==p.timescale&&h)&&(b.initPTS=w-u,p&&p.timescale===1&&k.warn("Adjusting initPTS by "+(b.initPTS-p.baseTime)),this.initPTS=p={baseTime:b.initPTS,timescale:1});var N=e?w-p.baseTime/p.timescale:y,U=N+A;Co(L,x,p.baseTime/p.timescale),A>0?this.lastEndTime=U:(k.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var $=!!L.audio,V=!!L.video,M="";$&&(M+="audio"),V&&(M+="video");var K={data1:x,startPTS:N,startDTS:N,endPTS:U,endDTS:U,type:M,hasAudio:$,hasVideo:V,nb:1,dropped:0};return T.audio=K.type==="audio"?K:void 0,T.video=K.type!=="audio"?K:void 0,T.initSegment=b,T.id3=Ua(r,u,p,p),o.samples.length&&(T.text=Ba(o,u,p)),T},s}();function Bl(s,a,i,e){if(s===null)return!0;var t=Math.max(e,1),r=a-s.baseTime/s.timescale;return Math.abs(r-i)>t}function Va(s,a){var i=s?.codec;if(i&&i.length>4)return i;if(a===Pe.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return Kr(i,e)}var t="mp4a.40.5";return k.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return k.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Ha=typeof self<"u"?self:void 0,Wt;try{Wt=self.performance.now.bind(self.performance)}catch{k.debug("Unable to use Performance API on this environment"),Wt=Ha?.Date.now}var Gi=[{demux:xl,remux:Ul},{demux:Cl,remux:Bi},{demux:Sl,remux:Bi},{demux:Il,remux:Bi}],Vi=function(){function s(i,e,t,r,o){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=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=o}var a=s.prototype;return a.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},a.push=function(e,t,r,o){var u=this,h=r.transmuxing;h.executeStart=Wt();var d=new Uint8Array(e),m=this.currentTransmuxState,p=this.transmuxConfig;o&&(this.currentTransmuxState=o);var y=o||m,T=y.contiguous,x=y.discontinuity,b=y.trackSwitch,L=y.accurateTimeOffset,A=y.timeOffset,D=y.initSegmentChange,w=p.audioCodec,N=p.videoCodec,U=p.defaultInitPts,$=p.duration,V=p.initSegmentData,M=Gl(d,t);if(M&&M.method==="AES-128"){var K=this.getDecrypter();if(K.isSync()){var z=K.softwareDecrypt(d,M.key.buffer,M.iv.buffer),te=r.part>-1;if(te&&(z=K.flush()),!z)return h.executeEnd=Wt(),Hi(r);d=new Uint8Array(z)}else return this.decryptionPromise=K.webCryptoDecrypt(d,M.key.buffer,M.iv.buffer).then(function(Le){var Ee=u.push(Le,null,r);return u.decryptionPromise=null,Ee}),this.decryptionPromise}var Z=this.needsProbing(x,b);if(Z){var ie=this.configureTransmuxer(d);if(ie)return k.warn("[transmuxer] "+ie.message),this.observer.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:ie,reason:ie.message}),h.executeEnd=Wt(),Hi(r)}(x||b||D||Z)&&this.resetInitSegment(V,w,N,$,t),(x||D||Z)&&this.resetInitialTimestamp(U),T||this.resetContiguity();var he=this.transmux(d,M,A,L,r),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,h.executeEnd=Wt(),he},a.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Wt();var o=this.decrypter,u=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then(function(){return t.flush(e)});var d=[],m=u.timeOffset;if(o){var p=o.flush();p&&d.push(this.push(p,null,e))}var y=this.demuxer,T=this.remuxer;if(!y||!T)return r.executeEnd=Wt(),[Hi(e)];var x=y.flush(m);return sr(x)?x.then(function(b){return t.flushRemux(d,b,e),d}):(this.flushRemux(d,x,e),d)},a.flushRemux=function(e,t,r){var o=t.audioTrack,u=t.videoTrack,h=t.id3Track,d=t.textTrack,m=this.currentTransmuxState,p=m.accurateTimeOffset,y=m.timeOffset;k.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var T=this.remuxer.remux(o,u,h,d,y,p,!0,this.id);e.push({remuxResult:T,chunkMeta:r}),r.transmuxing.executeEnd=Wt()},a.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},a.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},a.resetInitSegment=function(e,t,r,o,u){var h=this.demuxer,d=this.remuxer;!h||!d||(h.resetInitSegment(e,t,r,o),d.resetInitSegment(e,t,r,u))},a.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},a.transmux=function(e,t,r,o,u){var h;return t&&t.method==="SAMPLE-AES"?h=this.transmuxSampleAes(e,t,r,o,u):h=this.transmuxUnencrypted(e,r,o,u),h},a.transmuxUnencrypted=function(e,t,r,o){var u=this.demuxer.demux(e,t,!1,!this.config.progressive),h=u.audioTrack,d=u.videoTrack,m=u.id3Track,p=u.textTrack,y=this.remuxer.remux(h,d,m,p,t,r,!1,this.id);return{remuxResult:y,chunkMeta:o}},a.transmuxSampleAes=function(e,t,r,o,u){var h=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(d){var m=h.remuxer.remux(d.audioTrack,d.videoTrack,d.id3Track,d.textTrack,r,o,!1,h.id);return{remuxResult:m,chunkMeta:u}})},a.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,o=this.typeSupported,u=this.vendor,h,d=0,m=Gi.length;d<m;d++){var p;if((p=Gi[d].demux)!=null&&p.probe(e)){h=Gi[d];break}}if(!h)return new Error("Failed to find demuxer by probing fragment data");var y=this.demuxer,T=this.remuxer,x=h.remux,b=h.demux;(!T||!(T instanceof x))&&(this.remuxer=new x(r,t,o,u)),(!y||!(y instanceof b))&&(this.demuxer=new b(r,t,o),this.probe=b.probe)},a.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},a.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new ki(this.config)),e},s}();function Gl(s,a){var i=null;return s.byteLength>0&&a?.key!=null&&a.iv!==null&&a.method!=null&&(i=a),i}var Hi=function(a){return{remuxResult:{},chunkMeta:a}};function sr(s){return"then"in s&&s.then instanceof Function}var Vl=function(a,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=a,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Hl=function(a,i,e,t,r,o){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=a,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=o},Ka={exports:{}};(function(s){var a=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(h,d,m){this.fn=h,this.context=d,this.once=m||!1}function r(h,d,m,p,y){if(typeof m!="function")throw new TypeError("The listener must be a function");var T=new t(m,p||h,y),x=i?i+d:d;return h._events[x]?h._events[x].fn?h._events[x]=[h._events[x],T]:h._events[x].push(T):(h._events[x]=T,h._eventsCount++),h}function o(h,d){--h._eventsCount===0?h._events=new e:delete h._events[d]}function u(){this._events=new e,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],m,p;if(this._eventsCount===0)return d;for(p in m=this._events)a.call(m,p)&&d.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(m)):d},u.prototype.listeners=function(d){var m=i?i+d:d,p=this._events[m];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,T=p.length,x=new Array(T);y<T;y++)x[y]=p[y].fn;return x},u.prototype.listenerCount=function(d){var m=i?i+d:d,p=this._events[m];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,m,p,y,T,x){var b=i?i+d:d;if(!this._events[b])return!1;var L=this._events[b],A=arguments.length,D,w;if(L.fn){switch(L.once&&this.removeListener(d,L.fn,void 0,!0),A){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,m),!0;case 3:return L.fn.call(L.context,m,p),!0;case 4:return L.fn.call(L.context,m,p,y),!0;case 5:return L.fn.call(L.context,m,p,y,T),!0;case 6:return L.fn.call(L.context,m,p,y,T,x),!0}for(w=1,D=new Array(A-1);w<A;w++)D[w-1]=arguments[w];L.fn.apply(L.context,D)}else{var N=L.length,U;for(w=0;w<N;w++)switch(L[w].once&&this.removeListener(d,L[w].fn,void 0,!0),A){case 1:L[w].fn.call(L[w].context);break;case 2:L[w].fn.call(L[w].context,m);break;case 3:L[w].fn.call(L[w].context,m,p);break;case 4:L[w].fn.call(L[w].context,m,p,y);break;default:if(!D)for(U=1,D=new Array(A-1);U<A;U++)D[U-1]=arguments[U];L[w].fn.apply(L[w].context,D)}}return!0},u.prototype.on=function(d,m,p){return r(this,d,m,p,!1)},u.prototype.once=function(d,m,p){return r(this,d,m,p,!0)},u.prototype.removeListener=function(d,m,p,y){var T=i?i+d:d;if(!this._events[T])return this;if(!m)return o(this,T),this;var x=this._events[T];if(x.fn)x.fn===m&&(!y||x.once)&&(!p||x.context===p)&&o(this,T);else{for(var b=0,L=[],A=x.length;b<A;b++)(x[b].fn!==m||y&&!x[b].once||p&&x[b].context!==p)&&L.push(x[b]);L.length?this._events[T]=L.length===1?L[0]:L:o(this,T)}return this},u.prototype.removeAllListeners=function(d){var m;return d?(m=i?i+d:d,this._events[m]&&o(this,m)):(this._events=new e,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,s.exports=u})(Ka);var Kl=Ka.exports,Ki=se(Kl);typeof g<"u"&&g&&Wl(self);function Wl(s){var a=new Ki,i=function(r,o){s.postMessage({event:r,data:o})};a.on(R.FRAG_DECRYPTED,i),a.on(R.ERROR,i);var e=function(){var r=function(h){var d=function(p){i("workerLog",{logType:h,message:p})};k[h]=d};for(var o in k)r(o)};s.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var o=JSON.parse(r.config);s.transmuxer=new Vi(a,r.typeSupported,o,"",r.id),X(o.debug,r.id),e(),i("init",null);break}case"configure":{s.transmuxer.configure(r.config);break}case"demux":{var u=s.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);sr(u)?(s.transmuxer.async=!0,u.then(function(p){Wi(s,p)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,Wi(s,u));break}case"flush":{var h=r.chunkMeta,d=s.transmuxer.flush(h),m=sr(d);m||s.transmuxer.async?(sr(d)||(d=Promise.resolve(d)),d.then(function(p){ja(s,p,h)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):ja(s,d,h);break}}})}function Wi(s,a){if(jl(a.remuxResult))return!1;var i=[],e=a.remuxResult,t=e.audio,r=e.video;return t&&Wa(i,t),r&&Wa(i,r),s.postMessage({event:"transmuxComplete",data:a},i),!0}function Wa(s,a){a.data1&&s.push(a.data1.buffer),a.data2&&s.push(a.data2.buffer)}function ja(s,a,i){var e=a.reduce(function(t,r){return Wi(s,r)||t},!1);e||s.postMessage({event:"transmuxComplete",data:a[0]}),s.postMessage({event:"flush",data:i})}function jl(s){return!s.audio&&!s.video&&!s.text&&!s.id3&&!s.initSegment}function zl(){return typeof c=="function"}function Yl(){var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+c.toString()+")(true);"],{type:"text/javascript"}),a=self.URL.createObjectURL(s),i=new self.Worker(a);return{worker:i,objectURL:a}}function ql(s){var a=new self.URL(s,self.location.href).href,i=new self.Worker(a);return{worker:i,scriptURL:a}}var Xl=function(){function s(i,e,t,r){var o=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 u=i.config;this.hls=i,this.id=e,this.useWorker=!!u.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var h=function(x,b){b=b||{},b.frag=o.frag,b.id=o.id,x===R.ERROR&&(o.error=b.error),o.hls.trigger(x,b)};this.observer=new Ki,this.observer.on(R.FRAG_DECRYPTED,h),this.observer.on(R.ERROR,h);var d=ar(u.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},m={mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&typeof Worker<"u"){var p=u.workerPath||zl();if(p){try{u.workerPath?(k.log("loading Web Worker "+u.workerPath+' for "'+e+'"'),this.workerContext=ql(u.workerPath)):(k.log('injecting Web Worker for "'+e+'"'),this.workerContext=Yl()),this.onwmsg=function(T){return o.onWorkerMessage(T)};var y=this.workerContext.worker;y.addEventListener("message",this.onwmsg),y.onerror=function(T){var x=new Error(T.message+" ("+T.filename+":"+T.lineno+")");u.enableWorker=!1,k.warn('Error in "'+e+'" Web Worker, fallback to inline'),o.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:x})},y.postMessage({cmd:"init",typeSupported:m,vendor:"",id:e,config:JSON.stringify(u)})}catch(T){k.warn('Error setting up "'+e+'" Web Worker, fallback to inline',T),this.resetWorker(),this.error=null,this.transmuxer=new Vi(this.observer,m,u,"",e)}return}}this.transmuxer=new Vi(this.observer,m,u,"",e)}var a=s.prototype;return a.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}},a.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},a.push=function(e,t,r,o,u,h,d,m,p,y){var T,x,b=this;p.transmuxing.start=self.performance.now();var L=this.transmuxer,A=h?h.start:u.start,D=u.decryptdata,w=this.frag,N=!(w&&u.cc===w.cc),U=!(w&&p.level===w.level),$=w?p.sn-w.sn:-1,V=this.part?p.part-this.part.index:-1,M=$===0&&p.id>1&&p.id===w?.stats.chunkCount,K=!U&&($===1||$===0&&(V===1||M&&V<=0)),z=self.performance.now();(U||$||u.stats.parsing.start===0)&&(u.stats.parsing.start=z),h&&(V||!K)&&(h.stats.parsing.start=z);var te=!(w&&((T=u.initSegment)==null?void 0:T.url)===((x=w.initSegment)==null?void 0:x.url)),Z=new Hl(N,K,m,U,A,te);if(!K||N||te){k.log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
10
- discontinuity: `+N+`
11
- trackSwitch: `+U+`
12
- contiguous: `+K+`
13
- accurateTimeOffset: `+m+`
14
- timeOffset: `+A+`
15
- initSegmentChange: `+te);var ie=new Vl(r,o,t,d,y);this.configureTransmuxer(ie)}if(this.frag=u,this.part=h,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:D,chunkMeta:p,state:Z},e instanceof ArrayBuffer?[e]:[]);else if(L){var he=L.push(e,D,p,Z);sr(he)?(L.async=!0,he.then(function(fe){b.handleTransmuxComplete(fe)}).catch(function(fe){b.transmuxerError(fe,p,"transmuxer-interface push error")})):(L.async=!1,this.handleTransmuxComplete(he))}},a.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 o=r.flush(e),u=sr(o);u||r.async?(sr(o)||(o=Promise.resolve(o)),o.then(function(h){t.handleFlushResult(h,e)}).catch(function(h){t.transmuxerError(h,e,"transmuxer-interface flush error")})):this.handleFlushResult(o,e)}},a.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},a.handleFlushResult=function(e,t){var r=this;e.forEach(function(o){r.handleTransmuxComplete(o)}),this.onFlush(t)},a.onWorkerMessage=function(e){var t=e.data;if(!(t!=null&&t.event)){k.warn("worker message received with no "+(t?"event name":"data"));return}var r=this.hls;if(this.hls)switch(t.event){case"init":{var o,u=(o=this.workerContext)==null?void 0:o.objectURL;u&&self.URL.revokeObjectURL(u);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":k[t.data.logType]&&k[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);break}}},a.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},a.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),$l=250,ti=2,Ql=.1,Jl=.05,Zl=function(){function s(i,e,t,r){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=i,this.media=e,this.fragmentTracker=t,this.hls=r}var a=s.prototype;return a.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},a.poll=function(e,t){var r=this.config,o=this.media,u=this.stalled;if(o!==null){var h=o.currentTime,d=o.seeking,m=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,h!==e){if(this.moved=!0,d||(this.nudgeRetry=0),u!==null){if(this.stallReported){var y=self.performance.now()-u;k.warn("playback not stuck anymore @"+h+", after "+Math.round(y)+"ms"),this.stallReported=!1}this.stalled=null}return}if(p||m){this.stalled=null;return}if(o.paused&&!d||o.ended||o.playbackRate===0||!rt.getBuffered(o).length){this.nudgeRetry=0;return}var T=rt.bufferInfo(o,h,0),x=T.nextStart||0;if(d){var b=T.len>ti,L=!x||t&&t.start<=h||x-h>ti&&!this.fragmentTracker.getPartialFragment(h);if(b||L)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A,D=T.len>0;if(!D&&!x)return;var w=Math.max(x,T.start||0)-h,N=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=N==null||(A=N.details)==null?void 0:A.live,$=U?N.details.targetduration*2:ti,V=this.fragmentTracker.getPartialFragment(h);if(w>0&&(w<=$||V)){o.paused||this._trySkipBufferHole(V);return}}var M=self.performance.now();if(u===null){this.stalled=M;return}var K=M-u;if(!(!d&&K>=$l&&(this._reportStall(T),!this.media))){var z=rt.bufferInfo(o,h,r.maxBufferHole);this._tryFixBufferStall(z,K)}}},a._tryFixBufferStall=function(e,t){var r=this.config,o=this.fragmentTracker,u=this.media;if(u!==null){var h=u.currentTime,d=o.getPartialFragment(h);if(d){var m=this._trySkipBufferHole(d);if(m||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-h<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(k.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},a._reportStall=function(e){var t=this.hls,r=this.media,o=this.stallReported;if(!o&&r){this.stallReported=!0;var u=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");k.warn(u.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,fatal:!1,error:u,buffer:e.len})}},a._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(o===null)return 0;var u=o.currentTime,h=rt.bufferInfo(o,u,0),d=u<h.start?h.start:h.nextStart;if(d){var m=h.len<=t.maxBufferHole,p=h.len>0&&h.len<1&&o.readyState<3,y=d-u;if(y>0&&(m||p)){if(y>t.maxBufferHole){var T=this.fragmentTracker,x=!1;if(u===0){var b=T.getAppendedFrag(0,Me.MAIN);b&&d<b.end&&(x=!0)}if(!x){var L=e||T.getAppendedFrag(u,Me.MAIN);if(L){for(var A=!1,D=L.end;D<d;){var w=T.getPartialFragment(D);if(w)D+=w.duration;else{A=!0;break}}if(A)return 0}}}var N=Math.max(d+Jl,u+Ql);if(k.warn("skipping hole, adjusting currentTime from "+u+" to "+N),this.moved=!0,this.stalled=null,o.currentTime=N,e&&!e.gap){var U=new Error("fragment loaded with buffer holes, seeking from "+u+" to "+N);r.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:U,reason:U.message,frag:e})}return N}}return 0},a._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,o=this.nudgeRetry;if(r!==null){var u=r.currentTime;if(this.nudgeRetry++,o<e.nudgeMaxRetry){var h=u+(o+1)*e.nudgeOffset,d=new Error("Nudging 'currentTime' from "+u+" to "+h);k.warn(d.message),r.currentTime=h,t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{var m=new Error("Playhead still not moving while enough data buffered @"+u+" after "+e.nudgeMaxRetry+" nudges");k.error(m.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,error:m,fatal:!0})}}},s}(),ef=100,tf=function(s){I(a,s);function a(e,t,r){var o;return o=s.call(this,e,t,r,"[stream-controller]",Me.MAIN)||this,o.audioCodecSwap=!1,o.gapController=null,o.level=-1,o._forceStartLoad=!1,o.altAudio=!1,o.audioOnly=!1,o.fragPlaying=null,o.onvplaying=null,o.onvseeked=null,o.fragLastKbps=0,o.couldBacktrack=!1,o.backtrackFragment=null,o.audioCodecSwitch=!1,o.videoBuffer=null,o._registerListeners(),o}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),s.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(ef),this.level=-1,!this.startFragRequested){var u=o.startLevel;u===-1&&(o.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=o.firstAutoLevel),o.nextLoadLevel=u,this.level=o.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=ne.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ne.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ne.WAITING_LEVEL:{var t=this.levels,r=this.level,o=t?.[r],u=o?.details;if(u&&(!u.live||this.levelLastLoaded===o)){if(this.waitForCdnTuneIn(u))break;this.state=ne.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=ne.IDLE;break}break}case ne.FRAG_LOADING_WAITING_RETRY:{var h,d=self.performance.now(),m=this.retryDate;if(!m||d>=m||(h=this.media)!=null&&h.seeking){var p=this.levels,y=this.level,T=p?.[y];this.resetStartWhenNotLoaded(T||null),this.state=ne.IDLE}}break}this.state===ne.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,o=this.levels,u=this.media;if(!(r===null||!u&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var h=t.nextLoadLevel;if(o!=null&&o[h]){var d=o[h],m=this.getMainFwdBufferInfo();if(m!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(m,p)){var y={};this.altAudio&&(y.type="video"),this.hls.trigger(R.BUFFER_EOS,y),this.state=ne.ENDED;return}t.loadLevel!==h&&t.manualLevel===-1&&this.log("Adapting to level "+h+" from level "+this.level),this.level=t.nextLoadLevel=h;var T=d.details;if(!T||this.state===ne.WAITING_LEVEL||T.live&&this.levelLastLoaded!==d){this.level=h,this.state=ne.WAITING_LEVEL;return}var x=m.len,b=this.getMaxBufferLength(d.maxBitrate);if(!(x>=b)){this.backtrackFragment&&this.backtrackFragment.start>m.end&&(this.backtrackFragment=null);var L=this.backtrackFragment?this.backtrackFragment.start:m.end,A=this.getNextFragment(L,T);if(this.couldBacktrack&&!this.fragPrevious&&A&&A.sn!=="initSegment"&&this.fragmentTracker.getState(A)!==gt.OK){var D,w=((D=this.backtrackFragment)!=null?D:A).sn,N=w-T.startSN,U=T.fragments[N-1];U&&A.cc===U.cc&&(A=U,this.fragmentTracker.removeFragment(U))}else this.backtrackFragment&&m.len&&(this.backtrackFragment=null);if(A&&this.isLoopLoading(A,L)){var $=A.gap;if(!$){var V=this.audioOnly&&!this.altAudio?Pe.AUDIO:Pe.VIDEO,M=(V===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;M&&this.afterBufferFlushed(M,V,Me.MAIN)}A=this.getNextFragmentLoopLoading(A,T,m,Me.MAIN,b)}A&&(A.initSegment&&!A.initSegment.data&&!this.bitrateTest&&(A=A.initSegment),this.loadFragment(A,d,L))}}}}},i.loadFragment=function(t,r,o){var u=this.fragmentTracker.getState(t);this.fragCurrent=t,u===gt.NOT_LOADED||u===gt.PARTIAL?t.sn==="initSegment"?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,s.prototype.loadFragment.call(this,t,r,o)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Me.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var o,u=this.getAppendedFrag(r.currentTime);u&&u.start>1&&this.flushMainBuffer(0,u.start-1);var h=this.getLevelDetails();if(h!=null&&h.live){var d=this.getMainFwdBufferInfo();if(!d||d.len<h.targetduration*2)return}if(!r.paused&&t){var m=this.hls.nextLoadLevel,p=t[m],y=this.fragLastKbps;y&&this.fragCurrent?o=this.fragCurrent.duration*p.maxBitrate/(1e3*y)+1:o=0}else o=0;var T=this.getBufferedFrag(r.currentTime+o);if(T){var x=this.followingBufferedFrag(T);if(x){this.abortCurrentFrag();var b=x.maxStartPTS?x.maxStartPTS:x.start,L=x.duration,A=Math.max(T.end,b+Math.min(Math.max(L-this.config.maxFragLookUpTolerance,L*(this.couldBacktrack?.5:.125)),L*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(A,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case ne.KEY_LOADING:case ne.FRAG_LOADING:case ne.FRAG_LOADING_WAITING_RETRY:case ne.PARSING:case ne.PARSED:this.state=ne.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var o=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new Zl(this.config,o,this.fragmentTracker,this.hls)},i.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),s.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;j(r)&&this.log("Media seeked to "+r.toFixed(3));var o=this.getMainFwdBufferInfo();if(o===null||o.len===0){this.warn('Main forward buffer length on "seeked" event '+(o?o.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.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},i.onManifestParsed=function(t,r){var o=!1,u=!1;r.levels.forEach(function(h){var d=h.audioCodec;d&&(o=o||d.indexOf("mp4a.40.2")!==-1,u=u||d.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=o&&u&&!ll(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var o=this.levels;if(!(!o||this.state!==ne.IDLE)){var u=o[r.level];(!u.details||u.details.live&&this.levelLastLoaded!==u||this.waitForCdnTuneIn(u.details))&&(this.state=ne.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var o,u=this.levels,h=r.level,d=r.details,m=d.totalduration;if(!u){this.warn("Levels were reset while loading level "+h);return}this.log("Level "+h+" loaded ["+d.startSN+","+d.endSN+"]"+(d.lastPartSn?"[part-"+d.lastPartSn+"-"+d.lastPartIndex+"]":"")+", cc ["+d.startCC+", "+d.endCC+"] duration:"+m);var p=u[h],y=this.fragCurrent;y&&(this.state===ne.FRAG_LOADING||this.state===ne.FRAG_LOADING_WAITING_RETRY)&&y.level!==r.level&&y.loader&&this.abortCurrentFrag();var T=0;if(d.live||(o=p.details)!=null&&o.live){var x;if(this.checkLiveUpdate(d),d.deltaUpdateFailed)return;T=this.alignPlaylists(d,p.details,(x=this.levelLastLoaded)==null?void 0:x.details)}if(p.details=d,this.levelLastLoaded=p,this.hls.trigger(R.LEVEL_UPDATED,{details:d,level:h}),this.state===ne.WAITING_LEVEL){if(this.waitForCdnTuneIn(d))return;this.state=ne.IDLE}this.startFragRequested?d.live&&this.synchronizeToLiveEdge(d):this.setStartPosition(d,T),this.tick()},i._handleFragmentLoadProgress=function(t){var r,o=t.frag,u=t.part,h=t.payload,d=this.levels;if(!d){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var m=d[o.level],p=m.details;if(!p){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset"),this.fragmentTracker.removeFragment(o);return}var y=m.videoCodec,T=p.PTSKnown||!p.live,x=(r=o.initSegment)==null?void 0:r.data,b=this._getAudioCodec(m),L=this.transmuxer=this.transmuxer||new Xl(this.hls,Me.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=u?u.index:-1,D=A!==-1,w=new _a(o.level,o.sn,o.stats.chunkCount,h.byteLength,A,D),N=this.initPTS[o.cc];L.push(h,x,b,y,o,u,p.totalduration,T,w,N)},i.onAudioTrackSwitching=function(t,r){var o=this.altAudio,u=!!r.url;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var h=this.fragCurrent;h&&(this.log("Switching to main audio track, cancel main fragment load"),h.abortRequests(),this.fragmentTracker.removeFragment(h)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var d=this.hls;o&&(d.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),d.trigger(R.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var o=r.id,u=!!this.hls.audioTracks[o].url;if(u){var h=this.videoBuffer;h&&this.mediaBuffer!==h&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=h)}this.altAudio=u,this.tick()},i.onBufferCreated=function(t,r){var o=r.tracks,u,h,d=!1;for(var m in o){var p=o[m];if(p.id==="main"){if(h=m,u=p,m==="video"){var y=o[m];y&&(this.videoBuffer=y.buffer)}}else d=!0}d&&u?(this.log("Alternate track found, use "+h+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var o=r.frag,u=r.part;if(!(o&&o.type!==Me.MAIN)){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(u?" p: "+u.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===ne.PARSED&&(this.state=ne.IDLE);return}var h=u?u.stats:o.stats;this.fragLastKbps=Math.round(8*h.total/(h.buffering.end-h.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,u)}},i.onError=function(t,r){var o;if(r.fatal){this.state=ne.ERROR;return}switch(r.details){case G.FRAG_GAP:case G.FRAG_PARSING_ERROR:case G.FRAG_DECRYPT_ERROR:case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me.MAIN,r);break;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:case G.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===ne.WAITING_LEVEL&&((o=r.context)==null?void 0:o.type)===Oe.LEVEL&&(this.state=ne.IDLE);break;case G.BUFFER_APPEND_ERROR:case G.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===G.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case G.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!rt.getBuffered(t).length){var o=this.state!==ne.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,o)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=ne.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var o=r.type;if(o!==Pe.AUDIO||this.audioOnly&&!this.altAudio){var u=(o===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,o,Me.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,o=this.startPosition;if(o>=0&&r<o){if(t.seeking){this.log("could not seek to "+o+", already seeking at "+r);return}var u=rt.getBuffered(t),h=u.length?u.start(0):0,d=h-o;d>0&&(d<this.config.maxBufferHole||d<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+d+" to match buffer start"),o+=d,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+r),t.currentTime=o}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var o=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(u){var h=o.hls;if(!(!u||o.fragContextChanged(t))){r.fragmentError=0,o.state=ne.IDLE,o.startFragRequested=!1,o.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),h.trigger(R.FRAG_LOADED,u),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,o="main",u=this.hls,h=t.remuxResult,d=t.chunkMeta,m=this.getCurrentContext(d);if(!m){this.resetWhenMissingContext(d);return}var p=m.frag,y=m.part,T=m.level,x=h.video,b=h.text,L=h.id3,A=h.initSegment,D=T.details,w=this.altAudio?void 0:h.audio;if(this.fragContextChanged(p)){this.fragmentTracker.removeFragment(p);return}if(this.state=ne.PARSING,A){if(A!=null&&A.tracks){var N=p.initSegment||p;this._bufferInitSegment(T,A.tracks,N,d),u.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:o,tracks:A.tracks})}var U=A.initPTS,$=A.timescale;j(U)&&(this.initPTS[p.cc]={baseTime:U,timescale:$},u.trigger(R.INIT_PTS_FOUND,{frag:p,id:o,initPTS:U,timescale:$}))}if(x&&D&&p.sn!=="initSegment"){var V=D.fragments[p.sn-1-D.startSN],M=p.sn===D.startSN,K=!V||p.cc>V.cc;if(h.independent!==!1){var z=x.startPTS,te=x.endPTS,Z=x.startDTS,ie=x.endDTS;if(y)y.elementaryStreams[x.type]={startPTS:z,endPTS:te,startDTS:Z,endDTS:ie};else if(x.firstKeyFrame&&x.independent&&d.id===1&&!K&&(this.couldBacktrack=!0),x.dropped&&x.independent){var he=this.getMainFwdBufferInfo(),fe=(he?he.end:this.getLoadPosition())+this.config.maxBufferHole,Le=x.firstKeyFramePTS?x.firstKeyFramePTS:z;if(!M&&fe<Le-this.config.maxBufferHole&&!K){this.backtrack(p);return}else K&&(p.gap=!0);p.setElementaryStreamInfo(x.type,p.start,te,p.start,ie,!0)}else M&&z>ti&&(p.gap=!0);p.setElementaryStreamInfo(x.type,z,te,Z,ie),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(x,p,y,d,M||K)}else if(M||K)p.gap=!0;else{this.backtrack(p);return}}if(w){var Ee=w.startPTS,we=w.endPTS,Ae=w.startDTS,ye=w.endDTS;y&&(y.elementaryStreams[Pe.AUDIO]={startPTS:Ee,endPTS:we,startDTS:Ae,endDTS:ye}),p.setElementaryStreamInfo(Pe.AUDIO,Ee,we,Ae,ye),this.bufferFragmentData(w,p,y,d)}if(D&&L!=null&&(r=L.samples)!=null&&r.length){var je={id:o,frag:p,details:D,samples:L.samples};u.trigger(R.FRAG_PARSING_METADATA,je)}if(D&&b){var Fe={id:o,frag:p,details:D,samples:b.samples};u.trigger(R.FRAG_PARSING_USERDATA,Fe)}},i._bufferInitSegment=function(t,r,o,u){var h=this;if(this.state===ne.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,m=r.video,p=r.audiovideo;if(d){var y=t.audioCodec,T=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){y&&(y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5");var x=d.metadata;x&&"channelCount"in x&&(x.channelCount||1)!==1&&T.indexOf("firefox")===-1&&(y="mp4a.40.5")}y&&y.indexOf("mp4a.40.5")!==-1&&T.indexOf("android")!==-1&&d.container!=="audio/mpeg"&&(y="mp4a.40.2",this.log("Android: force audio codec to "+y)),t.audioCodec&&t.audioCodec!==y&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+y+'"'),d.levelCodec=y,d.id="main",this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(y||"")+"/"+(t.audioCodec||"")+"/"+d.codec+"]")}m&&(m.levelCodec=t.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+m.codec+"]")),p&&this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+t.codecs+"/"+p.codec+"]"),this.hls.trigger(R.BUFFER_CODECS,r),Object.keys(r).forEach(function(b){var L=r[b],A=L.initSegment;A!=null&&A.byteLength&&h.hls.trigger(R.BUFFER_APPENDING,{type:b,data:A,frag:o,part:null,chunkMeta:u,parent:o.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me.MAIN)},i.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=ne.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var o=t.currentTime;if(rt.isBuffered(t,o)?r=this.getAppendedFrag(o):rt.isBuffered(t,o+.1)&&(r=this.getAppendedFrag(o+.1)),r){this.backtrackFragment=null;var u=this.fragPlaying,h=r.level;(!u||r.sn!==u.sn||u.level!==h)&&(this.fragPlaying=r,this.hls.trigger(R.FRAG_CHANGED,{frag:r}),(!u||u.level!==h)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:h}))}}},_(a,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var r=t.currentTime,o=this.currentFrag;if(o&&j(r)&&j(o.programDateTime)){var u=o.programDateTime+(r-o.start)*1e3;return new Date(u)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),a}(ol),za=function(){s.isMSESupported=function(){return ba()},s.isSupported=function(){return ul()},s.getMediaSource=function(){return ar()};function s(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Ki,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,X(i.debug||!1,"Hls instance");var e=this.config=Ku(s.DefaultConfig,i);this.userConfig=i,e.progressive&&Wu(e);var t=e.abrController,r=e.bufferController,o=e.capLevelController,u=e.errorController,h=e.fpsController,d=new u(this),m=this.abrController=new t(this),p=this.bufferController=new r(this),y=this.capLevelController=new o(this),T=new h(this),x=new Wo(this),b=new Jo(this),L=e.contentSteeringController,A=L?new L(this):null,D=this.levelController=new ju(this,A),w=new zu(this),N=new qu(this.config),U=this.streamController=new tf(this,w,N);y.setStreamController(U),T.setStreamController(U);var $=[x,D,U];A&&$.splice(1,0,A),this.networkControllers=$;var V=[m,p,y,T,b,w];this.audioTrackController=this.createController(e.audioTrackController,$);var M=e.audioStreamController;M&&$.push(new M(this,w,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,$);var K=e.subtitleStreamController;K&&$.push(new K(this,w,N)),this.createController(e.timelineController,V),N.emeController=this.emeController=this.createController(e.emeController,V),this.cmcdController=this.createController(e.cmcdController,V),this.latencyController=this.createController(Zo,V),this.coreComponents=V,$.push(d);var z=d.onErrorOut;typeof z=="function"&&this.on(R.ERROR,z,d)}var a=s.prototype;return a.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},a.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},a.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},a.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},a.off=function(e,t,r,o){r===void 0&&(r=this),this._emitter.off(e,t,r,o)},a.listeners=function(e){return this._emitter.listeners(e)},a.emit=function(e,t,r){return this._emitter.emit(e,t,r)},a.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(o){if(k.error("An internal error happened while handling event "+e+'. Error message: "'+o.message+'". Here is a stacktrace:',o),!this.triggeringException){this.triggeringException=!0;var r=e===R.ERROR;this.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:r,event:e,error:o}),this.triggeringException=!1}}return!1},a.listenerCount=function(e){return this._emitter.listenerCount(e)},a.destroy=function(){k.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},a.attachMedia=function(e){k.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})},a.detachMedia=function(){k.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null},a.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,o=this.url=oe.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,k.log("loadSource:"+o),t&&r&&(r!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})},a.startLoad=function(e){e===void 0&&(e=-1),k.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},a.stopLoad=function(){k.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},a.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},a.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},a.swapAudioCodec=function(){k.log("swapAudioCodec"),this.streamController.swapAudioCodec()},a.recoverMediaError=function(){k.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},a.removeLevel=function(e){this.levelController.removeLevel(e)},a.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},a.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},_(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){k.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){k.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){k.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){k.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){k.log("set startLevel:"+e),e!==-1&&(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&&(k.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){eu(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{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,o=0;o<r;o++)if(e[o].maxBitrate>=t)return o;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,o;if(t===-1&&e!=null&&e.length?o=e.length-1:o=t,r)for(var u=o;u--;){var h=e[u].attrs["HDCP-LEVEL"];if(h&&h<=r)return u}return o}},{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:!1},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 R}},{key:"ErrorTypes",get:function(){return le}},{key:"ErrorDetails",get:function(){return G}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:pa},set:function(e){s.defaultConfig=e}}]),s}();return za.defaultConfig=void 0,za})})(!1)});var th={};yf(th,{Flv:()=>br,Hls:()=>Sn.default});module.exports=Ef(th);function ts(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function bt(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?ts(Object(n),!0).forEach(function(l){ce(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):ts(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Re(){Re=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){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(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function rs(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function it(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){rs(v,l,f,E,_,"next",S)}function _(S){rs(v,l,f,E,_,"throw",S)}E(void 0)})}}function yr(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function is(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ss(l.key),l)}}function Er(c,g,n){return g&&is(c.prototype,g),n&&is(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function ce(c,g,n){return g=ss(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function ns(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&qi(c,g)}function si(c){return si=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},si(c)}function qi(c,g){return qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},qi(c,g)}function _f(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ie(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Sf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ie(c)}function as(c){var g=_f();return function(){var l=si(c),f;if(g){var v=si(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Sf(this,f)}}function Tf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ss(c){var g=Tf(c,"string");return typeof g=="symbol"?g:String(g)}function us(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function er(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?us(Object(n),!0).forEach(function(l){q(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):us(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Ye(){Ye=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){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(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function Gt(c){"@babel/helpers - typeof";return Gt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},Gt(c)}function ls(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function St(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){ls(v,l,f,E,_,"next",S)}function _(S){ls(v,l,f,E,_,"throw",S)}E(void 0)})}}function Be(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function fs(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ps(l.key),l)}}function Ge(c,g,n){return g&&fs(c.prototype,g),n&&fs(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function q(c,g,n){return g=ps(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function It(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&Dr(c,g)}function Zt(c){return Zt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Zt(c)}function Dr(c,g){return Dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},Dr(c,g)}function ds(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ui(c,g,n){return ds()?ui=Reflect.construct.bind():ui=function(f,v,E){var _=[null];_.push.apply(_,v);var S=Function.bind.apply(f,_),C=new S;return E&&Dr(C,E.prototype),C},ui.apply(null,arguments)}function Lf(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function ur(c){var g=typeof Map=="function"?new Map:void 0;return ur=function(l){if(l===null||!Lf(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g<"u"){if(g.has(l))return g.get(l);g.set(l,f)}function f(){return ui(l,arguments,Zt(this).constructor)}return f.prototype=Object.create(l.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Dr(f,l)},ur(c)}function Af(c,g){if(c==null)return{};var n={},l=Object.keys(c),f,v;for(v=0;v<l.length;v++)f=l[v],!(g.indexOf(f)>=0)&&(n[f]=c[f]);return n}function cs(c,g){if(c==null)return{};var n=Af(c,g),l,f;if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(c);for(f=0;f<v.length;f++)l=v[f],!(g.indexOf(l)>=0)&&Object.prototype.propertyIsEnumerable.call(c,l)&&(n[l]=c[l])}return n}function de(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Rf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return de(c)}function Pt(c){var g=ds();return function(){var l=Zt(c),f;if(g){var v=Zt(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Rf(this,f)}}function Cf(c,g){for(;!Object.prototype.hasOwnProperty.call(c,g)&&(c=Zt(c),c!==null););return c}function Cr(){return typeof Reflect<"u"&&Reflect.get?Cr=Reflect.get.bind():Cr=function(g,n,l){var f=Cf(g,n);if(f){var v=Object.getOwnPropertyDescriptor(f,n);return v.get?v.get.call(arguments.length<3?g:l):v.value}},Cr.apply(this,arguments)}function Df(c,g){if(c){if(typeof c=="string")return hs(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return hs(c,g)}}function hs(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function vs(c,g){var n=typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(!n){if(Array.isArray(c)||(n=Df(c))||g&&c&&typeof c.length=="number"){n&&(c=n);var l=0,f=function(){};return{s:f,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(S){throw S},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
16
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var v=!0,E=!1,_;return{s:function(){n=n.call(c)},n:function(){var S=n.next();return v=S.done,S},e:function(S){E=!0,_=S},f:function(){try{!v&&n.return!=null&&n.return()}finally{if(E)throw _}}}}function wf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ps(c){var g=wf(c,"string");return typeof g=="symbol"?g:String(g)}var tt=function(){function c(){Be(this,c)}return Ge(c,null,[{key:"start",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6||n.length===1&&n.start(0)<0?0:n.start(0)}},{key:"end",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6?0:n.end(n.length-1)}},{key:"get",value:function(n){if(n)try{return n.buffered}catch{}}},{key:"buffers",value:function(n,l){if(!n||!n.length)return[];for(var f=[],v=0,E=n.length;v<E;v++){var _=f.length;if(!_||!l)f.push([n.start(v),n.end(v)]);else{var S=f[_-1],C=S[1],I=n.start(v);if(I-C<=l){var P=n.end(v);P>C&&(S[1]=P)}else f.push([n.start(v),n.end(v)])}}return f}},{key:"totalLength",value:function(n){return!n||!n.length?0:n.reduce(function(l,f){return l+=f[1]-f[0]},0)}},{key:"info",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!n||!n.length)return{start:0,end:0,buffers:[]};for(var v=0,E=0,_=0,S=0,C=0,I=0,P=0,H=c.buffers(n,f),W=0,Y=H.length;W<Y;W++){var ee=H[W];if(l+f>=ee[0]&&l<=ee[1])v=ee[0],E=ee[1],_=W;else if(l+f<ee[0]){S=ee[0],C=ee[1];break}else l+f>ee[1]&&(I=ee[0],P=ee[1])}return{start:v,end:E,index:_,buffers:H,nextStart:S,nextEnd:C,prevStart:I,prevEnd:P,currentTime:l,behind:l-v,remaining:E?E-l:0,length:c.totalLength&&c.totalLength(H)}}},{key:"isBuffered",value:function(n,l){if(n){var f=c.get(n);if(f!=null&&f.length){for(var v=0;v<f.length;v++)if(l>=f.start(v)&&l<=f.end(v))return!0}}return!1}}]),c}();var ms=typeof window<"u";var Et,Ce={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},li=(Et={},q(Et,Ce.MANIFEST,{HLS:1100,DASH:1200}),q(Et,Ce.NETWORK,2100),q(Et,Ce.NETWORK_TIMEOUT,2101),q(Et,Ce.NETWORK_FORBIDDEN,2103),q(Et,Ce.NETWORK_NOTFOUND,2104),q(Et,Ce.NETWROK_RANGE_NOT_SATISFIABLE,2116),q(Et,Ce.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),q(Et,Ce.REMUX,{FMP4:4100,MP4:4200}),q(Et,Ce.MEDIA,{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}),q(Et,Ce.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),q(Et,Ce.OTHER,8e3),q(Et,Ce.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),Et),dt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E,_){var S;return Be(this,n),S=g.call(this,_||v?.message),S.errorType=l===Ce.NETWORK_TIMEOUT?Ce.NETWORK:l,S.originError=v,S.ext=E,S.errorCode=li[l][f]||li[l],S.errorMessage=S.message,S.errorCode||(S.errorType=Ce.OTHER,S.errorCode=li[S.errorType]),S}return Ge(n,null,[{key:"create",value:function(f,v,E,_,S){return f instanceof n?f:(f instanceof Error&&(E=f,f=""),f||(f=Ce.OTHER),new n(f,v,E,_,S))}},{key:"network",value:function(f){var v;return new n(f!=null&&f.isTimeout?Ce.NETWORK_TIMEOUT:Ce.NETWORK,null,f instanceof Error?f:null,{url:f?.url,response:f?.response,httpCode:f==null||(v=f.response)===null||v===void 0?void 0:v.status})}}]),n}(ur(Error));var Ir={DEBUG:1,LOG:2,WARN:3,ERROR:4},If=200*1024,Pf=["Boolean","Number","String","Undefined","Null","Date","Object"],Tt=function(){function c(g,n){Be(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=n?.logCacheLevel||3,this.logMaxSize=n?.logMaxSize||If,this.logSize=0,this.logTextArray=[]}return Ge(c,[{key:"debug",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.DEBUG].concat(f)),!c.disabled&&(n=console).debug.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"log",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.LOG].concat(f)),!c.disabled&&(n=console).log.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"warn",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.WARN].concat(f)),!c.disabled&&(n=console).warn.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"error",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.ERROR].concat(f)),!c.disabled&&(n=console).error.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"logCache",value:function(n){if(!(n<this.logCacheLevel)){var l="";try{for(var f=arguments.length,v=new Array(f>1?f-1:0),E=1;E<f;E++)v[E-1]=arguments[E];var _=v.map(function(C){return gs(C)});l="[".concat(wr(),"]")+this._prefix+JSON.stringify(_)}catch{return}if(n>=this.logCacheLevel&&(this.logSize+=l.length,this.logTextArray.push(l)),this.logSize>this.logMaxSize){var S=this.logTextArray.shift();this.logSize-=S.length}}}},{key:"getLogCache",value:function(){var n=this.logTextArray.join(`
17
- `);return this.reset(),n}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(n){this.logCacheLevel=n}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();q(Tt,"disabled",!0);function wr(){return new Date().toLocaleString()}function kf(c){if(Gt(c)!=="object")return c;var g=Object.prototype.toString.call(c).slice(8,-1);switch(g){case"Array":case"Uint8Array":case"ArrayBuffer":return g+"["+c.length+"]";case"Object":return"{}";default:return g}}function gs(c,g,n){n||(n=1),g||(g=2);var l={};if(!c||Gt(c)!=="object")return c;var f=Object.prototype.toString.call(c).slice(8,-1);if(!Pf.includes(f))return f;if(!(n>g)){for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(n===g?l[v]=kf(c[v]):Gt(c[v])==="object"?l[v]=gs(c[v],g,n+1):l[v]=c[v]);return l}}function tr(){var c,g,n=new Promise(function(l,f){c=l,g=f});return n.used=!1,n.resolve=function(){return n.used=!0,c.apply(void 0,arguments)},n.reject=function(){return n.used=!0,g.apply(void 0,arguments)},n}function lr(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ys={stringify:function(g){try{return JSON.stringify(g)}catch{return""}},parse:function(g){try{return JSON.parse(g)}catch{return}}};function Es(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return ms?c&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function $i(c){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(c))}function Of(c){var g=[];if(c instanceof TimeRanges)for(var n=0;n<c.length;n++)g.push({start:c.start(n),end:c.end(n)});return g}var fi={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var rr=function(){function c(g,n){var l=this;Be(this,c),q(this,"media",null),q(this,"mediaSource",null),q(this,"_openPromise",tr()),q(this,"_queue",Object.create(null)),q(this,"_sourceBuffer",Object.create(null)),q(this,"_mseFullFlag",{}),q(this,"_st",0),q(this,"_opst",0),q(this,"_logger",null),q(this,"_config",null),q(this,"_url",null),q(this,"_onStartStreaming",function(){l._logger.debug("startstreaming")}),q(this,"_onEndStreaming",function(){l._logger.debug("endstreaming")}),q(this,"_onSBUpdateEnd",function(f){var v=l._queue[f];if(v){var E=v[0];if(E?.opName!==fi.UPDATE_DURATION&&v.shift(),E){var _,S,C=lr()-l._opst;l._logger.debug("UpdateEnd(".concat(f,"/").concat(E.opName,")"),ys.stringify(Of((_=l._sourceBuffer[f])===null||_===void 0?void 0:_.buffered)),C,E.context),E.promise.resolve({name:E.opName,context:E.context,costtime:C});var I=(S=E.context)===null||S===void 0?void 0:S.callback;I&&typeof I=="function"&&I(E.context),l._startQueue(f)}}}),q(this,"_onSBUpdateError",function(f,v){var E=l._queue[f];if(E){var _=E[0];_&&(l._logger.error("UpdateError",f,_.opName,_.context),_.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_APPEND_BUFFER,v)))}}),this._config=Object.assign(c.getDefaultConfig(),n),g&&this.bindMedia(g),this._logger=new Tt("MSE"),this._config.openLog&&Tt.enable()}return Ge(c,[{key:"isOpened",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.readyState)==="open"}},{key:"hasOpTasks",get:function(){var n=this,l=!1;return Object.keys(this._queue).forEach(function(f){var v=n._queue[f];Array.isArray(v)&&(l||(l=v.length>0))}),l}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return $i(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(n){return n?this._mseFullFlag[n]:this._mseFullFlag[c.VIDEO]}},{key:"updateDuration",value:function(n){var l=this,f=this.mediaSource&&this.mediaSource.duration>n;if(this.mediaSource&&this.mediaSource.duration>n){var v=0;if(Object.keys(this._sourceBuffer).forEach(function(E){try{v=Math.max(l.bufferEnd(E)||0,v)}catch{}}),n<v)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(l.isEnded){l._logger.debug("setDuration but ended");return}l.mediaSource&&(l.mediaSource.duration=n,l._logger.debug("setDuration",n))},fi.UPDATE_DURATION,{isReduceDuration:f})}},{key:"open",value:function(){var n=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var l=this.mediaSource,f=function v(){var E=lr()-n._st;n._logger.debug("sourceopen",E),l.removeEventListener("sourceopen",v),n._openPromise.resolve({costtime:E})};l.addEventListener("sourceopen",f),this._openPromise=tr()}return this._openPromise}},{key:"bindMedia",value:function(){var g=St(Ye().mark(function l(f){var v=this,E,_,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(!(this.mediaSource||this.media)){P.next=3;break}return P.next=3,this.unbindMedia();case 3:if(E=Es(this._config.preferMMS),!(!f||!E)){P.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=f,_=this.mediaSource=new E,S=$i(_),this._st=lr(),C=function H(){var W=lr()-v._st;v._logger.debug("sourceopen"),_.removeEventListener("sourceopen",H),URL.revokeObjectURL(f.src),v._openPromise.resolve({costtime:W})},_.addEventListener("sourceopen",C),S&&(_.addEventListener("startstreaming",this._onStartStreaming),_.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(_),f.src=this._url,f.disableRemotePlayback=S,P.abrupt("return",this._openPromise);case 17:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"unbindMedia",value:function(){var g=St(Ye().mark(function l(){var f=this,v,E,_;return Ye().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),v=this.mediaSource,v){if(Object.keys(this._queue).forEach(function(I){var P=f._queue[I];P&&P.forEach(function(H){var W,Y;return(W=H.promise)===null||W===void 0||(Y=W.resolve)===null||Y===void 0?void 0:Y.call(W)})}),E=!!this.media&&this.media.readyState>=1,_=v.readyState==="open",E&&_)try{v.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(I){try{v.removeSourceBuffer(f._sourceBuffer[I])}catch{}}),$i(v)&&(v.removeEventListener("startstreaming",this._onStartStreaming),v.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=tr(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return C.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"createSource",value:function(n,l){if(!(this._sourceBuffer[n]||!this.mediaSource)){var f;try{f=this._sourceBuffer[n]=this.mediaSource.addSourceBuffer(l)}catch(v){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_ADD_SB,v)}f.mimeType=l,f.addEventListener("updateend",this._onSBUpdateEnd.bind(this,n)),f.addEventListener("error",this._onSBUpdateError.bind(this,n))}}},{key:"changeType",value:function(n,l){var f=this,v=this._sourceBuffer[n];return!this.mediaSource||!v||v.mimeType===l?Promise.resolve():typeof v.changeType!="function"?Promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(n,function(){try{v.changeType(l)}catch(E){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,E)}v.mimeType=l,f._onSBUpdateEnd(n)},"changeType",{mimeType:l})}},{key:"createOrChangeSource",value:function(n,l){return this.createSource(n,l),this.changeType(n,l)}},{key:"append",value:function(n,l,f){var v=this;return!l||!l.byteLength||!this._sourceBuffer[n]?Promise.resolve():this._enqueueOp(n,function(){var E;!v.mediaSource||v.media.error||(v._logger.debug("MSE APPEND START",f),v._opst=lr(),(E=v._sourceBuffer[n])===null||E===void 0||E.appendBuffer(l))},fi.APPEND,f)}},{key:"remove",value:function(n,l,f,v){var E=this,_=!1;return this._mseFullFlag[n]&&(_=!0),this._enqueueOp(n,function(){if(!(!E.mediaSource||E.media.error)){var S=E._sourceBuffer[n];if(l>=f||!S){E._onSBUpdateEnd(n);return}E._opst=lr(),E._logger.debug("MSE REMOVE START",n,l,f,v),S.remove(l,f)}},fi.REMOVE,v,_)}},{key:"clearBuffer",value:function(n,l){var f=this,v;return Object.keys(this._sourceBuffer).forEach(function(E){v=f.remove(E,n,l)}),v||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var n=this,l;return Object.keys(this._sourceBuffer).forEach(function(f){var v=n._sourceBuffer[f];l=n.remove(f,0,tt.end(tt.get(v)))}),l}},{key:"clearOpQueues",value:function(n,l){var f;this._logger.debug("MSE clearOpQueue START");var v=this._queue[n];if(l&&v){this._queue[n]=[];return}if(!(!v||!v[n]||v.length<5)){var E=[];v.forEach(function(_){_.context&&_.context.isinit&&E.push(_)}),this._queue[n]=v.slice(0,2),E.length>0&&(f=this._queue[n]).push.apply(f,E)}}},{key:"endOfStream",value:function(n){var l=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var f=l.mediaSource;!f||f.readyState!=="open"||(l._logger.debug("MSE endOfStream START"),n?f.endOfStream(n):f.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(n,l){var f=this.mediaSource;n<0||l<n||!(f!=null&&f.setLiveSeekableRange)||f.readyState!=="open"||f.setLiveSeekableRange(n,l)}},{key:"getSourceBuffer",value:function(n){return this._sourceBuffer[n]}},{key:"buffered",value:function(n){return tt.get(this._sourceBuffer[n])}},{key:"bufferStart",value:function(n){return tt.start(this.buffered(n))}},{key:"bufferEnd",value:function(n){return tt.end(this.buffered(n))}},{key:"_enqueueOp",value:function(n,l,f,v,E){var _=this;if(!this.mediaSource)return Promise.resolve();var S=this._queue[n]=this._queue[n]||[],C={exec:l,promise:tr(),opName:f,context:v};return E?(S.splice(0,0,C),this._mseFullFlag[n]=!1,this._startQueue(n)):S.push(C),this.isOpened||this.isEnded?S.length===1&&this._startQueue(n):this._openPromise.then(function(){S.length===1&&_._startQueue(n)}),C.promise}},{key:"_enqueueBlockingOp",value:function(){var g=St(Ye().mark(function l(f,v,E){var _=this,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.mediaSource){P.next=2;break}return P.abrupt("return",Promise.resolve());case 2:if(S=Object.keys(this._sourceBuffer),S.length){P.next=5;break}return P.abrupt("return",f());case 5:return C=[],S.forEach(function(H){var W=_._queue[H],Y=tr();C.push(Y),W.push({exec:function(){Y.resolve()},promise:Y,opName:v,context:E}),W.length===1&&_._startQueue(H)}),P.abrupt("return",Promise.all(C).then(function(){try{return f()}finally{S.forEach(function(H){var W=_._queue[H],Y=_._sourceBuffer[H];W?.shift(),(!Y||!Y.updating)&&_._startQueue(H)})}}));case 8:case"end":return P.stop()}},l,this)}));function n(l,f,v){return g.apply(this,arguments)}return n}()},{key:"_startQueue",value:function(n){var l=this._queue[n];if(l){var f=l[0];if(f&&!this._mseFullFlag[n])try{f.exec()}catch(v){v&&v.message&&v.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[n]=!0,f.context&&Gt(f.context)==="object"&&(f.context.isFull=!0),this._logger.error("[MSE error], context,",f.context," ,name,",f.opName,",err,SourceBuffer is full"),f.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_FULL,v))):(this._logger.error(v),f.promise.reject(v.constructor===dt?v:new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_OTHER,v)),l.shift(),this._startQueue(n))}}}},{key:"setTimeoffset",value:function(n,l,f){var v=this;return this._enqueueOp(n,function(){l<0&&(l+=.001),v._sourceBuffer[n].timestampOffset=l,v._onSBUpdateEnd(n)},"setTimeoffset",f)}},{key:"abort",value:function(n,l){var f=this;return this.isOpened?this._enqueueOp(n,function(){f._sourceBuffer[n].abort(),f._onSBUpdateEnd(n)},"abort",l):Promise.resolve()}}],[{key:"isSupported",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',l=Es();if(!l)return!1;try{return l.isTypeSupported(n)}catch(f){return this._logger.error(n,f),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),c}();q(rr,"VIDEO","video");q(rr,"AUDIO","audio");var kt={FETCH:"fetch",XHR:"xhr"},ir={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var Lt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E){var _;return Be(this,n),_=g.call(this,E),q(de(_),"retryCount",0),q(de(_),"isTimeout",!1),q(de(_),"loaderType",kt.FETCH),q(de(_),"startTime",0),q(de(_),"endTime",0),q(de(_),"options",{}),_.url=l,_.request=f,_.response=v,_}return Ge(n)}(ur(Error));var _s=Object.prototype.toString;function Ss(c){return c!==null&&Gt(c)==="object"}function Qi(c){if(_s.call(c)!=="[object Object]")return!1;var g=Object.getPrototypeOf(c);return g===null||g===Object.prototype}function Ts(c){return _s.call(c)==="[object Date]"}function hi(c){if(!(!c||c[0]===null||c[0]===void 0||c[0]===0&&(c[1]===null||c[1]===void 0))){var g="bytes="+c[0]+"-";return c[1]&&(g+=c[1]),g}}function xs(c){return encodeURIComponent(c).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function di(c,g){if(c){if(!g)return c;var n,l=Object.keys(g).map(function(v){if(n=g[v],n!=null)return Array.isArray(n)?v=v+"[]":n=[n],n.map(function(E){return Ts(E)?E=E.toISOString():Ss(E)&&(E=JSON.stringify(E)),"".concat(xs(v),"=").concat(xs(E))}).join("&")}).filter(Boolean).join("&");if(l){var f=c.indexOf("#");f!==-1&&(c=c.slice(0,f)),c+=(c.indexOf("?")===-1?"?":"&")+l}return c}}function Pr(c,g,n,l,f,v,E,_,S,C,I){f=f!=null?parseFloat(f):null,l=parseInt(l||"0",10),Number.isNaN(l)&&(l=0);var P={range:S,vid:C,index:_,contentLength:l,age:f,startTime:v,firstByteTime:E,endTime:Date.now(),priOptions:I};return{data:c,done:g,options:P,response:n}}function kr(c,g){return Math.round(c*8*1e3/g/1024)}var me={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var Ls=gr(_r()),bs=2*1024*1024,Or=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_abortController",null),q(de(l),"_timeoutTimer",null),q(de(l),"_reader",null),q(de(l),"_response",null),q(de(l),"_aborted",!1),q(de(l),"_index",-1),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_running",!1),q(de(l),"_logger",null),q(de(l),"_vid",""),q(de(l),"_onProcessMinLen",0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v,E=this,_=f.url,S=f.vid,C=f.timeout,I=f.responseType,P=f.onProgress,H=f.index,W=f.onTimeout,Y=f.onCancel,ee=f.range,J=f.transformResponse,ae=f.request,se=f.params,_e=f.logger,oe=f.method,j=f.headers,ue=f.body,Ve=f.mode,R=f.credentials,le=f.cache,G=f.redirect,He=f.referrer,F=f.referrerPolicy,O=f.onProcessMinLen,B=f.priOptions;this._logger=_e,this._aborted=!1,this._onProcessMinLen=O,this._onCancel=Y,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=H,this._range=ee||[0,0],this._vid=S||_,this._priOptions=B||{};var re={method:oe,headers:j,body:ue,mode:Ve,credentials:R,cache:le,redirect:G,referrer:He,referrerPolicy:F,signal:(v=this._abortController)===null||v===void 0?void 0:v.signal},X=!1;clearTimeout(this._timeoutTimer),_=di(_,se);var k=hi(ee);k&&(ae?j=ae.headers:j=re.headers=re.headers||(Headers?new Headers:{}),Headers&&j instanceof Headers?j.append("Range",k):j.Range=k),C&&(this._timeoutTimer=setTimeout(function(){if(X=!0,E.cancel(),W){var De=new Lt(_,re,null,"timeout");De.isTimeout=!0,W(De,{index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions})}},C));var ge=Date.now();return this._logger.debug("[fetch load start], index,",H,",range,",ee),new Promise(function(De,pe){fetch(ae||_,ae?void 0:re).then(function(){var Ne=St(Ye().mark(function Qe(ke){var $t,Pe,hr,dr;return Ye().wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(clearTimeout(E._timeoutTimer),E._response=ke,!(E._aborted||!E._running)){Je.next=4;break}return Je.abrupt("return");case 4:if(J&&(ke=J(ke,_)||ke),ke.ok){Je.next=7;break}throw new Lt(_,re,ke,"bad network response");case 7:if($t=Date.now(),I!==ir.TEXT){Je.next=15;break}return Je.next=11,ke.text();case 11:Pe=Je.sent,E._running=!1,Je.next=37;break;case 15:if(I!==ir.JSON){Je.next=22;break}return Je.next=18,ke.json();case 18:Pe=Je.sent,E._running=!1,Je.next=37;break;case 22:if(!P){Je.next=29;break}return E.resolve=De,E.reject=pe,E._loadChunk(ke,P,ge,$t),Je.abrupt("return");case 29:return Je.next=31,ke.arrayBuffer();case 31:Pe=Je.sent,Pe=new Uint8Array(Pe),E._running=!1,hr=Date.now()-ge,dr=kr(Pe.byteLength,hr),E.emit(me.REAL_TIME_SPEED,{speed:dr,len:Pe.byteLength,time:hr,vid:E._vid,index:E._index,range:E._range,priOptions:E._priOptions});case 37:E._logger.debug("[fetch load end], index,",H,",range,",ee),De(Pr(Pe,!0,ke,ke.headers.get("Content-Length"),ke.headers.get("age"),ge,$t,H,ee,E._vid,E._priOptions));case 39:case"end":return Je.stop()}},Qe)}));return function(Qe){return Ne.apply(this,arguments)}}()).catch(function(Ne){var Qe;clearTimeout(E._timeoutTimer),E._running=!1,!(E._aborted&&!X)&&(Ne=Ne instanceof Lt?Ne:new Lt(_,re,null,(Qe=Ne)===null||Qe===void 0?void 0:Qe.message),Ne.startTime=ge,Ne.endTime=Date.now(),Ne.isTimeout=X,Ne.options={index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions},pe(Ne))})})}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){return Ye().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._aborted){_.next=2;break}return _.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){_.next=14;break}if(_.prev=5,!this._reader){_.next=9;break}return _.next=9,this._reader.cancel();case 9:_.next=13;break;case 11:_.prev=11,_.t0=_.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return _.stop()}},v,this,[[5,11]])}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadChunk",value:function(f,v,E,_){var S=this;if(!f.body||!f.body.getReader){this._running=!1;var C=new Lt(f.url,"",f,"onProgress of bad response.body.getReader");C.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(C);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(bs),this._writeIdx=0);var I=this._reader=f.body.getReader(),P,H,W,Y=function(){var ee=St(Ye().mark(function J(){var ae,se,_e,oe,j,ue,Ve,R;return Ye().wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return H=Date.now(),G.prev=1,G.next=4,I.read();case 4:P=G.sent,W=Date.now(),G.next=13;break;case 8:return G.prev=8,G.t0=G.catch(1),W=Date.now(),S._aborted||(S._running=!1,G.t0.options={index:S._index,range:S._range,vid:S._vid,priOptions:S._priOptions},S.reject(G.t0)),G.abrupt("return");case 13:if(se=((ae=S._range)===null||ae===void 0?void 0:ae.length)>0?S._range[0]:0,_e=se+S._receivedLength,!S._aborted){G.next=19;break}return S._running=!1,v(void 0,!1,{range:[_e,_e],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),G.abrupt("return");case 19:oe=P.value?P.value.byteLength:0,S._receivedLength+=oe,S._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",S._range,", start,",_e,", end,",se+S._receivedLength,", done,",P.done),S._onProcessMinLen>0?S._writeIdx+oe>=S._onProcessMinLen||P.done?(j=new Uint8Array(S._writeIdx+oe),j.set(S._cache.slice(0,S._writeIdx),0),oe>0&&j.set(P.value,S._writeIdx),S._writeIdx=0,S._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",P.done,",len,",j.byteLength,", writeIdx,",S._writeIdx)):oe>0&&S._writeIdx+oe<bs?(S._cache.set(P.value,S._writeIdx),S._writeIdx+=oe,S._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",oe,", writeIdx,",S._writeIdx)):oe>0&&(ue=new Uint8Array(S._writeIdx+oe+2048),S._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",S._writeIdx+oe+2048,", datalen,",oe,", writeIdx,",S._writeIdx),ue.set(S._cache.slice(0,S._writeIdx),0),oe>0&&ue.set(P.value,S._writeIdx),S._writeIdx+=oe,delete S._cache,S._cache=ue,S._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",oe,", writeIdx,",S._writeIdx)):j=P.value,(j&&j.byteLength>0||P.done)&&v(j,P.done,{range:[S._range[0]+S._receivedLength-(j?j.byteLength:0),S._range[0]+S._receivedLength],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),P.done?(Ve=Date.now()-E,R=kr(S._receivedLength,Ve),S.emit(me.REAL_TIME_SPEED,{speed:R,len:S._receivedLength,time:Ve,vid:S._vid,index:S._index,range:S._range,priOptions:S._priOptions}),S._running=!1,S._logger.debug("[fetchLoader onProgress end],task,",S._range,",done,",P.done),S.resolve(Pr(P,!0,f,f.headers.get("Content-Length"),f.headers.get("age"),E,_,S._index,S._range,S._vid,S._priOptions))):Y();case 25:case"end":return G.stop()}},J,null,[[1,8]])}));return function(){return ee.apply(this,arguments)}}();Y()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),n}(Ls.default);function As(c){return er({loaderType:kt.FETCH,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:ir.TEXT,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},c)}var Rs=gr(_r()),Cs=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_xhr",null),q(de(l),"_aborted",!1),q(de(l),"_timeoutTimer",null),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_url",null),q(de(l),"_onProgress",null),q(de(l),"_index",-1),q(de(l),"_headers",null),q(de(l),"_currentChunkSizeKB",384),q(de(l),"_timeout",null),q(de(l),"_xhr",null),q(de(l),"_withCredentials",null),q(de(l),"_startTime",-1),q(de(l),"_loadCompleteResolve",null),q(de(l),"_loadCompleteReject",null),q(de(l),"_runing",!1),q(de(l),"_logger",!1),q(de(l),"_vid",""),q(de(l),"_responseType",void 0),q(de(l),"_credentials",void 0),q(de(l),"_method",void 0),q(de(l),"_transformResponse",void 0),q(de(l),"_firstRtt",void 0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v=this;clearTimeout(this._timeoutTimer),this._logger=f.logger,this._range=f.range,this._onProgress=f.onProgress,this._index=f.index,this._headers=f.headers,this._withCredentials=f.credentials==="include"||f.credentials==="same-origin",this._body=f.body||null,f.method&&(this._method=f.method),this._timeout=f.timeout||null,this._runing=!0,this._vid=f.vid||f.url,this._responseType=f.responseType,this._firstRtt=-1,this._onTimeout=f.onTimeout,this._onCancel=f.onCancel,this._request=f.request,this._priOptions=f.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=di(f.url,f.params);var E=Date.now();return new Promise(function(_,S){v._loadCompleteResolve=_,v._loadCompleteReject=S,v._startLoad()}).catch(function(_){if(clearTimeout(v._timeoutTimer),v._runing=!1,!v._aborted)throw _=_ instanceof Lt?_:new Lt(v._url,v._request),_.startTime=E,_.endTime=Date.now(),_.options={index:v._index,vid:v._vid,priOptions:v._priOptions},_})}},{key:"_startLoad",value:function(){var f=null;if(this._responseType===ir.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var v=this._currentChunkSizeKB*1024,E=this._range[0]+this._receivedLength,_=this._range[1];v<this._range[1]-E&&(_=E+v),f=[E,_],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",f)}else f=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",f);this._internalOpen(f)}},{key:"_internalOpen",value:function(f){var v=this;try{this._startTime=Date.now();var E=this._xhr=new XMLHttpRequest;E.open(this._method||"GET",this._url,!0),E.responseType=this._responseType,this._timeout&&(E.timeout=this._timeout),E.withCredentials=this._withCredentials,E.onload=this._onLoad.bind(this),E.onreadystatechange=this._onReadyStatechange.bind(this),E.onerror=function(C){var I,P,H;v._running=!1;var W=new Lt(v._url,v._request,C==null||(I=C.currentTarget)===null||I===void 0?void 0:I.response,"xhr.onerror.status:"+(C==null||(P=C.currentTarget)===null||P===void 0?void 0:P.status)+",statusText,"+(C==null||(H=C.currentTarget)===null||H===void 0?void 0:H.statusText));W.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(W)},E.ontimeout=function(C){v.cancel();var I=new Lt(v._url,v._request,{status:408},"timeout");v._onTimeout&&(I.isTimeout=!0,v._onTimeout(I,{index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions})),I.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(I)};var _=this._headers||{},S=hi(f);S&&(_.Range=S),_&&Object.keys(_).forEach(function(C){E.setRequestHeader(C,_[C])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",f),E.send(this._body)}catch(C){C.options={index:this._index,range:f,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(C)}}},{key:"_onReadyStatechange",value:function(f){var v=f.target;v.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(f){var v,E=f.target.status;if(E<200||E>299){var _=new Lt(this._url,null,er(er({},f.target.response),{},{status:E}),"bad response,status:"+E);return _.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(_)}var S=null,C=!1,I,P=((v=this._range)===null||v===void 0?void 0:v.length)>0?this._range[0]:0;if(this._responseType===ir.ARRAY_BUFFER){var H,W=new Uint8Array(f.target.response);if(I=P+this._receivedLength,W&&W.byteLength>0){this._receivedLength+=W.byteLength;var Y=Date.now()-this._startTime,ee=kr(this._receivedLength,Y);this.emit(me.REAL_TIME_SPEED,{speed:ee,len:this._receivedLength,time:Y,vid:this._vid,index:this._index,range:[I,P+this._receivedLength],priOptions:this._priOptions})}S=W,((H=this._range)===null||H===void 0?void 0:H.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?C=!1:C=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",I,"end ",P+this._receivedLength,",dataLen,",W?W.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",C)}else C=!0,S=f.target.response;var J={ok:E>=200&&E<300,status:E,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(J=this._transformResponse(J,this._url)||J),this._onProgress&&this._onProgress(S,C,{index:this._index,vid:this._vid,range:[I,P+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},J),C?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Pr(this._onProgress?null:S,C,J,J.headers["content-length"],J.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Cr(Zt(n.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}},{key:"_getHeaders",value:function(f){var v=f.getAllResponseHeaders().trim().split(`\r
18
- `),E={},_=vs(v),S;try{for(_.s();!(S=_.n()).done;){var C=S.value,I=C.split(": ");E[I[0].toLowerCase()]=I.slice(1).join(": ")}}catch(P){_.e(P)}finally{_.f()}return E}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),n}(Rs.default);var Mf=["retry","retryDelay","onRetryError","transformError"],Ds=function(){function c(g,n){Be(this,c),this.promise=tr(),this.alive=!!n.onProgress,!n.logger&&(n.logger=new Tt("Loader")),this._loaderType=g,this._loader=g===kt.FETCH&&typeof fetch<"u"?new Or:new Cs,this._config=n,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=n.retryCheckFunc,this._logger=n.logger}return Ge(c,[{key:"exec",value:function(){var n=this,l=this._config,f=l.retry,v=l.retryDelay,E=l.onRetryError,_=l.transformError,S=cs(l,Mf),C=function(){var I=St(Ye().mark(function P(){var H,W,Y;return Ye().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.prev=0,J.next=3,n._loader.load(S);case 3:H=J.sent,n.promise.resolve(H),J.next=27;break;case 7:if(J.prev=7,J.t0=J.catch(0),n._loader.running=!1,n._logger.debug("[task request catch err]",J.t0),!n._canceled){J.next=13;break}return J.abrupt("return");case 13:if(J.t0.loaderType=n._loaderType,J.t0.retryCount=n._retryCount,W=J.t0,_&&(W=_(W)||W),E&&n._retryCount>0&&E(W,n._retryCount,{index:S.index,vid:S.vid,range:S.range,priOptions:S.priOptions}),n._retryCount++,Y=!0,n._retryCheckFunc&&(Y=n._retryCheckFunc(J.t0)),!(Y&&n._retryCount<=f)){J.next=26;break}return clearTimeout(n._retryTimer),n._logger.debug("[task request setTimeout],retry",n._retryCount,",retry range,",S.range),n._retryTimer=setTimeout(C,v),J.abrupt("return");case 26:n.promise.reject(W);case 27:case"end":return J.stop()}},P,null,[[0,7]])}));return function(){return I.apply(this,arguments)}}();return C(),this.promise}},{key:"cancel",value:function(){var g=St(Ye().mark(function l(){return Ye().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,v.abrupt("return",this._loader.cancel());case 4:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),c}();function Ji(c){return c&&!c.paused&&!c.ended&&c.playbackRate!==0&&c.readyState!==0}function Zi(c){if(!c)return{};if(typeof c.getVideoPlaybackQuality=="function"){var g=c.getVideoPlaybackQuality();return{droppedVideoFrames:g.droppedVideoFrames||g.corruptedVideoFrames,totalVideoFrames:g.totalVideoFrames,creationTime:g.creationTime}}return{droppedVideoFrames:c.webkitDroppedFrameCount,totalVideoFrames:c.webkitDecodedFrameCount,creationTime:performance.now()}}function en(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];if(g=g.filter(Boolean),g.length<2)return g[0];var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}function tn(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(g){return setTimeout(g,c)})}var ws=gr(_r()),rn=function(c){It(n,c);var g=Pt(n);function n(l){var f;return Be(this,n),f=g.call(this,l),q(de(f),"type",kt.FETCH),q(de(f),"_queue",[]),q(de(f),"_alive",[]),q(de(f),"_currentTask",null),q(de(f),"_finnalUrl",""),q(de(f),"_config",void 0),f._config=As(l),(f._config.loaderType===kt.XHR||!Or.isSupported())&&(f.type=kt.XHR),f.log=l.logger,f}return Ge(n,[{key:"isFetch",value:function(){return this.type===kt.FETCH}},{key:"load",value:function(f){var v=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof f=="string"||!f?E.url=f||E.url||this._config.url:E=f,E=Object.assign({},this._config,E),E.params&&(E.params=Object.assign({},E.params)),E.headers&&Qi(E.headers)&&(E.headers=Object.assign({},E.headers)),E.body&&Qi(E.body)&&(E.body=Object.assign({},E.body)),E.transformRequest&&(E=E.transformRequest(E)||E),E.logger=this.log;var _=new Ds(this.type,E);return _.loader.on(me.REAL_TIME_SPEED,function(S){v.emit(me.REAL_TIME_SPEED,S)}),this._queue.push(_),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),_.promise}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){var E;return Ye().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return E=this._queue.map(function(C){return C.cancel()}).concat(this._alive.map(function(C){return C.cancel()})),this._currentTask&&E.push(this._currentTask.cancel()),this._queue=[],this._alive=[],S.next=6,Promise.all(E);case 6:return S.next=8,tn();case 8:case"end":return S.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_processTask",value:function(){var f=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var v=this._currentTask.exec().catch(function(E){});v&&typeof v.finally=="function"&&v.finally(function(){var E,_;(E=f._currentTask)!==null&&E!==void 0&&E.alive&&((_=f._alive)===null||_===void 0?void 0:_.length)>0&&(f._alive=f._alive.filter(function(S){return S&&S!==f._currentTask})),f._processTask()})}}}],[{key:"isFetchSupport",value:function(){return Or.isSupported()}}]),n}(ws.default);var nn=function(){function c(){Be(this,c),q(this,"_prevCurrentTime",0)}return Ge(c,[{key:"do",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,f=arguments.length>2?arguments[2]:void 0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(n){var E=n.currentTime,_=0;if(this._prevCurrentTime===E){var S=tt.info(tt.get(n),E);if(!S.buffers.length)return;f&&S.nextStart||S.nextStart&&S.nextStart-E<l?_=S.nextStart+.1:S.end&&S.end-E>v&&!n.seeking&&(_=E+.1)}this._prevCurrentTime=E,_&&E!==_&&(n.currentTime=_)}}}]),c}();var an=function(){function c(g){var n=this;Be(this,c),q(this,"_seiSet",new Set),this.emitter=g,g.on(me.SEI,function(l){l&&n._seiSet.add(l)})}return Ge(c,[{key:"throw",value:function(n,l){var f=this;if(!(n==null||!this._seiSet.size)){var v=n-.2,E=n+.2,_=[];this._seiSet.forEach(function(S){S.time>=v&&S.time<=E&&_.push(S)}),_.forEach(function(S){f._seiSet.delete(S),f.emitter.emit(me.SEI_IN_TIME,S)}),l&&this._seiSet.forEach(function(S){S.time<n-5&&f._seiSet.delete(S)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),c}();var Ff=1e3,Nf=50,Uf=3,Bf=3e3,sn=function(){function c(g){Be(this,c),q(this,"_chunkSpeed",0),q(this,"_chunkCache",[]),q(this,"_speeds",[]),q(this,"_totalSize",0),q(this,"_totalCost",0),this._opts=g||{}}return Ge(c,[{key:"addRecord",value:function(n,l){!n||!l||(this._speeds.push(8e3*n/l),this._speeds=this._speeds.slice(-Uf))}},{key:"addChunkRecord",value:function(n,l){var f,v;if(!(!n||!l||n<(((f=this._opts)===null||f===void 0?void 0:f.skipChunkSize)||Ff))){this._totalSize+=n,this._totalCost+=l,this._chunkSpeed=8e3*n/l,this._chunkCache.push({size:n,duration:l,timestamp:performance.now()});var E=((v=this._opts)===null||v===void 0?void 0:v.chunkCountForSpeed)||Nf;this._chunkCache.length>E&&(this._chunkCache=this._chunkCache.slice(-E))}}},{key:"getAvgSpeed",value:function(){var n;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(_,S){return _+=S})/this._speeds.length;var l=this._chunkCache[this._chunkCache.length-1],f=performance.now()-l.timestamp;f>(((n=this._opts)===null||n===void 0?void 0:n.longtimeNoReceived)||Bf)&&this._chunkCache.push({size:0,duration:f,timestamp:performance.now()});var v=this._chunkCache.reduce(function(_,S){return _+=S.size},0),E=this._chunkCache.reduce(function(_,S){return _+=S.duration},0);return 8e3*v/E}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{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}}]),c}();var yd=gr(_r());var Is=function(){function c(g){Be(this,c),q(this,"encodeType",""),q(this,"audioCodec",""),q(this,"videoCodec",""),q(this,"domain",""),q(this,"fps",0),q(this,"bitrate",0),q(this,"width",0),q(this,"height",0),q(this,"samplerate",0),q(this,"channelCount",0),q(this,"gop",0),q(this,"_bitsAccumulateSize",0),q(this,"_bitsAccumulateDuration",0),q(this,"_startGopId",-1),this._timescale=g}return Ge(c,[{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(n){this.encodeType=n}},{key:"setFpsFromScriptData",value:function(n){var l,f=n.data,v=f==null||(l=f.onMetaData)===null||l===void 0?void 0:l.framerate;v&&v>0&&v<100&&(this.fps=v)}},{key:"setVideoMeta",value:function(n){if(this.width=n.width,this.height=n.height,this.videoCodec=n.codec,this.encodeType=n.codecType,n.fpsNum&&n.fpsDen){var l=n.fpsNum/n.fpsDen;l>0&&l<100&&(this.fps=l)}}},{key:"setAudioMeta",value:function(n){this.audioCodec=n.codec,this.samplerate=n.sampleRate,this.channelCount=n.channelCount}},{key:"setDomain",value:function(n){this.domain=n.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(n){var l=this;if((!this.fps||this.fps>=100)&&n.length){var f=n.reduce(function(v,E){return v+=E.duration},0)/n.length;this.fps=Math.round(this._timescale/f)}n.forEach(function(v){l._startGopId===-1&&(l._startGopId=v.gopId),v.gopId===l._startGopId&&l.gop++,l._bitsAccumulateDuration+=v.duration/(l._timescale/1e3),l._bitsAccumulateSize+=v.units.reduce(function(E,_){return E+=_.length},0),l._bitsAccumulateDuration>=1e3&&(l.bitrate=l._bitsAccumulateSize*8,l._bitsAccumulateDuration=0,l._bitsAccumulateSize=0)})}}]),c}(),on=function(){function c(g){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;Be(this,c),q(this,"_core",null),q(this,"_samples",[]),this._core=g,this._timescale=n,this._stats=new Is(n),this._bindEvents()}return Ge(c,[{key:"getStats",value:function(){var n,l,f,v,E,_,S,C,I,P,H,W=((n=this._core)===null||n===void 0?void 0:n.media)||{},Y=W.currentTime,ee=Y===void 0?0:Y,J=W.decodeFps,ae=J===void 0?0:J;return er(er({},this._stats.getStats()),{},{downloadSpeed:((l=this._core)===null||l===void 0||(f=l.speedInfo)===null||f===void 0?void 0:f.call(l).speed)||0,avgSpeed:((v=this._core)===null||v===void 0||(E=v.speedInfo)===null||E===void 0?void 0:E.call(v).avgSpeed)||0,totalReceivedByte:((_=this._core)===null||_===void 0||(S=_.speedInfo)===null||S===void 0?void 0:S.call(_).totalSize)||0,totalReceivedCost:((C=this._core)===null||C===void 0||(I=C.speedInfo)===null||I===void 0?void 0:I.call(C).totalCost)||0,currentTime:ee,bufferEnd:((P=this._core)===null||P===void 0||(H=P.bufferInfo())===null||H===void 0?void 0:H.remaining)||0,decodeFps:ae})}},{key:"_bindEvents",value:function(){var n=this;this._core.on(me.DEMUXED_TRACK,function(l){var f=l.videoTrack;return n._stats.updateBitrate(f.samples)}),this._core.on(me.FLV_SCRIPT_DATA,function(l){n._stats.setFpsFromScriptData(l)}),this._core.on(me.METADATA_PARSED,function(l){l.type==="video"?n._stats.setVideoMeta(l.track):n._stats.setAudioMeta(l.track)}),this._core.on(me.TTFB,function(l){n._stats.setDomain(l.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Is(this._timescale)}}]),c}();var no=gr(_r());function Gf(c,g){var n=c==null?null:typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(n!=null){var l,f,v,E,_=[],S=!0,C=!1;try{if(v=(n=n.call(c)).next,g===0){if(Object(n)!==n)return;S=!1}else for(;!(S=(l=v.call(n)).done)&&(_.push(l.value),_.length!==g);S=!0);}catch(I){C=!0,f=I}finally{try{if(!S&&n.return!=null&&(E=n.return(),Object(E)!==E))return}finally{if(C)throw f}}return _}}function Se(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function Ps(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,Ms(l.key),l)}}function Te(c,g,n){return g&&Ps(c.prototype,g),n&&Ps(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function Q(c,g,n){return g=Ms(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function fn(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&un(c,g)}function ci(c){return ci=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ci(c)}function un(c,g){return un=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},un(c,g)}function Vf(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Hf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Kf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hf(c)}function hn(c){var g=Vf();return function(){var l=ci(c),f;if(g){var v=ci(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Kf(this,f)}}function ks(c,g){return jf(c)||Gf(c,g)||Os(c,g)||qf()}function Ot(c){return Wf(c)||zf(c)||Os(c)||Yf()}function Wf(c){if(Array.isArray(c))return ln(c)}function jf(c){if(Array.isArray(c))return c}function zf(c){if(typeof Symbol<"u"&&c[Symbol.iterator]!=null||c["@@iterator"]!=null)return Array.from(c)}function Os(c,g){if(c){if(typeof c=="string")return ln(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ln(c,g)}}function ln(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function Yf(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
19
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
20
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function Ms(c){var g=Xf(c,"string");return typeof g=="symbol"?g:String(g)}var Mt={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},zt={AV1:"av1",AVC:"avc",HEVC:"hevc"},We={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus"},mt={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var Fs=function(){function c(){Se(this,c),Q(this,"id",1),Q(this,"type",Mt.VIDEO),Q(this,"codecType",zt.AVC),Q(this,"pid",-1),Q(this,"hvcC",void 0),Q(this,"codec",""),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"sequenceNumber",0),Q(this,"baseMediaDecodeTime",0),Q(this,"baseDts",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"pps",[]),Q(this,"sps",[]),Q(this,"vps",[]),Q(this,"fpsNum",0),Q(this,"fpsDen",0),Q(this,"sarRatio",[]),Q(this,"width",0),Q(this,"height",0),Q(this,"nalUnitSize",4),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"isVideo",!0),Q(this,"lastKeyFrameDts",0),Q(this,"kid",null),Q(this,"pssh",null),Q(this,"ext",void 0)}return Te(c,[{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 n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),c}();var Ns=function(){function c(){Se(this,c),Q(this,"id",2),Q(this,"type",Mt.AUDIO),Q(this,"codecType",We.AAC),Q(this,"pid",-1),Q(this,"codec",""),Q(this,"sequenceNumber",0),Q(this,"sampleDuration",0),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"baseMediaDecodeTime",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"baseDts",0),Q(this,"sampleSize",16),Q(this,"sampleRate",0),Q(this,"channelCount",0),Q(this,"objectType",0),Q(this,"sampleRateIndex",0),Q(this,"config",[]),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"kid",null),Q(this,"ext",void 0)}return Te(c,[{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===We.AAC||this.codecType===We.G711PCMA||this.codecType===We.G711PCMU||this.codecType===We.OPUS))}},{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 n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}}]),c}();var Us=function(){function c(g,n,l){Se(this,c),Q(this,"flag",{}),Q(this,"keyframe",!1),Q(this,"gopId",0),Q(this,"duration",0),Q(this,"size",0),Q(this,"units",[]),Q(this,"chromaFormat",420),this.originPts=this.pts=g,this.originDts=this.dts=n,l&&(this.units=l)}return Te(c,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),c}();var Sr=Te(function c(g,n,l,f){Se(this,c),Q(this,"duration",1024),Q(this,"flag",{dependsOn:2,isNonSyncSample:0}),Q(this,"keyframe",!0),this.originPts=this.pts=this.dts=g,this.data=n,this.size=n.byteLength,this.sampleOffset=f,l&&(this.duration=l)});var Bs=Te(function c(g,n){Se(this,c),Q(this,"time",0),this.data=g,this.originPts=this.pts=n}),Gs=function(c){fn(n,c);var g=hn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Bs),Vs=function(c){fn(n,c);var g=hn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Bs),Hs=function(){function c(){Se(this,c),Q(this,"id",3),Q(this,"type",Mt.METADATA),Q(this,"timescale",0),Q(this,"flvScriptSamples",[]),Q(this,"seiSamples",[])}return Te(c,[{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)}}]),c}();var fr=function(){function c(g){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]")}return Te(c,[{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(fr,"disabled",!0);var vi=typeof window<"u",dn=vi&&navigator.userAgent.toLocaleLowerCase(),Ks=vi&&/^((?!chrome|android).)*safari/.test(dn),Ws=vi&&dn.includes("firefox"),js=vi&&dn.includes("android");var Tr=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getRateIndexByRate",value:function(n){return c.FREQ.indexOf(n)}},{key:"parseADTS",value:function(n,l){for(var f=n.length,v=0;v+2<f&&!(n[v]===255&&(n[v+1]&246)===240);)v++;if(!(v>=f)){var E=v,_=[],S=(n[v+2]&60)>>>2,C=c.FREQ[S];if(!C)throw new Error("Invalid sampling index: ".concat(S));for(var I=((n[v+2]&192)>>>6)+1,P=(n[v+2]&1)<<2|(n[v+3]&192)>>>6,H=c._getConfig(S,P,I),W=H.config,Y=H.codec,ee,J,ae=0,se=c.getFrameDuration(C);v+7<f;){if(n[v]!==255||(n[v+1]&246)!==240){v++;continue}if(J=(n[v+3]&3)<<11|n[v+4]<<3|(n[v+5]&224)>>5,!J||f-v<J)break;ee=(~n[v+1]&1)*2,_.push({pts:l+ae*se,data:n.subarray(v+7+ee,v+J)}),ae++,v+=J}return{skip:E,remaining:v>=f?void 0:n.subarray(v),frames:_,samplingFrequencyIndex:S,sampleRate:C,objectType:I,channelCount:P,codec:Y,config:W,originCodec:"mp4a.40.".concat(I)}}}},{key:"parseAudioSpecificConfig",value:function(n){if(n.length){var l=n[0]>>>3,f=(n[0]&7)<<1|n[1]>>>7,v=(n[1]&120)>>>3,E=c.FREQ[f];if(E){var _=c._getConfig(f,v,l),S=_.config,C=_.codec;return{samplingFrequencyIndex:f,sampleRate:E,objectType:l,channelCount:v,config:S,codec:C,originCodec:"mp4a.40.".concat(l)}}}}},{key:"getFrameDuration",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*l/n}},{key:"_getConfig",value:function(n,l,f){var v=[],E,_;return Ws?n>=6?(E=5,_=n-3):(E=2,_=n):js?(E=2,_=n):(E=f===2||f===5?f:5,_=n,n>=6?_=n-3:l===1&&(E=2,_=n)),v[0]=E<<3,v[0]|=(n&14)>>1,v[1]=(n&1)<<7,v[1]|=l<<3,E===5&&(v[1]|=(_&14)>>1,v[2]=(_&1)<<7,v[2]|=8,v[3]=0),{config:v,codec:"mp4a.40.".concat(E)}}},{key:"getSilentFrame",value:function(n,l){switch(n){case"mp4a.40.2":if(l===1)return new Uint8Array([0,200,0,128,35,128]);if(l===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(l===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(l===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(l===5)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(l===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(l===1)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(l===2)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(l===3)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]);break}}}]),c}();Q(Tr,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Mr=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getFrameDuration",value:function(n){return 20}},{key:"parseHeaderPackets",value:function(n){if(n.length){for(var l=new DataView(n.buffer,n.byteOffset,n.byteLength),f="",v=0;v<8;v++)f+=String.fromCodePoint(n[v]);if(f!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var E=n[9];console.log("Pre-skip",n[10],n[11]);var _=l.getUint32(12,!0),S=l.getInt16(16,!0);if(_){var C="opus",I="opus",P=new Uint8Array(n.buffer,n.byteOffset+8,n.byteLength-8);return{outputGain:S,sampleRate:_,channelCount:E,config:P,codec:C,originCodec:I}}}}}]),c}();var $f=500,zs=3,cn=1e3,vn=5e3,Qf=1e3,Jf=200,Ys=5e3,qs=5,Xs=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n,this.metadataTrack=l,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 Te(c,[{key:"fix",value:function(){var n=this,l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;l=Math.round(l*1e3);var E=this.videoTrack,_=this.audioTrack;(f||!v)&&(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),f&&!v&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(_,E),!v&&l&&(this._audioNextPts=this._videoNextDts=l);var S=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(S&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(_),this._keyFrameInNextChunk=!1,this._fixVideo(E),this.metadataTrack.exist()){var C=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C}),this.metadataTrack.flvScriptSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C})}E.samples.length&&(E.baseMediaDecodeTime=E.samples[0].dts),_.samples.length&&(_.baseMediaDecodeTime=_.samples[0].pts*_.timescale/1e3)}},{key:"_fixVideo",value:function(n){var l=this,f=n.samples;if(f.length){f.forEach(function(se){se.dts-=l._baseDts,se.pts-=l._baseDts,se.keyframe&&(l._keyFrameInNextChunk=!0)});var v;if(n.fpsNum&&n.fpsDen)v=n.timescale*(n.fpsDen/n.fpsNum);else if(n.length>1){var E=n.samples[0],_=n.samples[f.length-1];v=Math.floor((_.dts-E.dts)/(f.length-1))}else v=this._lastVideoDuration||40;var S=f.pop();if(this._videoLastSample&&f.unshift(this._videoLastSample),this._videoLastSample=S,!!f.length){if(this._videoNextDts===void 0){var C=f[0];this._videoNextDts=C.dts}var I=f.length,P=0,H=f[0],W=this._videoNextDts-H.dts;if(Math.abs(W)>Jf){if(Math.abs(H.dts-this._lastVideoExceptionChunkFirstDtsDot)>Ys){var Y;this._lastVideoExceptionChunkFirstDtsDot=H.dts,n.warnings.push({type:mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:H.dts,nextSampleDts:(Y=f[1])===null||Y===void 0?void 0:Y.dts,sampleDuration:W})}this._videoTimestampBreak>=qs?(this._videoNextDts=H.dts,this._videoTimestampBreak=0):(H.dts+=W,H.pts+=W,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var ee=0;ee<I;ee++){var J=f[ee].dts,ae=f[ee+1];ee<I-1?P=ae.dts-J:S?P=S.dts-J:P=v,(P>Qf||P<0)&&(this._videoTimestampBreak++,Math.abs(J-this._lastVideoExceptionLargeGapDot)>Ys&&(this._lastVideoExceptionLargeGapDot=J,n.warnings.push({type:mt.LARGE_VIDEO_GAP,time:J/n.timescale,dts:J,originDts:f[ee].originDts,nextDts:this._videoNextDts,sampleDuration:P,refSampleDuration:v})),P=v),f[ee].duration=P,this._videoNextDts+=P,this._lastVideoDuration=P}}}}},{key:"_fixAudio",value:function(n){var l=this,f=n.samples;f.length&&(f.forEach(function(v){v.dts=v.pts-=l._baseDts}),this._doFixAudioInternal(n,f,1e3))}},{key:"_calculateBaseDts",value:function(n,l){var f=n.samples,v=l.samples;if(!f.length&&!v.length)return!1;var E=1/0,_=1/0;f.length&&(n.baseDts=E=f[0].pts),v.length&&(l.baseDts=_=v[0].dts),this._baseDts=Math.min(E,_);var S=_-E;return Number.isFinite(S)&&Math.abs(S)>$f&&l.warnings.push({type:mt.LARGE_AV_SHIFT,videoBaseDts:_,audioBasePts:E,baseDts:this._baseDts,delta:S}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var n=this._calculateBaseDts(this.audioTrack,this.videoTrack);n&&(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(n,l,f){if(!n.sampleDuration)switch(n.codecType){case We.AAC:{n.sampleDuration=Tr.getFrameDuration(n.timescale,f);break}case We.OPUS:{n.sampleDuration=Mr.getFrameDuration(n.samples,f);break}case We.G711PCMA:case We.G711PCMU:{n.sampleDuration=this._getG711Duration(n);break}default:console.error("can't fix audio codecType:",n.codecType);break}var v=n.sampleDuration,E=n.codecType===We.OPUS?20:n.codecType===We.AAC?1024:v*n.timescale/1e3;if(this._audioNextPts===void 0){var _=l[0];this._audioNextPts=_.pts}for(var S=0;S<l.length;S++){var C=this._audioNextPts,I=l[S],P=I.pts-C;if(S===0&&this._audioTimestampBreak>=qs&&this._keyFrameInNextChunk&&(C=this._audioNextPts=I.dts,P=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&P>=zs*v&&P<=cn&&!Ks){var H=this._getSilentFrame(n)||l[0].data.subarray(),W=Math.floor(P/v);Math.abs(I.pts-this._lastAudioExceptionGapDot)>vn&&(this._lastAudioExceptionGapDot=I.pts,n.warnings.push({type:mt.AUDIO_FILLED,pts:I.pts,originPts:I.originPts,count:W,nextPts:C,refSampleDuration:v}));for(var Y=0;Y<W;Y++){var ee=new Sr(Math.floor(this._audioNextPts+v)-Math.floor(this._audioNextPts),H,E);ee.originPts=Math.floor(this._baseDts+C),l.splice(S,0,ee),this._audioNextPts+=v,S++}S--}else if(P<=-zs*v&&P>=-1*cn)Math.abs(I.pts-this._lastAudioExceptionOverlapDot)>vn&&(this._lastAudioExceptionOverlapDot=I.pts,n.warnings.push({type:mt.AUDIO_DROPPED,pts:I.pts,originPts:I.originPts,nextPts:C,refSampleDuration:v})),l.splice(S,1),S--;else{if(Math.abs(P)>cn&&(this._audioTimestampBreak++,Math.abs(I.pts-this._lastAudioExceptionLargeGapDot)>vn&&(this._lastAudioExceptionLargeGapDot=I.pts,n.warnings.push({type:mt.LARGE_AUDIO_GAP,time:I.pts/1e3,pts:I.pts,originPts:I.originPts,nextPts:C,sampleDuration:P,refSampleDuration:v}))),n.codecType===We.OPUS){var J=l[l.length-1];J&&(J.duration=I.pts-J.pts)}else I.dts=I.pts=C,I.duration=E;this._audioNextPts+=v}}}},{key:"_getG711Duration",value:function(n){var l=n.sampleSize,f=n.channelCount,v=n.sampleRate,E=n.samples[0];if(E)return E.data.byteLength*2/f/(l/8)/v*1e3}},{key:"_getSilentFrame",value:function(n){return n.codecType===We.AAC?Tr.getSilentFrame(n.codec,n.channelCount):new Uint8Array(8*n.sampleDuration*n.channelCount)}}]),c}();function xt(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];g=g.filter(Boolean);var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}var fc=Math.pow(2,32);function xr(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(c[g]<<24>>>0)+(c[g+1]<<16)+(c[g+2]<<8)+(c[g+3]||0)}function $s(c){for(var g="avc1.",n,l=0;l<3;l++)n=c[l].toString(16),n.length<2&&(n="0".concat(n)),g+=n;return g}function pn(c){if(!Array.isArray(c)){for(var g=[],n="",l=0;l<c.length;l++)l%2&&(n=c[l-1]+c[l],g.push(parseInt(n,16)),n="");return g}return c.map(function(f){return parseInt(f,16)})}var Yt=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAnnexB",value:function(n){for(var l=n.length,f=2,v=0;n[f]!==null&&n[f]!==void 0&&n[f]!==1;)f++;if(f++,v=f+2,v>=l)return[];for(var E=[];v<l;)switch(n[v]){case 0:if(n[v-1]!==0){v+=2;break}else if(n[v-2]!==0){v++;break}f!==v-2&&E.push(n.subarray(f,v-2));do v++;while(n[v]!==1&&v<l);f=v+1,v=f+2;break;case 1:if(n[v-1]!==0||n[v-2]!==0){v+=3;break}f!==v-2&&E.push(n.subarray(f,v-2)),f=v+1,v=f+2;break;default:v+=3;break}return f<l&&E.push(n.subarray(f)),E}},{key:"parseAvcC",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(n.length<4)){for(var f=n.length,v=[],E=0,_;E+l<f;)if(_=xr(n,E),l===3&&(_>>>=8),E+=l,!!_){if(E+_>f)break;v.push(n.subarray(E,E+_)),E+=_}return v}}},{key:"parseSEI",value:function(n,l){for(var f=n.length,v=l?2:1,E=0,_=0,S="";n[v]===255;)E+=255,v++;for(E+=n[v++];n[v]===255;)_+=255,v++;if(_+=n[v++],E===5&&f>v+16)for(var C=0;C<16;C++)S+=n[v].toString(16),v++;return{payload:n.subarray(v,v+_),type:E,size:_,uuid:S}}},{key:"removeEPB",value:function(n){for(var l=n.byteLength,f=[],v=1;v<l-2;)n[v]===0&&n[v+1]===0&&n[v+2]===3?(f.push(v+2),v+=2):v++;if(!f.length)return n;var E=l-f.length,_=new Uint8Array(E),S=0;for(v=0;v<E;S++,v++)S===f[0]&&(S++,f.shift()),_[v]=n[S];return _}}]),c}();var Fr=function(){function c(g){if(Se(this,c),Q(this,"_bytesAvailable",void 0),Q(this,"_bitsAvailable",0),Q(this,"_word",0),!g)throw new Error("ExpGolomb data params is required");this._data=g,this._bytesAvailable=g.byteLength,this._bytesAvailable&&this._loadWord()}return Te(c,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var n=this._data.byteLength-this._bytesAvailable,l=Math.min(4,this._bytesAvailable);if(l===0)throw new Error("No bytes available");var f=new Uint8Array(4);f.set(this._data.subarray(n,n+l)),this._word=new DataView(f.buffer).getUint32(0),this._bitsAvailable=l*8,this._bytesAvailable-=l}},{key:"skipBits",value:function(n){if(this._bitsAvailable>n)this._word<<=n,this._bitsAvailable-=n;else{n-=this._bitsAvailable;var l=Math.floor(n/8);n-=l*8,this._bytesAvailable-=l,this._loadWord(),this._word<<=n,this._bitsAvailable-=n}}},{key:"readBits",value:function(n){if(n>32)throw new Error("Cannot read more than 32 bits");var l=Math.min(this._bitsAvailable,n),f=this._word>>>32-l;return this._bitsAvailable-=l,this._bitsAvailable>0?this._word<<=l:this._bytesAvailable>0&&this._loadWord(),l=n-l,l>0&&this._bitsAvailable?f<<l|this.readBits(l):f}},{key:"skipLZ",value:function(){var n;for(n=0;n<this._bitsAvailable;++n)if(this._word&2147483648>>>n)return this._word<<=n,this._bitsAvailable-=n,n;return this._loadWord(),n+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var n=this.skipLZ();return this.readBits(n+1)-1}},{key:"readEG",value:function(){var n=this.readUEG();return 1&n?1+n>>>1:-1*(n>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(n){for(var l=8,f=8,v,E=0;E<n;E++)f!==0&&(v=this.readEG(),f=(l+v+256)%256),l=f===0?l:f}}]),c}();var Qs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(n){if(!(n.length<7)){for(var l=(n[4]&3)+1,f,v=[],E=[],_=6,S=n[5]&31,C,I=0;I<S;I++)if(C=n[_]<<8|n[_+1],_+=2,!!C){var P=n.subarray(_,_+C);_+=C,v.push(P),f||(f=c.parseSPS(Yt.removeEPB(P)))}var H=n[_];_++;for(var W,Y=0;Y<H;Y++)W=n[_]<<8|n[_+1],_+=2,W&&(E.push(n.subarray(_,_+W)),_+=W);return{sps:f,spsArr:v,ppsArr:E,nalUnitSize:l}}}},{key:"parseSPS",value:function(n){var l=new Fr(n);l.readUByte();var f=l.readUByte(),v=l.readUByte(),E=l.readUByte();l.skipUEG();var _=420;if(f===100||f===110||f===122||f===244||f===44||f===83||f===86||f===118||f===128||f===138||f===144){var S=l.readUEG();if(S<=3&&(_=[0,420,422,444][S]),S===3&&l.skipBits(1),l.skipUEG(),l.skipUEG(),l.skipBits(1),l.readBool())for(var C=S!==3?8:12,I=0;I<C;I++)l.readBool()&&(I<6?l.skipScalingList(16):l.skipScalingList(64))}l.skipUEG();var P=l.readUEG();if(P===0)l.readUEG();else if(P===1){l.skipBits(1),l.skipUEG(),l.skipUEG();for(var H=l.readUEG(),W=0;W<H;W++)l.skipUEG()}l.skipUEG(),l.skipBits(1);var Y=l.readUEG(),ee=l.readUEG(),J=l.readBits(1);J===0&&l.skipBits(1),l.skipBits(1);var ae=0,se=0,_e=0,oe=0;l.readBool()&&(ae=l.readUEG(),se=l.readUEG(),_e=l.readUEG(),oe=l.readUEG());var j,ue,Ve,R,le;if(l.readBool()){if(l.readBool()){var G=l.readUByte();switch(G){case 1:j=[1,1];break;case 2:j=[12,11];break;case 3:j=[10,11];break;case 4:j=[16,11];break;case 5:j=[40,33];break;case 6:j=[24,11];break;case 7:j=[20,11];break;case 8:j=[32,11];break;case 9:j=[80,33];break;case 10:j=[18,11];break;case 11:j=[15,11];break;case 12:j=[64,33];break;case 13:j=[160,99];break;case 14:j=[4,3];break;case 15:j=[3,2];break;case 16:j=[2,1];break;case 255:{j=[l.readUByte()<<8|l.readUByte(),l.readUByte()<<8|l.readUByte()];break}}}if(l.readBool()&&l.readBool(),l.readBool()&&(l.readBits(4),l.readBool()&&l.readBits(24)),l.readBool()&&(l.readUEG(),l.readUEG()),l.readBool()){var He=l.readBits(32),F=l.readBits(32);ue=l.readBool(),Ve=F,R=He*2,le=Ve/R}}return{codec:$s(n.subarray(1,4)),profileIdc:f,profileCompatibility:v,levelIdc:E,chromaFormat:_,width:Math.ceil((Y+1)*16-2*(ae+se)),height:(2-J)*(ee+1)*16-(J?2:4)*(_e+oe),sarRatio:j,fpsNum:Ve,fpsDen:R,fps:le,fixedFrame:ue}}}]),c}();var Js=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(n.length<23)){l=l||{};for(var f=(n[21]&3)+1,v,E,_=[],S=[],C=[],I=23,P=n[22],H,W,Y,ee=0;ee<P;ee++){H=n[I]&63,W=n[I+1]<<8|n[I+2],I+=3;for(var J=0;J<W;J++)if(Y=n[I]<<8|n[I+1],I+=2,!!Y){switch(H){case 32:{var ae=n.subarray(I,I+Y);v||(v=c.parseVPS(Yt.removeEPB(ae),l)),C.push(ae)}break;case 33:{var se=n.subarray(I,I+Y);E||(E=c.parseSPS(Yt.removeEPB(se),l)),_.push(se)}break;case 34:S.push(n.subarray(I,I+Y));break}I+=Y}}return{hvcC:l,sps:E,spsArr:_,ppsArr:S,vpsArr:C,nalUnitSize:f}}}},{key:"parseVPS",value:function(n,l){l=l||{};var f=new Fr(n);f.readUByte(),f.readUByte(),f.readBits(12);var v=f.readBits(3);return l.numTemporalLayers=Math.max(l.numTemporalLayers||0,v+1),f.readBits(17),c._parseProfileTierLevel(f,v,l),l}},{key:"parseSPS",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};l=l||{};var f=new Fr(n);f.readUByte(),f.readUByte(),f.readBits(4);var v=f.readBits(3);l.numTemporalLayers=Math.max(v+1,l.numTemporalLayers||0),l.temporalIdNested=f.readBits(1),c._parseProfileTierLevel(f,v,l),f.readUEG();var E=l.chromaFormatIdc=f.readUEG(),_=420;E<=3&&(_=[0,420,422,444][E]);var S=0;E===3&&(S=f.readBits(1));var C=f.readUEG(),I=f.readUEG(),P=f.readBits(1),H,W,Y,ee;if(P===1&&(H=f.readUEG(),W=f.readUEG(),Y=f.readUEG(),ee=f.readUEG()),l.bitDepthLumaMinus8=f.readUEG(),l.bitDepthChromaMinus8=f.readUEG(),P===1){var J=(E===1||E===2)&&S===0?2:1,ae=E===1&&S===0?2:1;C-=J*(W+H),I-=ae*(ee+Y)}return{codec:"hev1.1.6.L93.B0",width:C,height:I,chromaFormat:_,hvcC:l}}},{key:"_parseProfileTierLevel",value:function(n,l,f){var v=f.generalTierFlag||0;f.generalProfileSpace=n.readBits(2),f.generalTierFlag=Math.max(n.readBits(1),v),f.generalProfileIdc=Math.max(n.readBits(5),f.generalProfileIdc||0),f.generalProfileCompatibilityFlags=n.readBits(32),f.generalConstraintIndicatorFlags=[n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8)];var E=n.readBits(8);v<f.generalTierFlag?f.generalLevelIdc=E:f.generalLevelIdc=Math.max(E,f.generalLevelIdc||0);var _=[],S=[];if(l>n.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(l));for(var C=0;C<l;C++)_[C]=n.readBits(1),S[C]=n.readBits(1);l>0&&n.readBits((8-l)*2);for(var I=0;I<l;I++)_[I]!==0&&(n.readBits(2),n.readBits(1),n.readBits(5),n.readBits(16),n.readBits(16),n.readBits(4),n.readBits(16),n.readBits(16),n.readBits(12)),S[I]!==0&&n.readBits(8)}}]),c}();var mn=function(){function c(){Se(this,c)}return Te(c,null,[{key:"decode",value:function(n){for(var l=[],f=n,v=0,E=n.length;v<E;){if(f[v]<128){l.push(String.fromCharCode(f[v])),++v;continue}else if(!(f[v]<192)){if(f[v]<224){if(c._checkContinuation(f,v,1)){var _=(f[v]&31)<<6|f[v+1]&63;if(_>=128){l.push(String.fromCharCode(_&65535)),v+=2;continue}}}else if(f[v]<240){if(c._checkContinuation(f,v,2)){var S=(f[v]&15)<<12|(f[v+1]&63)<<6|f[v+2]&63;if(S>=2048&&(S&63488)!==55296){l.push(String.fromCharCode(S&65535)),v+=3;continue}}}else if(f[v]<248&&c._checkContinuation(f,v,3)){var C=(f[v]&7)<<18|(f[v+1]&63)<<12|(f[v+2]&63)<<6|f[v+3]&63;if(C>65536&&C<1114112){C-=65536,l.push(String.fromCharCode(C>>>10|55296)),l.push(String.fromCharCode(C&1023|56320)),v+=4;continue}}}l.push("\uFFFD"),++v}return l.join("")}},{key:"_checkContinuation",value:function(n,l,f){var v=n;if(l+f<v.length){for(;f--;)if((v[++l]&192)!==128)return!1;return!0}else return!1}}]),c}();var Zs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parse",value:function(n){if(!(n.length<3)){var l={},f=c._parseValue(new DataView(n.buffer,n.byteOffset,n.byteLength)),v=c._parseValue(new DataView(n.buffer,n.byteOffset+f.size,n.byteLength-f.size));return l[f.data]=v.data,l}}},{key:"_parseValue",value:function(n){var l=n.byteLength,f=n.getUint8(0),v=1,E=!1,_;switch(f){case 0:_=n.getFloat64(1),v+=8;break;case 1:{_=!!n.getUint8(1),v+=1;break}case 2:{var S=c._parseString(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),C=S.data,I=S.size;_=C,v+=I}break;case 3:{_={};var P=0;for((n.getUint32(l-4)&16777215)===9&&(P=3);v<l-4;){var H=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-P)),W=H.size,Y=H.data,ee=H.isEnd;if(ee)break;_[Y.name]=Y.value,v+=W}if(v<=l-3){var J=n.getUint32(v-1)&16777215;J===9&&(v+=3)}}break;case 8:{_={},v+=4;var ae=0;for((n.getUint32(l-4)&16777215)===9&&(ae=3);v<l-8;){var se=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-ae)),_e=se.size,oe=se.data,j=se.isEnd;if(j)break;_[oe.name]=oe.value,v+=_e}if(v<=l-3){var ue=n.getUint32(v-1)&16777215;ue===9&&(v+=3)}}break;case 9:_=void 0,v=1,E=!0;break;case 10:{_=[];var Ve=n.getUint32(1);v+=4;for(var R=0;R<Ve;R++){var le=c._parseValue(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),G=le.data,He=le.size;_.push(G),v+=He}}break;case 11:{var F=n.getFloat64(v)+n.getInt16(v+8)*6e4;_=new Date(F),v+=10}break;case 12:{var O=n.getUint32(1);v+=4,_="",O>0&&(_=mn.decode(new Uint8Array(n.buffer,n.byteOffset+v,O))),v+=O}break;default:v=l;break}return{data:_,size:v,isEnd:E}}},{key:"_parseString",value:function(n){var l=n.getUint16(0),f="";return l>0&&(f=mn.decode(new Uint8Array(n.buffer,n.byteOffset+2,l))),{data:f,size:2+l}}},{key:"_parseObject",value:function(n){if(!(n.byteLength<3)){var l=c._parseString(n),f=c._parseValue(new DataView(n.buffer,n.byteOffset+l.size,n.byteLength-l.size));return{data:{name:l.data,value:f.data},size:l.size+f.size,isEnd:f.isEnd}}}}]),c}();var Ft={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Nt=new fr("FlvDemuxer"),pi=function(){function c(g,n,l){Se(this,c),Q(this,"_headerParsed",!1),Q(this,"_remainingData",null),Q(this,"_gopId",0),Q(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=g||new Fs,this.audioTrack=n||new Ns,this.metadataTrack=l||new Hs,this._fixer=new Xs(this.videoTrack,this.audioTrack,this.metadataTrack)}return Te(c,[{key:"demux",value:function(n){var l,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,E=arguments.length>3?arguments[3]:void 0,_=this.audioTrack,S=this.videoTrack,C=this.metadataTrack;if((f||!v)&&(this._remainingData=null),f&&(this._headerParsed=!1),f?(S.reset(),_.reset(),C.reset()):(S.samples=[],_.samples=[],C.seiSamples=[],C.flvScriptSamples=[],S.warnings=[],_.warnings=[],this._remainingData&&(n=xt(this._remainingData,n),this._remainingData=null)),!n.length)return{videoTrack:S,audioTrack:_,metadataTrack:C};var I=0;if(!this._headerParsed){if(!c.probe(n))throw new Error("Invalid flv file");_.present=(n[4]&4)>>>2!==0,S.present=(n[4]&1)!==0,this._headerParsed=!0,I=xr(n,5)+4}for(var P=n.length,H,W,Y,ee,J;I+15<P&&(H=n[I],W=n[I+1]<<16|n[I+2]<<8|n[I+3],!(I+15+W>P));)Y=(n[I+7]<<24>>>0)+(n[I+4]<<16)+(n[I+5]<<8)+n[I+6],I+=11,ee=n.subarray(I,I+W),H===8?this._parseAudio(ee,Y):H===9?(E&&(this.seamlessLoadingSwitching=!0),this._parseVideo(ee,Y)):H===18?this._parseScript(ee,Y):Nt.warn("Invalid tag type: ".concat(H)),I+=W,J=xr(n,I),J!==11+W&&Nt.warn("Invalid PrevTagSize ".concat(J," (").concat(11+W,")")),I+=4;I<P&&(this._remainingData=n.subarray(I)),_.formatTimescale=S.formatTimescale=S.timescale=C.timescale=1e3,_.timescale=_.codecType===We.OPUS?1e3:_.sampleRate||0,!_.exist()&&_.hasSample()&&_.reset(),!S.exist()&&S.hasSample()&&S.reset();var ae=C.flvScriptSamples[C.flvScriptSamples.length-1],se=ae==null||(l=ae.data)===null||l===void 0?void 0:l.onMetaData;return se&&(S!=null&&S.exist()&&(se.hasOwnProperty("duration")&&(S.duration=se.duration*1e3),se.hasOwnProperty("width")&&se.hasOwnProperty("height")&&(S.width=se.width,S.height=se.height)),_!=null&&_.exist()&&se.hasOwnProperty("duration")&&(_.duration=se.duration*1e3)),{videoTrack:S,audioTrack:_,metadataTrack:C}}},{key:"fix",value:function(n,l,f){return this._fixer.fix(n,l,f),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(n,l,f,v,E){return this.demux(n,l,f,E),this.fix(v,l,f)}},{key:"_parseAudio",value:function(n,l){if(n.length){var f=(n[0]&240)>>>4,v=this.audioTrack;if(f!==Ft.AAC&&f!==Ft.G711A&&f!==Ft.G711M&&f!==Ft.OPUS){Nt.warn("Unsupported sound format: ".concat(f)),v.reset();return}if(f!==Ft.AAC&&f!==Ft.OPUS){var E=(n[0]&12)>>2,_=(n[0]&2)>>1,S=n[0]&1;v.sampleRate=c.AUDIO_RATE[E],v.sampleSize=_?16:8,v.channelCount=S+1}switch(f){case Ft.G711A:case Ft.G711M:this._parseG711(n,l,f);break;case Ft.AAC:this._parseAac(n,l);break;case Ft.OPUS:this._parseOpus(n,l);break}}}},{key:"_parseOpus",value:function(n,l){var f=this.audioTrack,v=n[1];switch(f.codecType=We.OPUS,v){case 0:{var E=Mr.parseHeaderPackets(n.subarray(2));E?(f.codec=E.codec,f.channelCount=E.channelCount,f.sampleRate=E.sampleRate,f.config=E.config,f.sampleDuration=Mr.getFrameDuration([],f.timescale)):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n));break}case 1:{if(l==null)return;var _=new Sr(l,n.subarray(2),f.sampleDuration);f.samples.push(_);break}default:Nt.warn("Unknown OpusPacketType: ".concat(v))}}},{key:"_parseG711",value:function(n,l,f){var v=this.audioTrack;v.codecType=f===7?We.G711PCMA:We.G711PCMU,v.sampleRate=8e3,v.codec=v.codecType,v.samples.push(new Sr(l,n.subarray(1)))}},{key:"_parseAac",value:function(n,l){var f=this.audioTrack;if(f.codecType=We.AAC,n[1]===0){var v=Tr.parseAudioSpecificConfig(n.subarray(2));v?(f.codec=v.codec,f.channelCount=v.channelCount,f.sampleRate=v.sampleRate,f.config=v.config,f.objectType=v.objectType,f.sampleRateIndex=v.samplingFrequencyIndex):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n))}else if(n[1]===1){if(l==null)return;f.samples.push(new Sr(l,n.subarray(2)))}else Nt.warn("Unknown AACPacketType: ".concat(n[1]))}},{key:"_parseVideo",value:function(n,l){var f=this;if(!(n.length<6)){var v=(n[0]&240)>>>4,E=n[0]&15,_=this.videoTrack;if(E!==7&&E!==12){_.reset(),Nt.warn("Unsupported codecId: ".concat(E));return}var S=E===12;_.codecType=S?zt.HEVC:zt.AVC;var C=n[1],I=(n[2]<<16|n[3]<<8|n[4])<<8>>8;if(C===0){var P=n.subarray(5),H=S?Js.parseHEVCDecoderConfigurationRecord(P):Qs.parseAVCDecoderConfigurationRecord(P);if(H){var W=H.hvcC,Y=H.sps,ee=H.ppsArr,J=H.spsArr,ae=H.vpsArr,se=H.nalUnitSize;W&&(_.hvcC=_.hvcC||W),Y&&(_.codec=Y.codec,_.width=Y.width,_.height=Y.height,_.sarRatio=Y.sarRatio,_.fpsNum=Y.fpsNum,_.fpsDen=Y.fpsDen),J.length&&(_.sps=J),ee.length&&(_.pps=ee),ae&&ae.length&&(_.vps=ae),se&&(_.nalUnitSize=se)}else Nt.warn("Cannot parse ".concat(S?"HEVC":"AVC","DecoderConfigurationRecord"),n)}else if(C===1){var _e=Yt.parseAvcC(n.subarray(5),_.nalUnitSize);if(_e=this._checkAddMetaNalToUnits(S,_e,_),_e&&_e.length){var oe=new Us(l+I,l,_e);if(this.seamlessLoadingSwitching&&l<_.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,v===1&&(oe.setToKeyframe(),_.lastKeyFrameDts=l),_.samples.push(oe),_e.forEach(function(j){var ue=S?j[0]>>>1&63:j[0]&31;switch(ue){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!S&&ue!==5||S&&ue===5)break;oe.setToKeyframe();break;case 6:case 39:case 40:if(!S&&ue!==6||S&&ue===6)break;f.metadataTrack.seiSamples.push(new Vs(Yt.parseSEI(Yt.removeEPB(j),S),l+I));break}}),oe.keyframe&&this._gopId++,oe.gopId=this._gopId}else Nt.warn("Cannot parse NALUs",n)}else C===2||Nt.warn("Unknown AVCPacketType: ".concat(C))}}},{key:"_checkAddMetaNalToUnits",value:function(n,l,f){if(!n||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,l;var v=l.map(function(E){return E[0]>>>1&63});return v.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,l):(l.unshift(f.pps[0]),l.unshift(f.sps[0]),l.unshift(f.vps[0]),l.filter(Boolean))}},{key:"_parseScript",value:function(n,l){this.metadataTrack.flvScriptSamples.push(new Gs(Zs.parse(n),l))}}],[{key:"probe",value:function(n){return n[0]!==70||n[1]!==76||n[2]!==86||n[3]!==1?!1:xr(n,5)>=9}}]),c}();Q(pi,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function Zf(c){for(var g=0,n=arguments.length,l=new Array(n>1?n-1:0),f=1;f<n;f++)l[f-1]=arguments[f];l.forEach(function(_){g+=_.length});var v=new c(g),E=0;return l.forEach(function(_){v.set(_,E),E+=_.length}),v}var lt=function(){function c(){Se(this,c),this.buffer=new Uint8Array(0)}return Te(c,[{key:"write",value:function(){for(var n=this,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];f.forEach(function(E){E?n.buffer=Zf(Uint8Array,n.buffer,E):window.console.warn(E)})}}],[{key:"writeUint16",value:function(n){return new Uint8Array([n>>8&255,n&255])}},{key:"writeUint32",value:function(n){return new Uint8Array([n>>24,n>>16&255,n>>8&255,n&255])}}]),c}();var eo=Math.pow(2,32)-1,xe=function(){function c(){Se(this,c)}return Te(c,null,[{key:"box",value:function(n){for(var l=arguments.length,f=new Array(l>1?l-1:0),v=1;v<l;v++)f[v-1]=arguments[v];f=f.filter(Boolean);var E=8+f.reduce(function(C,I){return C+I.byteLength},0),_=new Uint8Array(E);_[0]=E>>24&255,_[1]=E>>16&255,_[2]=E>>8&255,_[3]=E&255,_.set(n,4);var S=8;return f.forEach(function(C){_.set(C,S),S+=C.byteLength}),_}},{key:"ftyp",value:function(n){var l=n.find(function(f){return f.type===Mt.VIDEO&&f.codecType===zt.HEVC});return l?c.FTYPHEV1:c.FTYPAVC1}},{key:"initSegment",value:function(n){var l=c.ftyp(n),f=xt(l,c.moov(n));return f}},{key:"pssh",value:function(n){var l=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],pn(n.kid),[0,0,0,0]));return c.box(c.types.pssh,l)}},{key:"moov",value:function(n){if(n[0].useEME&&(n[0].encv||n[0].enca)){n[0].pssh||(n[0].pssh={kid:n[0].kid});var l=this.pssh(n[0].pssh);return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale),c.mvex(n)].concat(Ot(n.map(function(f){return c.trak(f)})),[l]))}else return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale)].concat(Ot(n.map(function(f){return c.trak(f)})),[c.mvex(n)]))}},{key:"mvhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return f}},{key:"trak",value:function(n){var l=c.box(c.types.trak,c.tkhd(n.id,n.tkhdDuration||0,n.width,n.height),c.mdia(n));return l}},{key:"tkhd",value:function(n,l){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,E=c.box(c.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,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,f>>8&255,f&255,0,0,v>>8&255,v&255,0,0]));return E}},{key:"mdia",value:function(n){var l=c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minf(n));return l}},{key:"mdhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,85,196,0,0]));return f}},{key:"hdlr",value:function(n){var l=c.box(c.types.hdlr,c.HDLR_TYPES[n]);return l}},{key:"minf",value:function(n){var l=c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stbl(n));return l}},{key:"stbl",value:function(n){var l=[];n&&n.ext&&n.ext.stss&&l.push(c.stss(n.ext.stss.entries));var f=c.box(c.types.stbl,c.stsd(n),c.STTS,l[0],c.STSC,c.STSZ,c.STCO);return f}},{key:"stsd",value:function(n){var l;n.type==="audio"?n.useEME&&n.enca?l=c.enca(n):n.codecType===We.OPUS?l=c.opus(n):l=c.mp4a(n):n.useEME&&n.encv?l=c.encv(n):n.av1C?l=c.av01(n):l=c.avc1hev1(n);var f=c.box(c.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),l);return f}},{key:"enca",value:function(n){var l=n.enca.channelCount,f=n.enca.sampleRate,v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,l,0,16,0,0,0,0,f>>8&255,f&255,0,0]),E=c.esds(n.config),_=c.sinf(n.enca);return c.box(c.types.enca,v,E,_)}},{key:"encv",value:function(n){var l,f,v=n.sps.length>0?n.sps[0]:[],E=n.pps.length>0?n.pps[0]:[],_=n.width,S=n.height,C=n.sarRatio[0],I=n.sarRatio[1],P=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,_>>8&255,_&255,S>>8&255,S&255,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((l=(f=[1,v[1],v[2],v[3],255,225,v.length>>>8&255,v.length&255]).concat.apply(f,Ot(v)).concat([1,E.length>>>8&255,E.length&255])).concat.apply(l,Ot(E))),W=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),Y=c.sinf(n.encv),ee=new Uint8Array([C>>24,C>>16&255,C>>8&255,C&255,I>>24,I>>16&255,I>>8&255,I&255]);return c.box(c.types.encv,P,c.box(c.types.avcC,H),c.box(c.types.btrt,W),Y,c.box(c.types.pasp,ee))}},{key:"schi",value:function(n){var l=new Uint8Array([]),f=c.tenc(n);return c.box(c.types.schi,l,f)}},{key:"tenc",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,n.default_IsEncrypted&255,n.default_IV_size&255].concat(pn(n.default_KID)));return c.box(c.types.tenc,l)}},{key:"sinf",value:function(n){var l=new Uint8Array([]),f=new Uint8Array([n.data_format.charCodeAt(0),n.data_format.charCodeAt(1),n.data_format.charCodeAt(2),n.data_format.charCodeAt(3)]),v=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),E=c.schi(n);return c.box(c.types.sinf,l,c.box(c.types.frma,f),c.box(c.types.schm,v),E)}},{key:"av01",value:function(n){return c.box(c.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,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,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.av1C,n.colr)}},{key:"avc1hev1",value:function(n){var l=n.codecType===zt.HEVC,f=l?c.types.hvc1:c.types.avc1,v=l?c.hvcC(n):c.avcC(n),E=[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,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,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]),v];return l?E.push(c.box(c.types.fiel,new Uint8Array([1,0]))):n.sarRatio&&n.sarRatio.length>1&&E.push(c.pasp(n.sarRatio)),c.box.apply(c,[f].concat(E))}},{key:"avcC",value:function(n){var l,f,v=[],E=[],_;return n.sps.forEach(function(S){_=S.byteLength,v.push(_>>>8&255),v.push(_&255),v.push.apply(v,Ot(S))}),n.pps.forEach(function(S){_=S.byteLength,E.push(_>>>8&255),E.push(_&255),E.push.apply(E,Ot(S))}),c.box(c.types.avcC,new Uint8Array((l=(f=[1,v[3],v[4],v[5],255,224|n.sps.length]).concat.apply(f,v).concat([n.pps.length])).concat.apply(l,E)))}},{key:"hvcC",value:function(n){var l=n.hvcC;if(l instanceof ArrayBuffer||l instanceof Uint8Array)return l;var f=n.vps,v=n.sps,E=n.pps,_;if(l){var S=l.generalProfileCompatibilityFlags,C=l.generalConstraintIndicatorFlags,I=(f.length&&1)+(v.length&&1)+(E.length&&1);_=[1,l.generalProfileSpace<<6|l.generalTierFlag<<5|l.generalProfileIdc,S>>>24,S>>>16,S>>>8,S,C[0],C[1],C[2],C[3],C[4],C[5],l.generalLevelIdc,240,0,252,l.chromaFormatIdc|252,l.bitDepthLumaMinus8|248,l.bitDepthChromaMinus8|248,0,0,l.numTemporalLayers<<3|l.temporalIdNested<<2|3,I];var P=function(W){var Y;_.push(W.length>>8,W.length),(Y=_).push.apply(Y,Ot(W))};f.length&&(_.push(160,0,f.length),f.forEach(P)),v.length&&(_.push(161,0,v.length),v.forEach(P)),E.length&&(_.push(162,0,E.length),E.forEach(P))}else _=[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 c.box(c.types.hvcC,new Uint8Array(_))}},{key:"pasp",value:function(n){var l=ks(n,2),f=l[0],v=l[1];return c.box(c.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"mp4a",value:function(n){return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),n.config.length?c.esds(n.config):void 0)}},{key:"esds",value:function(n){var l=n.length,f=c.box(c.types.esds,new Uint8Array([0,0,0,0,3,23+l,0,0,0,4,15+l,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([l]).concat(n).concat([6,1,2])));return f}},{key:"opus",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),f=n.config.length?c.dOps(n):[];return c.box(c.types.Opus,l,f)}},{key:"dOps",value:function(n){if(n.config)return n.config[4]=n.sampleRate>>>24&255,n.config[5]=n.sampleRate>>>16&255,n.config[6]=n.sampleRate>>>8&255,n.config[7]=n.sampleRate&255,c.box(c.types.dOps,n.config)}},{key:"mvex",value:function(n){var l=c.box.apply(c,[c.types.mvex].concat(Ot(n.map(function(f){return c.trex(f.id)}))));return l}},{key:"trex",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return l}},{key:"trex1",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return l}},{key:"trex2",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return l}},{key:"moof",value:function(n){var l=c.box.apply(c,[c.types.moof,c.mfhd(n[0].samples?n[0].samples[0].gopId:0)].concat(Ot(n.map(function(f){return c.traf(f)}))));return l}},{key:"mfhd",value:function(n){var l=c.box(c.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]));return l}},{key:"traf",value:function(n){var l=c.tfhd(n.id),f=c.tfdt(n,n.baseMediaDecodeTime),v=0,E;if(n.isVideo&&n.videoSenc&&(E=n.videoSenc,E.forEach(function(O){v=v+8,O.subsamples&&O.subsamples.length&&(v=v+2,v=v+O.subsamples.length*6)})),n.videoSencLength=v,!n.useEME||!n.isVideoEncryption&&!n.isAudioEncryption){var _=c.sdtp(n),S=76;return c.box(c.types.traf,l,f,_,c.trun(n.samples,_.byteLength+S))}else if(n.isVideoEncryption)if(n.isVideo){var C=c.saiz(n),I=c.saio(n),P=c.trun1(n),H=c.senc(n),W=c.box(c.types.traf,l,f,C,I,P,H);return W}else if(n.isAudioEncryption){var J=c.sbgp(),ae=c.saiz(n),se=c.saio(n),_e=c.senc(n),oe=c.trun1(n),j=c.box(c.types.traf,l,f,J,ae,se,_e,oe);return j}else{var Y=c.sbgp(),ee=c.trun1(n);return c.box(c.types.traf,l,f,Y,ee)}else if(n.isVideo){var ue=c.trun1(n);return c.box(c.types.traf,l,f,ue)}else{var Ve=c.sbgp(),R=c.saiz(n),le=c.saio(n),G=c.senc(n),He=c.trun1(n),F=c.box(c.types.traf,l,f,Ve,R,le,G,He);return F}}},{key:"sdtp",value:function(n){var l=new lt;return n.samples.forEach(function(f){l.write(new Uint8Array(n.isVideo?[f.keyframe?32:16]:[16]))}),c.box(c.types.sdtp,this.extension(0,0),l.buffer)}},{key:"trun1",value:function(n){var l=new lt,f=lt.writeUint32(n.samples.length),v=null;if(n.isVideo){var E=n.videoSencLength;v=lt.writeUint32(n.samples.length*16+E+149),!n.isVideoEncryption&&n.isAudioEncryption&&(v=lt.writeUint32(n.samples.length*16+92))}else{var _=n.samples.length*12+124;n.isAudioEncryption&&(_=n.samples.length*12+8*n.audioSenc.length+177),v=lt.writeUint32(_)}return n.samples.forEach(function(S){l.write(lt.writeUint32(S.duration)),l.write(lt.writeUint32(S.size)),l.write(lt.writeUint32(S.keyframe?33554432:65536)),n.isVideo&&l.write(lt.writeUint32(S.cts?S.cts:0))}),c.box(c.types.trun,this.extension(0,n.flags),f,v,l.buffer)}},{key:"senc",value:function(n){var l=new lt,f=n.samples.length,v=n.isVideo?16:8,E=n.isVideo?2:0,_=[],S=0;return n.isVideo?(_=n.videoSenc,S=n.videoSencLength):_=n.audioSenc,S=S||v*f,l.write(lt.writeUint32(16+S),c.types.senc,this.extension(0,E)),l.write(lt.writeUint32(f)),_.forEach(function(C){for(var I=0;I<C.InitializationVector.length;I++)l.write(new Uint8Array([C.InitializationVector[I]]));C.subsamples&&C.subsamples.length&&(l.write(lt.writeUint16(C.subsamples.length)),C.subsamples.forEach(function(P){l.write(lt.writeUint16(P.BytesOfClearData)),l.write(lt.writeUint32(P.BytesOfProtectedData))}))}),l.buffer}},{key:"saio",value:function(n){var l=n.samples.length*12+141;!n.isVideo&&n.isAudioEncryption&&(l=149);var f=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saio,f)}},{key:"saiz",value:function(n){var l=n.samples.length,f=new Uint8Array([0,0,0,0,16,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saiz,f)}},{key:"sbgp",value:function(){var n=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return c.box(c.types.sbgp,this.extension(0,0),n)}},{key:"extension",value:function(n,l){return new Uint8Array([n,l>>16&255,l>>8&255,l&255])}},{key:"tfhd",value:function(n){return c.box(c.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"tfdt",value:function(n,l){var f=Math.floor(l/(eo+1)),v=Math.floor(l%(eo+1));return n.useEME&&(n.isVideoEncryption||n.isAudioEncryption)?c.box(c.types.tfdt,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])):c.box(c.types.tfdt,new Uint8Array([1,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"trun",value:function(n,l){var f=n.length,v=12+16*f;l+=8+v;var E=new Uint8Array(v);E.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255],0);for(var _=0;_<f;_++){var S=n[_],C=S.duration,I=S.size,P=S.flag,H=P===void 0?{}:P,W=S.cts,Y=W===void 0?0:W;E.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,H.isLeading<<2|(H.dependsOn===null||H.dependsOn===void 0?1:H.dependsOn),H.isDependedOn<<6|H.hasRedundancy<<4|H.paddingValue<<1|(H.isNonSyncSample===null||H.isNonSyncSample===void 0?1:H.isNonSyncSample),H.degradationPriority&61440,H.degradationPriority&15,Y>>>24&255,Y>>>16&255,Y>>>8&255,Y&255],12+16*_)}return c.box(c.types.trun,E)}},{key:"moovMP4",value:function(n){return c.box.apply(c,[c.types.moov,c.mvhd(n[0].duration,n[0].timescale)].concat(Ot(n.map(function(l){return c.trackMP4(l)}))))}},{key:"trackMP4",value:function(n){return c.box(c.types.trak,c.tkhd(n.id,n.duration,n.width,n.height),c.mdiaMP4(n))}},{key:"mdiaMP4",value:function(n){return c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minfMP4(n))}},{key:"minfMP4",value:function(n){return c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stblMP4(n))}},{key:"stblMP4",value:function(n){var l=n.ext,f=[c.stsd(n),c.stts(l.stts),c.stsc(l.stsc),c.stsz(l.stsz),c.stco(l.stco)];return l.stss.length&&f.push(c.stss(l.stss)),l.ctts.length&&f.push(c.ctts(l.ctts)),c.box.apply(c,[c.types.stbl].concat(f))}},{key:"stts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.stts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsc",value:function(n){var l=n.length,f=new Uint8Array(12*l),v=0;return n.forEach(function(E){var _=E.firstChunk,S=E.samplesPerChunk,C=E.sampleDescIndex;f.set([_>>24,_>>16&255,_>>8&255,_&255,S>>24,S>>16&255,S>>8&255,S&255,C>>24,C>>16&255,C>>8&255,C&255],v),v+=12}),c.box(c.types.stsc,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsz",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stsz,xt(new Uint8Array([0,0,0,0,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stco",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stco,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stss",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stss,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"ctts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.ctts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"styp",value:function(){return c.box(c.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(n){var l=n.timescale,f=n.samples[0].duration,v=f*n.samples.length,E=n.samples[0].sampleOffset*f,_=8;n.samples.forEach(function(H){_+=H.size});var S=0;if(n.isVideo){var C=0,I;n.videoSenc&&(I=n.videoSenc),n.isVideo&&I.forEach(function(H){C=C+8,H.subsamples&&H.subsamples.length&&(C=C+2,C=C+H.subsamples.length*6)}),n.videoSencLength=C,S=_+141+n.samples.length*16+C,n.useEME&&n.isAudioEncryption&&!n.isVideoEncryption&&(S=_+n.samples.length*16+84)}else S=_+116+n.samples.length*12,n.useEME&&n.isAudioEncryption&&(S=_+169+n.samples.length*12+8*n.audioSenc.length);var P=new Uint8Array([0,0,0,0,0,0,0,n.id&255,l>>24&255,l>>16&255,l>>8&255,l&255,E>>24&255,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,1,0,S>>16&255,S>>8&255,S&255,v>>24&255,v>>16&255,v>>8&255,v&255,144,0,0,0]);return c.box(c.types.sidx,P)}},{key:"mdat",value:function(n){var l=c.box(c.types.mdat,n);return l}}]),c}();Q(xe,"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(c,g){return c[g]=[g.charCodeAt(0),g.charCodeAt(1),g.charCodeAt(2),g.charCodeAt(3)],c},Object.create(null)));Q(xe,"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])});Q(xe,"FTYPAVC1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));Q(xe,"FTYPHEV1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));Q(xe,"DINF",xe.box(xe.types.dinf,xe.box(xe.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));Q(xe,"VMHD",xe.box(xe.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));Q(xe,"SMHD",xe.box(xe.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));Q(xe,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));Q(xe,"STTS",xe.box(xe.types.stts,xe.StblTable));Q(xe,"STSC",xe.box(xe.types.stsc,xe.StblTable));Q(xe,"STSZ",xe.box(xe.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));Q(xe,"STCO",xe.box(xe.types.stco,xe.StblTable));var gn=function(){function c(g,n){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),c.disabled=n}return Te(c,[{key:"debug",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).debug.apply(n,[this._prefix].concat(f))}}},{key:"log",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).log.apply(n,[this._prefix].concat(f))}}},{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}},{key:"error",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).error.apply(n,[this._prefix].concat(f))}}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(gn,"disabled",!0);var yn=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n;var f=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=f&&Number(f[1])<50,this.log=new gn("FMP4Remuxer",l&&l.openLog?!l.openLog:!0)}return Te(c,[{key:"remux",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=this.videoTrack,v=this.audioTrack,E=f.exist(),_=v.exist(),S,C,I,P=[];n&&(l&&l.initMerge?(E&&P.push(this.videoTrack),_&&P.push(this.audioTrack),I=xe.initSegment(P)):(E&&(S=xe.initSegment([this.videoTrack])),_&&(C=xe.initSegment([this.audioTrack]))));var H,W;return E&&f.hasSample()&&(H=this._remuxVideo()),_&&v.hasSample()&&(W=this._remuxAudio()),f.samples=[],v.samples=[],{initSegment:I,videoInitSegment:S,audioInitSegment:C,videoSegment:H,audioSegment:W}}},{key:"_remuxVideo",value:function(){var n=this.videoTrack;this.forceFirstIDR&&(n.samples[0].flag={dependsOn:2,isNonSyncSample:0});var l=n.samples,f=/av01/.test(n.codec),v=0;f?l.forEach(function(_e){v+=_e.data.byteLength}):l.forEach(function(_e){v+=_e.units.reduce(function(oe,j){return oe+j.byteLength},0),v+=_e.units.length*4});var E=new Uint8Array(v);if(f)for(var _=0,S=l.length,C=0,I;_<S;_++)I=l[_],E.set(I.data,C),I.size=I.data.byteLength,C+=I.size;else for(var P=new DataView(E.buffer),H=function(oe,j){j=l[W];var ue=0;j.units.forEach(function(Ve){P.setUint32(oe,Ve.byteLength),oe+=4,E.set(Ve,oe),oe+=Ve.byteLength,ue+=4+Ve.byteLength}),j.size=ue,ee=oe,J=j},W=0,Y=l.length,ee=0,J;W<Y;W++)H(ee,J);var ae=xe.mdat(E),se=xe.moof([n]);return xt(se,ae)}},{key:"_remuxAudio",value:function(){var n=this.audioTrack,l=new Uint8Array(n.samples.reduce(function(E,_){return E+_.size},0));n.samples.reduce(function(E,_){return l.set(_.data,E),E+_.size},0);var f=xe.mdat(l),v=xe.moof([n]);return xt(v,f)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),c}();var to=function(){function c(){yr(this,c),ce(this,"_ttfb",0),ce(this,"_demuxStart",0),ce(this,"_demuxEnd",0),ce(this,"_demuxCost",0),ce(this,"_remuxStart",0),ce(this,"_remuxEnd",0),ce(this,"_remuxCost",0),ce(this,"_appendStart",0),ce(this,"_appendEnd",0),ce(this,"_appendCost",0)}return Er(c,[{key:"set",value:function(n,l){this["_".concat(n)]=l}},{key:"start",value:function(n){this["_".concat(n,"Start")]=Date.now()}},{key:"end",value:function(n){this["_".concat(n,"End")]=Date.now(),this["_".concat(n,"Cost")]=this["_".concat(n,"Cost")]+(this["_".concat(n,"End")]-this["_".concat(n,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),c}(),qt={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var Xt=new Tt("BufferService"),ro=function(){function c(g,n){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};yr(this,c),ce(this,"flv",null),ce(this,"_demuxer",new pi),ce(this,"_remuxer",null),ce(this,"_mse",null),ce(this,"_softVideo",null),ce(this,"_sourceCreated",!1),ce(this,"_needInitSegment",!0),ce(this,"_discontinuity",!0),ce(this,"_contiguous",!1),ce(this,"_initSegmentId",""),ce(this,"_cachedBuffer",null),ce(this,"_demuxStartTime",0),ce(this,"_opts",null),this.flv=g,this._opts=l,n?this._softVideo=n:(this._remuxer=new yn(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new rr(null,{preferMMS:typeof l.preferMMS=="boolean"?l.preferMMS:!!l.perferMMS}),this._mse.bindMedia(g.media))}return Er(c,[{key:"baseDts",get:function(){var n,l;return(n=this._demuxer)===null||n===void 0||(l=n._fixer)===null||l===void 0?void 0:l._baseDts}},{key:"blobUrl",get:function(){var n;return(n=this._mse)===null||n===void 0?void 0:n.url}},{key:"isFull",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:rr.VIDEO;return this._mse.isFull(n)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(n){this._contiguous=!1,this._demuxStartTime=n}},{key:"reset",value:function(){var g=it(Re().mark(function l(){var f,v=arguments;return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=v.length>0&&v[0]!==void 0?v[0]:!1,!(this._mse&&!f)){_.next=6;break}return _.next=4,this._mse.unbindMedia();case 4:return _.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 _.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=7;break}if(!this._sourceCreated){v.next=5;break}return v.next=4,this._mse.endOfStream();case 4:this.flv.emit(me.BUFFEREOS);case 5:v.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"updateDuration",value:function(){var g=it(Re().mark(function l(f){return Re().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 Xt.debug("update duration",f),E.next=7,this._mse.updateDuration(f);case 7:case"end":return E.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"destroy",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=3;break}return v.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"appendBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C,I,P,H,W,Y,ee,J,ae,se,_e,oe,j,ue;return Re().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(E=!1,this._cachedBuffer&&(f=en(this._cachedBuffer,f),this._cachedBuffer=null),_=this._demuxer,!(!f||!f.length||!_)){R.next=5;break}return R.abrupt("return");case 5:R.prev=5,this.flv._transferCost.start(qt.DEMUX),_.demuxAndFix(f,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(qt.DEMUX),R.next=15;break;case 12:throw R.prev=12,R.t0=R.catch(5),new dt(Ce.DEMUX,Ce.SUB_TYPES.FLV,R.t0);case 15:if(S=_.videoTrack,C=_.audioTrack,I=_.metadataTrack,!this.seamlessLoadingSwitch){R.next=25;break}if(P=S.samples.findIndex(function(le){return le.originDts===S.lastKeyFrameDts}),!(P>=0)){R.next=25;break}return S.samples.splice(P),R.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,f=null,E=!0;case 25:if(H=S.exist(),W=C.exist(),this._opts.onlyAudio&&(H=!1,S.present=!1),this._opts.onlyVideo&&(W=!1,C.present=!1),!(!H&&S.present||!W&&C.present)){R.next=42;break}if(Y=0,ee=H?S:W?C:void 0,ee&&ee.samples.length&&(Y=(ee.samples[ee.samples.length-1].originPts-ee.samples[0].originPts)/ee.timescale*1e3),!(Y>this._opts.analyzeDuration)){R.next=40;break}Xt.warn("analyze duration exceeded, ".concat(Y,"ms"),ee),S.present=H,C.present=W,this.flv.emit(me.ANALYZE_DURATION_EXCEEDED,{duration:Y}),R.next=42;break;case 40:return this._cachedBuffer=f,R.abrupt("return");case 42:if(J=S.type,ae=C.type,this._fireEvents(S,C,I),E||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),se=this._mse,_e=function(){var G;if((G=v.flv)!==null&&G!==void 0&&G.emit){var He;(He=v.flv)===null||He===void 0||He.emit(me.APPEND_BUFFER,{})}},this.flv.emit(me.DEMUXED_TRACK,{videoTrack:S}),oe="".concat(S.codec,"/").concat(S.width,"/").concat(S.height,"/").concat(C.codec,"/").concat(C.config),oe!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=oe,this._emitMetaParsedEvent(S,C)),!se){R.next=81;break}if(this._sourceCreated){R.next=59;break}return R.next=55,se.open();case 55:H&&(Xt.log("codec: video/mp4;codecs=".concat(S.codec)),se.createSource(J,"video/mp4;codecs=".concat(S.codec))),W&&(Xt.log("codec: audio/mp4;codecs=".concat(C.codec)),se.createSource(ae,"audio/mp4;codecs=".concat(C.codec))),this._sourceCreated=!0,this.flv.emit(me.SOURCEBUFFER_CREATED);case 59:R.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(S.duration=this._opts.durationForMSELowLatencyOff*S.timescale,C.duration=this._opts.durationForMSELowLatencyOff*W.timescale),this.flv._transferCost.start(qt.REMUX),j=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(qt.REMUX),R.next=69;break;case 66:throw R.prev=66,R.t1=R.catch(59),new dt(Ce.REMUX,Ce.SUB_TYPES.FMP4,R.t1);case 69:if(!(this._needInitSegment&&!j.videoInitSegment&&!j.audioInitSegment)){R.next=71;break}return R.abrupt("return");case 71:return this._needInitSegment=!1,ue=[],j.videoInitSegment&&ue.push(se.append(J,j.videoInitSegment)),j.audioInitSegment&&ue.push(se.append(ae,j.audioInitSegment)),j.videoSegment&&ue.push(se.append(J,j.videoSegment)),j.audioSegment&&ue.push(se.append(ae,j.audioSegment)),this.flv._transferCost.start(qt.APPEND),R.abrupt("return",Promise.all(ue).then(_e).then(function(){v.flv._transferCost.end(qt.APPEND),_e()}));case 81:this._softVideo&&(this._softVideo.appendBuffer(S,C),_e());case 82:case"end":return R.stop()}},l,this,[[5,12],[59,66]])}));function n(l){return g.apply(this,arguments)}return n}()},{key:"evictBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(E=this.flv.media,!(!this._mse||!this._demuxer||!E||!f||f<0)){P.next=3;break}return P.abrupt("return");case 3:if(_=E.currentTime,S=_-f,!(S<=0)){P.next=7;break}return P.abrupt("return");case 7:if(C=tt.start(tt.get(E)),!(C+1>=S)){P.next=10;break}return P.abrupt("return");case 10:return P.abrupt("return",this._mse.clearBuffer(0,S).then(function(){return v.flv.emit(me.REMOVE_BUFFER,{removeEnd:S})}));case 11:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"_emitMetaParsedEvent",value:function(n,l){n.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"video",track:n,meta:{codec:n.codec,timescale:n.timescale,width:n.width,height:n.height,sarRatio:n.sarRatio,baseDts:n.baseDts}}),l.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"audio",track:l,meta:{codec:l.codec,channelCount:l.channelCount,sampleRate:l.sampleRate,timescale:l.timescale,baseDts:l.baseDts}}),Xt.debug("track parsed",n,l)}},{key:"_fireEvents",value:function(n,l,f){var v=this;Xt.debug("videoTrack samples count: ".concat(n.samples.length,", audioTrack samples count: ").concat(l.samples.length)),f.flvScriptSamples.forEach(function(E){v.flv.emit(me.FLV_SCRIPT_DATA,E),Xt.debug("flvScriptData",E)}),n.samples.forEach(function(E){E.keyframe&&v.flv.emit(me.KEYFRAME,{pts:E.originPts})}),n.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AV_SHIFT:_=me.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP:_=me.LARGE_VIDEO_DTS_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK:_=me.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("video exception",E)}),l.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AUDIO_GAP:_=me.LARGE_AUDIO_DTS_GAP_DETECT;break;case mt.AUDIO_FILLED:_=me.AUDIO_GAP_DETECT;break;case mt.AUDIO_DROPPED:_=me.AUDIO_OVERLAP_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("audio exception",E)}),f.seiSamples.forEach(function(E){v.flv.emit(me.SEI,bt(bt({},E),{},{sei:{code:E.data.type,content:E.data.payload,dts:E.pts}}))})}}]),c}();function io(c){var g=bt({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},c);return g.isLive&&g.preloadTime&&(g.maxLatency||(g.maxLatency=g.preloadTime*2),g.targetLatency||(g.targetLatency=g.preloadTime),(g.disconnectTime===null||g.disconnectTime===void 0)&&(g.disconnectTime=g.maxLatency)),g}function En(c,g){var n=0,l=c.length-1,f=0,v=0,E=l;for(g<c[0]&&(n=0,v=E+1);v<=E;)if(f=v+Math.floor((E-v)/2),f===l||g>=c[f]&&g<c[f+1]){n=f;break}else c[f]<g?v=f+1:E=f-1;return n}var Vt=new Tt("flv"),mi=.1,eh=.3,br=function(c){ns(n,c);var g=as(n);function n(l){var f;return yr(this,n),f=g.call(this),ce(Ie(f),"media",null),ce(Ie(f),"_loading",!1),ce(Ie(f),"_opts",null),ce(Ie(f),"_bufferService",null),ce(Ie(f),"_gapService",null),ce(Ie(f),"_stats",null),ce(Ie(f),"_mediaLoader",null),ce(Ie(f),"_maxChunkWaitTimer",null),ce(Ie(f),"_tickTimer",null),ce(Ie(f),"_tickInterval",500),ce(Ie(f),"_urlSwitching",!1),ce(Ie(f),"_seamlessSwitching",!1),ce(Ie(f),"_disconnectRetryCount",0),ce(Ie(f),"_preLoadEndPoint",0),ce(Ie(f),"_keyframes",null),ce(Ie(f),"_acceptRanges",!0),ce(Ie(f),"_onProgress",function(){var v=it(Re().mark(function E(_,S,C,I){var P,H,W,Y,ee,J,ae,se,_e,oe;return Re().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(P=C.startTime,H=C.endTime,W=C.st,Y=C.firstByteTime,f._loading=!S,f._firstProgressEmit){ue.next=13;break}if(f.media){ue.next=6;break}return(ee=f._mediaLoader)===null||ee===void 0||ee.cancel(),ue.abrupt("return");case 6:J=I.headers,ae=W?Y-W:H-P,f.emit(me.TTFB,{url:f._opts.url,responseUrl:I.url,elapsed:ae}),f.emit(me.LOAD_RESPONSE_HEADERS,{headers:J}),f._transferCost.set(qt.TTFB,ae),f._acceptRanges=!!(J!=null&&J.get("Accept-Ranges"))||!!(J!=null&&J.get("Content-Range")),f._firstProgressEmit=!0;case 13:if(f._bufferService){ue.next=15;break}return ue.abrupt("return");case 15:return clearTimeout(f._maxChunkWaitTimer),f._bandwidthService.addChunkRecord(_?.byteLength,H-P),ue.prev=17,ue.next=20,f._bufferService.appendBuffer(_);case 20:(se=f._bufferService)===null||se===void 0||se.evictBuffer(f._opts.bufferBehind),ue.next=33;break;case 23:if(ue.prev=23,ue.t0=ue.catch(17),!(!f.isLive&&f._bufferService.isFull())){ue.next=32;break}return ue.next=28,f._mediaLoader.cancel();case 28:return f._loading=!1,_e=f.bufferInfo().remaining,f._opts.preloadTime=parseInt(_e)/2,ue.abrupt("return");case 32:return ue.abrupt("return",f._emitError(dt.create(ue.t0)));case 33:if(f._urlSwitching&&(f._urlSwitching=!1,f.emit(me.SWITCH_URL_SUCCESS,{url:f._opts.url})),f._seamlessSwitching&&(f._seamlessSwitching=!1,f._tick()),!(S&&!f.media.seeking)){ue.next=40;break}return f.emit(me.LOAD_COMPLETE),Vt.debug("load done"),f.isLive&&f._disconnectRetryCount<=0&&f._end(),ue.abrupt("return");case 40:if(f.isLive){ue.next=42;break}return ue.abrupt("return");case 42:oe=f._opts.maxReaderInterval,oe&&f._firstProgressEmit&&(clearTimeout(f._maxChunkWaitTimer),f._maxChunkWaitTimer=setTimeout(function(){if(f._disconnectRetryCount){f._disconnectRetryCount--,f.load();return}Vt.debug("onMaxChunkWait",oe),f._end()},oe));case 44:case"end":return ue.stop()}},E,null,[[17,23]])}));return function(E,_,S,C){return v.apply(this,arguments)}}()),ce(Ie(f),"_onRetryError",function(v,E){Vt.debug("load retry",v,E),f.emit(me.LOAD_RETRY,{error:dt.network(v),retryTime:E})}),ce(Ie(f),"_end",function(){f._clear(),f._bufferService&&f._bufferService.endOfStream(),Vt.debug("end stream")}),ce(Ie(f),"_resetDisconnectCount",function(){f._disconnectRetryCount=f._opts.disconnectRetryCount}),ce(Ie(f),"_tick",function(){clearTimeout(f._tickTimer);var v=Ie(f),E=v.media;if(E){f._tickTimer=setTimeout(f._tick,f._tickInterval);var _=tt.end(tt.get(E));if(!(_<mi||!E.readyState)){var S=f._opts;if(Ji(E)&&E.currentTime)f._gapService&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);else{if(!E.currentTime&&f._gapService&&S.enableStartGapJump){var C=f._opts.mseLowLatency||f._opts.mseLowLatency===!1&&f.bufferInfo(eh).nextStart;C&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);return}S.isLive&&E.readyState===4&&_-E.currentTime>S.disconnectTime&&f.disconnect()}}}}),ce(Ie(f),"_onPlay",function(){var v,E,_=f._opts.softDecode||((v=f.media)===null||v===void 0||(E=v.buffered)===null||E===void 0?void 0:E.length);if(f.isLive){!f._loading&&_&&f.replay(void 0,!0);return}var S=f.bufferInfo();(S.start||S.nextStart)>mi&&f._tick()}),ce(Ie(f),"_onLoadeddata",function(){f.isLive&&!f._opts.mseLowLatency&&f.media.duration!==1/0&&f._bufferService.updateDuration(1/0).catch(function(v){})}),ce(Ie(f),"_onSeeking",it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:!f.isLive&&f.seekable&&(f._preLoadEndPoint=-1,f._checkPreload());case 1:case"end":return _.stop()}},v)}))),ce(Ie(f),"_onTimeupdate",function(){if(f.media){var v=f._opts,E=f.media.currentTime;if(v.isLive&&v.maxLatency&&v.targetLatency){var _=tt.end(tt.get(f.media)),S=_-E;S>=v.maxLatency&&(f.media.currentTime=_-v.targetLatency,f.emit(me.CHASEFRAME,{currentTime:f.media.currentTime,latency:v.targetLatency}))}f._seiService.throw(E,!0),!(v.isLive||!f.seekable||f._loading)&&f._checkPreload()}}),ce(Ie(f),"_onWaiting",function(){f.isLive&&!f._loading&&f._disconnectRetryCount&&(f._disconnectRetryCount--,f.load())}),ce(Ie(f),"_onBufferUpdate",function(){if(!f._opts.isLive){var v=f.bufferInfo(),E=v.end,_=v.nextEnd;Math.abs((E||_)-f.media.duration)<1&&(f._end(),f.media.readyState<=2&&f._tick())}}),ce(Ie(f),"_checkPreload",it(Re().mark(function v(){var E,_,S,C,I,P,H,W,Y,ee;return Re().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(E=f.bufferInfo(),_=E.remaining,S=_===void 0?0:_,C=f._opts,I=f._keyframes.filepositions,P=f._keyframes.times,H=f.media.currentTime,!(S<C.preloadTime)){ae.next=19;break}if(W=En(f._keyframes.times,H+S+mi),Y=En(f._keyframes.times,H+S+f._opts.preloadTime),Y===W&&(Y=W+1),f._preLoadEndPoint!==Y){ae.next=11;break}return ae.abrupt("return");case 11:if(ee=I[W],ee!=null){ae.next=14;break}return ae.abrupt("return");case 14:return ae.next=16,f._mediaLoader.cancel();case 16:f._loadData(null,[ee,I[Y]]),f._preLoadEndPoint=Y,f._bufferService.unContiguous(P[W]);case 19:case"end":return ae.stop()}},v)}))),ce(Ie(f),"_onFlvScriptData",function(v){var E,_,S,C,I=(E=v.data)===null||E===void 0||(_=E.onMetaData)===null||_===void 0?void 0:_.keyframes,P=(S=v.data)===null||S===void 0||(C=S.onMetaData)===null||C===void 0?void 0:C.duration;I&&(f._keyframes=I),!f._opts.isLive&&P&&f._bufferService.updateDuration(P)}),f._opts=io(l),f.media=f._opts.media||document.createElement("video"),f._opts.media=null,f._firstProgressEmit=!1,f._mediaLoader=new rn(bt(bt({},f._opts.fetchOptions),{},{retry:f._opts.retryCount,retryDelay:f._opts.retryDelay,timeout:f._opts.loadTimeout,onRetryError:f._onRetryError,onProgress:f._onProgress,responseType:"arraybuffer"})),f._disconnectRetryCount=f._opts.disconnectRetryCount,f._transferCost=new to,f._bufferService=new ro(Ie(f),f._opts.softDecode?f.media:void 0,f._opts),f._seiService=new an(Ie(f)),f._bandwidthService=new sn({chunkCountForSpeed:f._opts.chunkCountForSpeed,skipChunkSize:f._opts.skipChunkSize,longtimeNoReceived:f._opts.longtimeNoReceived}),f._stats=new on(Ie(f)),f._opts.softDecode||(f._gapService=new nn),f.media.addEventListener("play",f._onPlay),f.media.addEventListener("loadeddata",f._onLoadeddata),f.media.addEventListener("seeking",f._onSeeking),f.media.addEventListener("timeupdate",f._onTimeupdate),f.media.addEventListener("progress",f._onBufferUpdate),f.media.addEventListener("waiting",f._onWaiting),f.on(me.FLV_SCRIPT_DATA,f._onFlvScriptData),f}return Er(n,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.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 f,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mi;return tt.info(tt.get(this.media),(f=this.media)===null||f===void 0?void 0:f.currentTime,v)}},{key:"playbackQuality",value:function(){return Zi(this.media)}},{key:"load",value:function(){var l=it(Re().mark(function v(E){var _,S=arguments;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(_=S.length>1&&S[1]!==void 0?S[1]:!1,this._bufferService){I.next=3;break}return I.abrupt("return");case 3:return I.next=5,this._reset(_);case 5:this._loadData(E,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return I.stop()}},v,this)}));function f(v){return l.apply(this,arguments)}return f}()},{key:"replay",value:function(){var l=it(Re().mark(function v(){var E=this,_,S,C=arguments;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(_=C.length>0&&C[0]!==void 0?C[0]:this._opts.seamlesslyReload,S=C.length>1?C[1]:void 0,this.media){P.next=4;break}return P.abrupt("return");case 4:if(this._resetDisconnectCount(),!_){P.next=11;break}return P.next=8,this._clear();case 8:setTimeout(function(){E._seamlessSwitching=!0,E._loadData(E._opts.url),E._bufferService.seamlessSwitch()}),P.next=13;break;case 11:return P.next=13,this.load();case 13:return P.abrupt("return",this.media.play(!S).catch(function(){}));case 14:case"end":return P.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"disconnect",value:function(){var f;return Vt.debug("disconnect!"),(f=this._bufferService)===null||f===void 0||f.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var l=it(Re().mark(function v(E,_){var S=this;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this._bufferService){I.next=2;break}return I.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&_)){I.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var P=it(Re().mark(function H(W){return Re().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ee.next=2,S._clear();case 2:S._bufferService.seamlessLoadingSwitching=!0,S._urlSwitching=!0,S._seamlessSwitching=!0,S._bufferService.seamlessSwitch(),S._loadData(E);case 7:case"end":return ee.stop()}},H)}));return function(H){return P.apply(this,arguments)}}(),I.abrupt("return");case 6:if(!(!_||!this._opts.isLive)){I.next=11;break}return I.next=9,this.load(E);case 9:return this._urlSwitching=!0,I.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return I.next=13,this._clear();case 13:setTimeout(function(){S._urlSwitching=!0,S._seamlessSwitching=!0,S._loadData(E),S._bufferService.seamlessSwitch()});case 14:case"end":return I.stop()}},v,this)}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"destroy",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.media){_.next=2;break}return _.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),_.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_emitError",value:function(f){var v,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Vt.table(f),Vt.error(f),Vt.error((v=this.media)===null||v===void 0?void 0:v.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(me.SWITCH_URL_FAILED,f)),this.emit(me.ERROR,f),E&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var l=it(Re().mark(function v(){var E,_=arguments;return Re().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return E=_.length>0&&_[0]!==void 0?_[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),C.next=6,this._clear();case 6:return C.next=8,this._bufferService.reset(E);case 8:case"end":return C.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadData",value:function(){var l=it(Re().mark(function v(E,_){var S;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(E&&(this._opts.url=E),S=E=this._opts.url,E){I.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(S=this._opts.preProcessUrl(E).url),this._mediaLoader.finnalUrl=S,this.emit(me.LOAD_START,{url:S,seamlessSwitching:this._seamlessSwitching}),Vt.debug("load data, loading:",this._loading,S),!this._loading){I.next=11;break}return I.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,I.prev=12,I.next=15,this._mediaLoader.load({url:S,range:_});case 15:I.next=21;break;case 17:return I.prev=17,I.t0=I.catch(12),this._loading=!1,I.abrupt("return",this._emitError(dt.network(I.t0),!1));case 21:case"end":return I.stop()}},v,this,[[12,17]])}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"_clear",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._mediaLoader){_.next=3;break}return _.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()}],[{key:"isSupported",value:function(f){return!f||f==="video"||f==="audio"?rr.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){Tt.enable(),fr.enable()}},{key:"disableLogger",value:function(){Tt.disable(),fr.disable()}}]),n}(no.default);try{localStorage.getItem("xgd")?br.enableLogger():br.disableLogger()}catch{}var Sn=gr(so(),1);
21
- ;if (typeof module.exports == "object" && typeof exports == "object") {
22
- var __cp = (to, from, except, desc) => {
23
- if ((from && typeof from === "object") || typeof from === "function") {
24
- for (let key of Object.getOwnPropertyNames(from)) {
25
- if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
26
- Object.defineProperty(to, key, {
27
- get: () => from[key],
28
- enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
29
- });
30
- }
31
- }
32
- return to;
33
- };
34
- module.exports = __cp(module.exports, exports);
35
- }
36
- return module.exports;
37
- }))
1
+ var FG=Object.create;var{getPrototypeOf:EG,defineProperty:_Z,getOwnPropertyNames:BG}=Object;var wG=Object.prototype.hasOwnProperty;var IY=(j,F,K)=>{K=j!=null?FG(EG(j)):{};let U=F||!j||!j.__esModule?_Z(K,"default",{value:j,enumerable:!0}):K;for(let N of BG(j))if(!wG.call(U,N))_Z(U,N,{get:()=>j[N],enumerable:!0});return U};var pZ=(j,F)=>()=>(F||j((F={exports:{}}).exports,F),F.exports);var MY=pZ((XW,FQ)=>{var LG=Object.prototype.hasOwnProperty,F1="~";function pY(){}if(Object.create){if(pY.prototype=Object.create(null),!new pY().__proto__)F1=!1}function bG(j,F,K){this.fn=j,this.context=F,this.once=K||!1}function iZ(j,F,K,U,N){if(typeof K!=="function")throw new TypeError("The listener must be a function");var O=new bG(K,U||j,N),B=F1?F1+F:F;if(!j._events[B])j._events[B]=O,j._eventsCount++;else if(!j._events[B].fn)j._events[B].push(O);else j._events[B]=[j._events[B],O];return j}function LJ(j,F){if(--j._eventsCount===0)j._events=new pY;else delete j._events[F]}function j1(){this._events=new pY,this._eventsCount=0}j1.prototype.eventNames=function j(){var F=[],K,U;if(this._eventsCount===0)return F;for(U in K=this._events)if(LG.call(K,U))F.push(F1?U.slice(1):U);if(Object.getOwnPropertySymbols)return F.concat(Object.getOwnPropertySymbols(K));return F};j1.prototype.listeners=function j(F){var K=F1?F1+F:F,U=this._events[K];if(!U)return[];if(U.fn)return[U.fn];for(var N=0,O=U.length,B=new Array(O);N<O;N++)B[N]=U[N].fn;return B};j1.prototype.listenerCount=function j(F){var K=F1?F1+F:F,U=this._events[K];if(!U)return 0;if(U.fn)return 1;return U.length};j1.prototype.emit=function j(F,K,U,N,O,B){var w=F1?F1+F:F;if(!this._events[w])return!1;var R=this._events[w],P=arguments.length,x,k;if(R.fn){if(R.once)this.removeListener(F,R.fn,void 0,!0);switch(P){case 1:return R.fn.call(R.context),!0;case 2:return R.fn.call(R.context,K),!0;case 3:return R.fn.call(R.context,K,U),!0;case 4:return R.fn.call(R.context,K,U,N),!0;case 5:return R.fn.call(R.context,K,U,N,O),!0;case 6:return R.fn.call(R.context,K,U,N,O,B),!0}for(k=1,x=new Array(P-1);k<P;k++)x[k-1]=arguments[k];R.fn.apply(R.context,x)}else{var f=R.length,l;for(k=0;k<f;k++){if(R[k].once)this.removeListener(F,R[k].fn,void 0,!0);switch(P){case 1:R[k].fn.call(R[k].context);break;case 2:R[k].fn.call(R[k].context,K);break;case 3:R[k].fn.call(R[k].context,K,U);break;case 4:R[k].fn.call(R[k].context,K,U,N);break;default:if(!x)for(l=1,x=new Array(P-1);l<P;l++)x[l-1]=arguments[l];R[k].fn.apply(R[k].context,x)}}}return!0};j1.prototype.on=function j(F,K,U){return iZ(this,F,K,U,!1)};j1.prototype.once=function j(F,K,U){return iZ(this,F,K,U,!0)};j1.prototype.removeListener=function j(F,K,U,N){var O=F1?F1+F:F;if(!this._events[O])return this;if(!K)return LJ(this,O),this;var B=this._events[O];if(B.fn){if(B.fn===K&&(!N||B.once)&&(!U||B.context===U))LJ(this,O)}else{for(var w=0,R=[],P=B.length;w<P;w++)if(B[w].fn!==K||N&&!B[w].once||U&&B[w].context!==U)R.push(B[w]);if(R.length)this._events[O]=R.length===1?R[0]:R;else LJ(this,O)}return this};j1.prototype.removeAllListeners=function j(F){var K;if(F){if(K=F1?F1+F:F,this._events[K])LJ(this,K)}else this._events=new pY,this._eventsCount=0;return this};j1.prototype.off=j1.prototype.removeListener;j1.prototype.addListener=j1.prototype.on;j1.prefixed=F1;j1.EventEmitter=j1;if(typeof FQ!=="undefined")FQ.exports=j1});var o8=pZ((n8,pQ)=>{(function j(F){(function(K,U){typeof n8==="object"&&typeof pQ!=="undefined"?pQ.exports=U():typeof define==="function"&&define.amd?define(U):(K=typeof globalThis!=="undefined"?globalThis:K||self,K.Hls=U())})(this,function(){function K(X,W,Z){if(x())return Reflect.construct.apply(null,arguments);var J=[null];J.push.apply(J,W);var Y=new(X.bind.apply(X,J));return Z&&l(Y,Z.prototype),Y}function U(X,W){for(var Z=0;Z<W.length;Z++){var J=W[Z];J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(X,Y0(J.key),J)}}function N(X,W,Z){return W&&U(X.prototype,W),Z&&U(X,Z),Object.defineProperty(X,"prototype",{writable:!1}),X}function O(X,W,Z){return(W=Y0(W))in X?Object.defineProperty(X,W,{value:Z,enumerable:!0,configurable:!0,writable:!0}):X[W]=Z,X}function B(){return B=Object.assign?Object.assign.bind():function(X){for(var W=1;W<arguments.length;W++){var Z=arguments[W];for(var J in Z)({}).hasOwnProperty.call(Z,J)&&(X[J]=Z[J])}return X},B.apply(null,arguments)}function w(X){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(W){return W.__proto__||Object.getPrototypeOf(W)},w(X)}function R(X,W){X.prototype=Object.create(W.prototype),X.prototype.constructor=X,l(X,W)}function P(X){try{return Function.toString.call(X).indexOf("[native code]")!==-1}catch(W){return typeof X=="function"}}function x(){try{var X=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(W){}return(x=function(){return!!X})()}function k(X,W){var Z=Object.keys(X);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(X);W&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(X,Y).enumerable})),Z.push.apply(Z,J)}return Z}function f(X){for(var W=1;W<arguments.length;W++){var Z=arguments[W]!=null?arguments[W]:{};W%2?k(Object(Z),!0).forEach(function(J){O(X,J,Z[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(X,Object.getOwnPropertyDescriptors(Z)):k(Object(Z)).forEach(function(J){Object.defineProperty(X,J,Object.getOwnPropertyDescriptor(Z,J))})}return X}function l(X,W){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,J){return Z.__proto__=J,Z},l(X,W)}function s(X,W){if(typeof X!="object"||!X)return X;var Z=X[Symbol.toPrimitive];if(Z!==void 0){var J=Z.call(X,W);if(typeof J!="object")return J;throw new TypeError("@@toPrimitive must return a primitive value.")}return(W==="string"?String:Number)(X)}function Y0(X){var W=s(X,"string");return typeof W=="symbol"?W:W+""}function t(X){var W=typeof Map=="function"?new Map:void 0;return t=function(Z){if(Z===null||!P(Z))return Z;if(typeof Z!="function")throw new TypeError("Super expression must either be null or a function");if(W!==void 0){if(W.has(Z))return W.get(Z);W.set(Z,J)}function J(){return K(Z,arguments,w(this).constructor)}return J.prototype=Object.create(Z.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),l(J,Z)},t(X)}function K0(){try{return crypto.randomUUID()}catch(Y){try{var X=URL.createObjectURL(new Blob),W=X.toString();return URL.revokeObjectURL(X),W.slice(W.lastIndexOf("/")+1)}catch(Q){var Z=new Date().getTime(),J="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(G){var q=(Z+Math.random()*16)%16|0;return Z=Math.floor(Z/16),(G=="x"?q:q&3|8).toString(16)});return J}}}function q0(X){return X&&X.__esModule&&Object.prototype.hasOwnProperty.call(X,"default")?X.default:X}var R0={exports:{}},U0;function W0(){if(U0)return R0.exports;return U0=1,function(X){var W=Object.prototype.hasOwnProperty,Z="~";function J(){}if(Object.create){if(J.prototype=Object.create(null),!new J().__proto__)Z=!1}function Y(H,V,z){this.fn=H,this.context=V,this.once=z||!1}function Q(H,V,z,A,E){if(typeof z!=="function")throw new TypeError("The listener must be a function");var I=new Y(z,A||H,E),$=Z?Z+V:V;if(!H._events[$])H._events[$]=I,H._eventsCount++;else if(!H._events[$].fn)H._events[$].push(I);else H._events[$]=[H._events[$],I];return H}function G(H,V){if(--H._eventsCount===0)H._events=new J;else delete H._events[V]}function q(){this._events=new J,this._eventsCount=0}q.prototype.eventNames=function H(){var V=[],z,A;if(this._eventsCount===0)return V;for(A in z=this._events)if(W.call(z,A))V.push(Z?A.slice(1):A);if(Object.getOwnPropertySymbols)return V.concat(Object.getOwnPropertySymbols(z));return V},q.prototype.listeners=function H(V){var z=Z?Z+V:V,A=this._events[z];if(!A)return[];if(A.fn)return[A.fn];for(var E=0,I=A.length,$=new Array(I);E<I;E++)$[E]=A[E].fn;return $},q.prototype.listenerCount=function H(V){var z=Z?Z+V:V,A=this._events[z];if(!A)return 0;if(A.fn)return 1;return A.length},q.prototype.emit=function H(V,z,A,E,I,$){var L=Z?Z+V:V;if(!this._events[L])return!1;var b=this._events[L],C=arguments.length,D,y;if(b.fn){if(b.once)this.removeListener(V,b.fn,void 0,!0);switch(C){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,z),!0;case 3:return b.fn.call(b.context,z,A),!0;case 4:return b.fn.call(b.context,z,A,E),!0;case 5:return b.fn.call(b.context,z,A,E,I),!0;case 6:return b.fn.call(b.context,z,A,E,I,$),!0}for(y=1,D=new Array(C-1);y<C;y++)D[y-1]=arguments[y];b.fn.apply(b.context,D)}else{var S=b.length,v;for(y=0;y<S;y++){if(b[y].once)this.removeListener(V,b[y].fn,void 0,!0);switch(C){case 1:b[y].fn.call(b[y].context);break;case 2:b[y].fn.call(b[y].context,z);break;case 3:b[y].fn.call(b[y].context,z,A);break;case 4:b[y].fn.call(b[y].context,z,A,E);break;default:if(!D)for(v=1,D=new Array(C-1);v<C;v++)D[v-1]=arguments[v];b[y].fn.apply(b[y].context,D)}}}return!0},q.prototype.on=function H(V,z,A){return Q(this,V,z,A,!1)},q.prototype.once=function H(V,z,A){return Q(this,V,z,A,!0)},q.prototype.removeListener=function H(V,z,A,E){var I=Z?Z+V:V;if(!this._events[I])return this;if(!z)return G(this,I),this;var $=this._events[I];if($.fn){if($.fn===z&&(!E||$.once)&&(!A||$.context===A))G(this,I)}else{for(var L=0,b=[],C=$.length;L<C;L++)if($[L].fn!==z||E&&!$[L].once||A&&$[L].context!==A)b.push($[L]);if(b.length)this._events[I]=b.length===1?b[0]:b;else G(this,I)}return this},q.prototype.removeAllListeners=function H(V){var z;if(V){if(z=Z?Z+V:V,this._events[z])G(this,z)}else this._events=new J,this._eventsCount=0;return this},q.prototype.off=q.prototype.removeListener,q.prototype.addListener=q.prototype.on,q.prefixed=Z,q.EventEmitter=q,X.exports=q}(R0),R0.exports}var z0=W0(),h0=q0(z0),l0={exports:{}},E0;function y0(){if(E0)return l0.exports;return E0=1,function(X,W){(function(Z){var J=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Y=/^(?=([^\/?#]*))\1([^]*)$/,Q=/(?:\/|^)\.(?=\/)/g,G=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,q={buildAbsoluteURL:function(H,V,z){if(z=z||{},H=H.trim(),V=V.trim(),!V){if(!z.alwaysNormalize)return H;var A=q.parseURL(H);if(!A)throw new Error("Error trying to parse base URL.");return A.path=q.normalizePath(A.path),q.buildURLFromParts(A)}var E=q.parseURL(V);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme){if(!z.alwaysNormalize)return V;return E.path=q.normalizePath(E.path),q.buildURLFromParts(E)}var I=q.parseURL(H);if(!I)throw new Error("Error trying to parse base URL.");if(!I.netLoc&&I.path&&I.path[0]!=="/"){var $=Y.exec(I.path);I.netLoc=$[1],I.path=$[2]}if(I.netLoc&&!I.path)I.path="/";var L={scheme:I.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc){if(L.netLoc=I.netLoc,E.path[0]!=="/")if(!E.path){if(L.path=I.path,!E.params){if(L.params=I.params,!E.query)L.query=I.query}}else{var b=I.path,C=b.substring(0,b.lastIndexOf("/")+1)+E.path;L.path=q.normalizePath(C)}}if(L.path===null)L.path=z.alwaysNormalize?q.normalizePath(E.path):E.path;return q.buildURLFromParts(L)},parseURL:function(H){var V=J.exec(H);if(!V)return null;return{scheme:V[1]||"",netLoc:V[2]||"",path:V[3]||"",params:V[4]||"",query:V[5]||"",fragment:V[6]||""}},normalizePath:function(H){H=H.split("").reverse().join("").replace(Q,"");while(H.length!==(H=H.replace(G,"")).length);return H.split("").reverse().join("")},buildURLFromParts:function(H){return H.scheme+H.netLoc+H.path+H.params+H.query+H.fragment}};X.exports=q})()}(l0),l0.exports}var t0=y0(),T=Number.isFinite||function(X){return typeof X==="number"&&isFinite(X)},u=Number.isSafeInteger||function(X){return typeof X==="number"&&Math.abs(X)<=_},_=Number.MAX_SAFE_INTEGER||9007199254740991,n=function(X){return X.NETWORK_ERROR="networkError",X.MEDIA_ERROR="mediaError",X.KEY_SYSTEM_ERROR="keySystemError",X.MUX_ERROR="muxError",X.OTHER_ERROR="otherError",X}({}),h=function(X){return X.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",X.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",X.KEY_SYSTEM_NO_SESSION="keySystemNoSession",X.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",X.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",X.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",X.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",X.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",X.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",X.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",X.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",X.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",X.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",X.MANIFEST_LOAD_ERROR="manifestLoadError",X.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",X.MANIFEST_PARSING_ERROR="manifestParsingError",X.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",X.LEVEL_EMPTY_ERROR="levelEmptyError",X.LEVEL_LOAD_ERROR="levelLoadError",X.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",X.LEVEL_PARSING_ERROR="levelParsingError",X.LEVEL_SWITCH_ERROR="levelSwitchError",X.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",X.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",X.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",X.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",X.FRAG_LOAD_ERROR="fragLoadError",X.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",X.FRAG_DECRYPT_ERROR="fragDecryptError",X.FRAG_PARSING_ERROR="fragParsingError",X.FRAG_GAP="fragGap",X.REMUX_ALLOC_ERROR="remuxAllocError",X.KEY_LOAD_ERROR="keyLoadError",X.KEY_LOAD_TIMEOUT="keyLoadTimeOut",X.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",X.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",X.BUFFER_APPEND_ERROR="bufferAppendError",X.BUFFER_APPENDING_ERROR="bufferAppendingError",X.BUFFER_STALLED_ERROR="bufferStalledError",X.BUFFER_FULL_ERROR="bufferFullError",X.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",X.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",X.ASSET_LIST_LOAD_ERROR="assetListLoadError",X.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",X.ASSET_LIST_PARSING_ERROR="assetListParsingError",X.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",X.INTERNAL_EXCEPTION="internalException",X.INTERNAL_ABORTED="aborted",X.ATTACH_MEDIA_ERROR="attachMediaError",X.UNKNOWN="unknown",X}({}),M=function(X){return X.MEDIA_ATTACHING="hlsMediaAttaching",X.MEDIA_ATTACHED="hlsMediaAttached",X.MEDIA_DETACHING="hlsMediaDetaching",X.MEDIA_DETACHED="hlsMediaDetached",X.MEDIA_ENDED="hlsMediaEnded",X.STALL_RESOLVED="hlsStallResolved",X.BUFFER_RESET="hlsBufferReset",X.BUFFER_CODECS="hlsBufferCodecs",X.BUFFER_CREATED="hlsBufferCreated",X.BUFFER_APPENDING="hlsBufferAppending",X.BUFFER_APPENDED="hlsBufferAppended",X.BUFFER_EOS="hlsBufferEos",X.BUFFERED_TO_END="hlsBufferedToEnd",X.BUFFER_FLUSHING="hlsBufferFlushing",X.BUFFER_FLUSHED="hlsBufferFlushed",X.MANIFEST_LOADING="hlsManifestLoading",X.MANIFEST_LOADED="hlsManifestLoaded",X.MANIFEST_PARSED="hlsManifestParsed",X.LEVEL_SWITCHING="hlsLevelSwitching",X.LEVEL_SWITCHED="hlsLevelSwitched",X.LEVEL_LOADING="hlsLevelLoading",X.LEVEL_LOADED="hlsLevelLoaded",X.LEVEL_UPDATED="hlsLevelUpdated",X.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",X.LEVELS_UPDATED="hlsLevelsUpdated",X.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",X.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",X.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",X.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",X.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",X.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",X.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",X.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",X.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",X.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",X.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",X.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",X.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",X.CUES_PARSED="hlsCuesParsed",X.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",X.INIT_PTS_FOUND="hlsInitPtsFound",X.FRAG_LOADING="hlsFragLoading",X.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",X.FRAG_LOADED="hlsFragLoaded",X.FRAG_DECRYPTED="hlsFragDecrypted",X.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",X.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",X.FRAG_PARSING_METADATA="hlsFragParsingMetadata",X.FRAG_PARSED="hlsFragParsed",X.FRAG_BUFFERED="hlsFragBuffered",X.FRAG_CHANGED="hlsFragChanged",X.FPS_DROP="hlsFpsDrop",X.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",X.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",X.ERROR="hlsError",X.DESTROYING="hlsDestroying",X.KEY_LOADING="hlsKeyLoading",X.KEY_LOADED="hlsKeyLoaded",X.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",X.BACK_BUFFER_REACHED="hlsBackBufferReached",X.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",X.ASSET_LIST_LOADING="hlsAssetListLoading",X.ASSET_LIST_LOADED="hlsAssetListLoaded",X.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",X.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",X.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",X.INTERSTITIAL_STARTED="hlsInterstitialStarted",X.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",X.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",X.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",X.INTERSTITIAL_ENDED="hlsInterstitialEnded",X.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",X.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",X.EVENT_CUE_ENTER="hlsEventCueEnter",X}({}),Z0={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},G0={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},C0=function(){function X(Z,J,Y){if(J===void 0)J=0;if(Y===void 0)Y=0;this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=Z,this.alpha_=Z?Math.exp(Math.log(0.5)/Z):0,this.estimate_=J,this.totalWeight_=Y}var W=X.prototype;return W.sample=function Z(J,Y){var Q=Math.pow(this.alpha_,J);this.estimate_=Y*(1-Q)+Q*this.estimate_,this.totalWeight_+=J},W.getTotalWeight=function Z(){return this.totalWeight_},W.getEstimate=function Z(){if(this.alpha_){var J=1-Math.pow(this.alpha_,this.totalWeight_);if(J)return this.estimate_/J}return this.estimate_},X}(),u0=function(){function X(Z,J,Y,Q){if(Q===void 0)Q=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_=Y,this.minWeight_=0.001,this.minDelayMs_=50,this.slow_=new C0(Z),this.fast_=new C0(J),this.defaultTTFB_=Q,this.ttfb_=new C0(Z)}var W=X.prototype;return W.update=function Z(J,Y){var Q=this.slow_,G=this.fast_,q=this.ttfb_;if(Q.halfLife!==J)this.slow_=new C0(J,Q.getEstimate(),Q.getTotalWeight());if(G.halfLife!==Y)this.fast_=new C0(Y,G.getEstimate(),G.getTotalWeight());if(q.halfLife!==J)this.ttfb_=new C0(J,q.getEstimate(),q.getTotalWeight())},W.sample=function Z(J,Y){J=Math.max(J,this.minDelayMs_);var Q=8*Y,G=J/1000,q=Q/G;this.fast_.sample(G,q),this.slow_.sample(G,q)},W.sampleTTFB=function Z(J){var Y=J/1000,Q=Math.sqrt(2)*Math.exp(-Math.pow(Y,2)/2);this.ttfb_.sample(Q,Math.max(J,5))},W.canEstimate=function Z(){return this.fast_.getTotalWeight()>=this.minWeight_},W.getEstimate=function Z(){if(this.canEstimate())return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate());else return this.defaultEstimate_},W.getEstimateTTFB=function Z(){if(this.ttfb_.getTotalWeight()>=this.minWeight_)return this.ttfb_.getEstimate();else return this.defaultTTFB_},W.destroy=function Z(){},N(X,[{key:"defaultEstimate",get:function Z(){return this.defaultEstimate_}}])}(),d0=function X(W,Z){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var J="["+W+"]:";this.trace=M0,this.debug=Z.debug.bind(null,J),this.log=Z.log.bind(null,J),this.warn=Z.warn.bind(null,J),this.info=Z.info.bind(null,J),this.error=Z.error.bind(null,J)},M0=function X(){},PY={trace:M0,debug:M0,log:M0,warn:M0,info:M0,error:M0};function P1(){return B({},PY)}function yY(X,W){var Z=self.console[X];return Z?Z.bind(self.console,(W?"["+W+"] ":"")+"["+X+"] >"):M0}function TY(X,W,Z){return W[X]?W[X].bind(W):yY(X,Z)}var tY=P1();function e0(X,W,Z){var J=P1();if(typeof console==="object"&&X===!0||typeof X==="object"){var Y=["debug","log","info","warn","error"];Y.forEach(function(Q){J[Q]=TY(Q,X,Z)});try{J.log('Debug logs enabled for "'+W+'" in hls.js version 1.6.0')}catch(Q){return P1()}Y.forEach(function(Q){tY[Q]=TY(Q,X)})}else B(tY,J);return J}var v0=tY,vJ,fQ;function s8(){if(fQ)return vJ;return fQ=1,vJ=void 0,vJ}var cQ=s8(),r8=q0(cQ);function x1(X,W){if(W===void 0)W=!1;if(typeof TextDecoder!=="undefined"){var Z=new TextDecoder("utf-8"),J=Z.decode(X);if(W){var Y=J.indexOf("\x00");return Y!==-1?J.substring(0,Y):J}return J.replace(/\0/g,"")}var Q=X.length,G,q,H,V="",z=0;while(z<Q){if(G=X[z++],G===0&&W)return V;else if(G===0||G===3)continue;switch(G>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:V+=String.fromCharCode(G);break;case 12:case 13:q=X[z++],V+=String.fromCharCode((G&31)<<6|q&63);break;case 14:q=X[z++],H=X[z++],V+=String.fromCharCode((G&15)<<12|(q&63)<<6|(H&63)<<0);break}}return V}var lQ={hexDump:function X(W){var Z="";for(var J=0;J<W.length;J++){var Y=W[J].toString(16);if(Y.length<2)Y="0"+Y;Z+=Y}return Z}},hJ=function X(){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}},i0={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},dQ=function(){function X(Z){if(this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof Z==="string")Z={url:Z};this.base=Z,t8(this,"stats")}var W=X.prototype;return W.setByteRange=function Z(J,Y){var Q=J.split("@",2),G;if(Q.length===1)G=(Y==null?void 0:Y.byteRangeEndOffset)||0;else G=parseInt(Q[1]);this._byteRange=[G,parseInt(Q[0])+G]},W.clearElementaryStreamInfo=function Z(){var J=this.elementaryStreams;J[i0.AUDIO]=null,J[i0.VIDEO]=null,J[i0.AUDIOVIDEO]=null},N(X,[{key:"baseurl",get:function Z(){return this.base.url}},{key:"byteRange",get:function Z(){if(this._byteRange===null)return[];return this._byteRange}},{key:"byteRangeStartOffset",get:function Z(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function Z(){return this.byteRange[1]}},{key:"elementaryStreams",get:function Z(){if(this._streams===null){var J;this._streams=(J={},J[i0.AUDIO]=null,J[i0.VIDEO]=null,J[i0.AUDIOVIDEO]=null,J)}return this._streams},set:function Z(J){this._streams=J}},{key:"hasStats",get:function Z(){return this._stats!==null}},{key:"hasStreams",get:function Z(){return this._streams!==null}},{key:"stats",get:function Z(){if(this._stats===null)this._stats=new hJ;return this._stats},set:function Z(J){this._stats=J}},{key:"url",get:function Z(){if(!this._url&&this.baseurl&&this.relurl)this._url=t0.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0});return this._url||""},set:function Z(J){this._url=J}}])}();function d1(X){return X.sn!=="initSegment"}var kJ=function(X){function W(J,Y){var Q=X.call(this,Y)||this;return Q._decryptdata=null,Q._programDateTime=null,Q._ref=null,Q._bitrate=void 0,Q.rawProgramDateTime=null,Q.tagList=[],Q.duration=0,Q.sn=0,Q.levelkeys=void 0,Q.type=void 0,Q.loader=null,Q.keyLoader=null,Q.level=-1,Q.cc=0,Q.startPTS=void 0,Q.endPTS=void 0,Q.startDTS=void 0,Q.endDTS=void 0,Q.start=0,Q.playlistOffset=0,Q.deltaPTS=void 0,Q.maxStartPTS=void 0,Q.minEndPTS=void 0,Q.data=void 0,Q.bitrateTest=!1,Q.title=null,Q.initSegment=null,Q.endList=void 0,Q.gap=void 0,Q.urlId=0,Q.type=J,Q}R(W,X);var Z=W.prototype;return Z.addStart=function J(Y){this.setStart(this.start+Y)},Z.setStart=function J(Y){if(this.start=Y,this._ref)this._ref.start=Y},Z.setDuration=function J(Y){if(this.duration=Y,this._ref)this._ref.duration=Y},Z.setKeyFormat=function J(Y){if(this.levelkeys){var Q=this.levelkeys[Y];if(Q&&!this._decryptdata)this._decryptdata=Q.getDecryptData(this.sn)}},Z.abortRequests=function J(){var Y,Q;(Y=this.loader)==null||Y.abort(),(Q=this.keyLoader)==null||Q.abort()},Z.setElementaryStreamInfo=function J(Y,Q,G,q,H,V){if(V===void 0)V=!1;var z=this.elementaryStreams,A=z[Y];if(!A){z[Y]={startPTS:Q,endPTS:G,startDTS:q,endDTS:H,partial:V};return}A.startPTS=Math.min(A.startPTS,Q),A.endPTS=Math.max(A.endPTS,G),A.startDTS=Math.min(A.startDTS,q),A.endDTS=Math.max(A.endDTS,H)},N(W,[{key:"byteLength",get:function J(){if(this.hasStats){var Y=this.stats.total;if(Y)return Y}if(this.byteRange){var Q=this.byteRange[0],G=this.byteRange[1];if(T(Q)&&T(G))return G-Q}return null}},{key:"bitrate",get:function J(){if(this.byteLength)return this.byteLength*8/this.duration;if(this._bitrate)return this._bitrate;return null},set:function J(Y){this._bitrate=Y}},{key:"decryptdata",get:function J(){var Y=this.levelkeys;if(!Y&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var Q=this.levelkeys.identity;if(Q)this._decryptdata=Q.getDecryptData(this.sn);else{var G=Object.keys(this.levelkeys);if(G.length===1)return this._decryptdata=this.levelkeys[G[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function J(){return this.start+this.duration}},{key:"endProgramDateTime",get:function J(){if(this.programDateTime===null)return null;var Y=!T(this.duration)?0:this.duration;return this.programDateTime+Y*1000}},{key:"encrypted",get:function J(){var Y;if((Y=this._decryptdata)!=null&&Y.encrypted)return!0;else if(this.levelkeys){var Q=Object.keys(this.levelkeys),G=Q.length;if(G>1||G===1&&this.levelkeys[Q[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function J(){if(this._programDateTime===null&&this.rawProgramDateTime)this.programDateTime=Date.parse(this.rawProgramDateTime);return this._programDateTime},set:function J(Y){if(!T(Y)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=Y}},{key:"ref",get:function J(){if(!d1(this))return null;if(!this._ref)this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime};return this._ref}}])}(dQ),a8=function(X){function W(Z,J,Y,Q,G){var q=X.call(this,Y)||this;q.fragOffset=0,q.duration=0,q.gap=!1,q.independent=!1,q.relurl=void 0,q.fragment=void 0,q.index=void 0,q.duration=Z.decimalFloatingPoint("DURATION"),q.gap=Z.bool("GAP"),q.independent=Z.bool("INDEPENDENT"),q.relurl=Z.enumeratedString("URI"),q.fragment=J,q.index=Q;var H=Z.enumeratedString("BYTERANGE");if(H)q.setByteRange(H,G);if(G)q.fragOffset=G.fragOffset+G.duration;return q}return R(W,X),N(W,[{key:"start",get:function Z(){return this.fragment.start+this.fragOffset}},{key:"end",get:function Z(){return this.start+this.duration}},{key:"loaded",get:function Z(){var J=this.elementaryStreams;return!!(J.audio||J.video||J.audiovideo)}}])}(dQ);function nQ(X,W){var Z=Object.getPrototypeOf(X);if(Z){var J=Object.getOwnPropertyDescriptor(Z,W);if(J)return J;return nQ(Z,W)}}function t8(X,W){var Z=nQ(X,W);if(Z)Z.enumerable=!0,Object.defineProperty(X,W,Z)}var eY=Math.pow(2,32)-1,e8=[].push,oQ={video:1,audio:2,id3:3,text:4};function W1(X){return String.fromCharCode.apply(null,X)}function iQ(X,W){var Z=X[W]<<8|X[W+1];return Z<0?65536+Z:Z}function B0(X,W){var Z=rQ(X,W);return Z<0?4294967296+Z:Z}function sQ(X,W){var Z=B0(X,W);return Z*=Math.pow(2,32),Z+=B0(X,W+4),Z}function rQ(X,W){return X[W]<<24|X[W+1]<<16|X[W+2]<<8|X[W+3]}function gJ(X,W,Z){X[W]=Z>>24,X[W+1]=Z>>16&255,X[W+2]=Z>>8&255,X[W+3]=Z&255}function YX(X){var W=X.byteLength;for(var Z=0;Z<W;){var J=B0(X,Z);if(J>8&&X[Z+4]===109&&X[Z+5]===111&&X[Z+6]===111&&X[Z+7]===102)return!0;Z=J>1?Z+J:W}return!1}function $0(X,W){var Z=[];if(!W.length)return Z;var J=X.byteLength;for(var Y=0;Y<J;){var Q=B0(X,Y),G=W1(X.subarray(Y+4,Y+8)),q=Q>1?Y+Q:J;if(G===W[0])if(W.length===1)Z.push(X.subarray(Y+8,q));else{var H=$0(X.subarray(Y+8,q),W.slice(1));if(H.length)e8.apply(Z,H)}Y=q}return Z}function JX(X){var W=[],Z=X[0],J=8,Y=B0(X,J);J+=4;var Q=0,G=0;if(Z===0)Q=B0(X,J),G=B0(X,J+4),J+=8;else Q=sQ(X,J),G=sQ(X,J+8),J+=16;J+=2;var q=X.length+G,H=iQ(X,J);J+=2;for(var V=0;V<H;V++){var z=J,A=B0(X,z);z+=4;var E=A&2147483647,I=(A&2147483648)>>>31;if(I===1)return v0.warn("SIDX has hierarchical references (not supported)"),null;var $=B0(X,z);z+=4,W.push({referenceSize:E,subsegmentDuration:$,info:{duration:$/Y,start:q,end:q+E-1}}),q+=E,z+=4,J=z}return{earliestPresentationTime:Q,timescale:Y,version:Z,referencesCount:H,references:W}}function aQ(X){var W=[],Z=$0(X,["moov","trak"]);for(var J=0;J<Z.length;J++){var Y=Z[J],Q=$0(Y,["tkhd"])[0];if(Q){var G=Q[0],q=B0(Q,G===0?12:20),H=$0(Y,["mdia","mdhd"])[0];if(H){G=H[0];var V=B0(H,G===0?12:20),z=$0(Y,["mdia","hdlr"])[0];if(z){var A=W1(z.subarray(8,12)),E={soun:i0.AUDIO,vide:i0.VIDEO}[A],I=$0(Y,["mdia","minf","stbl","stsd"])[0],$=QX(I);if(E)W[q]={timescale:V,type:E,stsd:$},W[E]=f({timescale:V,id:q},$);else W[q]={timescale:V,type:A,stsd:$}}}}}var L=$0(X,["moov","mvex","trex"]);return L.forEach(function(b){var C=B0(b,4),D=W[C];if(D)D.default={duration:B0(b,12),flags:B0(b,20)}}),W}function QX(X){var W=X.subarray(8),Z=W.subarray(86),J=W1(W.subarray(4,8)),Y=J,Q,G=J==="enca"||J==="encv";if(G){var q=$0(W,[J])[0],H=q.subarray(J==="enca"?28:78),V=$0(H,["sinf"]);V.forEach(function(V1){var M1=$0(V1,["schm"])[0];if(M1){var n0=W1(M1.subarray(4,8));if(n0==="cbcs"||n0==="cenc"){var z1=$0(V1,["frma"])[0];if(z1)Y=W1(z1)}}})}var z=Y;switch(Y){case"avc1":case"avc2":case"avc3":case"avc4":{var A=$0(Z,["avcC"])[0];Y+="."+JJ(A[1])+JJ(A[2])+JJ(A[3]),Q=YJ(z==="avc1"?"dva1":"dvav",Z);break}case"mp4a":{var E=$0(W,[J])[0],I=$0(E.subarray(28),["esds"])[0];if(I&&I.length>7){var $=4;if(I[$++]!==3)break;$=uJ(I,$),$+=2;var L=I[$++];if(L&128)$+=2;if(L&64)$+=I[$++];if(I[$++]!==4)break;$=uJ(I,$);var b=I[$++];if(b===64)Y+="."+JJ(b);else break;if($+=12,I[$++]!==5)break;$=uJ(I,$);var C=I[$++],D=(C&248)>>3;if(D===31)D+=1+((C&7)<<3)+((I[$]&224)>>5);Y+="."+D}break}case"hvc1":case"hev1":{var y=$0(Z,["hvcC"]);if(y){var S=y[0],v=S[1],p=["","A","B","C"][v>>6],g=v&31,m=B0(S,2),r=(v&32)>>5?"H":"L",o=S[12],c=S.subarray(6,12);Y+="."+p+g,Y+="."+m.toString(16).toUpperCase(),Y+="."+r+o;var d="";for(var e=c.length;e--;){var H0=c[e];if(H0||d){var Q0=H0.toString(16).toUpperCase();d="."+Q0+d}}Y+=d}Q=YJ(z=="hev1"?"dvhe":"dvh1",Z);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{Y=YJ(Y,Z)||Y;break}case"vp09":{var J0=$0(Z,["vpcC"])[0],N0=J0[4],V0=J0[5],j0=J0[6]>>4&15;Y+="."+n1(N0)+"."+n1(V0)+"."+n1(j0);break}case"av01":{var O0=$0(Z,["av1C"])[0],g0=O0[1]>>>5,T0=O0[1]&31,m0=O0[2]>>>7?"H":"M",D0=(O0[2]&64)>>6,Y1=(O0[2]&32)>>5,_0=g0===2&&D0?Y1?12:10:D0?10:8,a0=(O0[2]&16)>>4,w1=(O0[2]&8)>>3,q1=(O0[2]&4)>>2,p0=O0[2]&3,R1=1,Z1=1,s0=1,$1=0;Y+="."+g0+"."+n1(T0)+m0+"."+n1(_0)+"."+a0+"."+w1+q1+p0+"."+n1(R1)+"."+n1(Z1)+"."+n1(s0)+"."+$1,Q=YJ("dav1",Z);break}}return{codec:Y,encrypted:G,supplemental:Q}}function YJ(X,W){var Z=$0(W,["dvvC"]),J=Z.length?Z[0]:$0(W,["dvcC"])[0];if(J){var Y=J[2]>>1&127,Q=J[2]<<5&32|J[3]>>3&31;return X+"."+n1(Y)+"."+n1(Q)}}function uJ(X,W){var Z=W+5;while(X[W++]&128&&W<Z);return W}function JJ(X){return("0"+X.toString(16).toUpperCase()).slice(-2)}function n1(X){return(X<10?"0":"")+X}function ZX(X,W){if(!X||!W)return X;var Z=W.keyId;if(Z&&W.isCommonEncryption){var J=$0(X,["moov","trak"]);J.forEach(function(Y){var Q=$0(Y,["mdia","minf","stbl","stsd"])[0],G=Q.subarray(8),q=$0(G,["enca"]),H=q.length>0;if(!H)q=$0(G,["encv"]);q.forEach(function(V){var z=H?V.subarray(28):V.subarray(78),A=$0(z,["sinf"]);A.forEach(function(E){var I=XX(E);if(I){var $=I.subarray(8,24);if(!$.some(function(L){return L!==0}))v0.log("[eme] Patching keyId in 'enc"+(H?"a":"v")+">sinf>>tenc' box: "+lQ.hexDump($)+" -> "+lQ.hexDump(Z)),I.set(Z,8)}})})})}return X}function XX(X){var W=$0(X,["schm"])[0];if(W){var Z=W1(W.subarray(4,8));if(Z==="cbcs"||Z==="cenc")return $0(X,["schi","tenc"])[0]}return null}function GX(X,W){return $0(W,["moof","traf"]).reduce(function(Z,J){var Y=$0(J,["tfdt"])[0],Q=Y[0],G=$0(J,["tfhd"]).reduce(function(q,H){var V=B0(H,4),z=X[V];if(z){var A=B0(Y,4);if(Q===1){if(A===eY)return v0.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),q;A*=eY+1,A+=B0(Y,8)}var E=z.timescale||90000,I=A/E;if(T(I)&&(q===null||I<q))return I}return q},null);if(G!==null&&T(G)&&(Z===null||G<Z))return G;return Z},null)}function WX(X,W){var Z=0,J=0,Y=0,Q=$0(X,["moof","traf"]);for(var G=0;G<Q.length;G++){var q=Q[G],H=$0(q,["tfhd"])[0],V=B0(H,4),z=W[V];if(!z)continue;var A=z.default,E=B0(H,0)|(A==null?void 0:A.flags),I=A==null?void 0:A.duration;if(E&8)if(E&2)I=B0(H,12);else I=B0(H,8);var $=z.timescale||90000,L=$0(q,["trun"]);for(var b=0;b<L.length;b++){if(Z=KX(L[b]),!Z&&I){var C=B0(L[b],4);Z=I*C}if(z.type===i0.VIDEO)J+=Z/$;else if(z.type===i0.AUDIO)Y+=Z/$}}if(J===0&&Y===0){var D=1/0,y=0,S=0,v=$0(X,["sidx"]);for(var p=0;p<v.length;p++){var g=JX(v[p]);if(g!=null&&g.references){D=Math.min(D,g.earliestPresentationTime/g.timescale);var m=g.references.reduce(function(r,o){return r+o.info.duration||0},0);y=Math.max(y,m+g.earliestPresentationTime/g.timescale),S=y-D}}if(S&&T(S))return S}if(J)return J;return Y}function KX(X){var W=B0(X,0),Z=8;if(W&1)Z+=4;if(W&4)Z+=4;var J=0,Y=B0(X,4);for(var Q=0;Q<Y;Q++){if(W&256){var G=B0(X,Z);J+=G,Z+=4}if(W&512)Z+=4;if(W&1024)Z+=4;if(W&2048)Z+=4}return J}function qX(X,W,Z){$0(W,["moof","traf"]).forEach(function(J){$0(J,["tfhd"]).forEach(function(Y){var Q=B0(Y,4),G=X[Q];if(!G)return;var q=G.timescale||90000;$0(J,["tfdt"]).forEach(function(H){var V=H[0],z=Z*q;if(z){var A=B0(H,4);if(V===0)A-=z,A=Math.max(A,0),gJ(H,4,A);else{A*=Math.pow(2,32),A+=B0(H,8),A-=z,A=Math.max(A,0);var E=Math.floor(A/(eY+1)),I=Math.floor(A%(eY+1));gJ(H,4,E),gJ(H,8,I)}}})})})}function HX(X){var W={valid:null,remainder:null},Z=$0(X,["moof"]);if(Z.length<2)return W.remainder=X,W;var J=Z[Z.length-1];return W.valid=X.slice(0,J.byteOffset-8),W.remainder=X.slice(J.byteOffset-8),W}function v1(X,W){var Z=new Uint8Array(X.length+W.length);return Z.set(X),Z.set(W,X.length),Z}function tQ(X,W){var Z=[],J=W.samples,Y=W.timescale,Q=W.id,G=!1,q=$0(J,["moof"]);return q.map(function(H){var V=H.byteOffset-8,z=$0(H,["traf"]);z.map(function(A){var E=$0(A,["tfdt"]).map(function(I){var $=I[0],L=B0(I,4);if($===1)L*=Math.pow(2,32),L+=B0(I,8);return L/Y})[0];if(E!==void 0)X=E;return $0(A,["tfhd"]).map(function(I){var $=B0(I,4),L=B0(I,0)&16777215,b=(L&1)!==0,C=(L&2)!==0,D=(L&8)!==0,y=0,S=(L&16)!==0,v=0,p=(L&32)!==0,g=8;if($===Q){if(b)g+=8;if(C)g+=4;if(D)y=B0(I,g),g+=4;if(S)v=B0(I,g),g+=4;if(p)g+=4;if(W.type==="video")G=mJ(W.codec);$0(A,["trun"]).map(function(m){var r=m[0],o=B0(m,0)&16777215,c=(o&1)!==0,d=0,e=(o&4)!==0,H0=(o&256)!==0,Q0=0,J0=(o&512)!==0,N0=0,V0=(o&1024)!==0,j0=(o&2048)!==0,O0=0,g0=B0(m,4),T0=8;if(c)d=B0(m,T0),T0+=4;if(e)T0+=4;var m0=d+V;for(var D0=0;D0<g0;D0++){if(H0)Q0=B0(m,T0),T0+=4;else Q0=y;if(J0)N0=B0(m,T0),T0+=4;else N0=v;if(V0)T0+=4;if(j0){if(r===0)O0=B0(m,T0);else O0=rQ(m,T0);T0+=4}if(W.type===i0.VIDEO){var Y1=0;while(Y1<N0){var _0=B0(J,m0);if(m0+=4,NX(G,J[m0])){var a0=J.subarray(m0,m0+_0);eQ(a0,G?2:1,X+O0/Y,Z)}m0+=_0,Y1+=_0+4}}X+=Q0/Y}})}})})}),Z}function mJ(X){if(!X)return!1;var W=X.substring(0,4);return W==="hvc1"||W==="hev1"||W==="dvh1"||W==="dvhe"}function NX(X,W){if(X){var Z=W>>1&63;return Z===39||Z===40}else{var J=W&31;return J===6}}function eQ(X,W,Z,J){var Y=Y2(X),Q=0;Q+=W;var G=0,q=0,H=0;while(Q<Y.length){G=0;do{if(Q>=Y.length)break;H=Y[Q++],G+=H}while(H===255);q=0;do{if(Q>=Y.length)break;H=Y[Q++],q+=H}while(H===255);var V=Y.length-Q,z=Q;if(q<V)Q+=q;else if(q>V){v0.error("Malformed SEI payload. "+q+" is too small, only "+V+" bytes left to parse.");break}if(G===4){var A=Y[z++];if(A===181){var E=iQ(Y,z);if(z+=2,E===49){var I=B0(Y,z);if(z+=4,I===1195456820){var $=Y[z++];if($===3){var L=Y[z++],b=31&L,C=64&L,D=C?2+b*3:0,y=new Uint8Array(D);if(C){y[0]=L;for(var S=1;S<D;S++)y[S]=Y[z++]}J.push({type:$,payloadType:G,pts:Z,bytes:y})}}}}}else if(G===5){if(q>16){var v=[];for(var p=0;p<16;p++){var g=Y[z++].toString(16);if(v.push(g.length==1?"0"+g:g),p===3||p===5||p===7||p===9)v.push("-")}var m=q-16,r=new Uint8Array(m);for(var o=0;o<m;o++)r[o]=Y[z++];J.push({payloadType:G,pts:Z,uuid:v.join(""),userData:x1(r),userDataBytes:r})}}}}function Y2(X){var W=X.byteLength,Z=[],J=1;while(J<W-2)if(X[J]===0&&X[J+1]===0&&X[J+2]===3)Z.push(J+2),J+=2;else J++;if(Z.length===0)return X;var Y=W-Z.length,Q=new Uint8Array(Y),G=0;for(J=0;J<Y;G++,J++){if(G===Z[0])G++,Z.shift();Q[J]=X[G]}return Q}function UX(X){var W=X[0],Z="",J="",Y=0,Q=0,G=0,q=0,H=0,V=0;if(W===0){while(W1(X.subarray(V,V+1))!=="\x00")Z+=W1(X.subarray(V,V+1)),V+=1;Z+=W1(X.subarray(V,V+1)),V+=1;while(W1(X.subarray(V,V+1))!=="\x00")J+=W1(X.subarray(V,V+1)),V+=1;J+=W1(X.subarray(V,V+1)),V+=1,Y=B0(X,12),Q=B0(X,16),q=B0(X,20),H=B0(X,24),V=28}else if(W===1){V+=4,Y=B0(X,V),V+=4;var z=B0(X,V);V+=4;var A=B0(X,V);if(V+=4,G=Math.pow(2,32)*z+A,!u(G))G=Number.MAX_SAFE_INTEGER,v0.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box");q=B0(X,V),V+=4,H=B0(X,V),V+=4;while(W1(X.subarray(V,V+1))!=="\x00")Z+=W1(X.subarray(V,V+1)),V+=1;Z+=W1(X.subarray(V,V+1)),V+=1;while(W1(X.subarray(V,V+1))!=="\x00")J+=W1(X.subarray(V,V+1)),V+=1;J+=W1(X.subarray(V,V+1)),V+=1}var E=X.subarray(V,X.byteLength);return{schemeIdUri:Z,value:J,timeScale:Y,presentationTime:G,presentationTimeDelta:Q,eventDuration:q,id:H,payload:E}}function XY(X){if(X===void 0)X=!0;if(typeof self==="undefined")return;var W=(X||!self.MediaSource)&&self.ManagedMediaSource;return W||self.MediaSource||self.WebKitMediaSource}function VX(X){return typeof self!=="undefined"&&X===self.ManagedMediaSource}function zX(X,W){var Z=Object.keys(X),J=Object.keys(W),Y=Z.length,Q=J.length;return!Y||!Q||Y===Q&&!Z.some(function(G){return J.indexOf(G)===-1})}var J2=function X(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},OY={audio:{a3ds:1,"ac-3":0.95,"ac-4":1,alac:0.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":0.9,enca:1,fLaC:0.9,flac:0.9,FLAC:0.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:0.8,dav1:0.8,drac:1,dva1:1,dvav:1,dvh1:0.7,dvhe:0.7,encv:1,hev1:0.75,hvc1:0.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:0.9},text:{stpp:1,wvtt:1}};function Q2(X,W){var Z=OY[W];return!!Z&&!!Z[X.slice(0,4)]}function _J(X,W,Z){if(Z===void 0)Z=!0;return!X.split(",").some(function(J){return!Z2(J,W,Z)})}function Z2(X,W,Z){var J;if(Z===void 0)Z=!0;var Y=XY(Z);return(J=Y==null?void 0:Y.isTypeSupported(xY(X,W)))!=null?J:!1}function xY(X,W){return W+"/mp4;codecs="+X}function X2(X){if(X){var W=X.substring(0,4);return OY.video[W]}return 2}function QJ(X){var W=J2();return X.split(",").reduce(function(Z,J){var Y=W&&mJ(J),Q=Y?9:OY.video[J];if(Q)return(Q*2+Z)/(Z?3:2);return(OY.audio[J]+Z)/(Z?2:1)},0)}var pJ={};function jX(X,W){if(W===void 0)W=!0;if(pJ[X])return pJ[X];var Z={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[X];for(var J=0;J<Z.length;J++){var Y;if(Z2(Z[J],"audio",W))return pJ[X]=Z[J],Z[J];else if(Z[J]==="mp3"&&(Y=XY(W))!=null&&Y.isTypeSupported("audio/mpeg"))return""}return X}var AX=/flac|opus|mp4a\.40\.34/i;function ZJ(X,W){if(W===void 0)W=!0;return X.replace(AX,function(Z){return jX(Z.toLowerCase(),W)})}function OX(X,W){var Z=[];if(X){var J=X.split(",");for(var Y=0;Y<J.length;Y++)if(!Q2(J[Y],"video"))Z.push(J[Y])}if(W)Z.push(W);return Z.join(",")}function XJ(X,W){if(X&&(X.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(X)!==-1))return X;if(W){var Z=W.split(",");if(Z.length>1){if(X){for(var J=Z.length;J--;)if(Z[J].substring(0,4)===X.substring(0,4))return Z[J]}return Z[0]}}return W||X}function FX(X){var W=X.split(",");for(var Z=0;Z<W.length;Z++){var J=W[Z].split(".");if(J.length>2){var Y=J.shift()+".";Y+=parseInt(J.shift()).toString(16),Y+=("000"+parseInt(J.shift()).toString(16)).slice(-4),W[Z]=Y}}return W.join(",")}function EX(X){if(X.startsWith("av01.")){var W=X.split("."),Z=["0","111","01","01","01","0"];for(var J=W.length;J>4&&J<10;J++)W[J]=Z[J-4];return W.join(".")}return X}function G2(X){var W=XY(X)||{isTypeSupported:function Z(){return!1}};return{mpeg:W.isTypeSupported("audio/mpeg"),mp3:W.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function W2(X){return X.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var fJ=["NONE","TYPE-0","TYPE-1",null];function BX(X){return fJ.indexOf(X)>-1}var GJ=["SDR","PQ","HLG"];function wX(X){return!!X&&GJ.indexOf(X)>-1}var WJ={No:"",Yes:"YES",v2:"v2"};function K2(X){var{canSkipUntil:W,canSkipDateRanges:Z,age:J}=X,Y=J<W/2;if(W&&Y){if(Z)return WJ.v2;return WJ.Yes}return WJ.No}var q2=function(){function X(Z,J,Y){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=Z,this.part=J,this.skip=Y}var W=X.prototype;return W.addDirectives=function Z(J){var Y=new self.URL(J);if(this.msn!==void 0)Y.searchParams.set("_HLS_msn",this.msn.toString());if(this.part!==void 0)Y.searchParams.set("_HLS_part",this.part.toString());if(this.skip)Y.searchParams.set("_HLS_skip",this.skip);return Y.href},X}(),H2=function(){function X(Z){if(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.supplemental=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=[Z.url],this._attrs=[Z.attrs],this.bitrate=Z.bitrate,Z.details)this.details=Z.details;if(this.id=Z.id||0,this.name=Z.name,this.width=Z.width||0,this.height=Z.height||0,this.frameRate=Z.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=Z.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=Z.audioCodec,this.videoCodec=Z.videoCodec,this.codecSet=[Z.videoCodec,Z.audioCodec].filter(function(Q){return!!Q}).map(function(Q){return Q.substring(0,4)}).join(","),"supplemental"in Z){var J;this.supplemental=Z.supplemental;var Y=(J=Z.supplemental)==null?void 0:J.videoCodec;if(Y&&Y!==Z.videoCodec)this.codecSet+=","+Y.substring(0,4)}this.addGroupId("audio",Z.attrs.AUDIO),this.addGroupId("text",Z.attrs.SUBTITLES)}var W=X.prototype;return W.hasAudioGroup=function Z(J){return N2(this._audioGroups,J)},W.hasSubtitleGroup=function Z(J){return N2(this._subtitleGroups,J)},W.addGroupId=function Z(J,Y){if(!Y)return;if(J==="audio"){var Q=this._audioGroups;if(!Q)Q=this._audioGroups=[];if(Q.indexOf(Y)===-1)Q.push(Y)}else if(J==="text"){var G=this._subtitleGroups;if(!G)G=this._subtitleGroups=[];if(G.indexOf(Y)===-1)G.push(Y)}},W.addFallback=function Z(){},N(X,[{key:"maxBitrate",get:function Z(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function Z(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function Z(){return this._attrs[0]}},{key:"codecs",get:function Z(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function Z(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function Z(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function Z(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function Z(){return this.url[0]||""}},{key:"audioGroups",get:function Z(){return this._audioGroups}},{key:"subtitleGroups",get:function Z(){return this._subtitleGroups}},{key:"urlId",get:function Z(){return 0},set:function Z(J){}},{key:"audioGroupIds",get:function Z(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function Z(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function Z(){var J;return(J=this.audioGroups)==null?void 0:J[0]}},{key:"textGroupId",get:function Z(){var J;return(J=this.subtitleGroups)==null?void 0:J[0]}}])}();function N2(X,W){if(!W||!X)return!1;return X.indexOf(W)!==-1}function RX(){if(typeof matchMedia==="function"){var X=matchMedia("(dynamic-range: high)"),W=matchMedia("bad query");if(X.media!==W.media)return X.matches===!0}return!1}function $X(X,W){var Z=!1,J=[];if(X)Z=X!=="SDR",J=[X];if(W){J=W.allowedVideoRanges||GJ.slice(0);var Y=J.join("")!=="SDR"&&!W.videoCodec;if(Z=W.preferHDR!==void 0?W.preferHDR:Y&&RX(),!Z)J=["SDR"]}return{preferHDR:Z,allowedVideoRanges:J}}var IX=function X(W){var Z=new WeakSet;return function(J,Y){if(W)Y=W(J,Y);if(typeof Y==="object"&&Y!==null){if(Z.has(Y))return;Z.add(Y)}return Y}},O1=function X(W,Z){return JSON.stringify(W,IX(Z))};function LX(X,W,Z,J,Y){var Q=Object.keys(X),G=J==null?void 0:J.channels,q=J==null?void 0:J.audioCodec,H=Y==null?void 0:Y.videoCodec,V=G&&parseInt(G)===2,z=!1,A=!1,E=1/0,I=1/0,$=1/0,L=1/0,b=0,C=[],D=$X(W,Y),y=D.preferHDR,S=D.allowedVideoRanges,v=function c(){var d=X[Q[p]];z||(z=d.channels[2]>0),E=Math.min(E,d.minHeight),I=Math.min(I,d.minFramerate),$=Math.min($,d.minBitrate);var e=S.filter(function(H0){return d.videoRanges[H0]>0});if(e.length>0)A=!0};for(var p=Q.length;p--;)v();E=T(E)?E:0,I=T(I)?I:0;var g=Math.max(1080,E),m=Math.max(30,I);if($=T($)?$:Z,Z=Math.max($,Z),!A)W=void 0;var r=Q.length>1,o=Q.reduce(function(c,d){var e=X[d];if(d===c)return c;if(C=A?S.filter(function(H0){return e.videoRanges[H0]>0}):[],r){if(e.minBitrate>Z)return o1(d,"min bitrate of "+e.minBitrate+" > current estimate of "+Z),c;if(!e.hasDefaultAudio)return o1(d,"no renditions with default or auto-select sound found"),c;if(q&&d.indexOf(q.substring(0,4))%5!==0)return o1(d,'audio codec preference "'+q+'" not found'),c;if(G&&!V){if(!e.channels[G])return o1(d,"no renditions with "+G+" channel sound found (channels options: "+Object.keys(e.channels)+")"),c}else if((!q||V)&&z&&e.channels["2"]===0)return o1(d,"no renditions with stereo sound found"),c;if(e.minHeight>g)return o1(d,"min resolution of "+e.minHeight+" > maximum of "+g),c;if(e.minFramerate>m)return o1(d,"min framerate of "+e.minFramerate+" > maximum of "+m),c;if(!C.some(function(H0){return e.videoRanges[H0]>0}))return o1(d,"no variants with VIDEO-RANGE of "+O1(C)+" found"),c;if(H&&d.indexOf(H.substring(0,4))%5!==0)return o1(d,'video codec preference "'+H+'" not found'),c;if(e.maxScore<b)return o1(d,"max score of "+e.maxScore+" < selected max of "+b),c}if(c&&(QJ(d)>=QJ(c)||e.fragmentError>X[c].fragmentError))return c;return L=e.minIndex,b=e.maxScore,d},void 0);return{codecSet:o,videoRanges:C,preferHDR:y,minFramerate:I,minBitrate:$,minIndex:L}}function o1(X,W){v0.log('[abr] start candidates with "'+X+'" ignored because '+W)}function U2(X){return X.reduce(function(W,Z){var J=W.groups[Z.groupId];if(!J)J=W.groups[Z.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1};J.tracks.push(Z);var Y=Z.channels||"2";if(J.channels[Y]=(J.channels[Y]||0)+1,J.hasDefault=J.hasDefault||Z.default,J.hasAutoSelect=J.hasAutoSelect||Z.autoselect,J.hasDefault)W.hasDefaultAudio=!0;if(J.hasAutoSelect)W.hasAutoSelectAudio=!0;return W},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function bX(X,W,Z,J){return X.slice(Z,J+1).reduce(function(Y,Q,G){if(!Q.codecSet)return Y;var q=Q.audioGroups,H=Y[Q.codecSet];if(!H)Y[Q.codecSet]=H={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:G,maxScore:0,videoRanges:{SDR:0},channels:{"2":0},hasDefaultAudio:!q,fragmentError:0};H.minBitrate=Math.min(H.minBitrate,Q.bitrate);var V=Math.min(Q.height,Q.width);return H.minHeight=Math.min(H.minHeight,V),H.minFramerate=Math.min(H.minFramerate,Q.frameRate),H.minIndex=Math.min(H.minIndex,G),H.maxScore=Math.max(H.maxScore,Q.score),H.fragmentError+=Q.fragmentError,H.videoRanges[Q.videoRange]=(H.videoRanges[Q.videoRange]||0)+1,Y},{})}function V2(X,W){var Z;return!!X&&X!==((Z=W.loadLevelObj)==null?void 0:Z.uri)}var MX=function(X){function W(J){var Y=X.call(this,"abr",J.logger)||this;return Y.hls=void 0,Y.lastLevelLoadSec=0,Y.lastLoadedFragLevel=-1,Y.firstSelection=-1,Y._nextAutoLevel=-1,Y.nextAutoLevelKey="",Y.audioTracksByGroup=null,Y.codecTiers=null,Y.timer=-1,Y.fragCurrent=null,Y.partCurrent=null,Y.bitrateTestDelay=0,Y.rebufferNotice=-1,Y.bwEstimator=void 0,Y._abandonRulesCheck=function(Q){var G,q=Y,H=q.fragCurrent,V=q.partCurrent,z=q.hls,A=z.autoLevelEnabled,E=z.media;if(!H||!E)return;var I=performance.now(),$=V?V.stats:H.stats,L=V?V.duration:H.duration,b=I-$.loading.start,C=z.minAutoLevel,D=H.level,y=Y._nextAutoLevel;if($.aborted||$.loaded&&$.loaded===$.total||D<=C){Y.clearTimer(),Y._nextAutoLevel=-1;return}if(!A)return;var S=y>-1&&y!==D,v=!!Q||S;if(!v&&(E.paused||!E.playbackRate||!E.readyState))return;var p=z.mainForwardBufferInfo;if(!v&&p===null)return;var g=Y.bwEstimator.getEstimateTTFB(),m=Math.abs(E.playbackRate);if(b<=Math.max(g,1000*(L/(m*2))))return;var r=p?p.len/m:0,o=$.loading.first?$.loading.first-$.loading.start:-1,c=$.loaded&&o>-1,d=Y.getBwEstimate(),e=z.levels,H0=e[D],Q0=Math.max($.loaded,Math.round(L*(H.bitrate||H0.averageBitrate)/8)),J0=c?b-o:b;if(J0<1&&c)J0=Math.min(b,$.loaded*8/d);var N0=c?$.loaded*1000/J0:0,V0=g/1000,j0=N0?(Q0-$.loaded)/N0:Q0*8/d+V0;if(j0<=r)return;var O0=N0?N0*8:d,g0=((G=(Q==null?void 0:Q.details)||Y.hls.latestLevelDetails)==null?void 0:G.live)===!0,T0=Y.hls.config.abrBandWidthUpFactor,m0=Number.POSITIVE_INFINITY,D0;for(D0=D-1;D0>C;D0--){var Y1=e[D0].maxBitrate,_0=!e[D0].details||g0;if(m0=Y.getTimeToLoadFrag(V0,O0,L*Y1,_0),m0<Math.min(r,L+V0))break}if(m0>=j0)return;if(m0>L*10)return;if(c)Y.bwEstimator.sample(b-Math.min(g,o),$.loaded);else Y.bwEstimator.sampleTTFB(b);var a0=e[D0].maxBitrate;if(Y.getBwEstimate()*T0>a0)Y.resetEstimator(a0);var w1=Y.findBestLevel(a0,C,D0,0,r,1,1);if(w1>-1)D0=w1;Y.warn("Fragment "+H.sn+(V?" part "+V.index:"")+" of level "+D+` is loading too slowly;
2
+ Fragment duration: `+H.duration.toFixed(3)+`
3
+ Time to underbuffer: `+r.toFixed(3)+` s
4
+ Estimated load time for current fragment: `+j0.toFixed(3)+` s
5
+ Estimated load time for down switch fragment: `+m0.toFixed(3)+` s
6
+ TTFB estimate: `+(o|0)+` ms
7
+ Current BW estimate: `+(T(d)?d|0:"Unknown")+` bps
8
+ New BW estimate: `+(Y.getBwEstimate()|0)+` bps
9
+ Switching to level `+D0+" @ "+(a0|0)+" bps"),z.nextLoadLevel=z.nextAutoLevel=D0,Y.clearTimer();var q1=function p0(){if(Y.clearTimer(),Y.fragCurrent===H&&Y.hls.loadLevel===D0&&D0>0){var R1=Y.getStarvationDelay();if(Y.warn("Aborting inflight request "+(D0>0?"and switching down":"")+`
10
+ Fragment duration: `+H.duration.toFixed(3)+` s
11
+ Time to underbuffer: `+R1.toFixed(3)+" s"),H.abortRequests(),Y.fragCurrent=Y.partCurrent=null,D0>C){var Z1=Y.findBestLevel(Y.hls.levels[C].bitrate,C,D0,0,R1,1,1);if(Z1===-1)Z1=C;Y.hls.nextLoadLevel=Y.hls.nextAutoLevel=Z1,Y.resetEstimator(Y.hls.levels[Z1].bitrate)}}};if(S||j0>m0*2)q1();else Y.timer=self.setInterval(q1,m0*1000);z.trigger(M.FRAG_LOAD_EMERGENCY_ABORTED,{frag:H,part:V,stats:$})},Y.hls=J,Y.bwEstimator=Y.initEstimator(),Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.resetEstimator=function J(Y){if(Y)this.log("setting initial bwe to "+Y),this.hls.config.abrEwmaDefaultEstimate=Y;this.firstSelection=-1,this.bwEstimator=this.initEstimator()},Z.initEstimator=function J(){var Y=this.hls.config;return new u0(Y.abrEwmaSlowVoD,Y.abrEwmaFastVoD,Y.abrEwmaDefaultEstimate)},Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.FRAG_LOADING,this.onFragLoading,this),Y.on(M.FRAG_LOADED,this.onFragLoaded,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.on(M.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.FRAG_LOADING,this.onFragLoading,this),Y.off(M.FRAG_LOADED,this.onFragLoaded,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.off(M.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.off(M.ERROR,this.onError,this)},Z.destroy=function J(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},Z.onManifestLoading=function J(Y,Q){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},Z.onLevelsUpdated=function J(){if(this.lastLoadedFragLevel>-1&&this.fragCurrent)this.lastLoadedFragLevel=this.fragCurrent.level;this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},Z.onMaxAutoLevelUpdated=function J(){this.firstSelection=-1,this.nextAutoLevelKey=""},Z.onFragLoading=function J(Y,Q){var G=Q.frag;if(this.ignoreFragment(G))return;if(!G.bitrateTest){var q;this.fragCurrent=G,this.partCurrent=(q=Q.part)!=null?q:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)},Z.onLevelSwitching=function J(Y,Q){this.clearTimer()},Z.onError=function J(Y,Q){if(Q.fatal)return;switch(Q.details){case h.BUFFER_ADD_CODEC_ERROR:case h.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case h.FRAG_LOAD_TIMEOUT:{var G=Q.frag,q=this.fragCurrent,H=this.partCurrent;if(G&&q&&G.sn===q.sn&&G.level===q.level){var V=performance.now(),z=H?H.stats:G.stats,A=V-z.loading.start,E=z.loading.first?z.loading.first-z.loading.start:-1,I=z.loaded&&E>-1;if(I){var $=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(A-Math.min($,E),z.loaded)}else this.bwEstimator.sampleTTFB(A)}break}}},Z.getTimeToLoadFrag=function J(Y,Q,G,q){var H=Y+G/Q,V=q?Y+this.lastLevelLoadSec:0;return H+V},Z.onLevelLoaded=function J(Y,Q){var G=this.hls.config,q=Q.stats.loading,H=q.end-q.first;if(T(H))this.lastLevelLoadSec=H/1000;if(Q.details.live)this.bwEstimator.update(G.abrEwmaSlowLive,G.abrEwmaFastLive);else this.bwEstimator.update(G.abrEwmaSlowVoD,G.abrEwmaFastVoD);if(this.timer>-1)this._abandonRulesCheck(Q.levelInfo)},Z.onFragLoaded=function J(Y,Q){var{frag:G,part:q}=Q,H=q?q.stats:G.stats;if(G.type===G0.MAIN)this.bwEstimator.sampleTTFB(H.loading.first-H.loading.start);if(this.ignoreFragment(G))return;if(this.clearTimer(),G.level===this._nextAutoLevel)this._nextAutoLevel=-1;if(this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var V=q?q.duration:G.duration,z=this.hls.levels[G.level],A=(z.loaded?z.loaded.bytes:0)+H.loaded,E=(z.loaded?z.loaded.duration:0)+V;z.loaded={bytes:A,duration:E},z.realBitrate=Math.round(8*A/E)}if(G.bitrateTest){var I={stats:H,frag:G,part:q,id:G.type};this.onFragBuffered(M.FRAG_BUFFERED,I),G.bitrateTest=!1}else this.lastLoadedFragLevel=G.level},Z.onFragBuffered=function J(Y,Q){var{frag:G,part:q}=Q,H=q!=null&&q.stats.loaded?q.stats:G.stats;if(H.aborted)return;if(this.ignoreFragment(G))return;var V=H.parsing.end-H.loading.start-Math.min(H.loading.first-H.loading.start,this.bwEstimator.getEstimateTTFB());if(this.bwEstimator.sample(V,H.loaded),H.bwEstimate=this.getBwEstimate(),G.bitrateTest)this.bitrateTestDelay=V/1000;else this.bitrateTestDelay=0},Z.ignoreFragment=function J(Y){return Y.type!==G0.MAIN||Y.sn==="initSegment"},Z.clearTimer=function J(){if(this.timer>-1)self.clearInterval(this.timer),this.timer=-1},Z.getAutoLevelKey=function J(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},Z.getNextABRAutoLevel=function J(){var Y=this.fragCurrent,Q=this.partCurrent,G=this.hls;if(G.levels.length<=1)return G.loadLevel;var{maxAutoLevel:q,config:H,minAutoLevel:V}=G,z=Q?Q.duration:Y?Y.duration:0,A=this.getBwEstimate(),E=this.getStarvationDelay(),I=H.abrBandWidthFactor,$=H.abrBandWidthUpFactor;if(E){var L=this.findBestLevel(A,V,q,E,0,I,$);if(L>=0)return this.rebufferNotice=-1,L}var b=z?Math.min(z,H.maxStarvationDelay):H.maxStarvationDelay;if(!E){var C=this.bitrateTestDelay;if(C){var D=z?Math.min(z,H.maxLoadingDelay):H.maxLoadingDelay;b=D-C,this.info("bitrate test took "+Math.round(1000*C)+"ms, set first fragment max fetchDuration to "+Math.round(1000*b)+" ms"),I=$=1}}var y=this.findBestLevel(A,V,q,E,b,I,$);if(this.rebufferNotice!==y)this.rebufferNotice=y,this.info((E?"rebuffering expected":"buffer is empty")+", optimal quality level "+y);if(y>-1)return y;var S=G.levels[V],v=G.loadLevelObj;if(v&&(S==null?void 0:S.bitrate)<v.bitrate)return V;return G.loadLevel},Z.getStarvationDelay=function J(){var Y=this.hls,Q=Y.media;if(!Q)return 1/0;var G=Q&&Q.playbackRate!==0?Math.abs(Q.playbackRate):1,q=Y.mainForwardBufferInfo;return(q?q.len:0)/G},Z.getBwEstimate=function J(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},Z.findBestLevel=function J(Y,Q,G,q,H,V,z){var A,E=this,I=q+H,$=this.lastLoadedFragLevel,L=$===-1?this.hls.firstLevel:$,b=this.fragCurrent,C=this.partCurrent,D=this.hls,y=D.levels,S=D.allAudioTracks,v=D.loadLevel,p=D.config;if(y.length===1)return 0;var g=y[L],m=!!((A=this.hls.latestLevelDetails)!=null&&A.live),r=v===-1||$===-1,o,c="SDR",d=(g==null?void 0:g.frameRate)||0,e=p.audioPreference,H0=p.videoPreference,Q0=this.audioTracksByGroup||(this.audioTracksByGroup=U2(S)),J0=-1;if(r){if(this.firstSelection!==-1)return this.firstSelection;var N0=this.codecTiers||(this.codecTiers=bX(y,Q0,Q,G)),V0=LX(N0,c,Y,e,H0),j0=V0.codecSet,O0=V0.videoRanges,g0=V0.minFramerate,T0=V0.minBitrate,m0=V0.minIndex,D0=V0.preferHDR;J0=m0,o=j0,c=D0?O0[O0.length-1]:O0[0],d=g0,Y=Math.max(Y,T0),this.log("picked start tier "+O1(V0))}else o=g==null?void 0:g.codecSet,c=g==null?void 0:g.videoRange;var Y1=C?C.duration:b?b.duration:0,_0=this.bwEstimator.getEstimateTTFB()/1000,a0=[],w1=function R1(){var Z1,s0=y[p0],$1=p0>L;if(!s0)return 0;if(o&&s0.codecSet!==o||c&&s0.videoRange!==c||$1&&d>s0.frameRate||!$1&&d>0&&d<s0.frameRate||s0.supportedResult&&!((Z1=s0.supportedResult.decodingInfoResults)!=null&&Z1[0].smooth)){if(!r||p0!==J0)return a0.push(p0),0}var V1=s0.details,M1=(C?V1==null?void 0:V1.partTarget:V1==null?void 0:V1.averagetargetduration)||Y1,n0;if(!$1)n0=V*Y;else n0=z*Y;var z1=Y1&&q>=Y1*2&&H===0?s0.averageBitrate:s0.maxBitrate,X1=E.getTimeToLoadFrag(_0,n0,z1*M1,V1===void 0),I1=n0>=z1&&(p0===$||s0.loadError===0&&s0.fragmentError===0)&&(X1<=_0||!T(X1)||m&&!E.bitrateTestDelay||X1<I);if(I1){var _Y=E.forcedAutoLevel;if(p0!==v&&(_Y===-1||_Y!==v)){if(a0.length)E.trace("Skipped level(s) "+a0.join(",")+" of "+G+' max with CODECS and VIDEO-RANGE:"'+y[a0[0]].codecs+'" '+y[a0[0]].videoRange+'; not compatible with "'+o+'" '+c);E.info("switch candidate:"+L+"->"+p0+" adjustedbw("+Math.round(n0)+")-bitrate="+Math.round(n0-z1)+" ttfb:"+_0.toFixed(1)+" avgDuration:"+M1.toFixed(1)+" maxFetchDuration:"+I.toFixed(1)+" fetchDuration:"+X1.toFixed(1)+" firstSelection:"+r+" codecSet:"+s0.codecSet+" videoRange:"+s0.videoRange+" hls.loadLevel:"+v)}if(r)E.firstSelection=p0;return{v:p0}}},q1;for(var p0=G;p0>=Q;p0--){if(q1=w1(),q1===0)continue;if(q1)return q1.v}return-1},Z.deriveNextAutoLevel=function J(Y){var Q=this.hls,G=Q.maxAutoLevel,q=Q.minAutoLevel;return Math.min(Math.max(Y,q),G)},N(W,[{key:"firstAutoLevel",get:function J(){var Y=this.hls,Q=Y.maxAutoLevel,G=Y.minAutoLevel,q=this.getBwEstimate(),H=this.hls.config.maxStarvationDelay,V=this.findBestLevel(q,G,Q,0,H,1,1);if(V>-1)return V;var z=this.hls.firstLevel,A=Math.min(Math.max(z,G),Q);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+z+" clamped to "+A),A}},{key:"forcedAutoLevel",get:function J(){if(this.nextAutoLevelKey)return-1;return this._nextAutoLevel}},{key:"nextAutoLevel",get:function J(){var Y=this.forcedAutoLevel,Q=this.bwEstimator,G=Q.canEstimate(),q=this.lastLoadedFragLevel>-1;if(Y!==-1&&(!G||!q||this.nextAutoLevelKey===this.getAutoLevelKey()))return Y;var H=G&&q?this.getNextABRAutoLevel():this.firstAutoLevel;if(Y!==-1){var V=this.hls.levels;if(V.length>Math.max(Y,H)&&V[Y].loadError<=V[H].loadError)return Y}return this._nextAutoLevel=H,this.nextAutoLevelKey=this.getAutoLevelKey(),H},set:function J(Y){var Q=this.deriveNextAutoLevel(Y);if(this._nextAutoLevel!==Q)this.nextAutoLevelKey="",this._nextAutoLevel=Q}}])}(d0),CX=function(){function X(Z){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=Z}var W=X.prototype;return W.destroy=function Z(){this.tracks=this.queues=null},W.append=function Z(J,Y,Q){if(this.queues===null||this.tracks===null)return;var G=this.queues[Y];if(G.push(J),G.length===1&&!Q)this.executeNext(Y)},W.appendBlocker=function Z(J){var Y=this;return new Promise(function(Q){var G={label:"async-blocker",execute:Q,onStart:function q(){},onComplete:function q(){},onError:function q(){}};Y.append(G,J)})},W.prependBlocker=function Z(J){var Y=this;return new Promise(function(Q){if(Y.queues){var G={label:"async-blocker-prepend",execute:Q,onStart:function q(){},onComplete:function q(){},onError:function q(){}};Y.queues[J].unshift(G)}})},W.removeBlockers=function Z(){if(this.queues===null)return;[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(J){var Y,Q=(Y=J[0])==null?void 0:Y.label;if(Q==="async-blocker"||Q==="async-blocker-prepend")J[0].execute(),J.splice(0,1)})},W.unblockAudio=function Z(J){if(this.queues===null)return;var Y=this.queues.audio;if(Y[0]===J)this.shiftAndExecuteNext("audio")},W.executeNext=function Z(J){if(this.queues===null||this.tracks===null)return;var Y=this.queues[J];if(Y.length){var Q=Y[0];try{Q.execute()}catch(H){var G;if(Q.onError(H),this.queues===null||this.tracks===null)return;var q=(G=this.tracks[J])==null?void 0:G.buffer;if(!(q!=null&&q.updating))this.shiftAndExecuteNext(J)}}},W.shiftAndExecuteNext=function Z(J){if(this.queues===null)return;this.queues[J].shift(),this.executeNext(J)},W.current=function Z(J){var Y;return((Y=this.queues)==null?void 0:Y[J][0])||null},W.toString=function Z(){var J=this.queues,Y=this.tracks;if(J===null||Y===null)return"<destroyed>";return`
12
+ `+this.list("video")+`
13
+ `+this.list("audio")+`
14
+ `+this.list("audiovideo")+"}"},W.list=function Z(J){var Y,Q;return(Y=this.queues)!=null&&Y[J]||(Q=this.tracks)!=null&&Q[J]?J+": ("+this.listSbInfo(J)+") "+this.listOps(J):""},W.listSbInfo=function Z(J){var Y,Q=(Y=this.tracks)==null?void 0:Y[J],G=Q==null?void 0:Q.buffer;if(!G)return"none";return"SourceBuffer"+(G.updating?" updating":"")+(Q.ended?" ended":"")+(Q.ending?" ending":"")},W.listOps=function Z(J){var Y;return((Y=this.queues)==null?void 0:Y[J].map(function(Q){return Q.label}).join(", "))||""},X}(),z2={search:function X(W,Z){var J=0,Y=W.length-1,Q=null,G=null;while(J<=Y){Q=(J+Y)/2|0,G=W[Q];var q=Z(G);if(q>0)J=Q+1;else if(q<0)Y=Q-1;else return G}return null}};function DX(X,W,Z){if(W===null||!Array.isArray(X)||!X.length||!T(W))return null;var J=X[0].programDateTime;if(W<(J||0))return null;var Y=X[X.length-1].endProgramDateTime;if(W>=(Y||0))return null;Z=Z||0;for(var Q=0;Q<X.length;++Q){var G=X[Q];if(PX(W,Z,G))return G}return null}function cJ(X,W,Z,J,Y){if(Z===void 0)Z=0;if(J===void 0)J=0;if(Y===void 0)Y=0.005;var Q=null;if(X){Q=W[1+X.sn-W[0].sn]||null;var G=X.endDTS-Z;if(G>0&&G<0.0000015)Z+=0.0000015;if(Q&&X.level!==Q.level&&Q.end<=X.end)Q=W[2+X.sn-W[0].sn]||null}else if(Z===0&&W[0].start===0)Q=W[0];if(Q&&((!X||X.level===Q.level)&&j2(Z,J,Q)===0||SX(Q,X,Math.min(Y,J))))return Q;var q=z2.search(W,j2.bind(null,Z,J));if(q&&(q!==X||!Q))return q;return Q}function SX(X,W,Z){if(W&&W.start===0&&W.level<X.level&&(W.endPTS||0)>0){var J=W.tagList.reduce(function(Y,Q){if(Q[0]==="INF")Y+=parseFloat(Q[1]);return Y},Z);return X.start<=J}return!1}function j2(X,W,Z){if(X===void 0)X=0;if(W===void 0)W=0;if(Z.start<=X&&Z.start+Z.duration>X)return 0;var J=Math.min(W,Z.duration+(Z.deltaPTS?Z.deltaPTS:0));if(Z.start+Z.duration-J<=X)return 1;else if(Z.start-J>X&&Z.start)return-1;return 0}function PX(X,W,Z){var J=Math.min(W,Z.duration+(Z.deltaPTS?Z.deltaPTS:0))*1000,Y=Z.endProgramDateTime||0;return Y-J>X}function yX(X,W){return z2.search(X,function(Z){if(Z.cc<W)return 1;else if(Z.cc>W)return-1;else return 0})}function KJ(X){switch(X.details){case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_TIMEOUT:case h.LEVEL_LOAD_TIMEOUT:case h.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function A2(X,W){var Z=KJ(W);return X.default[(Z?"timeout":"error")+"Retry"]}function lJ(X,W){var Z=X.backoff==="linear"?1:Math.pow(2,W);return Math.min(Z*X.retryDelayMs,X.maxRetryDelayMs)}function O2(X){return f(f({},X),{errorRetry:null,timeoutRetry:null})}function qJ(X,W,Z,J){if(!X)return!1;var Y=J==null?void 0:J.code,Q=W<X.maxNumRetry&&(TX(Y)||!!Z);return X.shouldRetry?X.shouldRetry(X,W,Z,J,Q):Q}function TX(X){return X===0&&navigator.onLine===!1||!!X&&(X<400||X>499)}var U1={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},h1={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},xX=function(X){function W(J){var Y=X.call(this,"error-controller",J.logger)||this;return Y.hls=void 0,Y.playlistError=0,Y.penalizedRenditions={},Y.hls=J,Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.ERROR,this.onError,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.ERROR,this.onError,this),Y.off(M.ERROR,this.onErrorOut,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.destroy=function J(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},Z.startLoad=function J(Y){},Z.stopLoad=function J(){this.playlistError=0},Z.getVariantLevelIndex=function J(Y){return(Y==null?void 0:Y.type)===G0.MAIN?Y.level:this.hls.loadLevel},Z.onManifestLoading=function J(){this.playlistError=0,this.penalizedRenditions={}},Z.onLevelUpdated=function J(){this.playlistError=0},Z.onError=function J(Y,Q){var G;if(Q.fatal)return;var q=this.hls,H=Q.context;switch(Q.details){case h.FRAG_LOAD_ERROR:case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_ERROR:case h.KEY_LOAD_TIMEOUT:Q.errorAction=this.getFragRetryOrSwitchAction(Q);return;case h.FRAG_PARSING_ERROR:if((G=Q.frag)!=null&&G.gap){Q.errorAction=HJ();return}case h.FRAG_GAP:case h.FRAG_DECRYPT_ERROR:{Q.errorAction=this.getFragRetryOrSwitchAction(Q),Q.errorAction.action=U1.SendAlternateToPenaltyBox;return}case h.LEVEL_EMPTY_ERROR:case h.LEVEL_PARSING_ERROR:{var V,z,A=Q.parent===G0.MAIN?Q.level:q.loadLevel;if(Q.details===h.LEVEL_EMPTY_ERROR&&!!((V=Q.context)!=null&&(z=V.levelDetails)!=null&&z.live))Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,A);else Q.levelRetry=!1,Q.errorAction=this.getLevelSwitchAction(Q,A)}return;case h.LEVEL_LOAD_ERROR:case h.LEVEL_LOAD_TIMEOUT:if(typeof(H==null?void 0:H.level)==="number")Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,H.level);return;case h.AUDIO_TRACK_LOAD_ERROR:case h.AUDIO_TRACK_LOAD_TIMEOUT:case h.SUBTITLE_LOAD_ERROR:case h.SUBTITLE_TRACK_LOAD_TIMEOUT:if(H){var E=q.loadLevelObj;if(E&&(H.type===Z0.AUDIO_TRACK&&E.hasAudioGroup(H.groupId)||H.type===Z0.SUBTITLE_TRACK&&E.hasSubtitleGroup(H.groupId))){Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,q.loadLevel),Q.errorAction.action=U1.SendAlternateToPenaltyBox,Q.errorAction.flags=h1.MoveAllAlternatesMatchingHost;return}}return;case h.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var I=q.loadLevelObj,$=I==null?void 0:I.attrs["HDCP-LEVEL"];if($)Q.errorAction={action:U1.SendAlternateToPenaltyBox,flags:h1.MoveAllAlternatesMatchingHDCP,hdcpLevel:$};else this.keySystemError(Q)}return;case h.BUFFER_ADD_CODEC_ERROR:case h.REMUX_ALLOC_ERROR:case h.BUFFER_APPEND_ERROR:if(!Q.errorAction){var L;Q.errorAction=this.getLevelSwitchAction(Q,(L=Q.level)!=null?L:q.loadLevel)}return;case h.INTERNAL_EXCEPTION:case h.BUFFER_APPENDING_ERROR:case h.BUFFER_FULL_ERROR:case h.LEVEL_SWITCH_ERROR:case h.BUFFER_STALLED_ERROR:case h.BUFFER_SEEK_OVER_HOLE:case h.BUFFER_NUDGE_ON_STALL:Q.errorAction=HJ();return}if(Q.type===n.KEY_SYSTEM_ERROR)this.keySystemError(Q)},Z.keySystemError=function J(Y){var Q=this.getVariantLevelIndex(Y.frag);Y.levelRetry=!1,Y.errorAction=this.getLevelSwitchAction(Y,Q)},Z.getPlaylistRetryOrSwitchAction=function J(Y,Q){var G=this.hls,q=A2(G.config.playlistLoadPolicy,Y),H=this.playlistError++,V=qJ(q,H,KJ(Y),Y.response);if(V)return{action:U1.RetryRequest,flags:h1.None,retryConfig:q,retryCount:H};var z=this.getLevelSwitchAction(Y,Q);if(q)z.retryConfig=q,z.retryCount=H;return z},Z.getFragRetryOrSwitchAction=function J(Y){var Q=this.hls,G=this.getVariantLevelIndex(Y.frag),q=Q.levels[G],H=Q.config,V=H.fragLoadPolicy,z=H.keyLoadPolicy,A=A2(Y.details.startsWith("key")?z:V,Y),E=Q.levels.reduce(function(L,b){return L+b.fragmentError},0);if(q){if(Y.details!==h.FRAG_GAP)q.fragmentError++;var I=qJ(A,E,KJ(Y),Y.response);if(I)return{action:U1.RetryRequest,flags:h1.None,retryConfig:A,retryCount:E}}var $=this.getLevelSwitchAction(Y,G);if(A)$.retryConfig=A,$.retryCount=E;return $},Z.getLevelSwitchAction=function J(Y,Q){var G=this.hls;if(Q===null||Q===void 0)Q=G.loadLevel;var q=this.hls.levels[Q];if(q){var H,V,z=Y.details;if(q.loadError++,z===h.BUFFER_APPEND_ERROR)q.fragmentError++;var A=-1,E=G.levels,I=G.loadLevel,$=G.minAutoLevel,L=G.maxAutoLevel;if(!G.autoLevelEnabled)G.loadLevel=-1;var b=(H=Y.frag)==null?void 0:H.type,C=b===G0.AUDIO&&z===h.FRAG_PARSING_ERROR||Y.sourceBufferName==="audio"&&(z===h.BUFFER_ADD_CODEC_ERROR||z===h.BUFFER_APPEND_ERROR),D=C&&E.some(function(c){var d=c.audioCodec;return q.audioCodec!==d}),y=Y.sourceBufferName==="video"&&(z===h.BUFFER_ADD_CODEC_ERROR||z===h.BUFFER_APPEND_ERROR),S=y&&E.some(function(c){var{codecSet:d,audioCodec:e}=c;return q.codecSet!==d&&q.audioCodec===e}),v=(V=Y.context)!=null?V:{},p=v.type,g=v.groupId,m=function c(){var d=(o+I)%E.length;if(d!==I&&d>=$&&d<=L&&E[d].loadError===0){var e,H0,Q0=E[d];if(z===h.FRAG_GAP&&b===G0.MAIN&&Y.frag){var J0=E[d].details;if(J0){var N0=cJ(Y.frag,J0.fragments,Y.frag.start);if(N0!=null&&N0.gap)return 0}}else if(p===Z0.AUDIO_TRACK&&Q0.hasAudioGroup(g)||p===Z0.SUBTITLE_TRACK&&Q0.hasSubtitleGroup(g))return 0;else if(b===G0.AUDIO&&(e=q.audioGroups)!=null&&e.some(function(V0){return Q0.hasAudioGroup(V0)})||b===G0.SUBTITLE&&(H0=q.subtitleGroups)!=null&&H0.some(function(V0){return Q0.hasSubtitleGroup(V0)})||D&&q.audioCodec===Q0.audioCodec||!D&&q.audioCodec!==Q0.audioCodec||S&&q.codecSet===Q0.codecSet)return 0;return A=d,1}},r;for(var o=E.length;o--;){if(r=m(),r===0)continue;if(r===1)break}if(A>-1&&G.loadLevel!==A)return Y.levelRetry=!0,this.playlistError=0,{action:U1.SendAlternateToPenaltyBox,flags:h1.None,nextAutoLevel:A}}return{action:U1.SendAlternateToPenaltyBox,flags:h1.MoveAllAlternatesMatchingHost}},Z.onErrorOut=function J(Y,Q){var G;switch((G=Q.errorAction)==null?void 0:G.action){case U1.DoNothing:break;case U1.SendAlternateToPenaltyBox:if(this.sendAlternateToPenaltyBox(Q),!Q.errorAction.resolved&&Q.details!==h.FRAG_GAP)Q.fatal=!0;else if(/MediaSource readyState: ended/.test(Q.error.message))this.warn('MediaSource ended after "'+Q.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError();break}if(Q.fatal){this.hls.stopLoad();return}},Z.sendAlternateToPenaltyBox=function J(Y){var Q=this.hls,G=Y.errorAction;if(!G)return;var{flags:q,hdcpLevel:H,nextAutoLevel:V}=G;switch(q){case h1.None:this.switchLevel(Y,V);break;case h1.MoveAllAlternatesMatchingHDCP:if(H)Q.maxHdcpLevel=fJ[fJ.indexOf(H)-1],G.resolved=!0;this.warn('Restricting playback to HDCP-LEVEL of "'+Q.maxHdcpLevel+'" or lower');break}if(!G.resolved)this.switchLevel(Y,V)},Z.switchLevel=function J(Y,Q){if(Q!==void 0&&Y.errorAction){if(this.warn("switching to level "+Q+" after "+Y.details),this.hls.nextAutoLevel=Q,Y.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,Y.details===h.BUFFER_ADD_CODEC_ERROR&&Y.mimeType&&Y.sourceBufferName!=="audiovideo"){var G=W2(Y.mimeType),q=this.hls.levels;for(var H=q.length;H--;)if(q[H][Y.sourceBufferName+"Codec"]===G)this.hls.removeLevel(H)}}},W}(d0);function HJ(X){var W={action:U1.DoNothing,flags:h1.None};if(X)W.resolved=!0;return W}var F2={length:0,start:function X(){return 0},end:function X(){return 0}},k0=function(){function X(){}return X.isBuffered=function W(Z,J){if(Z){var Y=X.getBuffered(Z);for(var Q=Y.length;Q--;)if(J>=Y.start(Q)&&J<=Y.end(Q))return!0}return!1},X.bufferedRanges=function W(Z){if(Z){var J=X.getBuffered(Z);return X.timeRangesToArray(J)}return[]},X.timeRangesToArray=function W(Z){var J=[];for(var Y=0;Y<Z.length;Y++)J.push({start:Z.start(Y),end:Z.end(Y)});return J},X.bufferInfo=function W(Z,J,Y){if(Z){var Q=X.bufferedRanges(Z);if(Q.length)return X.bufferedInfo(Q,J,Y)}return{len:0,start:J,end:J,bufferedIndex:-1}},X.bufferedInfo=function W(Z,J,Y){if(J=Math.max(0,J),Z.length>1)Z.sort(function(C,D){return C.start-D.start||D.end-C.end});var Q=-1,G=[];if(Y)for(var q=0;q<Z.length;q++){if(J>=Z[q].start&&J<=Z[q].end)Q=q;var H=G.length;if(H){var V=G[H-1].end;if(Z[q].start-V<Y){if(Z[q].end>V)G[H-1].end=Z[q].end}else G.push(Z[q])}else G.push(Z[q])}else G=Z;var z=0,A,E=J,I=J;for(var $=0;$<G.length;$++){var L=G[$].start,b=G[$].end;if(Q===-1&&J>=L&&J<=b)Q=$;if(J+Y>=L&&J<b)E=L,I=b,z=I-J;else if(J+Y<L){A=L;break}}return{len:z,start:E||0,end:I||0,nextStart:A,buffered:Z,bufferedIndex:Q}},X.getBuffered=function W(Z){try{return Z.buffered||F2}catch(J){return v0.log("failed to get media.buffered",J),F2}},X}(),E2=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,B2="HlsJsTrackRemovedError",vX=function(X){function W(Z){var J=X.call(this,Z)||this;return J.name=B2,J}return R(W,X),W}(t(Error)),hX=function(X){function W(J,Y){var Q=X.call(this,"buffer-controller",J.logger)||this;return Q.hls=void 0,Q.fragmentTracker=void 0,Q.details=null,Q._objectUrl=null,Q.operationQueue=null,Q.bufferCodecEventsTotal=0,Q.media=null,Q.mediaSource=null,Q.lastMpegAudioChunk=null,Q.blockedAudioAppend=null,Q.lastVideoAppendEnd=0,Q.appendSource=void 0,Q.transferData=void 0,Q.overrides=void 0,Q.appendErrors={audio:0,video:0,audiovideo:0},Q.tracks={},Q.sourceBuffers=[[null,null],[null,null]],Q._onEndStreaming=function(G){var q;if(!Q.hls)return;if(((q=Q.mediaSource)==null?void 0:q.readyState)!=="open")return;Q.hls.pauseBuffering()},Q._onStartStreaming=function(G){if(!Q.hls)return;Q.hls.resumeBuffering()},Q._onMediaSourceOpen=function(G){var q=Q,H=q.media,V=q.mediaSource;if(G)Q.log("Media source opened");if(!H||!V)return;if(V.removeEventListener("sourceopen",Q._onMediaSourceOpen),H.removeEventListener("emptied",Q._onMediaEmptied),Q.updateDuration(),Q.hls.trigger(M.MEDIA_ATTACHED,{media:H,mediaSource:V}),Q.mediaSource!==null)Q.checkPendingTracks()},Q._onMediaSourceClose=function(){Q.log("Media source closed")},Q._onMediaSourceEnded=function(){Q.log("Media source ended")},Q._onMediaEmptied=function(){var G=Q,q=G.mediaSrc,H=G._objectUrl;if(q!==H)Q.error("Media element src was set while attaching MediaSource ("+H+" > "+q+")")},Q.hls=J,Q.fragmentTracker=Y,Q.appendSource=VX(XY(J.config.preferManagedMediaSource)),Q.initTracks(),Q.registerListeners(),Q}R(W,X);var Z=W.prototype;return Z.hasSourceTypes=function J(){return Object.keys(this.tracks).length>0},Z.destroy=function J(){if(this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue)this.operationQueue.destroy(),this.operationQueue=null;this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.BUFFER_RESET,this.onBufferReset,this),Y.on(M.BUFFER_APPENDING,this.onBufferAppending,this),Y.on(M.BUFFER_CODECS,this.onBufferCodecs,this),Y.on(M.BUFFER_EOS,this.onBufferEos,this),Y.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),Y.on(M.FRAG_PARSED,this.onFragParsed,this),Y.on(M.FRAG_CHANGED,this.onFragChanged,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;Y.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.BUFFER_RESET,this.onBufferReset,this),Y.off(M.BUFFER_APPENDING,this.onBufferAppending,this),Y.off(M.BUFFER_CODECS,this.onBufferCodecs,this),Y.off(M.BUFFER_EOS,this.onBufferEos,this),Y.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),Y.off(M.FRAG_PARSED,this.onFragParsed,this),Y.off(M.FRAG_CHANGED,this.onFragChanged,this),Y.off(M.ERROR,this.onError,this)},Z.transferMedia=function J(){var Y=this,Q=this.media,G=this.mediaSource;if(!Q)return null;var q={};if(this.operationQueue){var H=this.isUpdating();if(!H)this.operationQueue.removeBlockers();var V=this.isQueued();if(H||V)this.warn("Transfering MediaSource with"+(V?" operations in queue":"")+(H?" updating SourceBuffer(s)":"")+" "+this.operationQueue);this.operationQueue.destroy()}var z=this.transferData;if(!this.sourceBufferCount&&z&&z.mediaSource===G)B(q,z.tracks);else this.sourceBuffers.forEach(function(A){var E=A[0];if(E)q[E]=B({},Y.tracks[E]),Y.removeBuffer(E);A[0]=A[1]=null});return{media:Q,mediaSource:G,tracks:q}},Z.initTracks=function J(){var Y={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=Y,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},Z.onManifestLoading=function J(){this.bufferCodecEventsTotal=0,this.details=null},Z.onManifestParsed=function J(Y,Q){var G,q=2;if(Q.audio&&!Q.video||Q.altAudio,q=1,this.bufferCodecEventsTotal=q,this.log(q+" bufferCodec event(s) expected."),(G=this.transferData)!=null&&G.mediaSource&&this.sourceBufferCount&&q)this.bufferCreated()},Z.onMediaAttaching=function J(Y,Q){var G=this.media=Q.media,q=XY(this.appendSource);if(this.transferData=this.overrides=void 0,G&&q){var H=!!Q.mediaSource;if(H||Q.overrides)this.transferData=Q,this.overrides=Q.overrides;var V=this.mediaSource=Q.mediaSource||new q;if(this.assignMediaSource(V),H)this._objectUrl=G.src,this.attachTransferred();else{var z=this._objectUrl=self.URL.createObjectURL(V);if(this.appendSource)try{G.removeAttribute("src");var A=self.ManagedMediaSource;G.disableRemotePlayback=G.disableRemotePlayback||A&&V instanceof A,w2(G),kX(G,z),G.load()}catch(E){G.src=z}else G.src=z}G.addEventListener("emptied",this._onMediaEmptied)}},Z.assignMediaSource=function J(Y){var Q,G;if(this.log((((Q=this.transferData)==null?void 0:Q.mediaSource)===Y?"transferred":"created")+" media source: "+((G=Y.constructor)==null?void 0:G.name)),Y.addEventListener("sourceopen",this._onMediaSourceOpen),Y.addEventListener("sourceended",this._onMediaSourceEnded),Y.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)Y.addEventListener("startstreaming",this._onStartStreaming),Y.addEventListener("endstreaming",this._onEndStreaming)},Z.attachTransferred=function J(){var Y=this,Q=this.media,G=this.transferData;if(!G||!Q)return;var q=this.tracks,H=G.tracks,V=H?Object.keys(H):null,z=V?V.length:0,A=function L(){if(Y.media&&Y.mediaSourceOpenOrEnded)Y._onMediaSourceOpen()};if(H&&V&&z){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
15
+ required tracks: `+O1(q,function(L,b){return L==="initSegment"?void 0:b})+`;
16
+ transfer tracks: `+O1(H,function(L,b){return L==="initSegment"?void 0:b})+"}"),!zX(H,q)){G.mediaSource=null,G.tracks=void 0;var E=Q.currentTime,I=this.details,$=Math.max(E,(I==null?void 0:I.fragments[0].start)||0);if($-E>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+E+" -> "+$);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(H)+'"->"'+Object.keys(q)+'") start time: '+$+" currentTime: "+E),this.onMediaDetaching(M.MEDIA_DETACHING,{}),this.onMediaAttaching(M.MEDIA_ATTACHING,G),Q.currentTime=$;return}this.transferData=void 0,V.forEach(function(L){var b=L,C=H[b];if(C){var D=C.buffer;if(D){var y=Y.fragmentTracker,S=C.id;if(y.hasFragments(S)||y.hasParts(S)){var v=k0.getBuffered(D);y.detectEvictedFragments(b,v,S,null,!0)}var p=dJ(b),g=[b,D];if(Y.sourceBuffers[p]=g,D.updating&&Y.operationQueue)Y.operationQueue.prependBlocker(b);Y.trackSourceBuffer(b,C)}}}),A(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),A()},Z.onMediaDetaching=function J(Y,Q){var G=this,q=!!Q.transferMedia;this.transferData=this.overrides=void 0;var H=this.media,V=this.mediaSource,z=this._objectUrl;if(V){if(this.log("media source "+(q?"transferring":"detaching")),q)this.sourceBuffers.forEach(function($){var L=$[0];if(L)G.removeBuffer(L)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var A=V.readyState==="open";try{var E=V.sourceBuffers;for(var I=E.length;I--;){if(A)E[I].abort();V.removeSourceBuffer(E[I])}if(A)V.endOfStream()}catch($){this.warn("onMediaDetaching: "+$.message+" while calling endOfStream")}}if(this.sourceBufferCount)this.onBufferReset()}if(V.removeEventListener("sourceopen",this._onMediaSourceOpen),V.removeEventListener("sourceended",this._onMediaSourceEnded),V.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)V.removeEventListener("startstreaming",this._onStartStreaming),V.removeEventListener("endstreaming",this._onEndStreaming);this.mediaSource=null,this._objectUrl=null}if(H){if(H.removeEventListener("emptied",this._onMediaEmptied),!q){if(z)self.URL.revokeObjectURL(z);if(this.mediaSrc===z){if(H.removeAttribute("src"),this.appendSource)w2(H);H.load()}else this.warn("media|source.src was changed by a third party - skip cleanup")}this.media=null}this.hls.trigger(M.MEDIA_DETACHED,Q)},Z.onBufferReset=function J(){var Y=this;this.sourceBuffers.forEach(function(Q){var G=Q[0];if(G)Y.resetBuffer(G)}),this.initTracks()},Z.resetBuffer=function J(Y){var Q,G=(Q=this.tracks[Y])==null?void 0:Q.buffer;if(this.removeBuffer(Y),G)try{var q;if((q=this.mediaSource)!=null&&q.sourceBuffers.length)this.mediaSource.removeSourceBuffer(G)}catch(H){this.warn("onBufferReset "+Y,H)}delete this.tracks[Y]},Z.removeBuffer=function J(Y){this.removeBufferListeners(Y),this.sourceBuffers[dJ(Y)]=[null,null];var Q=this.tracks[Y];if(Q)Q.buffer=void 0},Z.resetQueue=function J(){if(this.operationQueue)this.operationQueue.destroy();this.operationQueue=new CX(this.tracks)},Z.onBufferCodecs=function J(Y,Q){var G=this,q=this.tracks,H=Object.keys(Q);this.log('BUFFER_CODECS: "'+H+'" (current SB count '+this.sourceBufferCount+")");var V="audiovideo"in Q&&(q.audio||q.video)||q.audiovideo&&(("audio"in Q)||("video"in Q)),z=!V&&this.sourceBufferCount&&this.media&&H.some(function(A){return!q[A]});if(V||z){this.warn('Unsupported transition between "'+Object.keys(q)+'" and "'+H+'" SourceBuffers');return}if(H.forEach(function(A){var E,I,$,L=Q[A],b=L.id,C=L.codec,D=L.levelCodec,y=L.container,S=L.metadata,v=L.supplemental,p=q[A],g=(E=G.transferData)==null?void 0:(I=E.tracks)==null?void 0:I[A],m=g!=null&&g.buffer?g:p,r=(m==null?void 0:m.pendingCodec)||(m==null?void 0:m.codec),o=m==null?void 0:m.levelCodec;if(!p)p=q[A]={buffer:void 0,listeners:[],codec:C,supplemental:v,container:y,levelCodec:D,metadata:S,id:b};var c=XJ(r,o),d=c==null?void 0:c.replace(E2,"$1"),e=XJ(C,D),H0=($=e)==null?void 0:$.replace(E2,"$1");if(e&&c&&d!==H0){if(A.slice(0,5)==="audio")e=ZJ(e,G.appendSource);if(G.log("switching codec "+r+" to "+e),e!==(p.pendingCodec||p.codec))p.pendingCodec=e;p.container=y,G.appendChangeType(A,y,e)}}),this.tracksReady||this.sourceBufferCount)Q.tracks=this.sourceBufferTracks;if(this.sourceBufferCount)return;if(this.mediaSourceOpenOrEnded)this.checkPendingTracks()},Z.appendChangeType=function J(Y,Q,G){var q=this,H=Q+";codecs="+G,V={label:"change-type="+H,execute:function z(){var A=q.tracks[Y];if(A){var E=A.buffer;if(E!=null&&E.changeType)q.log("changing "+Y+" sourceBuffer type to "+H),E.changeType(H),A.codec=G,A.container=Q}q.shiftAndExecuteNext(Y)},onStart:function z(){},onComplete:function z(){},onError:function z(A){q.warn("Failed to change "+Y+" SourceBuffer type",A)}};this.append(V,Y,this.isPending(this.tracks[Y]))},Z.blockAudio=function J(Y){var Q,G=this,q=Y.start,H=q+Y.duration*0.05,V=((Q=this.fragmentTracker.getAppendedFrag(q,G0.MAIN))==null?void 0:Q.gap)===!0;if(V)return;var z={label:"block-audio",execute:function A(){var E,I=G.tracks.video;if(G.lastVideoAppendEnd>H||I!=null&&I.buffer&&k0.isBuffered(I.buffer,H)||((E=G.fragmentTracker.getAppendedFrag(H,G0.MAIN))==null?void 0:E.gap)===!0)G.blockedAudioAppend=null,G.shiftAndExecuteNext("audio")},onStart:function A(){},onComplete:function A(){},onError:function A(E){G.warn("Error executing block-audio operation",E)}};this.blockedAudioAppend={op:z,frag:Y},this.append(z,"audio",!0)},Z.unblockAudio=function J(){var Y=this.blockedAudioAppend,Q=this.operationQueue;if(Y&&Q)this.blockedAudioAppend=null,Q.unblockAudio(Y.op)},Z.onBufferAppending=function J(Y,Q){var G=this,q=this.tracks,H=Q.data,V=Q.type,z=Q.parent,A=Q.frag,E=Q.part,I=Q.chunkMeta,$=I.buffering[V],L=A.sn,b=self.performance.now();$.start=b;var C=A.stats.buffering,D=E?E.stats.buffering:null;if(C.start===0)C.start=b;if(D&&D.start===0)D.start=b;var y=q.audio,S=!1;if(V==="audio"&&(y==null?void 0:y.container)==="audio/mpeg")S=!this.lastMpegAudioChunk||I.id===1||this.lastMpegAudioChunk.sn!==I.sn,this.lastMpegAudioChunk=I;var v=this.tracks.video,p=v==null?void 0:v.buffer;if(p&&L!=="initSegment"){var g=E||A,m=this.blockedAudioAppend;if(V==="audio"&&z!=="main"&&!this.blockedAudioAppend){var r=g.start,o=r+g.duration*0.05,c=p.buffered,d=this.currentOp("video");if(!c.length&&!d)this.blockAudio(g);else if(!d&&!k0.isBuffered(p,o)&&this.lastVideoAppendEnd<o)this.blockAudio(g)}else if(V==="video"){var e=g.end;if(m){var H0=m.frag.start;if(e>H0||e<this.lastVideoAppendEnd||k0.isBuffered(p,H0))this.unblockAudio()}this.lastVideoAppendEnd=e}}var Q0=(E||A).start,J0={label:"append-"+V,execute:function N0(){if($.executeStart=self.performance.now(),S){var V0=G.tracks[V];if(V0){var j0=V0.buffer;if(j0){var O0=Q0-j0.timestampOffset;if(Math.abs(O0)>=0.1)G.log("Updating audio SourceBuffer timestampOffset to "+Q0+" (delta: "+O0+") sn: "+L+")"),j0.timestampOffset=Q0}}}G.appendExecutor(H,V)},onStart:function N0(){},onComplete:function N0(){var V0=self.performance.now();if($.executeEnd=$.end=V0,C.first===0)C.first=V0;if(D&&D.first===0)D.first=V0;var j0={};if(G.sourceBuffers.forEach(function(O0){var g0=O0[0],T0=O0[1];if(g0)j0[g0]=k0.getBuffered(T0)}),G.appendErrors[V]=0,V==="audio"||V==="video")G.appendErrors.audiovideo=0;else G.appendErrors.audio=0,G.appendErrors.video=0;G.hls.trigger(M.BUFFER_APPENDED,{type:V,frag:A,part:E,chunkMeta:I,parent:A.type,timeRanges:j0})},onError:function N0(V0){var j0,O0={type:n.MEDIA_ERROR,parent:A.type,details:h.BUFFER_APPEND_ERROR,sourceBufferName:V,frag:A,part:E,chunkMeta:I,error:V0,err:V0,fatal:!1};if(V0.code===DOMException.QUOTA_EXCEEDED_ERR)O0.details=h.BUFFER_FULL_ERROR;else if(V0.code===DOMException.INVALID_STATE_ERR&&G.mediaSourceOpenOrEnded&&!((j0=G.media)!=null&&j0.error))O0.errorAction=HJ(!0);else if(V0.name===B2)if(G.sourceBufferCount===0)O0.errorAction=HJ(!0);else++G.appendErrors[V];else{var g0=++G.appendErrors[V];if(G.warn("Failed "+g0+"/"+G.hls.config.appendErrorMaxRetry+' times to append segment in "'+V+'" sourceBuffer'),g0>=G.hls.config.appendErrorMaxRetry)O0.fatal=!0}G.hls.trigger(M.ERROR,O0)}};this.append(J0,V,this.isPending(this.tracks[V]))},Z.getFlushOp=function J(Y,Q,G){var q=this;return this.log('queuing "'+Y+'" remove '+Q+"-"+G),{label:"remove",execute:function H(){q.removeExecutor(Y,Q,G)},onStart:function H(){},onComplete:function H(){q.hls.trigger(M.BUFFER_FLUSHED,{type:Y})},onError:function H(V){q.warn("Failed to remove "+Q+"-"+G+' from "'+Y+'" SourceBuffer',V)}}},Z.onBufferFlushing=function J(Y,Q){var G=this,q=Q.type,H=Q.startOffset,V=Q.endOffset;if(q)this.append(this.getFlushOp(q,H,V),q);else this.sourceBuffers.forEach(function(z){var A=z[0];if(A)G.append(G.getFlushOp(A,H,V),A)})},Z.onFragParsed=function J(Y,Q){var G=this,q=Q.frag,H=Q.part,V=[],z=H?H.elementaryStreams:q.elementaryStreams;if(z[i0.AUDIOVIDEO])V.push("audiovideo");else{if(z[i0.AUDIO])V.push("audio");if(z[i0.VIDEO])V.push("video")}var A=function E(){var I=self.performance.now();if(q.stats.buffering.end=I,H)H.stats.buffering.end=I;var $=H?H.stats:q.stats;G.hls.trigger(M.FRAG_BUFFERED,{frag:q,part:H,stats:$,id:q.type})};if(V.length===0)this.warn("Fragments must have at least one ElementaryStreamType set. type: "+q.type+" level: "+q.level+" sn: "+q.sn);this.blockBuffers(A,V)},Z.onFragChanged=function J(Y,Q){this.trimBuffers()},Z.onBufferEos=function J(Y,Q){var G=this,q;this.sourceBuffers.forEach(function(z){var A=z[0];if(A){var E=G.tracks[A];if(!Q.type||Q.type===A){if(E.ending=!0,!E.ended)E.ended=!0,G.log(A+" buffer reached EOS")}}});var H=((q=this.overrides)==null?void 0:q.endOfStream)!==!1,V=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(z){var A,E=z[0];return E&&!((A=G.tracks[E])!=null&&A.ended)});if(V)if(H)this.log("Queueing EOS"),this.blockUntilOpen(function(){G.tracksEnded();var z=G.mediaSource;if(!z||z.readyState!=="open"){if(z)G.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+z.readyState);return}G.log("Calling mediaSource.endOfStream()"),z.endOfStream(),G.hls.trigger(M.BUFFERED_TO_END,void 0)});else this.tracksEnded(),this.hls.trigger(M.BUFFERED_TO_END,void 0)},Z.tracksEnded=function J(){var Y=this;this.sourceBuffers.forEach(function(Q){var G=Q[0];if(G!==null){var q=Y.tracks[G];if(q)q.ending=!1}})},Z.onLevelUpdated=function J(Y,Q){var G=Q.details;if(!G.fragments.length)return;this.details=G,this.updateDuration()},Z.updateDuration=function J(){var Y=this,Q=this.getDurationAndRange();if(!Q)return;this.blockUntilOpen(function(){return Y.updateMediaSource(Q)})},Z.onError=function J(Y,Q){if(Q.details===h.BUFFER_APPEND_ERROR&&Q.frag){var G,q=(G=Q.errorAction)==null?void 0:G.nextAutoLevel;if(T(q)&&q!==Q.frag.level)this.resetAppendErrors()}},Z.resetAppendErrors=function J(){this.appendErrors={audio:0,video:0,audiovideo:0}},Z.trimBuffers=function J(){var Y=this.hls,Q=this.details,G=this.media;if(!G||Q===null)return;if(!this.sourceBufferCount)return;var q=Y.config,H=G.currentTime,V=Q.levelTargetDuration,z=Q.live&&q.liveBackBufferLength!==null?q.liveBackBufferLength:q.backBufferLength;if(T(z)&&z>=0){var A=Math.max(z,V),E=Math.floor(H/V)*V-A;this.flushBackBuffer(H,V,E)}if(T(q.frontBufferFlushThreshold)&&q.frontBufferFlushThreshold>0){var I=Math.max(q.maxBufferLength,q.frontBufferFlushThreshold),$=Math.max(I,V),L=Math.floor(H/V)*V+$;this.flushFrontBuffer(H,V,L)}},Z.flushBackBuffer=function J(Y,Q,G){var q=this;this.sourceBuffers.forEach(function(H){var V=H[0],z=H[1];if(z){var A=k0.getBuffered(z);if(A.length>0&&G>A.start(0)){var E;q.hls.trigger(M.BACK_BUFFER_REACHED,{bufferEnd:G});var I=q.tracks[V];if((E=q.details)!=null&&E.live)q.hls.trigger(M.LIVE_BACK_BUFFER_REACHED,{bufferEnd:G});else if(I!=null&&I.ended){q.log("Cannot flush "+V+" back buffer while SourceBuffer is in ended state");return}q.hls.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:G,type:V})}}})},Z.flushFrontBuffer=function J(Y,Q,G){var q=this;this.sourceBuffers.forEach(function(H){var V=H[0],z=H[1];if(z){var A=k0.getBuffered(z),E=A.length;if(E<2)return;var I=A.start(E-1),$=A.end(E-1);if(G>I||Y>=I&&Y<=$)return;q.hls.trigger(M.BUFFER_FLUSHING,{startOffset:I,endOffset:1/0,type:V})}})},Z.getDurationAndRange=function J(){var Y,Q=this.details,G=this.mediaSource;if(!Q||!this.media||(G==null?void 0:G.readyState)!=="open")return null;var q=Q.edge;if(Q.live&&this.hls.config.liveDurationInfinity){var H=Q.fragments.length;if(H&&Q.live&&!!G.setLiveSeekableRange){var V=Math.max(0,Q.fragmentStart),z=Math.max(V,q);return{duration:1/0,start:V,end:z}}return{duration:1/0}}var A=(Y=this.overrides)==null?void 0:Y.duration;if(A){if(!T(A))return null;return{duration:A}}var E=this.media.duration,I=T(G.duration)?G.duration:0;if(q>I&&q>E||!T(E))return{duration:q};return null},Z.updateMediaSource=function J(Y){var{duration:Q,start:G,end:q}=Y,H=this.mediaSource;if(!this.media||!H||H.readyState!=="open")return;if(H.duration!==Q){if(T(Q))this.log("Updating MediaSource duration to "+Q.toFixed(3));H.duration=Q}if(G!==void 0&&q!==void 0)this.log("MediaSource duration is set to "+H.duration+". Setting seekable range to "+G+"-"+q+"."),H.setLiveSeekableRange(G,q)},Z.checkPendingTracks=function J(){var Y=this.bufferCodecEventsTotal,Q=this.pendingTrackCount,G=this.tracks;if(this.log("checkPendingTracks (pending: "+Q+" codec events expected: "+Y+") "+O1(G)),this.tracksReady){var q,H=(q=this.transferData)==null?void 0:q.tracks;if(H&&Object.keys(H).length)this.attachTransferred();else this.createSourceBuffers()}},Z.bufferCreated=function J(){var Y=this;if(this.sourceBufferCount){var Q={};this.sourceBuffers.forEach(function(q){var H=q[0],V=q[1];if(H){var z=Y.tracks[H];Q[H]={buffer:V,container:z.container,codec:z.codec,supplemental:z.supplemental,levelCodec:z.levelCodec,id:z.id,metadata:z.metadata}}}),this.hls.trigger(M.BUFFER_CREATED,{tracks:Q}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(q){var H=q[0];Y.executeNext(H)})}else{var G=new Error("could not create source buffer for media codec(s)");this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:G,reason:G.message})}},Z.createSourceBuffers=function J(){var Y=this.tracks,Q=this.sourceBuffers,G=this.mediaSource;if(!G)throw new Error("createSourceBuffers called when mediaSource was null");for(var q in Y){var H=q,V=Y[H];if(this.isPending(V)){var z=this.getTrackCodec(V,H),A=V.container+";codecs="+z;V.codec=z,this.log("creating sourceBuffer("+A+")"+(this.currentOp(H)?" Queued":"")+" "+O1(V));try{var E=G.addSourceBuffer(A),I=dJ(H),$=[H,E];Q[I]=$,V.buffer=E}catch(b){var L;this.error("error while trying to add sourceBuffer: "+b.message),this.shiftAndExecuteNext(H),(L=this.operationQueue)==null||L.removeBlockers(),delete this.tracks[H],this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:b,sourceBufferName:H,mimeType:A,parent:V.id});return}this.trackSourceBuffer(H,V)}}this.bufferCreated()},Z.getTrackCodec=function J(Y,Q){var{supplemental:G,codec:q}=Y;if(G&&(Q==="video"||Q==="audiovideo")&&_J(G,"video"))q=OX(q,G);var H=XJ(q,Y.levelCodec);if(H){if(Q.slice(0,5)==="audio")return ZJ(H,this.appendSource);return H}return""},Z.trackSourceBuffer=function J(Y,Q){var G=this,q=Q.buffer;if(!q)return;var H=this.getTrackCodec(Q,Y);if(this.tracks[Y]={buffer:q,codec:H,container:Q.container,levelCodec:Q.levelCodec,supplemental:Q.supplemental,metadata:Q.metadata,id:Q.id,listeners:[]},this.removeBufferListeners(Y),this.addBufferListener(Y,"updatestart",this.onSBUpdateStart),this.addBufferListener(Y,"updateend",this.onSBUpdateEnd),this.addBufferListener(Y,"error",this.onSBUpdateError),this.appendSource)this.addBufferListener(Y,"bufferedchange",function(V,z){var A=z.removedRanges;if(A!=null&&A.length)G.hls.trigger(M.BUFFER_FLUSHED,{type:V})})},Z.onSBUpdateStart=function J(Y){var Q=this.currentOp(Y);if(!Q)return;Q.onStart()},Z.onSBUpdateEnd=function J(Y){var Q;if(((Q=this.mediaSource)==null?void 0:Q.readyState)==="closed"){this.resetBuffer(Y);return}var G=this.currentOp(Y);if(!G)return;G.onComplete(),this.shiftAndExecuteNext(Y)},Z.onSBUpdateError=function J(Y,Q){var G,q=new Error(Y+" SourceBuffer error. MediaSource readyState: "+((G=this.mediaSource)==null?void 0:G.readyState));this.error(""+q,Q),this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_APPENDING_ERROR,sourceBufferName:Y,error:q,fatal:!1});var H=this.currentOp(Y);if(H)H.onError(q)},Z.removeExecutor=function J(Y,Q,G){var q=this.media,H=this.mediaSource,V=this.tracks[Y],z=V==null?void 0:V.buffer;if(!q||!H||!z){this.warn("Attempting to remove from the "+Y+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(Y);return}var A=T(q.duration)?q.duration:1/0,E=T(H.duration)?H.duration:1/0,I=Math.max(0,Q),$=Math.min(G,A,E);if($>I&&(!V.ending||V.ended))V.ended=!1,this.log("Removing ["+I+","+$+"] from the "+Y+" SourceBuffer"),z.remove(I,$);else this.shiftAndExecuteNext(Y)},Z.appendExecutor=function J(Y,Q){var G=this.tracks[Q],q=G==null?void 0:G.buffer;if(!q)throw new vX("Attempting to append to the "+Q+" SourceBuffer, but it does not exist");G.ending=!1,G.ended=!1,q.appendBuffer(Y)},Z.blockUntilOpen=function J(Y){if(this.isUpdating()||this.isQueued())this.blockBuffers(Y);else Y()},Z.isUpdating=function J(){return this.sourceBuffers.some(function(Y){var Q=Y[0],G=Y[1];return Q&&G.updating})},Z.isQueued=function J(){var Y=this;return this.sourceBuffers.some(function(Q){var G=Q[0];return G&&!!Y.currentOp(G)})},Z.isPending=function J(Y){return!!Y&&!Y.buffer},Z.blockBuffers=function J(Y,Q){var G=this;if(Q===void 0)Q=this.sourceBufferTypes;if(!Q.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(Y);return}var q=this.operationQueue,H=Q.map(function(z){return G.appendBlocker(z)}),V=Q.length>1&&!!this.blockedAudioAppend;if(V)this.unblockAudio();Promise.all(H).then(function(z){if(q!==G.operationQueue)return;Y(),G.stepOperationQueue(Q)})},Z.stepOperationQueue=function J(Y){var Q=this;Y.forEach(function(G){var q,H=(q=Q.tracks[G])==null?void 0:q.buffer;if(!H||H.updating)return;Q.shiftAndExecuteNext(G)})},Z.append=function J(Y,Q,G){if(this.operationQueue)this.operationQueue.append(Y,Q,G)},Z.appendBlocker=function J(Y){if(this.operationQueue)return this.operationQueue.appendBlocker(Y)},Z.currentOp=function J(Y){if(this.operationQueue)return this.operationQueue.current(Y);return null},Z.executeNext=function J(Y){if(Y&&this.operationQueue)this.operationQueue.executeNext(Y)},Z.shiftAndExecuteNext=function J(Y){if(this.operationQueue)this.operationQueue.shiftAndExecuteNext(Y)},Z.addBufferListener=function J(Y,Q,G){var q=this.tracks[Y];if(!q)return;var H=q.buffer;if(!H)return;var V=G.bind(this,Y);q.listeners.push({event:Q,listener:V}),H.addEventListener(Q,V)},Z.removeBufferListeners=function J(Y){var Q=this.tracks[Y];if(!Q)return;var G=Q.buffer;if(!G)return;Q.listeners.forEach(function(q){G.removeEventListener(q.event,q.listener)}),Q.listeners.length=0},N(W,[{key:"mediaSourceOpenOrEnded",get:function J(){var Y,Q=(Y=this.mediaSource)==null?void 0:Y.readyState;return Q==="open"||Q==="ended"}},{key:"sourceBufferTracks",get:function J(){var Y=this;return Object.keys(this.tracks).reduce(function(Q,G){var q=Y.tracks[G];return Q[G]={id:q.id,container:q.container,codec:q.codec,levelCodec:q.levelCodec},Q},{})}},{key:"bufferedToEnd",get:function J(){var Y=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(Q){var G,q,H=Q[0];return H&&(!((G=Y.tracks[H])!=null&&G.ended)||((q=Y.tracks[H])==null?void 0:q.ending))})}},{key:"tracksReady",get:function J(){var Y=this.pendingTrackCount;return Y>0&&(Y>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function J(){var Y,Q,G=((Y=this.media)==null?void 0:(Q=Y.querySelector)==null?void 0:Q.call(Y,"source"))||this.media;return G==null?void 0:G.src}},{key:"pendingTrackCount",get:function J(){var Y=this;return Object.keys(this.tracks).reduce(function(Q,G){return Q+(Y.isPending(Y.tracks[G])?1:0)},0)}},{key:"sourceBufferCount",get:function J(){return this.sourceBuffers.reduce(function(Y,Q){var G=Q[0];return Y+(G?1:0)},0)}},{key:"sourceBufferTypes",get:function J(){return this.sourceBuffers.map(function(Y){var Q=Y[0];return Q}).filter(function(Y){return!!Y})}}])}(d0);function w2(X){var W=X.querySelectorAll("source");[].slice.call(W).forEach(function(Z){X.removeChild(Z)})}function kX(X,W){var Z=self.document.createElement("source");Z.type="video/mp4",Z.src=W,X.appendChild(Z)}function dJ(X){return X==="audio"?1:0}var gX=function(){function X(Z){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=Z,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var W=X.prototype;return W.setStreamController=function Z(J){this.streamController=J},W.destroy=function Z(){if(this.hls)this.unregisterListener();if(this.timer)this.stopCapping();this.media=null,this.clientRect=null,this.hls=this.streamController=null},W.registerListeners=function Z(){var J=this.hls;J.on(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),J.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.on(M.MANIFEST_PARSED,this.onManifestParsed,this),J.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),J.on(M.BUFFER_CODECS,this.onBufferCodecs,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.unregisterListener=function Z(){var J=this.hls;J.off(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),J.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.off(M.MANIFEST_PARSED,this.onManifestParsed,this),J.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),J.off(M.BUFFER_CODECS,this.onBufferCodecs,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.onFpsDropLevelCapping=function Z(J,Y){var Q=this.hls.levels[Y.droppedLevel];if(this.isLevelAllowed(Q))this.restrictedLevels.push({bitrate:Q.bitrate,height:Q.height,width:Q.width})},W.onMediaAttaching=function Z(J,Y){if(this.media=Y.media instanceof HTMLVideoElement?Y.media:null,this.clientRect=null,this.timer&&this.hls.levels.length)this.detectPlayerSize()},W.onManifestParsed=function Z(J,Y){var Q=this.hls;if(this.restrictedLevels=[],this.firstLevel=Y.firstLevel,Q.config.capLevelToPlayerSize&&Y.video)this.startCapping()},W.onLevelsUpdated=function Z(J,Y){if(this.timer&&T(this.autoLevelCapping))this.detectPlayerSize()},W.onBufferCodecs=function Z(J,Y){var Q=this.hls;if(Q.config.capLevelToPlayerSize&&Y.video)this.startCapping()},W.onMediaDetaching=function Z(){this.stopCapping(),this.media=null},W.detectPlayerSize=function Z(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var J=this.hls.levels;if(J.length){var Y=this.hls,Q=this.getMaxLevel(J.length-1);if(Q!==this.autoLevelCapping)Y.logger.log("Setting autoLevelCapping to "+Q+": "+J[Q].height+"p@"+J[Q].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight);if(Y.autoLevelCapping=Q,Y.autoLevelEnabled&&Y.autoLevelCapping>this.autoLevelCapping&&this.streamController)this.streamController.nextLevelSwitch();this.autoLevelCapping=Y.autoLevelCapping}}},W.getMaxLevel=function Z(J){var Y=this,Q=this.hls.levels;if(!Q.length)return-1;var G=Q.filter(function(q,H){return Y.isLevelAllowed(q)&&H<=J});return this.clientRect=null,X.getMaxLevelByMediaSize(G,this.mediaWidth,this.mediaHeight)},W.startCapping=function Z(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1000),this.detectPlayerSize()},W.stopCapping=function Z(){if(this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer)self.clearInterval(this.timer),this.timer=void 0},W.getDimensions=function Z(){if(this.clientRect)return this.clientRect;var J=this.media,Y={width:0,height:0};if(J){var Q=J.getBoundingClientRect();if(Y.width=Q.width,Y.height=Q.height,!Y.width&&!Y.height)Y.width=Q.right-Q.left||J.width||0,Y.height=Q.bottom-Q.top||J.height||0}return this.clientRect=Y,Y},W.isLevelAllowed=function Z(J){var Y=this.restrictedLevels;return!Y.some(function(Q){return J.bitrate===Q.bitrate&&J.width===Q.width&&J.height===Q.height})},X.getMaxLevelByMediaSize=function Z(J,Y,Q){if(!(J!=null&&J.length))return-1;var G=function A(E,I){if(!I)return!0;return E.width!==I.width||E.height!==I.height},q=J.length-1,H=Math.max(Y,Q);for(var V=0;V<J.length;V+=1){var z=J[V];if((z.width>=H||z.height>=H)&&G(z,J[V+1])){q=V;break}}return q},N(X,[{key:"mediaWidth",get:function Z(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function Z(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function Z(){var J=1;if(!this.hls.config.ignoreDevicePixelRatio)try{J=self.devicePixelRatio}catch(Y){}return Math.min(J,this.hls.config.maxDevicePixelRatio)}}])}(),uX=/^(\d+)x(\d+)$/,R2=/(.+?)=(".*?"|.*?)(?:,|$)/g,Q1=function(){function X(Z,J){if(typeof Z==="string")Z=X.parseAttrList(Z,J);B(this,Z)}var W=X.prototype;return W.decimalInteger=function Z(J){var Y=parseInt(this[J],10);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},W.hexadecimalInteger=function Z(J){if(this[J]){var Y=(this[J]||"0x").slice(2);Y=(Y.length&1?"0":"")+Y;var Q=new Uint8Array(Y.length/2);for(var G=0;G<Y.length/2;G++)Q[G]=parseInt(Y.slice(G*2,G*2+2),16);return Q}return null},W.hexadecimalIntegerAsNumber=function Z(J){var Y=parseInt(this[J],16);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},W.decimalFloatingPoint=function Z(J){return parseFloat(this[J])},W.optionalFloat=function Z(J,Y){var Q=this[J];return Q?parseFloat(Q):Y},W.enumeratedString=function Z(J){return this[J]},W.enumeratedStringList=function Z(J,Y){var Q=this[J];return(Q?Q.split(/[ ,]+/):[]).reduce(function(G,q){return G[q.toLowerCase()]=!0,G},Y)},W.bool=function Z(J){return this[J]==="YES"},W.decimalResolution=function Z(J){var Y=uX.exec(this[J]);if(Y===null)return;return{width:parseInt(Y[1],10),height:parseInt(Y[2],10)}},X.parseAttrList=function Z(J,Y){var Q,G={},q='"';R2.lastIndex=0;while((Q=R2.exec(J))!==null){var H=Q[1].trim(),V=Q[2],z=V.indexOf(q)===0&&V.lastIndexOf(q)===V.length-1,A=!1;if(z)V=V.slice(1,-1);else switch(H){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":A=!0}if(Y&&(z||A));else if(!A&&!z)switch(H){case"CLOSED-CAPTIONS":if(V==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":v0.warn(J+": attribute "+H+" is missing quotes")}G[H]=V}return G},N(X,[{key:"clientAttrs",get:function Z(){return Object.keys(this).filter(function(J){return J.substring(0,2)==="X-"})}}])}(),mX="com.apple.hls.interstitial";function _X(X){return X!=="ID"&&X!=="CLASS"&&X!=="CUE"&&X!=="START-DATE"&&X!=="DURATION"&&X!=="END-DATE"&&X!=="END-ON-NEXT"}function pX(X){return X==="SCTE35-OUT"||X==="SCTE35-IN"||X==="SCTE35-CMD"}var $2=function(){function X(W,Z,J){var Y;if(J===void 0)J=0;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(Z==null?void 0:Z.tagAnchor)||null,this.tagOrder=(Y=Z==null?void 0:Z.tagOrder)!=null?Y:J,Z){var Q=Z.attr;for(var G in Q)if(Object.prototype.hasOwnProperty.call(W,G)&&W[G]!==Q[G]){v0.warn('DATERANGE tag attribute: "'+G+'" does not match for tags with ID: "'+W.ID+'"'),this._badValueForSameId=G;break}W=B(new Q1({}),Q,W)}if(this.attr=W,Z)this._startDate=Z._startDate,this._cue=Z._cue,this._endDate=Z._endDate,this._dateAtEnd=Z._dateAtEnd;else this._startDate=new Date(W["START-DATE"]);if("END-DATE"in this.attr){var q=(Z==null?void 0:Z.endDate)||new Date(this.attr["END-DATE"]);if(T(q.getTime()))this._endDate=q}}return N(X,[{key:"id",get:function W(){return this.attr.ID}},{key:"class",get:function W(){return this.attr.CLASS}},{key:"cue",get:function W(){var Z=this._cue;if(Z===void 0)return this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1});return Z}},{key:"startTime",get:function W(){var Z=this.tagAnchor;if(Z===null||Z.programDateTime===null)return v0.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+Z),NaN;return Z.start+(this.startDate.getTime()-Z.programDateTime)/1000}},{key:"startDate",get:function W(){return this._startDate}},{key:"endDate",get:function W(){var Z=this._endDate||this._dateAtEnd;if(Z)return Z;var J=this.duration;if(J!==null)return this._dateAtEnd=new Date(this._startDate.getTime()+J*1000);return null}},{key:"duration",get:function W(){if("DURATION"in this.attr){var Z=this.attr.decimalFloatingPoint("DURATION");if(T(Z))return Z}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1000;return null}},{key:"plannedDuration",get:function W(){if("PLANNED-DURATION"in this.attr)return this.attr.decimalFloatingPoint("PLANNED-DURATION");return null}},{key:"endOnNext",get:function W(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function W(){return this.class===mX}},{key:"isValid",get:function W(){return!!this.id&&!this._badValueForSameId&&T(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||("X-ASSET-URI"in this.attr)||("X-ASSET-LIST"in this.attr))}}])}(),fX=10,cX=function(){function X(Z){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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=Z}var W=X.prototype;return W.reloaded=function Z(J){if(!J){this.advanced=!0,this.updated=!0;return}var Y=this.lastPartSn-J.lastPartSn,Q=this.lastPartIndex-J.lastPartIndex;if(this.updated=this.endSN!==J.endSN||!!Q||!!Y||!this.live,this.advanced=this.endSN>J.endSN||Y>0||Y===0&&Q>0,this.updated||this.advanced)this.misses=Math.floor(J.misses*0.6);else this.misses=J.misses+1},N(X,[{key:"hasProgramDateTime",get:function Z(){if(this.fragments.length)return T(this.fragments[this.fragments.length-1].programDateTime);return!1}},{key:"levelTargetDuration",get:function Z(){return this.averagetargetduration||this.targetduration||fX}},{key:"drift",get:function Z(){var J=this.driftEndTime-this.driftStartTime;if(J>0){var Y=this.driftEnd-this.driftStart;return Y*1000/J}return 1}},{key:"edge",get:function Z(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function Z(){var J;if((J=this.partList)!=null&&J.length)return this.partList[this.partList.length-1].end;return this.fragmentEnd}},{key:"fragmentEnd",get:function Z(){var J;if((J=this.fragments)!=null&&J.length)return this.fragments[this.fragments.length-1].end;return 0}},{key:"fragmentStart",get:function Z(){var J;if((J=this.fragments)!=null&&J.length)return this.fragments[0].start;return 0}},{key:"age",get:function Z(){if(this.advancedDateTime)return Math.max(Date.now()-this.advancedDateTime,0)/1000;return 0}},{key:"lastPartIndex",get:function Z(){var J;if((J=this.partList)!=null&&J.length)return this.partList[this.partList.length-1].index;return-1}},{key:"maxPartIndex",get:function Z(){var J=this.partList;if(J){var Y=this.lastPartIndex;if(Y!==-1){for(var Q=J.length;Q--;)if(J[Q].index>Y)return J[Q].index;return Y}}return 0}},{key:"lastPartSn",get:function Z(){var J;if((J=this.partList)!=null&&J.length)return this.partList[this.partList.length-1].fragment.sn;return this.endSN}},{key:"expired",get:function Z(){if(this.live&&this.age&&this.misses<3){var J=this.partEnd-this.fragmentStart;return this.age>Math.max(J,this.totalduration)+this.levelTargetDuration}return!1}}])}(),GY={cbc:0,ctr:1};function vY(X){return X==="AES-128"||X==="AES-256"||X==="AES-256-CTR"}function I2(X){switch(X){case"AES-128":case"AES-256":return GY.cbc;case"AES-256-CTR":return GY.ctr;default:throw new Error("invalid full segment method "+X)}}var lX=function(){function X(Z,J,Y,Q,G){if(Q===void 0)Q=[1];if(G===void 0)G=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=Z,this.uri=J,this.keyFormat=Y,this.keyFormatVersions=Q,this.iv=G,this.encrypted=Z?Z!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!vY(Z)}X.clearKeyUriToKeyIdMap=function Z(){};var W=X.prototype;return W.isSupported=function Z(){if(this.method){if(vY(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},W.getDecryptData=function Z(J){if(!this.encrypted||!this.uri)return null;if(vY(this.method)&&this.uri&&!this.iv){if(typeof J!=="number")v0.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),J=0;var Y=dX(J),Q=new X(this.method,this.uri,"identity",this.keyFormatVersions,Y);return Q}return this},X}();function dX(X){var W=new Uint8Array(16);for(var Z=12;Z<16;Z++)W[Z]=X>>8*(15-Z)&255;return W}var L2=/#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,b2=/#EXT-X-MEDIA:(.*)/g,nX=/^#EXT(?:INF|-X-TARGETDURATION):/m,nJ=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),oX=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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("|")),hY=function(){function X(){}return X.findGroup=function W(Z,J){for(var Y=0;Y<Z.length;Y++){var Q=Z[Y];if(Q.id===J)return Q}},X.resolve=function W(Z,J){return t0.buildAbsoluteURL(J,Z,{alwaysNormalize:!0})},X.isMediaPlaylist=function W(Z){return nX.test(Z)},X.parseMasterPlaylist=function W(Z,J){var Y=!1,Q={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Y},G=[];L2.lastIndex=0;var q;while((q=L2.exec(Z))!=null)if(q[1]){var H,V=new Q1(q[1],Q),z=q[2],A={attrs:V,bitrate:V.decimalInteger("BANDWIDTH")||V.decimalInteger("AVERAGE-BANDWIDTH"),name:V.NAME,url:X.resolve(z,J)},E=V.decimalResolution("RESOLUTION");if(E)A.width=E.width,A.height=E.height;S2(V.CODECS,A);var I=V["SUPPLEMENTAL-CODECS"];if(I)A.supplemental={},S2(I,A.supplemental);if(!((H=A.unknownCodecs)!=null&&H.length))G.push(A);Q.levels.push(A)}else if(q[3]){var $=q[3],L=q[4];switch($){case"SESSION-DATA":{var b=new Q1(L,Q),C=b["DATA-ID"];if(C){if(Q.sessionData===null)Q.sessionData={};Q.sessionData[C]=b}break}case"SESSION-KEY":{var D=C2(L,J,Q);if(D.encrypted&&D.isSupported()){if(Q.sessionKeys===null)Q.sessionKeys=[];Q.sessionKeys.push(D)}else v0.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+L+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var y=new Q1(L,Q);Q.contentSteering={uri:X.resolve(y["SERVER-URI"],J),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{Q.startTimeOffset=D2(L);break}}}var S=G.length>0&&G.length<Q.levels.length;if(Q.levels=S?G:Q.levels,Q.levels.length===0)Q.playlistParsingError=new Error("no levels found in manifest");return Q},X.parseMasterPlaylistMedia=function W(Z,J,Y){var Q,G={},q=Y.levels,H={AUDIO:q.map(function(v){return{id:v.attrs.AUDIO,audioCodec:v.audioCodec}}),SUBTITLES:q.map(function(v){return{id:v.attrs.SUBTITLES,textCodec:v.textCodec}}),"CLOSED-CAPTIONS":[]},V=0;b2.lastIndex=0;while((Q=b2.exec(Z))!==null){var z=new Q1(Q[1],Y),A=z.TYPE;if(A){var E=H[A],I=G[A]||[];G[A]=I;var $=z.LANGUAGE,L=z["ASSOC-LANGUAGE"],b=z.CHANNELS,C=z.CHARACTERISTICS,D=z["INSTREAM-ID"],y={attrs:z,bitrate:0,id:V++,groupId:z["GROUP-ID"]||"",name:z.NAME||$||"",type:A,default:z.bool("DEFAULT"),autoselect:z.bool("AUTOSELECT"),forced:z.bool("FORCED"),lang:$,url:z.URI?X.resolve(z.URI,J):""};if(L)y.assocLang=L;if(b)y.channels=b;if(C)y.characteristics=C;if(D)y.instreamId=D;if(E!=null&&E.length){var S=X.findGroup(E,y.groupId)||E[0];P2(y,S,"audioCodec"),P2(y,S,"textCodec")}I.push(y)}}return G},X.parseLevelPlaylist=function W(Z,J,Y,Q,G,q){var H,V={url:J},z=new cX(J),A=z.fragments,E=[],I=null,$=0,L=0,b=0,C=0,D=0,y=null,S=new kJ(Q,V),v,p,g,m=-1,r=!1,o=null,c;if(nJ.lastIndex=0,z.m3u8=Z,z.hasVariableRefs=!1,((H=nJ.exec(Z))==null?void 0:H[0])!=="#EXTM3U")return z.playlistParsingError=new Error("Missing format identifier #EXTM3U"),z;while((v=nJ.exec(Z))!==null){if(r){if(r=!1,S=new kJ(Q,V),S.playlistOffset=b,S.start=b,S.sn=$,S.cc=C,D)S.bitrate=D;if(S.level=Y,I){if(S.initSegment=I,I.rawProgramDateTime)S.rawProgramDateTime=I.rawProgramDateTime,I.rawProgramDateTime=null;if(o)S.setByteRange(o),o=null}}var d=v[1];if(d){S.duration=parseFloat(d);var e=(" "+v[2]).slice(1);S.title=e||null,S.tagList.push(e?["INF",d,e]:["INF",d])}else if(v[3]){if(T(S.duration)){if(S.playlistOffset=b,S.start=b,g)T2(S,g,z);S.sn=$,S.level=Y,S.cc=C,A.push(S);var H0=(" "+v[3]).slice(1);S.relurl=H0,oJ(S,y,E),y=S,b+=S.duration,$++,L=0,r=!0}}else{if(v=v[0].match(oX),!v){v0.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<v.length;p++)if(v[p]!==void 0)break;var Q0=(" "+v[p]).slice(1),J0=(" "+v[p+1]).slice(1),N0=v[p+2]?(" "+v[p+2]).slice(1):null;switch(Q0){case"BYTERANGE":if(y)S.setByteRange(J0,y);else S.setByteRange(J0);break;case"PROGRAM-DATE-TIME":if(S.rawProgramDateTime=J0,S.tagList.push(["PROGRAM-DATE-TIME",J0]),m===-1)m=A.length;break;case"PLAYLIST-TYPE":if(z.type)a1(z,Q0,v);z.type=J0.toUpperCase();break;case"MEDIA-SEQUENCE":if(z.startSN!==0)a1(z,Q0,v);else if(A.length>0)x2(z,Q0,v);$=z.startSN=parseInt(J0);break;case"SKIP":{if(z.skippedSegments)a1(z,Q0,v);var V0=new Q1(J0,z),j0=V0.decimalInteger("SKIPPED-SEGMENTS");if(T(j0)){z.skippedSegments+=j0;for(var O0=j0;O0--;)A.push(null);$+=j0}var g0=V0.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(g0)z.recentlyRemovedDateranges=(z.recentlyRemovedDateranges||[]).concat(g0.split("\t"));break}case"TARGETDURATION":if(z.targetduration!==0)a1(z,Q0,v);z.targetduration=Math.max(parseInt(J0),1);break;case"VERSION":if(z.version!==null)a1(z,Q0,v);z.version=parseInt(J0);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":if(!z.live)a1(z,Q0,v);z.live=!1;break;case"#":if(J0||N0)S.tagList.push(N0?[J0,N0]:[J0]);break;case"DISCONTINUITY":C++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([Q0]);break;case"BITRATE":if(S.tagList.push([Q0,J0]),D=parseInt(J0)*1000,T(D))S.bitrate=D;else D=0;break;case"DATERANGE":{var T0=new Q1(J0,z),m0=new $2(T0,z.dateRanges[T0.ID],z.dateRangeTagCount);if(z.dateRangeTagCount++,m0.isValid||z.skippedSegments)z.dateRanges[m0.id]=m0;else v0.warn('Ignoring invalid DATERANGE tag: "'+J0+'"');S.tagList.push(["EXT-X-DATERANGE",J0]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":if(z.startCC!==0)a1(z,Q0,v);else if(A.length>0)x2(z,Q0,v);z.startCC=C=parseInt(J0);break;case"KEY":{var D0=C2(J0,J,z);if(D0.isSupported()){if(D0.method==="NONE"){g=void 0;break}if(!g)g={};if(g[D0.keyFormat])g=B({},g);g[D0.keyFormat]=D0}else v0.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+J0+'"');break}case"START":z.startTimeOffset=D2(J0);break;case"MAP":{var Y1=new Q1(J0,z);if(S.duration){var _0=new kJ(Q,V);if(y2(_0,Y1,Y,g),I=_0,S.initSegment=I,I.rawProgramDateTime&&!S.rawProgramDateTime)S.rawProgramDateTime=I.rawProgramDateTime}else{var a0=S.byteRangeEndOffset;if(a0){var w1=S.byteRangeStartOffset;o=a0-w1+"@"+w1}else o=null;y2(S,Y1,Y,g),I=S,r=!0}I.cc=C;break}case"SERVER-CONTROL":{if(c)a1(z,Q0,v);c=new Q1(J0),z.canBlockReload=c.bool("CAN-BLOCK-RELOAD"),z.canSkipUntil=c.optionalFloat("CAN-SKIP-UNTIL",0),z.canSkipDateRanges=z.canSkipUntil>0&&c.bool("CAN-SKIP-DATERANGES"),z.partHoldBack=c.optionalFloat("PART-HOLD-BACK",0),z.holdBack=c.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{if(z.partTarget)a1(z,Q0,v);var q1=new Q1(J0);z.partTarget=q1.decimalFloatingPoint("PART-TARGET");break}case"PART":{var p0=z.partList;if(!p0)p0=z.partList=[];var R1=L>0?p0[p0.length-1]:void 0,Z1=L++,s0=new Q1(J0,z),$1=new a8(s0,S,V,Z1,R1);p0.push($1),S.duration+=$1.duration;break}case"PRELOAD-HINT":{var V1=new Q1(J0,z);z.preloadHint=V1;break}case"RENDITION-REPORT":{var M1=new Q1(J0,z);z.renditionReports=z.renditionReports||[],z.renditionReports.push(M1);break}default:v0.warn("line parsed but not handled: "+v);break}}}if(y&&!y.relurl){if(A.pop(),b-=y.duration,z.partList)z.fragmentHint=y}else if(z.partList){if(oJ(S,y,E),S.cc=C,z.fragmentHint=S,g)T2(S,g,z)}if(!z.targetduration)z.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required");var n0=A.length,z1=A[0],X1=A[n0-1];if(b+=z.skippedSegments*z.targetduration,b>0&&n0&&X1){z.averagetargetduration=b/n0;var I1=X1.sn;if(z.endSN=I1!=="initSegment"?I1:0,!z.live)X1.endList=!0;if(z1&&z.startCC===void 0)z.startCC=z1.cc;if(m>0){if(sX(A,m),z1)E.unshift(z1)}}else z.endSN=0,z.startCC=0;if(z.fragmentHint)b+=z.fragmentHint.duration;if(z.totalduration=b,E.length&&z.dateRangeTagCount&&z1)M2(E,z);return z.endCC=C,z},X}();function M2(X,W){var Z=X.length,J=X[Z-1],Y=W.live?1/0:W.totalduration,Q=Object.keys(W.dateRanges);for(var G=Q.length;G--;){var q=W.dateRanges[Q[G]],H=q.startDate.getTime();q.tagAnchor=J.ref;for(var V=Z;V--;){var z=iX(W,H,X,V,Y);if(z!==-1){q.tagAnchor=W.fragments[z].ref;break}}}}function iX(X,W,Z,J,Y){var Q=Z[J];if(Q){var G=Q.programDateTime;if(W>=G||J===0){var q,H=(((q=Z[J+1])==null?void 0:q.start)||Y)-Q.start;if(W<=G+H*1000){var V=Z[J].sn-X.startSN,z=X.fragments;if(z.length>Z.length){var A=Z[J+1]||z[z.length-1],E=A.sn-X.startSN;for(var I=E;I>V;I--){var $=z[I].programDateTime;if(W>=$&&W<$+z[I].duration*1000)return I}}return V}}}return-1}function C2(X,W,Z){var J,Y,Q=new Q1(X,Z),G=(J=Q.METHOD)!=null?J:"",q=Q.URI,H=Q.hexadecimalInteger("IV"),V=Q.KEYFORMATVERSIONS,z=(Y=Q.KEYFORMAT)!=null?Y:"identity";if(q&&Q.IV&&!H)v0.error("Invalid IV: "+Q.IV);var A=q?hY.resolve(q,W):"",E=(V?V:"1").split("/").map(Number).filter(Number.isFinite);return new lX(G,A,z,E,H)}function D2(X){var W=new Q1(X),Z=W.decimalFloatingPoint("TIME-OFFSET");if(T(Z))return Z;return null}function S2(X,W){var Z=(X||"").split(/[ ,]+/).filter(function(J){return J});["video","audio","text"].forEach(function(J){var Y=Z.filter(function(Q){return Q2(Q,J)});if(Y.length)W[J+"Codec"]=Y.map(function(Q){return Q.split("/")[0]}).join(","),Z=Z.filter(function(Q){return Y.indexOf(Q)===-1})}),W.unknownCodecs=Z}function P2(X,W,Z){var J=W[Z];if(J)X[Z]=J}function sX(X,W){var Z=X[W];for(var J=W;J--;){var Y=X[J];if(!Y)return;Y.programDateTime=Z.programDateTime-Y.duration*1000,Z=Y}}function oJ(X,W,Z){if(X.rawProgramDateTime)Z.push(X);else if(W!=null&&W.programDateTime)X.programDateTime=W.endProgramDateTime}function y2(X,W,Z,J){if(X.relurl=W.URI,W.BYTERANGE)X.setByteRange(W.BYTERANGE);if(X.level=Z,X.sn="initSegment",J)X.levelkeys=J;X.initSegment=null}function T2(X,W,Z){X.levelkeys=W;var J=Z.encryptedFragments;if((!J.length||J[J.length-1].levelkeys!==W)&&Object.keys(W).some(function(Y){return W[Y].isCommonEncryption}))J.push(X)}function a1(X,W,Z){X.playlistParsingError=new Error("#EXT-X-"+W+" must not appear more than once ("+Z[0]+")")}function x2(X,W,Z){X.playlistParsingError=new Error("#EXT-X-"+W+" must appear before the first Media Segment ("+Z[0]+")")}function iJ(X,W){var Z=W.startPTS;if(T(Z)){var J=0,Y;if(W.sn>X.sn)J=Z-X.start,Y=X;else J=X.start-Z,Y=W;if(Y.duration!==J)Y.setDuration(J)}else if(W.sn>X.sn){var Q=X.cc===W.cc;if(Q&&X.minEndPTS)W.setStart(X.start+(X.minEndPTS-X.start));else W.setStart(X.start+X.duration)}else W.setStart(Math.max(X.start-W.duration,0))}function v2(X,W,Z,J,Y,Q){var G=J-Z;if(G<=0)v0.warn("Fragment should have a positive duration",W),J=Z+W.duration,Q=Y+W.duration;var q=Z,H=J,V=W.startPTS,z=W.endPTS;if(T(V)){var A=Math.abs(V-Z);if(!T(W.deltaPTS))W.deltaPTS=A;else W.deltaPTS=Math.max(A,W.deltaPTS);q=Math.max(Z,V),Z=Math.min(Z,V),Y=Math.min(Y,W.startDTS),H=Math.min(J,z),J=Math.max(J,z),Q=Math.max(Q,W.endDTS)}var E=Z-W.start;if(W.start!==0)W.setStart(Z);W.setDuration(J-W.start),W.startPTS=Z,W.maxStartPTS=q,W.startDTS=Y,W.endPTS=J,W.minEndPTS=H,W.endDTS=Q;var I=W.sn;if(!X||I<X.startSN||I>X.endSN)return 0;var $,L=I-X.startSN,b=X.fragments;b[L]=W;for($=L;$>0;$--)iJ(b[$],b[$-1]);for($=L;$<b.length-1;$++)iJ(b[$],b[$+1]);if(X.fragmentHint)iJ(b[b.length-1],X.fragmentHint);return X.PTSKnown=X.alignedSliding=!0,E}function rX(X,W){if(X===W)return;var Z=null,J=X.fragments;for(var Y=J.length-1;Y>=0;Y--){var Q=J[Y].initSegment;if(Q){Z=Q;break}}if(X.fragmentHint)delete X.fragmentHint.endPTS;var G;eX(X,W,function($,L,b,C){if(W.skippedSegments){if(L.cc!==$.cc){var D=$.cc-L.cc;for(var y=b;y<C.length;y++)C[y].cc+=D}}if(T($.startPTS)&&T($.endPTS)){if(L.setStart(L.startPTS=$.startPTS),L.startDTS=$.startDTS,L.maxStartPTS=$.maxStartPTS,L.endPTS=$.endPTS,L.endDTS=$.endDTS,L.minEndPTS=$.minEndPTS,L.setDuration($.endPTS-$.startPTS),L.duration)G=L;W.PTSKnown=W.alignedSliding=!0}if($.hasStreams)L.elementaryStreams=$.elementaryStreams;if(L.loader=$.loader,$.hasStats)L.stats=$.stats;if($.initSegment)L.initSegment=$.initSegment,Z=$.initSegment});var q=W.fragments,H=W.fragmentHint?q.concat(W.fragmentHint):q;if(Z)H.forEach(function($){var L;if($&&(!$.initSegment||$.initSegment.relurl===((L=Z)==null?void 0:L.relurl)))$.initSegment=Z});if(W.skippedSegments)if(W.deltaUpdateFailed=q.some(function($){return!$}),W.deltaUpdateFailed){v0.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var V=W.skippedSegments;V--;)q.shift();W.startSN=q[0].sn}else{if(W.endCC=q[q.length-1].cc,W.canSkipDateRanges)W.dateRanges=aX(X.dateRanges,W);var z=X.fragments.filter(function($){return $.rawProgramDateTime});if(X.hasProgramDateTime&&!W.hasProgramDateTime){for(var A=1;A<H.length;A++)if(H[A].programDateTime===null)oJ(H[A],H[A-1],z)}M2(z,W)}if(tX(X.partList,W.partList,function($,L){L.elementaryStreams=$.elementaryStreams,L.stats=$.stats}),G)v2(W,G,G.startPTS,G.endPTS,G.startDTS,G.endDTS);else k2(X,W);if(q.length)W.totalduration=W.edge-q[0].start;W.driftStartTime=X.driftStartTime,W.driftStart=X.driftStart;var E=W.advancedDateTime;if(W.advanced&&E){var I=W.edge;if(!W.driftStart)W.driftStartTime=E,W.driftStart=I;W.driftEndTime=E,W.driftEnd=I}else W.driftEndTime=X.driftEndTime,W.driftEnd=X.driftEnd,W.advancedDateTime=X.advancedDateTime;if(W.requestScheduled===-1)W.requestScheduled=X.requestScheduled}function aX(X,W){var{dateRanges:Z,recentlyRemovedDateranges:J}=W,Y=B({},X);if(J)J.forEach(function(q){delete Y[q]});var Q=Object.keys(Y),G=Q.length;if(G)Object.keys(Z).forEach(function(q){var H=Y[q],V=new $2(Z[q].attr,H);if(V.isValid){if(Y[q]=V,!H)V.tagOrder+=G}else v0.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+O1(Z[q].attr)+'"')});return Y}function tX(X,W,Z){if(X&&W){var J=0;for(var Y=0,Q=X.length;Y<=Q;Y++){var G=X[Y],q=W[Y+J];if(G&&q&&G.index===q.index&&G.fragment.sn===q.fragment.sn)Z(G,q);else J--}}}function eX(X,W,Z){var J=W.skippedSegments,Y=Math.max(X.startSN,W.startSN)-W.startSN,Q=(X.fragmentHint?1:0)+(J?W.endSN:Math.min(X.endSN,W.endSN))-W.startSN,G=W.startSN-X.startSN,q=W.fragmentHint?W.fragments.concat(W.fragmentHint):W.fragments,H=X.fragmentHint?X.fragments.concat(X.fragmentHint):X.fragments;for(var V=Y;V<=Q;V++){var z=H[G+V],A=q[V];if(J&&!A&&z)A=W.fragments[V]=z;if(z&&A){if(Z(z,A,V,q),z.url&&z.url!==A.url){W.playlistParsingError=h2("media sequence mismatch "+A.sn+":",X,W,z,A);return}else if(z.cc!==A.cc){W.playlistParsingError=h2("discontinuity sequence mismatch ("+z.cc+"!="+A.cc+")",X,W,z,A);return}}}}function h2(X,W,Z,J,Y){return new Error(X+" "+Y.url+`
17
+ Playlist starting @`+W.startSN+`
18
+ `+W.m3u8+`
19
+
20
+ Playlist starting @`+Z.startSN+`
21
+ `+Z.m3u8)}function k2(X,W,Z){if(Z===void 0)Z=!0;var J=W.startSN+W.skippedSegments-X.startSN,Y=X.fragments,Q=J>=0,G=0;if(Q&&J<Y.length)G=Y[J].start;else if(Q&&W.startSN===X.endSN+1)G=X.fragmentEnd;else if(Q&&Z)G=X.fragmentStart+J*W.levelTargetDuration;else if(!W.skippedSegments&&W.fragmentStart===0)G=X.fragmentStart;else return;Y7(W,G)}function Y7(X,W){if(W){var Z=X.fragments;for(var J=X.skippedSegments;J<Z.length;J++)Z[J].addStart(W);if(X.fragmentHint)X.fragmentHint.addStart(W)}}function g2(X,W){if(W===void 0)W=1/0;var Z=1000*X.targetduration;if(X.updated){var J=X.fragments,Y=4;if(J.length&&Z*Y>W){var Q=J[J.length-1].duration*1000;if(Q<Z)Z=Q}}else Z/=2;return Math.round(Z)}function J7(X,W,Z){if(!X)return null;var J=X.fragments[W-X.startSN];if(J)return J;if(J=X.fragmentHint,J&&J.sn===W)return J;if(W<X.startSN&&Z&&Z.sn===W)return Z;return null}function u2(X,W,Z){if(!X)return null;return m2(X.partList,W,Z)}function m2(X,W,Z){if(X)for(var J=X.length;J--;){var Y=X[J];if(Y.index===Z&&Y.fragment.sn===W)return Y}return null}function _2(X){X.forEach(function(W,Z){var J;(J=W.details)==null||J.fragments.forEach(function(Y){if(Y.level=Z,Y.initSegment)Y.initSegment.level=Z})})}var Q7=300000,Z7=function(X){function W(J){var Y=X.call(this,"content-steering",J.logger)||this;return Y.hls=void 0,Y.loader=null,Y.uri=null,Y.pathwayId=".",Y._pathwayPriority=null,Y.timeToLoad=300,Y.reloadTimer=-1,Y.updated=0,Y.started=!1,Y.enabled=!0,Y.levels=null,Y.audioTracks=null,Y.subtitleTracks=null,Y.penalizedPathways={},Y.hls=J,Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.ERROR,this.onError,this)},Z.pathways=function J(){return(this.levels||[]).reduce(function(Y,Q){if(Y.indexOf(Q.pathwayId)===-1)Y.push(Q.pathwayId);return Y},[])},Z.startLoad=function J(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var Y=this.timeToLoad*1000-(performance.now()-this.updated);if(Y>0){this.scheduleRefresh(this.uri,Y);return}}this.loadSteeringManifest(this.uri)}},Z.stopLoad=function J(){if(this.started=!1,this.loader)this.loader.destroy(),this.loader=null;this.clearTimeout()},Z.clearTimeout=function J(){if(this.reloadTimer!==-1)self.clearTimeout(this.reloadTimer),this.reloadTimer=-1},Z.destroy=function J(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},Z.removeLevel=function J(Y){var Q=this.levels;if(Q)this.levels=Q.filter(function(G){return G!==Y})},Z.onManifestLoading=function J(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},Z.onManifestLoaded=function J(Y,Q){var G=Q.contentSteering;if(G===null)return;if(this.pathwayId=G.pathwayId,this.uri=G.uri,this.started)this.startLoad()},Z.onManifestParsed=function J(Y,Q){this.audioTracks=Q.audioTracks,this.subtitleTracks=Q.subtitleTracks},Z.onError=function J(Y,Q){var G=Q.errorAction;if((G==null?void 0:G.action)===U1.SendAlternateToPenaltyBox&&G.flags===h1.MoveAllAlternatesMatchingHost){var q=this.levels,H=this._pathwayPriority,V=this.pathwayId;if(Q.context){var z=Q.context,A=z.groupId,E=z.pathwayId,I=z.type;if(A&&q)V=this.getPathwayForGroupId(A,I,V);else if(E)V=E}if(!(V in this.penalizedPathways))this.penalizedPathways[V]=performance.now();if(!H&&q)H=this.pathways();if(H&&H.length>1)this.updatePathwayPriority(H),G.resolved=this.pathwayId!==V;if(!G.resolved)this.warn("Could not resolve "+Q.details+' ("'+Q.error.message+'") with content-steering for Pathway: '+V+" levels: "+(q?q.length:q)+" priorities: "+O1(H)+" penalized: "+O1(this.penalizedPathways))}},Z.filterParsedLevels=function J(Y){this.levels=Y;var Q=this.getLevelsForPathway(this.pathwayId);if(Q.length===0){var G=Y[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+G+'"'),Q=this.getLevelsForPathway(G),this.pathwayId=G}if(Q.length!==Y.length)this.log("Found "+Q.length+"/"+Y.length+' levels in Pathway "'+this.pathwayId+'"');return Q},Z.getLevelsForPathway=function J(Y){if(this.levels===null)return[];return this.levels.filter(function(Q){return Y===Q.pathwayId})},Z.updatePathwayPriority=function J(Y){this._pathwayPriority=Y;var Q,G=this.penalizedPathways,q=performance.now();Object.keys(G).forEach(function(I){if(q-G[I]>Q7)delete G[I]});for(var H=0;H<Y.length;H++){var V=Y[H];if(V in G)continue;if(V===this.pathwayId)return;var z=this.hls.nextLoadLevel,A=this.hls.levels[z];if(Q=this.getLevelsForPathway(V),Q.length>0){this.log('Setting Pathway to "'+V+'"'),this.pathwayId=V,_2(Q),this.hls.trigger(M.LEVELS_UPDATED,{levels:Q});var E=this.hls.levels[z];if(A&&E&&this.levels){if(E.attrs["STABLE-VARIANT-ID"]!==A.attrs["STABLE-VARIANT-ID"]&&E.bitrate!==A.bitrate)this.log("Unstable Pathways change from bitrate "+A.bitrate+" to "+E.bitrate);this.hls.nextLoadLevel=z}break}}},Z.getPathwayForGroupId=function J(Y,Q,G){var q=this.getLevelsForPathway(G).concat(this.levels||[]);for(var H=0;H<q.length;H++)if(Q===Z0.AUDIO_TRACK&&q[H].hasAudioGroup(Y)||Q===Z0.SUBTITLE_TRACK&&q[H].hasSubtitleGroup(Y))return q[H].pathwayId;return G},Z.clonePathways=function J(Y){var Q=this,G=this.levels;if(!G)return;var q={},H={};Y.forEach(function(V){var z=V.ID,A=V["BASE-ID"],E=V["URI-REPLACEMENT"];if(G.some(function($){return $.pathwayId===z}))return;var I=Q.getLevelsForPathway(A).map(function($){var L=new Q1($.attrs);L["PATHWAY-ID"]=z;var b=L.AUDIO&&L.AUDIO+"_clone_"+z,C=L.SUBTITLES&&L.SUBTITLES+"_clone_"+z;if(b)q[L.AUDIO]=b,L.AUDIO=b;if(C)H[L.SUBTITLES]=C,L.SUBTITLES=C;var D=f2($.uri,L["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",E),y=new H2({attrs:L,audioCodec:$.audioCodec,bitrate:$.bitrate,height:$.height,name:$.name,url:D,videoCodec:$.videoCodec,width:$.width});if($.audioGroups)for(var S=1;S<$.audioGroups.length;S++)y.addGroupId("audio",$.audioGroups[S]+"_clone_"+z);if($.subtitleGroups)for(var v=1;v<$.subtitleGroups.length;v++)y.addGroupId("text",$.subtitleGroups[v]+"_clone_"+z);return y});G.push.apply(G,I),p2(Q.audioTracks,q,E,z),p2(Q.subtitleTracks,H,E,z)})},Z.loadSteeringManifest=function J(Y){var Q=this,G=this.hls.config,q=G.loader;if(this.loader)this.loader.destroy();this.loader=new q(G);var H;try{H=new self.URL(Y)}catch(L){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+Y);return}if(H.protocol!=="data:"){var V=(this.hls.bandwidthEstimate||G.abrEwmaDefaultEstimate)|0;H.searchParams.set("_HLS_pathway",this.pathwayId),H.searchParams.set("_HLS_throughput",""+V)}var z={responseType:"json",url:H.href},A=G.steeringManifestLoadPolicy.default,E=A.errorRetry||A.timeoutRetry||{},I={loadPolicy:A,timeout:A.maxLoadTimeMs,maxRetry:E.maxNumRetry||0,retryDelay:E.retryDelayMs||0,maxRetryDelay:E.maxRetryDelayMs||0},$={onSuccess:function L(b,C,D,y){Q.log('Loaded steering manifest: "'+H+'"');var S=b.data;if((S==null?void 0:S.VERSION)!==1){Q.log("Steering VERSION "+S.VERSION+" not supported!");return}Q.updated=performance.now(),Q.timeToLoad=S.TTL;var v=S["RELOAD-URI"],p=S["PATHWAY-CLONES"],g=S["PATHWAY-PRIORITY"];if(v)try{Q.uri=new self.URL(v,H).href}catch(r){Q.enabled=!1,Q.log("Failed to parse Steering Manifest RELOAD-URI: "+v);return}if(Q.scheduleRefresh(Q.uri||D.url),p)Q.clonePathways(p);var m={steeringManifest:S,url:H.toString()};if(Q.hls.trigger(M.STEERING_MANIFEST_LOADED,m),g)Q.updatePathwayPriority(g)},onError:function L(b,C,D,y){if(Q.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+C.url+")"),Q.stopLoad(),b.code===410){Q.enabled=!1,Q.log("Steering manifest "+C.url+" no longer available");return}var S=Q.timeToLoad*1000;if(b.code===429){var v=Q.loader;if(typeof(v==null?void 0:v.getResponseHeader)==="function"){var p=v.getResponseHeader("Retry-After");if(p)S=parseFloat(p)*1000}Q.log("Steering manifest "+C.url+" rate limited");return}Q.scheduleRefresh(Q.uri||C.url,S)},onTimeout:function L(b,C,D){Q.log("Timeout loading steering manifest ("+C.url+")"),Q.scheduleRefresh(Q.uri||C.url)}};this.log("Requesting steering manifest: "+H),this.loader.load(z,I,$)},Z.scheduleRefresh=function J(Y,Q){var G=this;if(Q===void 0)Q=this.timeToLoad*1000;this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var q,H=(q=G.hls)==null?void 0:q.media;if(H&&!H.ended){G.loadSteeringManifest(Y);return}G.scheduleRefresh(Y,G.timeToLoad*1000)},Q)},N(W,[{key:"pathwayPriority",get:function J(){return this._pathwayPriority},set:function J(Y){this.updatePathwayPriority(Y)}}])}(d0);function p2(X,W,Z,J){if(!X)return;Object.keys(W).forEach(function(Y){var Q=X.filter(function(G){return G.groupId===Y}).map(function(G){var q=B({},G);return q.details=void 0,q.attrs=new Q1(q.attrs),q.url=q.attrs.URI=f2(G.url,G.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",Z),q.groupId=q.attrs["GROUP-ID"]=W[Y],q.attrs["PATHWAY-ID"]=J,q});X.push.apply(X,Q)})}function f2(X,W,Z,J){var{HOST:Y,PARAMS:Q}=J,G=J[Z],q;if(W){if(q=G==null?void 0:G[W],q)X=q}var H=new self.URL(X);if(Y&&!q)H.host=Y;if(Q)Object.keys(Q).sort().forEach(function(V){if(V)H.searchParams.set(V,Q[V])});return H.href}var X7=function(){function X(Z){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=Z,this.registerListeners()}var W=X.prototype;return W.setStreamController=function Z(J){this.streamController=J},W.registerListeners=function Z(){this.hls.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.unregisterListeners=function Z(){this.hls.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.destroy=function Z(){if(this.timer)clearInterval(this.timer);this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},W.onMediaAttaching=function Z(J,Y){var Q=this.hls.config;if(Q.capLevelOnFPSDrop){var G=Y.media instanceof self.HTMLVideoElement?Y.media:null;if(this.media=G,G&&typeof G.getVideoPlaybackQuality==="function")this.isVideoPlaybackQualityAvailable=!0;self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),Q.fpsDroppedMonitoringPeriod)}},W.onMediaDetaching=function Z(){this.media=null},W.checkFPS=function Z(J,Y,Q){var G=performance.now();if(Y){if(this.lastTime){var q=G-this.lastTime,H=Q-this.lastDroppedFrames,V=Y-this.lastDecodedFrames,z=1000*H/q,A=this.hls;if(A.trigger(M.FPS_DROP,{currentDropped:H,currentDecoded:V,totalDroppedFrames:Q}),z>0){if(H>A.config.fpsDroppedMonitoringThreshold*V){var E=A.currentLevel;if(A.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+E),E>0&&(A.autoLevelCapping===-1||A.autoLevelCapping>=E))E=E-1,A.trigger(M.FPS_DROP_LEVEL_CAPPING,{level:E,droppedLevel:A.currentLevel}),A.autoLevelCapping=E,this.streamController.nextLevelSwitch()}}}this.lastTime=G,this.lastDroppedFrames=Q,this.lastDecodedFrames=Y}},W.checkFPSInterval=function Z(){var J=this.media;if(J)if(this.isVideoPlaybackQualityAvailable){var Y=J.getVideoPlaybackQuality();this.checkFPS(J,Y.totalVideoFrames,Y.droppedVideoFrames)}else this.checkFPS(J,J.webkitDecodedFrameCount,J.webkitDroppedFrameCount)},X}(),G7=function(){function X(){this.chunks=[],this.dataLength=0}var W=X.prototype;return W.push=function Z(J){this.chunks.push(J),this.dataLength+=J.length},W.flush=function Z(){var J=this.chunks,Y=this.dataLength,Q;if(!J.length)return new Uint8Array(0);else if(J.length===1)Q=J[0];else Q=W7(J,Y);return this.reset(),Q},W.reset=function Z(){this.chunks.length=0,this.dataLength=0},X}();function W7(X,W){var Z=new Uint8Array(W),J=0;for(var Y=0;Y<X.length;Y++){var Q=X[Y];Z.set(Q,J),J+=Q.length}return Z}function c2(X,W){if(W+10<=X.length){if(X[W]===51&&X[W+1]===68&&X[W+2]===73){if(X[W+3]<255&&X[W+4]<255){if(X[W+6]<128&&X[W+7]<128&&X[W+8]<128&&X[W+9]<128)return!0}}}return!1}function sJ(X,W){if(W+10<=X.length){if(X[W]===73&&X[W+1]===68&&X[W+2]===51){if(X[W+3]<255&&X[W+4]<255){if(X[W+6]<128&&X[W+7]<128&&X[W+8]<128&&X[W+9]<128)return!0}}}return!1}function NJ(X,W){var Z=0;return Z=(X[W]&127)<<21,Z|=(X[W+1]&127)<<14,Z|=(X[W+2]&127)<<7,Z|=X[W+3]&127,Z}function UJ(X,W){var Z=W,J=0;while(sJ(X,W)){J+=10;var Y=NJ(X,W+6);if(J+=Y,c2(X,W+10))J+=10;W+=J}if(J>0)return X.subarray(Z,Z+J);return}function K7(X,W,Z,J){var Y=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],Q=W[Z+2],G=Q>>2&15;if(G>12){var q=new Error("invalid ADTS sampling index:"+G);X.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!0,error:q,reason:q.message});return}var H=(Q>>6&3)+1,V=W[Z+3]>>6&3|(Q&1)<<2,z="mp4a.40."+H,A=Y[G],E=G;if(H===5||H===29)E-=3;var I=[H<<3|(E&14)>>1,(E&1)<<7|V<<3];return v0.log("manifest codec:"+J+", parsed codec:"+z+", channels:"+V+", rate:"+A+" (ADTS object type:"+H+" sampling index:"+G+")"),{config:I,samplerate:A,channelCount:V,codec:z,parsedCodec:z,manifestCodec:J}}function l2(X,W){return X[W]===255&&(X[W+1]&246)===240}function d2(X,W){return X[W+1]&1?7:9}function rJ(X,W){return(X[W+3]&3)<<11|X[W+4]<<3|(X[W+5]&224)>>>5}function q7(X,W){return W+5<X.length}function VJ(X,W){return W+1<X.length&&l2(X,W)}function H7(X,W){return q7(X,W)&&l2(X,W)&&rJ(X,W)<=X.length-W}function N7(X,W){if(VJ(X,W)){var Z=d2(X,W);if(W+Z>=X.length)return!1;var J=rJ(X,W);if(J<=Z)return!1;var Y=W+J;return Y===X.length||VJ(X,Y)}return!1}function n2(X,W,Z,J,Y){if(!X.samplerate){var Q=K7(W,Z,J,Y);if(!Q)return;B(X,Q)}}function o2(X){return 92160000/X}function U7(X,W){var Z=d2(X,W);if(W+Z<=X.length){var J=rJ(X,W)-Z;if(J>0)return{headerLength:Z,frameLength:J}}}function i2(X,W,Z,J,Y){var Q=o2(X.samplerate),G=J+Y*Q,q=U7(W,Z),H;if(q){var{frameLength:V,headerLength:z}=q,A=z+V,E=Math.max(0,Z+A-W.length);if(E)H=new Uint8Array(A-z),H.set(W.subarray(Z+z,W.length),0);else H=W.subarray(Z+z,Z+A);var I={unit:H,pts:G};if(!E)X.samples.push(I);return{sample:I,length:A,missing:E}}var $=W.length-Z;H=new Uint8Array($),H.set(W.subarray(Z,W.length),0);var L={unit:H,pts:G};return{sample:L,length:$,missing:-1}}function V7(X,W){return sJ(X,W)&&NJ(X,W+6)+10<=X.length-W}function z7(X){if(X.size<2)return;var W=x1(X.data,!0),Z=new Uint8Array(X.data.subarray(W.length+1));return{key:X.type,info:W,data:Z.buffer}}function j7(X){if(X.size<2)return;if(X.type==="TXXX"){var W=1,Z=x1(X.data.subarray(W),!0);W+=Z.length+1;var J=x1(X.data.subarray(W));return{key:X.type,info:Z,data:J}}var Y=x1(X.data.subarray(1));return{key:X.type,info:"",data:Y}}function A7(X){if(X.type==="WXXX"){if(X.size<2)return;var W=1,Z=x1(X.data.subarray(W),!0);W+=Z.length+1;var J=x1(X.data.subarray(W));return{key:X.type,info:Z,data:J}}var Y=x1(X.data);return{key:X.type,info:"",data:Y}}function O7(X){if(X instanceof ArrayBuffer)return X;else{if(X.byteOffset==0&&X.byteLength==X.buffer.byteLength)return X.buffer;return new Uint8Array(X).buffer}}function aJ(X,W,Z){if(W===void 0)W=0;if(Z===void 0)Z=1/0;return F7(X,W,Z,Uint8Array)}function F7(X,W,Z,J){var Y=E7(X),Q=1;if("BYTES_PER_ELEMENT"in J)Q=J.BYTES_PER_ELEMENT;var G=B7(X)?X.byteOffset:0,q=(G+X.byteLength)/Q,H=(G+W)/Q,V=Math.floor(Math.max(0,Math.min(H,q))),z=Math.floor(Math.min(V+Math.max(Z,0),q));return new J(Y,V,z-V)}function E7(X){if(X instanceof ArrayBuffer)return X;else return X.buffer}function B7(X){return X&&X.buffer instanceof ArrayBuffer&&X.byteLength!==void 0&&X.byteOffset!==void 0}function w7(X){var W={key:X.type,description:"",data:"",mimeType:null,pictureType:null},Z=3;if(X.size<2)return;if(X.data[0]!==Z){console.log("Ignore frame with unrecognized character encoding");return}var J=X.data.subarray(1).indexOf(0);if(J===-1)return;var Y=x1(aJ(X.data,1,J)),Q=X.data[2+J],G=X.data.subarray(3+J).indexOf(0);if(G===-1)return;var q=x1(aJ(X.data,3+J,G)),H;if(Y==="-->")H=x1(aJ(X.data,4+J+G));else H=O7(X.data.subarray(4+J+G));return W.mimeType=Y,W.pictureType=Q,W.description=q,W.data=H,W}function R7(X){if(X.type==="PRIV")return z7(X);else if(X.type[0]==="W")return A7(X);else if(X.type==="APIC")return w7(X);return j7(X)}function $7(X){var W=String.fromCharCode(X[0],X[1],X[2],X[3]),Z=NJ(X,4),J=10;return{type:W,size:Z,data:X.subarray(J,J+Z)}}var zJ=10,I7=10;function s2(X){var W=0,Z=[];while(sJ(X,W)){var J=NJ(X,W+6);if(X[W+5]>>6&1)W+=zJ;W+=zJ;var Y=W+J;while(W+I7<Y){var Q=$7(X.subarray(W)),G=R7(Q);if(G)Z.push(G);W+=Q.size+zJ}if(c2(X,W))W+=zJ}return Z}function r2(X){return X&&X.key==="PRIV"&&X.info==="com.apple.streaming.transportStreamTimestamp"}function L7(X){if(X.data.byteLength===8){var W=new Uint8Array(X.data),Z=W[3]&1,J=(W[4]<<23)+(W[5]<<15)+(W[6]<<7)+W[7];if(J/=45,Z)J+=47721858.84;return Math.round(J)}return}function a2(X){var W=s2(X);for(var Z=0;Z<W.length;Z++){var J=W[Z];if(r2(J))return L7(J)}return}var b1=function(X){return X.audioId3="org.id3",X.dateRange="com.apple.quicktime.HLS",X.emsg="https://aomedia.org/emsg/ID3",X.misbklv="urn:misb:KLV:bin:1910.1",X}({});function i1(X,W){if(X===void 0)X="";if(W===void 0)W=90000;return{type:X,id:-1,pid:-1,inputTimeScale:W,sequenceNumber:-1,samples:[],dropped:0}}var t2=function(){function X(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var W=X.prototype;return W.resetInitSegment=function Z(J,Y,Q,G){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0}},W.resetTimeStamp=function Z(J){this.initPTS=J,this.resetContiguity()},W.resetContiguity=function Z(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},W.canParse=function Z(J,Y){return!1},W.appendFrame=function Z(J,Y,Q){},W.demux=function Z(J,Y){if(this.cachedData)J=v1(this.cachedData,J),this.cachedData=null;var Q=UJ(J,0),G=Q?Q.length:0,q,H=this._audioTrack,V=this._id3Track,z=Q?a2(Q):void 0,A=J.length;if(this.basePTS===null||this.frameIndex===0&&T(z))this.basePTS=b7(z,Y,this.initPTS),this.lastPTS=this.basePTS;if(this.lastPTS===null)this.lastPTS=this.basePTS;if(Q&&Q.length>0)V.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:Q,type:b1.audioId3,duration:Number.POSITIVE_INFINITY});while(G<A){if(this.canParse(J,G)){var E=this.appendFrame(H,J,G);if(E)this.frameIndex++,this.lastPTS=E.sample.pts,G+=E.length,q=G;else G=A}else if(V7(J,G))Q=UJ(J,G),V.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:Q,type:b1.audioId3,duration:Number.POSITIVE_INFINITY}),G+=Q.length,q=G;else G++;if(G===A&&q!==A){var I=J.slice(q);if(this.cachedData)this.cachedData=v1(this.cachedData,I);else this.cachedData=I}}return{audioTrack:H,videoTrack:i1(),id3Track:V,textTrack:i1()}},W.demuxSampleAes=function Z(J,Y,Q){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},W.flush=function Z(J){var Y=this.cachedData;if(Y)this.cachedData=null,this.demux(Y,0);return{audioTrack:this._audioTrack,videoTrack:i1(),id3Track:this._id3Track,textTrack:i1()}},W.destroy=function Z(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},X}(),b7=function X(W,Z,J){if(T(W))return W*90;var Y=J?J.baseTime*90000/J.timescale:0;return Z*90000+Y},jJ=null,M7=[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],C7=[44100,48000,32000,22050,24000,16000,11025,12000,8000],D7=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],S7=[0,1,1,4];function e2(X,W,Z,J,Y){if(Z+24>W.length)return;var Q=YZ(W,Z);if(Q&&Z+Q.frameLength<=W.length){var G=Q.samplesPerFrame*90000/Q.sampleRate,q=J+Y*G,H={unit:W.subarray(Z,Z+Q.frameLength),pts:q,dts:q};return X.config=[],X.channelCount=Q.channelCount,X.samplerate=Q.sampleRate,X.samples.push(H),{sample:H,length:Q.frameLength,missing:0}}}function YZ(X,W){var Z=X[W+1]>>3&3,J=X[W+1]>>1&3,Y=X[W+2]>>4&15,Q=X[W+2]>>2&3;if(Z!==1&&Y!==0&&Y!==15&&Q!==3){var G=X[W+2]>>1&1,q=X[W+3]>>6,H=Z===3?3-J:J===3?3:4,V=M7[H*14+Y-1]*1000,z=Z===3?0:Z===2?1:2,A=C7[z*3+Q],E=q===3?1:2,I=D7[Z][J],$=S7[J],L=I*8*$,b=Math.floor(I*V/A+G)*$;if(jJ===null){var C=navigator.userAgent||"",D=C.match(/Chrome\/(\d+)/i);jJ=D?parseInt(D[1]):0}var y=!!jJ&&jJ<=87;if(y&&J===2&&V>=224000&&q===0)X[W+3]=X[W+3]|128;return{sampleRate:A,channelCount:E,frameLength:b,samplesPerFrame:L}}}function tJ(X,W){return X[W]===255&&(X[W+1]&224)===224&&(X[W+1]&6)!==0}function JZ(X,W){return W+1<X.length&&tJ(X,W)}function P7(X,W){var Z=4;return tJ(X,W)&&Z<=X.length-W}function QZ(X,W){if(W+1<X.length&&tJ(X,W)){var Z=4,J=YZ(X,W),Y=Z;if(J!=null&&J.frameLength)Y=J.frameLength;var Q=W+Y;return Q===X.length||JZ(X,Q)}return!1}var y7=function(X){function W(J,Y){var Q=X.call(this)||this;return Q.observer=void 0,Q.config=void 0,Q.observer=J,Q.config=Y,Q}R(W,X);var Z=W.prototype;return Z.resetInitSegment=function J(Y,Q,G,q){X.prototype.resetInitSegment.call(this,Y,Q,G,q),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Q,duration:q,inputTimeScale:90000,dropped:0}},W.probe=function J(Y,Q){if(!Y)return!1;var G=UJ(Y,0),q=(G==null?void 0:G.length)||0;if(QZ(Y,q))return!1;for(var H=Y.length;q<H;q++)if(N7(Y,q))return Q.log("ADTS sync word found !"),!0;return!1},Z.canParse=function J(Y,Q){return H7(Y,Q)},Z.appendFrame=function J(Y,Q,G){n2(Y,this.observer,Q,G,Y.manifestCodec);var q=i2(Y,Q,G,this.basePTS,this.frameIndex);if(q&&q.missing===0)return q},W}(t2),T7=function X(W,Z){var J=0,Y=5;Z+=Y;var Q=new Uint32Array(1),G=new Uint32Array(1),q=new Uint8Array(1);while(Y>0){q[0]=W[Z];var H=Math.min(Y,8),V=8-H;G[0]=4278190080>>>24+V<<V,Q[0]=(q[0]&G[0])>>V,J=!J?Q[0]:J<<H|Q[0],Z+=1,Y-=H}return J},x7=function(X){function W(){return X.apply(this,arguments)||this}R(W,X);var Z=W.prototype;return Z.resetInitSegment=function J(Y,Q,G,q){X.prototype.resetInitSegment.call(this,Y,Q,G,q),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Q,duration:q,inputTimeScale:90000,dropped:0}},W.probe=function J(Y){if(!Y)return!1;var Q=UJ(Y,0),G=(Q==null?void 0:Q.length)||0;if(Q&&Y[G]===11&&Y[G+1]===119&&a2(Q)!==void 0&&T7(Y,G)<=16)return!1;for(var q=Y.length;G<q;G++)if(QZ(Y,G))return v0.log("MPEG Audio sync word found !"),!0;return!1},Z.canParse=function J(Y,Q){return P7(Y,Q)},Z.appendFrame=function J(Y,Q,G){if(this.basePTS===null)return;return e2(Y,Q,G,this.basePTS,this.frameIndex)},W}(t2),v7=function(){function X(Z,J,Y){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=Z,this.aesIV=J,this.aesMode=Y}var W=X.prototype;return W.decrypt=function Z(J,Y){switch(this.aesMode){case GY.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},Y,J);case GY.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},Y,J);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},X}();function h7(X){var W=X.byteLength,Z=W&&new DataView(X.buffer).getUint8(W-1);if(Z)return X.slice(0,W-Z);return X}var k7=function(){function X(){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 W=X.prototype;return W.uint8ArrayToUint32Array_=function Z(J){var Y=new DataView(J),Q=new Uint32Array(4);for(var G=0;G<4;G++)Q[G]=Y.getUint32(G*4);return Q},W.initTable=function Z(){var J=this.sBox,Y=this.invSBox,Q=this.subMix,G=Q[0],q=Q[1],H=Q[2],V=Q[3],z=this.invSubMix,A=z[0],E=z[1],I=z[2],$=z[3],L=new Uint32Array(256),b=0,C=0,D=0;for(D=0;D<256;D++)if(D<128)L[D]=D<<1;else L[D]=D<<1^283;for(D=0;D<256;D++){var y=C^C<<1^C<<2^C<<3^C<<4;y=y>>>8^y&255^99,J[b]=y,Y[y]=b;var S=L[b],v=L[S],p=L[v],g=L[y]*257^y*16843008;if(G[b]=g<<24|g>>>8,q[b]=g<<16|g>>>16,H[b]=g<<8|g>>>24,V[b]=g,g=p*16843009^v*65537^S*257^b*16843008,A[y]=g<<24|g>>>8,E[y]=g<<16|g>>>16,I[y]=g<<8|g>>>24,$[y]=g,!b)b=C=1;else b=S^L[L[L[p^S]]],C^=L[L[C]]}},W.expandKey=function Z(J){var Y=this.uint8ArrayToUint32Array_(J),Q=!0,G=0;while(G<Y.length&&Q)Q=Y[G]===this.key[G],G++;if(Q)return;this.key=Y;var q=this.keySize=Y.length;if(q!==4&&q!==6&&q!==8)throw new Error("Invalid aes key size="+q);var H=this.ksRows=(q+6+1)*4,V,z,A=this.keySchedule=new Uint32Array(H),E=this.invKeySchedule=new Uint32Array(H),I=this.sBox,$=this.rcon,L=this.invSubMix,b=L[0],C=L[1],D=L[2],y=L[3],S,v;for(V=0;V<H;V++){if(V<q){S=A[V]=Y[V];continue}if(v=S,V%q===0)v=v<<8|v>>>24,v=I[v>>>24]<<24|I[v>>>16&255]<<16|I[v>>>8&255]<<8|I[v&255],v^=$[V/q|0]<<24;else if(q>6&&V%q===4)v=I[v>>>24]<<24|I[v>>>16&255]<<16|I[v>>>8&255]<<8|I[v&255];A[V]=S=(A[V-q]^v)>>>0}for(z=0;z<H;z++){if(V=H-z,z&3)v=A[V];else v=A[V-4];if(z<4||V<=4)E[z]=v;else E[z]=b[I[v>>>24]]^C[I[v>>>16&255]]^D[I[v>>>8&255]]^y[I[v&255]];E[z]=E[z]>>>0}},W.networkToHostOrderSwap=function Z(J){return J<<24|(J&65280)<<8|(J&16711680)>>8|J>>>24},W.decrypt=function Z(J,Y,Q){var G=this.keySize+6,q=this.invKeySchedule,H=this.invSBox,V=this.invSubMix,z=V[0],A=V[1],E=V[2],I=V[3],$=this.uint8ArrayToUint32Array_(Q),L=$[0],b=$[1],C=$[2],D=$[3],y=new Int32Array(J),S=new Int32Array(y.length),v,p,g,m,r,o,c,d,e,H0,Q0,J0,N0,V0,j0=this.networkToHostOrderSwap;while(Y<y.length){e=j0(y[Y]),H0=j0(y[Y+1]),Q0=j0(y[Y+2]),J0=j0(y[Y+3]),r=e^q[0],o=J0^q[1],c=Q0^q[2],d=H0^q[3],N0=4;for(V0=1;V0<G;V0++)v=z[r>>>24]^A[o>>16&255]^E[c>>8&255]^I[d&255]^q[N0],p=z[o>>>24]^A[c>>16&255]^E[d>>8&255]^I[r&255]^q[N0+1],g=z[c>>>24]^A[d>>16&255]^E[r>>8&255]^I[o&255]^q[N0+2],m=z[d>>>24]^A[r>>16&255]^E[o>>8&255]^I[c&255]^q[N0+3],r=v,o=p,c=g,d=m,N0=N0+4;v=H[r>>>24]<<24^H[o>>16&255]<<16^H[c>>8&255]<<8^H[d&255]^q[N0],p=H[o>>>24]<<24^H[c>>16&255]<<16^H[d>>8&255]<<8^H[r&255]^q[N0+1],g=H[c>>>24]<<24^H[d>>16&255]<<16^H[r>>8&255]<<8^H[o&255]^q[N0+2],m=H[d>>>24]<<24^H[r>>16&255]<<16^H[o>>8&255]<<8^H[c&255]^q[N0+3],S[Y]=j0(v^L),S[Y+1]=j0(m^b),S[Y+2]=j0(g^C),S[Y+3]=j0(p^D),L=e,b=H0,C=Q0,D=J0,Y=Y+4}return S.buffer},X}(),g7=function(){function X(Z,J,Y){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=Z,this.key=J,this.aesMode=Y}var W=X.prototype;return W.expandKey=function Z(){var J=u7(this.aesMode);return this.subtle.importKey("raw",this.key,{name:J},!1,["encrypt","decrypt"])},X}();function u7(X){switch(X){case GY.cbc:return"AES-CBC";case GY.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+X)}}var m7=16,eJ=function(){function X(Z,J){var Y=J===void 0?{}:J,Q=Y.removePKCS7Padding,G=Q===void 0?!0:Q;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.enableSoftwareAES=void 0,this.enableSoftwareAES=Z.enableSoftwareAES,this.removePKCS7Padding=G,G)try{var q=self.crypto;if(q)this.subtle=q.subtle||q.webkitSubtle}catch(H){}this.useSoftware=!this.subtle}var W=X.prototype;return W.destroy=function Z(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},W.isSync=function Z(){return this.useSoftware},W.flush=function Z(){var J=this.currentResult,Y=this.remainderData;if(!J||Y)return this.reset(),null;var Q=new Uint8Array(J);if(this.reset(),this.removePKCS7Padding)return h7(Q);return Q},W.reset=function Z(){if(this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter)this.softwareDecrypter=null},W.decrypt=function Z(J,Y,Q,G){var q=this;if(this.useSoftware)return new Promise(function(H,V){var z=ArrayBuffer.isView(J)?J:new Uint8Array(J);q.softwareDecrypt(z,Y,Q,G);var A=q.flush();if(A)H(A.buffer);else V(new Error("[softwareDecrypt] Failed to decrypt data"))});return this.webCryptoDecrypt(new Uint8Array(J),Y,Q,G)},W.softwareDecrypt=function Z(J,Y,Q,G){var q=this.currentIV,H=this.currentResult,V=this.remainderData;if(G!==GY.cbc||Y.byteLength!==16)return v0.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;if(this.logOnce("JS AES decrypt"),V)J=v1(V,J),this.remainderData=null;var z=this.getValidChunk(J);if(!z.length)return null;if(q)Q=q;var A=this.softwareDecrypter;if(!A)A=this.softwareDecrypter=new k7;A.expandKey(Y);var E=H;if(this.currentResult=A.decrypt(z.buffer,0,Q),this.currentIV=z.slice(-16).buffer,!E)return null;return E},W.webCryptoDecrypt=function Z(J,Y,Q,G){var q=this;if(this.key!==Y||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(J,Y,Q,G));this.key=Y,this.fastAesKey=new g7(this.subtle,Y,G)}return this.fastAesKey.expandKey().then(function(H){if(!q.subtle)return Promise.reject(new Error("web crypto not initialized"));q.logOnce("WebCrypto AES decrypt");var V=new v7(q.subtle,new Uint8Array(Q),G);return V.decrypt(J.buffer,H)}).catch(function(H){return v0.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+H.name+": "+H.message),q.onWebCryptoError(J,Y,Q,G)})},W.onWebCryptoError=function Z(J,Y,Q,G){var q=this.enableSoftwareAES;if(q){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(J,Y,Q,G);var H=this.flush();if(H)return H.buffer}throw new Error("WebCrypto"+(q?" and softwareDecrypt":"")+": failed to decrypt data")},W.getValidChunk=function Z(J){var Y=J,Q=J.length-J.length%m7;if(Q!==J.length)Y=J.slice(0,Q),this.remainderData=J.slice(Q);return Y},W.logOnce=function Z(J){if(!this.logEnabled)return;v0.log("[decrypter]: "+J),this.logEnabled=!1},X}(),_7=/\/emsg[-/]ID3/i,p7=function(){function X(Z,J){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=J}var W=X.prototype;return W.resetTimeStamp=function Z(){},W.resetInitSegment=function Z(J,Y,Q,G){var q=this.videoTrack=i1("video",1),H=this.audioTrack=i1("audio",1),V=this.txtTrack=i1("text",1);if(this.id3Track=i1("id3",1),this.timeOffset=0,!(J!=null&&J.byteLength))return;var z=aQ(J);if(z.video){var A=z.video,E=A.id,I=A.timescale,$=A.codec,L=A.supplemental;q.id=E,q.timescale=V.timescale=I,q.codec=$,q.supplemental=L}if(z.audio){var b=z.audio,C=b.id,D=b.timescale,y=b.codec;H.id=C,H.timescale=D,H.codec=y}V.id=oQ.text,q.sampleDuration=0,q.duration=H.duration=G},W.resetContiguity=function Z(){this.remainderData=null},X.probe=function Z(J){return YX(J)},W.demux=function Z(J,Y){this.timeOffset=Y;var Q=J,G=this.videoTrack,q=this.txtTrack;if(this.config.progressive){if(this.remainderData)Q=v1(this.remainderData,J);var H=HX(Q);this.remainderData=H.remainder,G.samples=H.valid||new Uint8Array}else G.samples=Q;var V=this.extractID3Track(G,Y);return q.samples=tQ(Y,G),{videoTrack:G,audioTrack:this.audioTrack,id3Track:V,textTrack:this.txtTrack}},W.flush=function Z(){var J=this.timeOffset,Y=this.videoTrack,Q=this.txtTrack;Y.samples=this.remainderData||new Uint8Array,this.remainderData=null;var G=this.extractID3Track(Y,this.timeOffset);return Q.samples=tQ(J,Y),{videoTrack:Y,audioTrack:i1(),id3Track:G,textTrack:i1()}},W.extractID3Track=function Z(J,Y){var Q=this,G=this.id3Track;if(J.samples.length){var q=$0(J.samples,["emsg"]);if(q)q.forEach(function(H){var V=UX(H);if(_7.test(V.schemeIdUri)){var z=ZZ(V,Y),A=V.eventDuration===4294967295?Number.POSITIVE_INFINITY:V.eventDuration/V.timeScale;if(A<=0.001)A=Number.POSITIVE_INFINITY;var E=V.payload;G.samples.push({data:E,len:E.byteLength,dts:z,pts:z,type:b1.emsg,duration:A})}else if(Q.config.enableEmsgKLVMetadata&&V.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var I=ZZ(V,Y);G.samples.push({data:V.payload,len:V.payload.byteLength,dts:I,pts:I,type:b1.misbklv,duration:Number.POSITIVE_INFINITY})}})}return G},W.demuxSampleAes=function Z(J,Y,Q){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},W.destroy=function Z(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},X}();function ZZ(X,W){return T(X.presentationTime)?X.presentationTime/X.timeScale:W+X.presentationTimeDelta/X.timeScale}var f7=function(){function X(Z,J,Y){this.keyData=void 0,this.decrypter=void 0,this.keyData=Y,this.decrypter=new eJ(J,{removePKCS7Padding:!1})}var W=X.prototype;return W.decryptBuffer=function Z(J){return this.decrypter.decrypt(J,this.keyData.key.buffer,this.keyData.iv.buffer,GY.cbc)},W.decryptAacSample=function Z(J,Y,Q){var G=this,q=J[Y].unit;if(q.length<=16)return;var H=q.subarray(16,q.length-q.length%16),V=H.buffer.slice(H.byteOffset,H.byteOffset+H.length);this.decryptBuffer(V).then(function(z){var A=new Uint8Array(z);if(q.set(A,16),!G.decrypter.isSync())G.decryptAacSamples(J,Y+1,Q)})},W.decryptAacSamples=function Z(J,Y,Q){for(;;Y++){if(Y>=J.length){Q();return}if(J[Y].unit.length<32)continue;if(this.decryptAacSample(J,Y,Q),!this.decrypter.isSync())return}},W.getAvcEncryptedData=function Z(J){var Y=Math.floor((J.length-48)/160)*16+16,Q=new Int8Array(Y),G=0;for(var q=32;q<J.length-16;q+=160,G+=16)Q.set(J.subarray(q,q+16),G);return Q},W.getAvcDecryptedUnit=function Z(J,Y){var Q=new Uint8Array(Y),G=0;for(var q=32;q<J.length-16;q+=160,G+=16)J.set(Q.subarray(G,G+16),q);return J},W.decryptAvcSample=function Z(J,Y,Q,G,q){var H=this,V=Y2(q.data),z=this.getAvcEncryptedData(V);this.decryptBuffer(z.buffer).then(function(A){if(q.data=H.getAvcDecryptedUnit(V,A),!H.decrypter.isSync())H.decryptAvcSamples(J,Y,Q+1,G)})},W.decryptAvcSamples=function Z(J,Y,Q,G){if(J instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;Y++,Q=0){if(Y>=J.length){G();return}var q=J[Y].units;for(;;Q++){if(Q>=q.length)break;var H=q[Q];if(H.data.length<=48||H.type!==1&&H.type!==5)continue;if(this.decryptAvcSample(J,Y,Q,G,H),!this.decrypter.isSync())return}}},X}(),c7=function(){function X(){this.VideoSample=null}var W=X.prototype;return W.createVideoSample=function Z(J,Y,Q){return{key:J,frame:!1,pts:Y,dts:Q,units:[],length:0}},W.getLastNalUnit=function Z(J){var Y,Q=this.VideoSample,G;if(!Q||Q.units.length===0)Q=J[J.length-1];if((Y=Q)!=null&&Y.units){var q=Q.units;G=q[q.length-1]}return G},W.pushAccessUnit=function Z(J,Y){if(J.units.length&&J.frame){if(J.pts===void 0){var Q=Y.samples,G=Q.length;if(G){var q=Q[G-1];J.pts=q.pts,J.dts=q.dts}else{Y.dropped++;return}}Y.samples.push(J)}},W.parseNALu=function Z(J,Y,Q){var G=Y.byteLength,q=J.naluState||0,H=q,V=[],z=0,A,E,I,$=-1,L=0;if(q===-1)$=0,L=this.getNALuType(Y,0),q=0,z=1;while(z<G){if(A=Y[z++],!q){q=A?0:1;continue}if(q===1){q=A?0:2;continue}if(!A)q=3;else if(A===1){if(E=z-q-1,$>=0){var b={data:Y.subarray($,E),type:L};V.push(b)}else{var C=this.getLastNalUnit(J.samples);if(C){if(H&&z<=4-H){if(C.state)C.data=C.data.subarray(0,C.data.byteLength-H)}if(E>0)C.data=v1(C.data,Y.subarray(0,E)),C.state=0}}if(z<G)I=this.getNALuType(Y,z),$=z,L=I,q=0;else q=-1}else q=0}if($>=0&&q>=0){var D={data:Y.subarray($,G),type:L,state:q};V.push(D)}if(V.length===0){var y=this.getLastNalUnit(J.samples);if(y)y.data=v1(y.data,Y)}return J.naluState=q,V},X}(),XZ=function(){function X(Z){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=Z,this.bytesAvailable=Z.byteLength,this.word=0,this.bitsAvailable=0}var W=X.prototype;return W.loadWord=function Z(){var J=this.data,Y=this.bytesAvailable,Q=J.byteLength-Y,G=new Uint8Array(4),q=Math.min(4,Y);if(q===0)throw new Error("no bytes available");G.set(J.subarray(Q,Q+q)),this.word=new DataView(G.buffer).getUint32(0),this.bitsAvailable=q*8,this.bytesAvailable-=q},W.skipBits=function Z(J){var Y;if(J=Math.min(J,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>J)this.word<<=J,this.bitsAvailable-=J;else J-=this.bitsAvailable,Y=J>>3,J-=Y<<3,this.bytesAvailable-=Y,this.loadWord(),this.word<<=J,this.bitsAvailable-=J},W.readBits=function Z(J){var Y=Math.min(this.bitsAvailable,J),Q=this.word>>>32-Y;if(J>32)v0.error("Cannot read more than 32 bits at a time");if(this.bitsAvailable-=Y,this.bitsAvailable>0)this.word<<=Y;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");if(Y=J-Y,Y>0&&this.bitsAvailable)return Q<<Y|this.readBits(Y);else return Q},W.skipLZ=function Z(){var J;for(J=0;J<this.bitsAvailable;++J)if((this.word&2147483648>>>J)!==0)return this.word<<=J,this.bitsAvailable-=J,J;return this.loadWord(),J+this.skipLZ()},W.skipUEG=function Z(){this.skipBits(1+this.skipLZ())},W.skipEG=function Z(){this.skipBits(1+this.skipLZ())},W.readUEG=function Z(){var J=this.skipLZ();return this.readBits(J+1)-1},W.readEG=function Z(){var J=this.readUEG();if(1&J)return 1+J>>>1;else return-1*(J>>>1)},W.readBoolean=function Z(){return this.readBits(1)===1},W.readUByte=function Z(){return this.readBits(8)},W.readUShort=function Z(){return this.readBits(16)},W.readUInt=function Z(){return this.readBits(32)},X}(),GZ=function(X){function W(){return X.apply(this,arguments)||this}R(W,X);var Z=W.prototype;return Z.parsePES=function J(Y,Q,G,q){var H=this,V=this.parseNALu(Y,G.data,q),z=this.VideoSample,A,E=!1;if(G.data=null,z&&V.length&&!Y.audFound)this.pushAccessUnit(z,Y),z=this.VideoSample=this.createVideoSample(!1,G.pts,G.dts);if(V.forEach(function(I){var $,L;switch(I.type){case 1:{var b=!1;A=!0;var C=I.data;if(E&&C.length>4){var D=H.readSliceType(C);if(D===2||D===4||D===7||D===9)b=!0}if(b){var y;if((y=z)!=null&&y.frame&&!z.key)H.pushAccessUnit(z,Y),z=H.VideoSample=null}if(!z)z=H.VideoSample=H.createVideoSample(!0,G.pts,G.dts);z.frame=!0,z.key=b;break}case 5:if(A=!0,($=z)!=null&&$.frame&&!z.key)H.pushAccessUnit(z,Y),z=H.VideoSample=null;if(!z)z=H.VideoSample=H.createVideoSample(!0,G.pts,G.dts);z.key=!0,z.frame=!0;break;case 6:{A=!0,eQ(I.data,1,G.pts,Q.samples);break}case 7:{var S,v;A=!0,E=!0;var p=I.data,g=H.readSPS(p);if(!Y.sps||Y.width!==g.width||Y.height!==g.height||((S=Y.pixelRatio)==null?void 0:S[0])!==g.pixelRatio[0]||((v=Y.pixelRatio)==null?void 0:v[1])!==g.pixelRatio[1]){Y.width=g.width,Y.height=g.height,Y.pixelRatio=g.pixelRatio,Y.sps=[p];var m=p.subarray(1,4),r="avc1.";for(var o=0;o<3;o++){var c=m[o].toString(16);if(c.length<2)c="0"+c;r+=c}Y.codec=r}break}case 8:A=!0,Y.pps=[I.data];break;case 9:if(A=!0,Y.audFound=!0,(L=z)!=null&&L.frame)H.pushAccessUnit(z,Y),z=null;if(!z)z=H.VideoSample=H.createVideoSample(!1,G.pts,G.dts);break;case 12:A=!0;break;default:A=!1;break}if(z&&A){var d=z.units;d.push(I)}}),q&&z)this.pushAccessUnit(z,Y),this.VideoSample=null},Z.getNALuType=function J(Y,Q){return Y[Q]&31},Z.readSliceType=function J(Y){var Q=new XZ(Y);return Q.readUByte(),Q.readUEG(),Q.readUEG()},Z.skipScalingList=function J(Y,Q){var G=8,q=8,H;for(var V=0;V<Y;V++){if(q!==0)H=Q.readEG(),q=(G+H+256)%256;G=q===0?G:q}},Z.readSPS=function J(Y){var Q=new XZ(Y),G=0,q=0,H=0,V=0,z,A,E,I=Q.readUByte.bind(Q),$=Q.readBits.bind(Q),L=Q.readUEG.bind(Q),b=Q.readBoolean.bind(Q),C=Q.skipBits.bind(Q),D=Q.skipEG.bind(Q),y=Q.skipUEG.bind(Q),S=this.skipScalingList.bind(this);I();var v=I();if($(5),C(3),I(),y(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){var p=L();if(p===3)C(1);if(y(),y(),C(1),b()){A=p!==3?8:12;for(E=0;E<A;E++)if(b())if(E<6)S(16,Q);else S(64,Q)}}y();var g=L();if(g===0)L();else if(g===1){C(1),D(),D(),z=L();for(E=0;E<z;E++)D()}y(),C(1);var m=L(),r=L(),o=$(1);if(o===0)C(1);if(C(1),b())G=L(),q=L(),H=L(),V=L();var c=[1,1];if(b()){if(b()){var d=I();switch(d){case 1:c=[1,1];break;case 2:c=[12,11];break;case 3:c=[10,11];break;case 4:c=[16,11];break;case 5:c=[40,33];break;case 6:c=[24,11];break;case 7:c=[20,11];break;case 8:c=[32,11];break;case 9:c=[80,33];break;case 10:c=[18,11];break;case 11:c=[15,11];break;case 12:c=[64,33];break;case 13:c=[160,99];break;case 14:c=[4,3];break;case 15:c=[3,2];break;case 16:c=[2,1];break;case 255:{c=[I()<<8|I(),I()<<8|I()];break}}}}return{width:Math.ceil((m+1)*16-G*2-q*2),height:(2-o)*(r+1)*16-(o?2:4)*(H+V),pixelRatio:c}},W}(c7),K1=188,l7=function(){function X(Z,J,Y,Q){this.logger=void 0,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._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=Z,this.config=J,this.typeSupported=Y,this.logger=Q,this.videoParser=null}X.probe=function Z(J,Y){var Q=X.syncOffset(J);if(Q>0)Y.warn("MPEG2-TS detected but first sync word found @ offset "+Q);return Q!==-1},X.syncOffset=function Z(J){var Y=J.length,Q=Math.min(K1*5,Y-K1)+1,G=0;while(G<Q){var q=!1,H=-1,V=0;for(var z=G;z<Y;z+=K1)if(J[z]===71&&(Y-z===K1||J[z+K1]===71)){if(V++,H===-1){if(H=z,H!==0)Q=Math.min(H+K1*99,J.length-K1)+1}if(!q)q=YQ(J,z)===0;if(q&&V>1&&(H===0&&V>2||z+K1>Q))return H}else if(V)return-1;else break;G++}return-1},X.createTrack=function Z(J,Y){return{container:J==="video"||J==="audio"?"video/mp2t":void 0,type:J,id:oQ[J],pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0,duration:J==="audio"?Y:void 0}};var W=X.prototype;return W.resetInitSegment=function Z(J,Y,Q,G){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=X.createTrack("video"),this._videoTrack.duration=G,this._audioTrack=X.createTrack("audio",G),this._id3Track=X.createTrack("id3"),this._txtTrack=X.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=Y,this.videoCodec=Q},W.resetTimeStamp=function Z(){},W.resetContiguity=function Z(){var J=this._audioTrack,Y=this._videoTrack,Q=this._id3Track;if(J)J.pesData=null;if(Y)Y.pesData=null;if(Q)Q.pesData=null;this.aacOverFlow=null,this.remainderData=null},W.demux=function Z(J,Y,Q,G){if(Q===void 0)Q=!1;if(G===void 0)G=!1;if(!Q)this.sampleAes=null;var q,H=this._videoTrack,V=this._audioTrack,z=this._id3Track,A=this._txtTrack,E=H.pid,I=H.pesData,$=V.pid,L=z.pid,b=V.pesData,C=z.pesData,D=null,y=this.pmtParsed,S=this._pmtId,v=J.length;if(this.remainderData)J=v1(this.remainderData,J),v=J.length,this.remainderData=null;if(v<K1&&!G)return this.remainderData=J,{audioTrack:V,videoTrack:H,id3Track:z,textTrack:A};var p=Math.max(0,X.syncOffset(J));if(v-=(v-p)%K1,v<J.byteLength&&!G)this.remainderData=new Uint8Array(J.buffer,v,J.buffer.byteLength-v);var g=0;for(var m=p;m<v;m+=K1)if(J[m]===71){var r=!!(J[m+1]&64),o=YQ(J,m),c=(J[m+3]&48)>>4,d=void 0;if(c>1){if(d=m+5+J[m+4],d===m+K1)continue}else d=m+4;switch(o){case E:if(r){if(I&&(q=FY(I,this.logger))){if(this.videoParser===null)switch(H.segmentCodec){case"avc":this.videoParser=new GZ;break}if(this.videoParser!==null)this.videoParser.parsePES(H,A,q,!1)}I={data:[],size:0}}if(I)I.data.push(J.subarray(d,m+K1)),I.size+=m+K1-d;break;case $:if(r){if(b&&(q=FY(b,this.logger)))switch(V.segmentCodec){case"aac":this.parseAACPES(V,q);break;case"mp3":this.parseMPEGPES(V,q);break}b={data:[],size:0}}if(b)b.data.push(J.subarray(d,m+K1)),b.size+=m+K1-d;break;case L:if(r){if(C&&(q=FY(C,this.logger)))this.parseID3PES(z,q);C={data:[],size:0}}if(C)C.data.push(J.subarray(d,m+K1)),C.size+=m+K1-d;break;case 0:if(r)d+=J[d]+1;S=this._pmtId=d7(J,d);break;case S:{if(r)d+=J[d]+1;var e=n7(J,d,this.typeSupported,Q,this.observer,this.logger);if(E=e.videoPid,E>0)H.pid=E,H.segmentCodec=e.segmentVideoCodec;if($=e.audioPid,$>0)V.pid=$,V.segmentCodec=e.segmentAudioCodec;if(L=e.id3Pid,L>0)z.pid=L;if(D!==null&&!y)this.logger.warn("MPEG-TS PMT found at "+m+" after unknown PID '"+D+"'. Backtracking to sync byte @"+p+" to parse all TS packets."),D=null,m=p-188;y=this.pmtParsed=!0;break}case 17:case 8191:break;default:D=o;break}}else g++;if(g>0)AJ(this.observer,new Error("Found "+g+" TS packet/s that do not start with 0x47"),void 0,this.logger);H.pesData=I,V.pesData=b,z.pesData=C;var H0={audioTrack:V,videoTrack:H,id3Track:z,textTrack:A};if(G)this.extractRemainingSamples(H0);return H0},W.flush=function Z(){var J=this.remainderData;this.remainderData=null;var Y;if(J)Y=this.demux(J,-1,!1,!0);else Y={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack};if(this.extractRemainingSamples(Y),this.sampleAes)return this.decrypt(Y,this.sampleAes);return Y},W.extractRemainingSamples=function Z(J){var{audioTrack:Y,videoTrack:Q,id3Track:G,textTrack:q}=J,H=Q.pesData,V=Y.pesData,z=G.pesData,A;if(H&&(A=FY(H,this.logger))){if(this.videoParser===null)switch(Q.segmentCodec){case"avc":this.videoParser=new GZ;break}if(this.videoParser!==null)this.videoParser.parsePES(Q,q,A,!0),Q.pesData=null}else Q.pesData=H;if(V&&(A=FY(V,this.logger))){switch(Y.segmentCodec){case"aac":this.parseAACPES(Y,A);break;case"mp3":this.parseMPEGPES(Y,A);break}Y.pesData=null}else{if(V!=null&&V.size)this.logger.log("last AAC PES packet truncated,might overlap between fragments");Y.pesData=V}if(z&&(A=FY(z,this.logger)))this.parseID3PES(G,A),G.pesData=null;else G.pesData=z},W.demuxSampleAes=function Z(J,Y,Q){var G=this.demux(J,Q,!0,!this.config.progressive),q=this.sampleAes=new f7(this.observer,this.config,Y);return this.decrypt(G,q)},W.decrypt=function Z(J,Y){return new Promise(function(Q){var{audioTrack:G,videoTrack:q}=J;if(G.samples&&G.segmentCodec==="aac")Y.decryptAacSamples(G.samples,0,function(){if(q.samples)Y.decryptAvcSamples(q.samples,0,0,function(){Q(J)});else Q(J)});else if(q.samples)Y.decryptAvcSamples(q.samples,0,0,function(){Q(J)})})},W.destroy=function Z(){if(this.observer)this.observer.removeAllListeners();this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},W.parseAACPES=function Z(J,Y){var Q=0,G=this.aacOverFlow,q=Y.data;if(G){this.aacOverFlow=null;var H=G.missing,V=G.sample.unit.byteLength;if(H===-1)q=v1(G.sample.unit,q);else{var z=V-H;G.sample.unit.set(q.subarray(0,H),z),J.samples.push(G.sample),Q=G.missing}}var A,E;for(A=Q,E=q.length;A<E-1;A++)if(VJ(q,A))break;if(A!==Q){var I,$=A<E-1;if($)I="AAC PES did not start with ADTS header,offset:"+A;else I="No ADTS header found in AAC PES";if(AJ(this.observer,new Error(I),$,this.logger),!$)return}n2(J,this.observer,q,A,this.audioCodec);var L;if(Y.pts!==void 0)L=Y.pts;else if(G){var b=o2(J.samplerate);L=G.sample.pts+b}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}var C=0,D;while(A<E)if(D=i2(J,q,A,L,C),A+=D.length,!D.missing){C++;for(;A<E-1;A++)if(VJ(q,A))break}else{this.aacOverFlow=D;break}},W.parseMPEGPES=function Z(J,Y){var Q=Y.data,G=Q.length,q=0,H=0,V=Y.pts;if(V===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(H<G)if(JZ(Q,H)){var z=e2(J,Q,H,V,q);if(z)H+=z.length,q++;else break}else H++},W.parseAC3PES=function Z(J,Y){},W.parseID3PES=function Z(J,Y){if(Y.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var Q=B({},Y,{type:this._videoTrack?b1.emsg:b1.audioId3,duration:Number.POSITIVE_INFINITY});J.samples.push(Q)},X}();function YQ(X,W){return((X[W+1]&31)<<8)+X[W+2]}function d7(X,W){return(X[W+10]&31)<<8|X[W+11]}function n7(X,W,Z,J,Y,Q){var G={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},q=(X[W+1]&15)<<8|X[W+2],H=W+3+q-4,V=(X[W+10]&15)<<8|X[W+11];W+=12+V;while(W<H){var z=YQ(X,W),A=(X[W+3]&15)<<8|X[W+4];switch(X[W]){case 207:if(!J){JQ("ADTS AAC",Q);break}case 15:if(G.audioPid===-1)G.audioPid=z;break;case 21:if(G.id3Pid===-1)G.id3Pid=z;break;case 219:if(!J){JQ("H.264",Q);break}case 27:if(G.videoPid===-1)G.videoPid=z;break;case 3:case 4:if(!Z.mpeg&&!Z.mp3)Q.log("MPEG audio found, not supported in this browser");else if(G.audioPid===-1)G.audioPid=z,G.segmentAudioCodec="mp3";break;case 193:if(!J){JQ("AC-3",Q);break}case 129:Q.warn("AC-3 in M2TS support not included in build");break;case 6:if(G.audioPid===-1&&A>0){var E=W+5,I=A;while(I>2){var $=X[E];switch($){case 106:Q.warn("AC-3 in M2TS support not included in build");break}var L=X[E+1]+2;E+=L,I-=L}}break;case 194:case 135:return AJ(Y,new Error("Unsupported EC-3 in M2TS found"),void 0,Q),G;case 36:return AJ(Y,new Error("Unsupported HEVC in M2TS found"),void 0,Q),G}W+=A+5}return G}function AJ(X,W,Z,J){J.warn("parsing error: "+W.message),X.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,levelRetry:Z,error:W,reason:W.message})}function JQ(X,W){W.log(X+" with AES-128-CBC encryption found in unencrypted stream")}function FY(X,W){var Z=0,J,Y,Q,G,q,H=X.data;if(!X||X.size===0)return null;while(H[0].length<19&&H.length>1)H[0]=v1(H[0],H[1]),H.splice(1,1);J=H[0];var V=(J[0]<<16)+(J[1]<<8)+J[2];if(V===1){if(Y=(J[4]<<8)+J[5],Y&&Y>X.size-6)return null;var z=J[7];if(z&192)if(G=(J[9]&14)*536870912+(J[10]&255)*4194304+(J[11]&254)*16384+(J[12]&255)*128+(J[13]&254)/2,z&64){if(q=(J[14]&14)*536870912+(J[15]&255)*4194304+(J[16]&254)*16384+(J[17]&255)*128+(J[18]&254)/2,G-q>5400000)W.warn(Math.round((G-q)/90000)+"s delta between PTS and DTS, align them"),G=q}else q=G;Q=J[8];var A=Q+9;if(X.size<=A)return null;X.size-=A;var E=new Uint8Array(X.size);for(var I=0,$=H.length;I<$;I++){J=H[I];var L=J.byteLength;if(A)if(A>L){A-=L;continue}else J=J.subarray(A),L-=A,A=0;E.set(J,Z),Z+=L}if(Y)Y-=Q+3;return{data:E,pts:G,dts:q,len:Y}}return null}var o7=function(){function X(){}return X.getSilentFrame=function W(Z,J){switch(Z){case"mp4a.40.2":if(J===1)return new Uint8Array([0,200,0,128,35,128]);else if(J===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);else if(J===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(J===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(J===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(J===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(J===1)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]);else if(J===2)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]);else if(J===3)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]);break}return},X}(),WY=Math.pow(2,32)-1,H1=function(){function X(){}return X.init=function W(){X.types={avc1:[],avcC:[],hvc1:[],hvcC:[],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:[]};var Z;for(Z in X.types)if(X.types.hasOwnProperty(Z))X.types[Z]=[Z.charCodeAt(0),Z.charCodeAt(1),Z.charCodeAt(2),Z.charCodeAt(3)];var J=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]),Y=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]);X.HDLR_TYPES={video:J,audio:Y};var Q=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),G=new Uint8Array([0,0,0,0,0,0,0,0]);X.STTS=X.STSC=X.STCO=G,X.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),X.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),X.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),X.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var q=new Uint8Array([105,115,111,109]),H=new Uint8Array([97,118,99,49]),V=new Uint8Array([0,0,0,1]);X.FTYP=X.box(X.types.ftyp,q,V,q,H),X.DINF=X.box(X.types.dinf,X.box(X.types.dref,Q))},X.box=function W(Z){var J=8;for(var Y=arguments.length,Q=new Array(Y>1?Y-1:0),G=1;G<Y;G++)Q[G-1]=arguments[G];var q=Q.length,H=q;while(q--)J+=Q[q].byteLength;var V=new Uint8Array(J);V[0]=J>>24&255,V[1]=J>>16&255,V[2]=J>>8&255,V[3]=J&255,V.set(Z,4);for(q=0,J=8;q<H;q++)V.set(Q[q],J),J+=Q[q].byteLength;return V},X.hdlr=function W(Z){return X.box(X.types.hdlr,X.HDLR_TYPES[Z])},X.mdat=function W(Z){return X.box(X.types.mdat,Z)},X.mdhd=function W(Z,J){J*=Z;var Y=Math.floor(J/(WY+1)),Q=Math.floor(J%(WY+1));return X.box(X.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,Q>>24,Q>>16&255,Q>>8&255,Q&255,85,196,0,0]))},X.mdia=function W(Z){return X.box(X.types.mdia,X.mdhd(Z.timescale||0,Z.duration||0),X.hdlr(Z.type),X.minf(Z))},X.mfhd=function W(Z){return X.box(X.types.mfhd,new Uint8Array([0,0,0,0,Z>>24,Z>>16&255,Z>>8&255,Z&255]))},X.minf=function W(Z){if(Z.type==="audio")return X.box(X.types.minf,X.box(X.types.smhd,X.SMHD),X.DINF,X.stbl(Z));else return X.box(X.types.minf,X.box(X.types.vmhd,X.VMHD),X.DINF,X.stbl(Z))},X.moof=function W(Z,J,Y){return X.box(X.types.moof,X.mfhd(Z),X.traf(Y,J))},X.moov=function W(Z){var J=Z.length,Y=[];while(J--)Y[J]=X.trak(Z[J]);return X.box.apply(null,[X.types.moov,X.mvhd(Z[0].timescale||0,Z[0].duration||0)].concat(Y).concat(X.mvex(Z)))},X.mvex=function W(Z){var J=Z.length,Y=[];while(J--)Y[J]=X.trex(Z[J]);return X.box.apply(null,[X.types.mvex].concat(Y))},X.mvhd=function W(Z,J){J*=Z;var Y=Math.floor(J/(WY+1)),Q=Math.floor(J%(WY+1)),G=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,Q>>24,Q>>16&255,Q>>8&255,Q&255,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 X.box(X.types.mvhd,G)},X.sdtp=function W(Z){var J=Z.samples||[],Y=new Uint8Array(4+J.length),Q,G;for(Q=0;Q<J.length;Q++)G=J[Q].flags,Y[Q+4]=G.dependsOn<<4|G.isDependedOn<<2|G.hasRedundancy;return X.box(X.types.sdtp,Y)},X.stbl=function W(Z){return X.box(X.types.stbl,X.stsd(Z),X.box(X.types.stts,X.STTS),X.box(X.types.stsc,X.STSC),X.box(X.types.stsz,X.STSZ),X.box(X.types.stco,X.STCO))},X.avc1=function W(Z){var J=[],Y=[],Q,G,q;for(Q=0;Q<Z.sps.length;Q++)G=Z.sps[Q],q=G.byteLength,J.push(q>>>8&255),J.push(q&255),J=J.concat(Array.prototype.slice.call(G));for(Q=0;Q<Z.pps.length;Q++)G=Z.pps[Q],q=G.byteLength,Y.push(q>>>8&255),Y.push(q&255),Y=Y.concat(Array.prototype.slice.call(G));var H=X.box(X.types.avcC,new Uint8Array([1,J[3],J[4],J[5],255,224|Z.sps.length].concat(J).concat([Z.pps.length]).concat(Y))),V=Z.width,z=Z.height,A=Z.pixelRatio[0],E=Z.pixelRatio[1];return X.box(X.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,V>>8&255,V&255,z>>8&255,z&255,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,X.box(X.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),X.box(X.types.pasp,new Uint8Array([A>>24,A>>16&255,A>>8&255,A&255,E>>24,E>>16&255,E>>8&255,E&255])))},X.esds=function W(Z){var J=Z.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(J,[6,1,2]))},X.audioStsd=function W(Z){var J=Z.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,Z.channelCount||0,0,16,0,0,0,0,J>>8&255,J&255,0,0])},X.mp4a=function W(Z){return X.box(X.types.mp4a,X.audioStsd(Z),X.box(X.types.esds,X.esds(Z)))},X.mp3=function W(Z){return X.box(X.types[".mp3"],X.audioStsd(Z))},X.ac3=function W(Z){return X.box(X.types["ac-3"],X.audioStsd(Z),X.box(X.types.dac3,Z.config))},X.stsd=function W(Z){var J=Z.segmentCodec;if(Z.type==="audio"){if(J==="aac")return X.box(X.types.stsd,X.STSD,X.mp4a(Z));if(J==="mp3"&&Z.codec==="mp3")return X.box(X.types.stsd,X.STSD,X.mp3(Z))}else if(Z.pps&&Z.sps){if(J==="avc")return X.box(X.types.stsd,X.STSD,X.avc1(Z))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+Z.type+" segment codec ("+J+"/"+Z.codec+")")},X.tkhd=function W(Z){var J=Z.id,Y=(Z.duration||0)*(Z.timescale||0),Q=Z.width||0,G=Z.height||0,q=Math.floor(Y/(WY+1)),H=Math.floor(Y%(WY+1));return X.box(X.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,J>>24&255,J>>16&255,J>>8&255,J&255,0,0,0,0,q>>24,q>>16&255,q>>8&255,q&255,H>>24,H>>16&255,H>>8&255,H&255,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,Q>>8&255,Q&255,0,0,G>>8&255,G&255,0,0]))},X.traf=function W(Z,J){var Y=X.sdtp(Z),Q=Z.id,G=Math.floor(J/(WY+1)),q=Math.floor(J%(WY+1));return X.box(X.types.traf,X.box(X.types.tfhd,new Uint8Array([0,0,0,0,Q>>24,Q>>16&255,Q>>8&255,Q&255])),X.box(X.types.tfdt,new Uint8Array([1,0,0,0,G>>24,G>>16&255,G>>8&255,G&255,q>>24,q>>16&255,q>>8&255,q&255])),X.trun(Z,Y.length+16+20+8+16+8+8),Y)},X.trak=function W(Z){return Z.duration=Z.duration||4294967295,X.box(X.types.trak,X.tkhd(Z),X.mdia(Z))},X.trex=function W(Z){var J=Z.id;return X.box(X.types.trex,new Uint8Array([0,0,0,0,J>>24,J>>16&255,J>>8&255,J&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},X.trun=function W(Z,J){var Y=Z.samples||[],Q=Y.length,G=12+16*Q,q=new Uint8Array(G),H,V,z,A,E,I;J+=8+G,q.set([Z.type==="video"?1:0,0,15,1,Q>>>24&255,Q>>>16&255,Q>>>8&255,Q&255,J>>>24&255,J>>>16&255,J>>>8&255,J&255],0);for(H=0;H<Q;H++)V=Y[H],z=V.duration,A=V.size,E=V.flags,I=V.cts,q.set([z>>>24&255,z>>>16&255,z>>>8&255,z&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,E.isLeading<<2|E.dependsOn,E.isDependedOn<<6|E.hasRedundancy<<4|E.paddingValue<<1|E.isNonSync,E.degradPrio&61440,E.degradPrio&15,I>>>24&255,I>>>16&255,I>>>8&255,I&255],12+16*H);return X.box(X.types.trun,q)},X.initSegment=function W(Z){if(!X.types)X.init();var J=X.moov(Z),Y=v1(X.FTYP,J);return Y},X.hvc1=function W(Z){return new Uint8Array},X}();H1.types=void 0,H1.HDLR_TYPES=void 0,H1.STTS=void 0,H1.STSC=void 0,H1.STCO=void 0,H1.STSZ=void 0,H1.VMHD=void 0,H1.SMHD=void 0,H1.STSD=void 0,H1.FTYP=void 0,H1.DINF=void 0;var i7=90000;function s7(X,W,Z,J){var Y=X*W*Z;return Math.round(Y)}function kY(X,W){return s7(X,1000,1/i7)}var r7=1e4,a7=1024,t7=1152,e7=1536,EY=null,QQ=null;function WZ(X,W,Z,J){return{duration:W,size:Z,cts:J,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:X?2:1,isNonSync:X?0:1}}}var ZQ=function(){function X(Z,J,Y,Q){if(this.logger=void 0,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=Z,this.config=J,this.typeSupported=Y,this.logger=Q,this.ISGenerated=!1,EY===null){var G=navigator.userAgent||"",q=G.match(/Chrome\/(\d+)/i);EY=q?parseInt(q[1]):0}if(QQ===null){var H=navigator.userAgent.match(/Safari\/(\d+)/i);QQ=H?parseInt(H[1]):0}}var W=X.prototype;return W.destroy=function Z(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},W.resetTimeStamp=function Z(J){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=J},W.resetNextTimestamp=function Z(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},W.resetInitSegment=function Z(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},W.getVideoStartPts=function Z(J){var Y=!1,Q=J[0].pts,G=J.reduce(function(q,H){var V=H.pts,z=V-q;if(z<-4294967296)Y=!0,V=k1(V,Q),z=V-q;if(z>0)return q;return V},Q);if(Y)this.logger.debug("PTS rollover detected");return G},W.remux=function Z(J,Y,Q,G,q,H,V,z){var A,E,I,$,L,b,C=q,D=q,y=J.pid>-1,S=Y.pid>-1,v=Y.samples.length,p=J.samples.length>0,g=V&&v>0||v>1,m=(!y||p)&&(!S||g)||this.ISGenerated||V;if(m){if(this.ISGenerated){var r,o,c,d,e=this.videoTrackConfig;if(e&&(Y.width!==e.width||Y.height!==e.height||((r=Y.pixelRatio)==null?void 0:r[0])!==((o=e.pixelRatio)==null?void 0:o[0])||((c=Y.pixelRatio)==null?void 0:c[1])!==((d=e.pixelRatio)==null?void 0:d[1]))||!e&&g||this.nextAudioPts===null&&p)this.resetInitSegment()}if(!this.ISGenerated)I=this.generateIS(J,Y,q,H);var H0=this.isVideoContiguous,Q0=-1,J0;if(g){if(Q0=Y9(Y.samples),!H0&&this.config.forceKeyFrameOnDiscontinuity){if(b=!0,Q0>0){this.logger.warn("[mp4-remuxer]: Dropped "+Q0+" out of "+v+" video samples due to a missing keyframe");var N0=this.getVideoStartPts(Y.samples);Y.samples=Y.samples.slice(Q0),Y.dropped+=Q0,D+=(Y.samples[0].pts-N0)/Y.inputTimeScale,J0=D}else if(Q0===-1)this.logger.warn("[mp4-remuxer]: No keyframe found out of "+v+" video samples"),b=!1}}if(this.ISGenerated){if(p&&g){var V0=this.getVideoStartPts(Y.samples),j0=k1(J.samples[0].pts,V0)-V0,O0=j0/Y.inputTimeScale;C+=Math.max(0,O0),D+=Math.max(0,-O0)}if(p){if(!J.samplerate)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),I=this.generateIS(J,Y,q,H);if(E=this.remuxAudio(J,C,this.isAudioContiguous,H,S||g||z===G0.AUDIO?D:void 0),g){var g0=E?E.endPTS-E.startPTS:0;if(!Y.inputTimeScale)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),I=this.generateIS(J,Y,q,H);A=this.remuxVideo(Y,D,H0,g0)}}else if(g)A=this.remuxVideo(Y,D,H0,0);if(A)A.firstKeyFrame=Q0,A.independent=Q0!==-1,A.firstKeyFramePTS=J0}}if(this.ISGenerated&&this._initPTS&&this._initDTS){if(Q.samples.length)L=KZ(Q,q,this._initPTS,this._initDTS);if(G.samples.length)$=qZ(G,q,this._initPTS)}return{audio:E,video:A,initSegment:I,independent:b,text:$,id3:L}},W.generateIS=function Z(J,Y,Q,G){var q=J.samples,H=Y.samples,V=this.typeSupported,z={},A=this._initPTS,E=!A||G,I="audio/mp4",$,L,b;if(E)$=L=1/0;if(J.config&&q.length){switch(J.timescale=J.samplerate,J.segmentCodec){case"mp3":if(V.mpeg)I="audio/mpeg",J.codec="";else if(V.mp3)J.codec="mp3";break;case"ac3":J.codec="ac-3";break}if(z.audio={id:"audio",container:I,codec:J.codec,initSegment:J.segmentCodec==="mp3"&&V.mpeg?new Uint8Array(0):H1.initSegment([J]),metadata:{channelCount:J.channelCount}},E)if(b=J.inputTimeScale,!A||b!==A.timescale)$=L=q[0].pts-Math.round(b*Q);else E=!1}if(Y.sps&&Y.pps&&H.length){if(Y.timescale=Y.inputTimeScale,z.video={id:"main",container:"video/mp4",codec:Y.codec,initSegment:H1.initSegment([Y]),metadata:{width:Y.width,height:Y.height}},E)if(b=Y.inputTimeScale,!A||b!==A.timescale){var C=this.getVideoStartPts(H),D=Math.round(b*Q);L=Math.min(L,k1(H[0].dts,C)-D),$=Math.min($,C-D)}else E=!1;this.videoTrackConfig={width:Y.width,height:Y.height,pixelRatio:Y.pixelRatio}}if(Object.keys(z).length){if(this.ISGenerated=!0,E)this._initPTS={baseTime:$,timescale:b},this._initDTS={baseTime:L,timescale:b};else $=b=void 0;return{tracks:z,initPTS:$,timescale:b}}},W.remuxVideo=function Z(J,Y,Q,G){var{inputTimeScale:q,samples:H}=J,V=[],z=H.length,A=this._initPTS,E=this.nextAvcDts,I=8,$=this.videoSampleDuration,L,b,C=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,y=!1;if(!Q||E===null){var S=Y*q,v=H[0].pts-k1(H[0].dts,H[0].pts);if(EY&&E!==null&&Math.abs(S-v-E)<15000)Q=!0;else E=S-v}var p=A.baseTime*q/A.timescale;for(var g=0;g<z;g++){var m=H[g];if(m.pts=k1(m.pts-p,E),m.dts=k1(m.dts-p,E),m.dts<H[g>0?g-1:g].dts)y=!0}if(y)H.sort(function($J,mZ){var AG=$J.dts-mZ.dts,OG=$J.pts-mZ.pts;return AG||OG});L=H[0].dts,b=H[H.length-1].dts;var r=b-L,o=r?Math.round(r/(z-1)):$||J.inputTimeScale/30;if(Q){var c=L-E,d=c>o,e=c<-1;if(d||e){if(d)this.logger.warn((J.segmentCodec||"").toUpperCase()+": "+kY(c)+" ms ("+c+"dts) hole between fragments detected at "+Y.toFixed(3));else this.logger.warn((J.segmentCodec||"").toUpperCase()+": "+kY(-c)+" ms ("+c+"dts) overlapping between fragments detected at "+Y.toFixed(3));if(!e||E>=H[0].pts||EY){L=E;var H0=H[0].pts-c;if(d)H[0].dts=L,H[0].pts=H0;else{var Q0=!0;for(var J0=0;J0<H.length;J0++){if(H[J0].dts>H0&&Q0)break;var N0=H[J0].pts;if(H[J0].dts-=c,H[J0].pts-=c,J0<H.length-1){var V0=H[J0+1].pts,j0=H[J0].pts,O0=V0<=j0,g0=V0<=N0;Q0=O0==g0}}}this.logger.log("Video: Initial PTS/DTS adjusted: "+kY(H0)+"/"+kY(L)+", delta: "+kY(c)+" ms")}}}L=Math.max(0,L);var T0=0,m0=0,D0=L;for(var Y1=0;Y1<z;Y1++){var _0=H[Y1],a0=_0.units,w1=a0.length,q1=0;for(var p0=0;p0<w1;p0++)q1+=a0[p0].data.length;if(m0+=q1,T0+=w1,_0.length=q1,_0.dts<D0)_0.dts=D0,D0+=o/4|0||1;else D0=_0.dts;C=Math.min(_0.pts,C),D=Math.max(_0.pts,D)}b=H[z-1].dts;var R1=m0+4*T0+8,Z1;try{Z1=new Uint8Array(R1)}catch($J){this.observer.emit(M.ERROR,M.ERROR,{type:n.MUX_ERROR,details:h.REMUX_ALLOC_ERROR,fatal:!1,error:$J,bytes:R1,reason:"fail allocating video mdat "+R1});return}var s0=new DataView(Z1.buffer);s0.setUint32(0,R1),Z1.set(H1.types.mdat,4);var $1=!1,V1=Number.POSITIVE_INFINITY,M1=Number.POSITIVE_INFINITY,n0=Number.NEGATIVE_INFINITY,z1=Number.NEGATIVE_INFINITY;for(var X1=0;X1<z;X1++){var I1=H[X1],_Y=I1.units,xZ=0;for(var VQ=0,WG=_Y.length;VQ<WG;VQ++){var vZ=_Y[VQ],KG=vZ.data,zQ=vZ.data.byteLength;s0.setUint32(I,zQ),I+=4,Z1.set(KG,I),I+=zQ,xZ+=4+zQ}var wJ=void 0;if(X1<z-1)$=H[X1+1].dts-I1.dts,wJ=H[X1+1].pts-I1.pts;else{var hZ=this.config,RJ=X1>0?I1.dts-H[X1-1].dts:o;if(wJ=X1>0?I1.pts-H[X1-1].pts:o,hZ.stretchShortVideoTrack&&this.nextAudioPts!==null){var qG=Math.floor(hZ.maxBufferHole*q),jQ=(G?C+G*q:this.nextAudioPts)-I1.pts;if(jQ>qG){if($=jQ-RJ,$<0)$=RJ;else $1=!0;this.logger.log("[mp4-remuxer]: It is approximately "+jQ/90+" ms to the next segment; using duration "+$/90+" ms for the last video frame.")}else $=RJ}else $=RJ}var HG=Math.round(I1.pts-I1.dts);V1=Math.min(V1,$),n0=Math.max(n0,$),M1=Math.min(M1,wJ),z1=Math.max(z1,wJ),V.push(WZ(I1.key,$,xZ,HG))}if(V.length){if(EY){if(EY<70){var kZ=V[0].flags;kZ.dependsOn=2,kZ.isNonSync=0}}else if(QQ){if(z1-M1<n0-V1&&o/n0<0.025&&V[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");var AQ=L;for(var g1=0,gZ=V.length;g1<gZ;g1++){var uZ=AQ+V[g1].duration,NG=AQ+V[g1].cts;if(g1<gZ-1){var UG=uZ+V[g1+1].cts;V[g1].duration=UG-NG}else V[g1].duration=g1?V[g1-1].duration:o;V[g1].cts=0,AQ=uZ}}}}$=$1||!$?o:$,this.nextAvcDts=E=b+$,this.videoSampleDuration=$,this.isVideoContiguous=!0;var VG=H1.moof(J.sequenceNumber++,L,B(J,{samples:V})),zG="video",jG={data1:VG,data2:Z1,startPTS:C/q,endPTS:(D+$)/q,startDTS:L/q,endDTS:E/q,type:zG,hasAudio:!1,hasVideo:!0,nb:V.length,dropped:J.dropped};return J.samples=[],J.dropped=0,jG},W.getSamplesPerFrame=function Z(J){switch(J.segmentCodec){case"mp3":return t7;case"ac3":return e7;default:return a7}},W.remuxAudio=function Z(J,Y,Q,G,q){var H=J.inputTimeScale,V=J.samplerate?J.samplerate:H,z=H/V,A=this.getSamplesPerFrame(J),E=A*z,I=this._initPTS,$=J.segmentCodec==="mp3"&&this.typeSupported.mpeg,L=[],b=q!==void 0,C=J.samples,D=$?0:8,y=this.nextAudioPts||-1,S=Y*H,v=I.baseTime*H/I.timescale;if(this.isAudioContiguous=Q=Q||C.length&&y>0&&(G&&Math.abs(S-y)<9000||Math.abs(k1(C[0].pts-v,S)-y)<20*E),C.forEach(function(n0){n0.pts=k1(n0.pts-v,S)}),!Q||y<0){if(C=C.filter(function(n0){return n0.pts>=0}),!C.length)return;if(q===0)y=0;else if(G&&!b)y=Math.max(0,S);else y=C[0].pts}if(J.segmentCodec==="aac"){var p=this.config.maxAudioFramesDrift;for(var g=0,m=y;g<C.length;g++){var r=C[g],o=r.pts,c=o-m,d=Math.abs(1000*c/H);if(c<=-p*E&&b){if(g===0)this.logger.warn("Audio frame @ "+(o/H).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1000*c/H)+" ms."),this.nextAudioPts=y=m=o}else if(c>=p*E&&d<r7&&b){var e=Math.round(c/E);if(m=o-e*E,m<0)e--,m+=E;if(g===0)this.nextAudioPts=y=m;this.logger.warn("[mp4-remuxer]: Injecting "+e+" audio frame @ "+(m/H).toFixed(3)+"s due to "+Math.round(1000*c/H)+" ms gap.");for(var H0=0;H0<e;H0++){var Q0=Math.max(m,0),J0=o7.getSilentFrame(J.parsedCodec||J.manifestCodec||J.codec,J.channelCount);if(!J0)this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J0=r.unit.subarray();C.splice(g,0,{unit:J0,pts:Q0}),m+=E,g++}}r.pts=m,m+=E}}var N0=null,V0=null,j0,O0=0,g0=C.length;while(g0--)O0+=C[g0].unit.byteLength;for(var T0=0,m0=C.length;T0<m0;T0++){var D0=C[T0],Y1=D0.unit,_0=D0.pts;if(V0!==null){var a0=L[T0-1];a0.duration=Math.round((_0-V0)/z)}else{if(Q&&J.segmentCodec==="aac")_0=y;if(N0=_0,O0>0){O0+=D;try{j0=new Uint8Array(O0)}catch(n0){this.observer.emit(M.ERROR,M.ERROR,{type:n.MUX_ERROR,details:h.REMUX_ALLOC_ERROR,fatal:!1,error:n0,bytes:O0,reason:"fail allocating audio mdat "+O0});return}if(!$){var w1=new DataView(j0.buffer);w1.setUint32(0,O0),j0.set(H1.types.mdat,4)}}else return}j0.set(Y1,D);var q1=Y1.byteLength;D+=q1,L.push(WZ(!0,A,q1,0)),V0=_0}var p0=L.length;if(!p0)return;var R1=L[L.length-1];this.nextAudioPts=y=V0+z*R1.duration;var Z1=$?new Uint8Array(0):H1.moof(J.sequenceNumber++,N0/z,B({},J,{samples:L}));J.samples=[];var s0=N0/H,$1=y/H,V1="audio",M1={data1:Z1,data2:j0,startPTS:s0,endPTS:$1,startDTS:s0,endDTS:$1,type:V1,hasAudio:!0,hasVideo:!1,nb:p0};return this.isAudioContiguous=!0,M1},X}();function k1(X,W){var Z;if(W===null)return X;if(W<X)Z=-8589934592;else Z=8589934592;while(Math.abs(X-W)>4294967296)X+=Z;return X}function Y9(X){for(var W=0;W<X.length;W++)if(X[W].key)return W;return-1}function KZ(X,W,Z,J){var Y=X.samples.length;if(!Y)return;var Q=X.inputTimeScale;for(var G=0;G<Y;G++){var q=X.samples[G];q.pts=k1(q.pts-Z.baseTime*Q/Z.timescale,W*Q)/Q,q.dts=k1(q.dts-J.baseTime*Q/J.timescale,W*Q)/Q}var H=X.samples;return X.samples=[],{samples:H}}function qZ(X,W,Z){var J=X.samples.length;if(!J)return;var Y=X.inputTimeScale;for(var Q=0;Q<J;Q++){var G=X.samples[Q];G.pts=k1(G.pts-Z.baseTime*Y/Z.timescale,W*Y)/Y}X.samples.sort(function(H,V){return H.pts-V.pts});var q=X.samples;return X.samples=[],{samples:q}}var J9=function(){function X(Z,J,Y,Q){this.logger=void 0,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,this.logger=Q}var W=X.prototype;return W.destroy=function Z(){},W.resetTimeStamp=function Z(J){this.initPTS=J,this.lastEndTime=null},W.resetNextTimestamp=function Z(){this.lastEndTime=null},W.resetInitSegment=function Z(J,Y,Q,G){this.audioCodec=Y,this.videoCodec=Q,this.generateInitSegment(ZX(J,G)),this.emitInitSegment=!0},W.generateInitSegment=function Z(J){var Y=this.audioCodec,Q=this.videoCodec;if(!(J!=null&&J.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var G=this.initData=aQ(J);if(G.audio)Y=HZ(G.audio,i0.AUDIO);if(G.video)Q=HZ(G.video,i0.VIDEO);var q={};if(G.audio&&G.video)q.audiovideo={container:"video/mp4",codec:Y+","+Q,supplemental:G.video.supplemental,initSegment:J,id:"main"};else if(G.audio)q.audio={container:"audio/mp4",codec:Y,initSegment:J,id:"audio"};else if(G.video)q.video={container:"video/mp4",codec:Q,supplemental:G.video.supplemental,initSegment:J,id:"main"};else this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.");this.initTracks=q},W.remux=function Z(J,Y,Q,G,q,H){var V,z,A=this.initPTS,E=this.lastEndTime,I={audio:void 0,video:void 0,text:G,id3:Q,initSegment:void 0};if(!T(E))E=this.lastEndTime=q||0;var $=Y.samples;if(!($!=null&&$.length))return I;var L={initPTS:void 0,timescale:1},b=this.initData;if(!((V=b)!=null&&V.length))this.generateInitSegment($),b=this.initData;if(!((z=b)!=null&&z.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),I;if(this.emitInitSegment)L.tracks=this.initTracks,this.emitInitSegment=!1;var C=WX($,b),D=GX(b,$),y=D===null?q:D;if((H||!A)&&(Q9(A,y,q,C)||L.timescale!==A.timescale)){if(L.initPTS=y-q,A&&A.timescale===1)this.logger.warn("Adjusting initPTS @"+q+" from "+A.baseTime/A.timescale+" to "+L.initPTS);this.initPTS=A={baseTime:L.initPTS,timescale:1}}var S=J?y-A.baseTime/A.timescale:E,v=S+C;if(qX(b,$,A.baseTime/A.timescale),C>0)this.lastEndTime=v;else this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp();var p=!!b.audio,g=!!b.video,m="";if(p)m+="audio";if(g)m+="video";var r={data1:$,startPTS:S,startDTS:S,endPTS:v,endDTS:v,type:m,hasAudio:p,hasVideo:g,nb:1,dropped:0};if(I.audio=r.type==="audio"?r:void 0,I.video=r.type!=="audio"?r:void 0,I.initSegment=L,I.id3=KZ(Q,q,A,A),G.samples.length)I.text=qZ(G,q,A);return I},X}();function Q9(X,W,Z,J){if(X===null)return!0;var Y=Math.max(J,1),Q=W-X.baseTime/X.timescale;return Math.abs(Q-Z)>Y}function HZ(X,W){var Z=X==null?void 0:X.codec;if(Z&&Z.length>4)return Z;if(W===i0.AUDIO){if(Z==="ec-3"||Z==="ac-3"||Z==="alac")return Z;if(Z==="fLaC"||Z==="Opus"){var J=!1;return ZJ(Z,J)}return v0.warn('Unhandled audio codec "'+Z+'" in mp4 MAP'),Z||"mp4a"}return v0.warn('Unhandled video codec "'+Z+'" in mp4 MAP'),Z||"avc1"}var t1;try{t1=self.performance.now.bind(self.performance)}catch(X){t1=Date.now}var XQ=[{demux:p7,remux:J9},{demux:l7,remux:ZQ},{demux:y7,remux:ZQ},{demux:x7,remux:ZQ}],GQ=function(){function X(Z,J,Y,Q,G,q){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=Z,this.typeSupported=J,this.config=Y,this.id=G,this.logger=q}var W=X.prototype;return W.configure=function Z(J){if(this.transmuxConfig=J,this.decrypter)this.decrypter.reset()},W.push=function Z(J,Y,Q,G){var q=this,H=Q.transmuxing;H.executeStart=t1();var V=new Uint8Array(J),z=this.currentTransmuxState,A=this.transmuxConfig;if(G)this.currentTransmuxState=G;var E=G||z,I=E.contiguous,$=E.discontinuity,L=E.trackSwitch,b=E.accurateTimeOffset,C=E.timeOffset,D=E.initSegmentChange,y=A.audioCodec,S=A.videoCodec,v=A.defaultInitPts,p=A.duration,g=A.initSegmentData,m=Z9(V,Y);if(m&&vY(m.method)){var r=this.getDecrypter(),o=I2(m.method);if(r.isSync()){var c=r.softwareDecrypt(V,m.key.buffer,m.iv.buffer,o),d=Q.part>-1;if(d){var e=r.flush();c=e?e.buffer:e}if(!c)return H.executeEnd=t1(),WQ(Q);V=new Uint8Array(c)}else return this.asyncResult=!0,this.decryptionPromise=r.webCryptoDecrypt(V,m.key.buffer,m.iv.buffer,o).then(function(V0){var j0=q.push(V0,null,Q);return q.decryptionPromise=null,j0}),this.decryptionPromise}var H0=this.needsProbing($,L);if(H0){var Q0=this.configureTransmuxer(V);if(Q0)return this.logger.warn("[transmuxer] "+Q0.message),this.observer.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,error:Q0,reason:Q0.message}),H.executeEnd=t1(),WQ(Q)}if($||L||D||H0)this.resetInitSegment(g,y,S,p,Y);if($||D||H0)this.resetInitialTimestamp(v);if(!I)this.resetContiguity();var J0=this.transmux(V,m,C,b,Q);this.asyncResult=VY(J0);var N0=this.currentTransmuxState;return N0.contiguous=!0,N0.discontinuity=!1,N0.trackSwitch=!1,H.executeEnd=t1(),J0},W.flush=function Z(J){var Y=this,Q=J.transmuxing;Q.executeStart=t1();var G=this.decrypter,q=this.currentTransmuxState,H=this.decryptionPromise;if(H)return this.asyncResult=!0,H.then(function(){return Y.flush(J)});var V=[],z=q.timeOffset;if(G){var A=G.flush();if(A)V.push(this.push(A.buffer,null,J))}var E=this.demuxer,I=this.remuxer;if(!E||!I){Q.executeEnd=t1();var $=[WQ(J)];if(this.asyncResult)return Promise.resolve($);return $}var L=E.flush(z);if(VY(L))return this.asyncResult=!0,L.then(function(b){return Y.flushRemux(V,b,J),V});if(this.flushRemux(V,L,J),this.asyncResult)return Promise.resolve(V);return V},W.flushRemux=function Z(J,Y,Q){var{audioTrack:G,videoTrack:q,id3Track:H,textTrack:V}=Y,z=this.currentTransmuxState,A=z.accurateTimeOffset,E=z.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+Q.sn+(Q.part>-1?" part: "+Q.part:"")+" of "+(this.id===G0.MAIN?"level":"track")+" "+Q.level);var I=this.remuxer.remux(G,q,H,V,E,A,!0,this.id);J.push({remuxResult:I,chunkMeta:Q}),Q.transmuxing.executeEnd=t1()},W.resetInitialTimestamp=function Z(J){var Y=this.demuxer,Q=this.remuxer;if(!Y||!Q)return;Y.resetTimeStamp(J),Q.resetTimeStamp(J)},W.resetContiguity=function Z(){var J=this.demuxer,Y=this.remuxer;if(!J||!Y)return;J.resetContiguity(),Y.resetNextTimestamp()},W.resetInitSegment=function Z(J,Y,Q,G,q){var H=this.demuxer,V=this.remuxer;if(!H||!V)return;H.resetInitSegment(J,Y,Q,G),V.resetInitSegment(J,Y,Q,q)},W.destroy=function Z(){if(this.demuxer)this.demuxer.destroy(),this.demuxer=void 0;if(this.remuxer)this.remuxer.destroy(),this.remuxer=void 0},W.transmux=function Z(J,Y,Q,G,q){var H;if(Y&&Y.method==="SAMPLE-AES")H=this.transmuxSampleAes(J,Y,Q,G,q);else H=this.transmuxUnencrypted(J,Q,G,q);return H},W.transmuxUnencrypted=function Z(J,Y,Q,G){var q=this.demuxer.demux(J,Y,!1,!this.config.progressive),H=q.audioTrack,V=q.videoTrack,z=q.id3Track,A=q.textTrack,E=this.remuxer.remux(H,V,z,A,Y,Q,!1,this.id);return{remuxResult:E,chunkMeta:G}},W.transmuxSampleAes=function Z(J,Y,Q,G,q){var H=this;return this.demuxer.demuxSampleAes(J,Y,Q).then(function(V){var z=H.remuxer.remux(V.audioTrack,V.videoTrack,V.id3Track,V.textTrack,Q,G,!1,H.id);return{remuxResult:z,chunkMeta:q}})},W.configureTransmuxer=function Z(J){var Y=this.config,Q=this.observer,G=this.typeSupported,q;for(var H=0,V=XQ.length;H<V;H++){var z;if((z=XQ[H].demux)!=null&&z.probe(J,this.logger)){q=XQ[H];break}}if(!q)return new Error("Failed to find demuxer by probing fragment data");var A=this.demuxer,E=this.remuxer,I=q.remux,$=q.demux;if(!E||!(E instanceof I))this.remuxer=new I(Q,Y,G,this.logger);if(!A||!(A instanceof $))this.demuxer=new $(Q,Y,G,this.logger),this.probe=$.probe},W.needsProbing=function Z(J,Y){return!this.demuxer||!this.remuxer||J||Y},W.getDecrypter=function Z(){var J=this.decrypter;if(!J)J=this.decrypter=new eJ(this.config);return J},X}();function Z9(X,W){var Z=null;if(X.byteLength>0&&(W==null?void 0:W.key)!=null&&W.iv!==null&&W.method!=null)Z=W;return Z}var WQ=function X(W){return{remuxResult:{},chunkMeta:W}};function VY(X){return"then"in X&&X.then instanceof Function}var X9=function X(W,Z,J,Y,Q){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=W,this.videoCodec=Z,this.initSegmentData=J,this.duration=Y,this.defaultInitPts=Q||null},G9=function X(W,Z,J,Y,Q,G){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=W,this.contiguous=Z,this.accurateTimeOffset=J,this.trackSwitch=Y,this.timeOffset=Q,this.initSegmentChange=G};function W9(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(X){}return!1}var K9=/(\d+)-(\d+)\/(\d+)/,NZ=function(){function X(Z){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=Z.fetchSetup||U9,this.controller=new self.AbortController,this.stats=new hJ}var W=X.prototype;return W.destroy=function Z(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},W.abortInternal=function Z(){if(this.controller&&!this.stats.loading.end)this.stats.aborted=!0,this.controller.abort()},W.abort=function Z(){var J;if(this.abortInternal(),(J=this.callbacks)!=null&&J.onAbort)this.callbacks.onAbort(this.stats,this.context,this.response)},W.load=function Z(J,Y,Q){var G=this,q=this.stats;if(q.loading.start)throw new Error("Loader can only be used once.");q.loading.start=self.performance.now();var H=q9(J,this.controller.signal),V=J.responseType==="arraybuffer",z=V?"byteLength":"length",A=Y.loadPolicy,E=A.maxTimeToFirstByteMs,I=A.maxLoadTimeMs;this.context=J,this.config=Y,this.callbacks=Q,this.request=this.fetchSetup(J,H),self.clearTimeout(this.requestTimeout),Y.timeout=E&&T(E)?E:I,this.requestTimeout=self.setTimeout(function(){if(G.callbacks)G.abortInternal(),G.callbacks.onTimeout(q,J,G.response)},Y.timeout);var $=VY(this.request)?this.request.then(self.fetch):self.fetch(this.request);$.then(function(L){var b;G.response=G.loader=L;var C=Math.max(self.performance.now(),q.loading.start);if(self.clearTimeout(G.requestTimeout),Y.timeout=I,G.requestTimeout=self.setTimeout(function(){if(G.callbacks)G.abortInternal(),G.callbacks.onTimeout(q,J,G.response)},I-(C-q.loading.start)),!L.ok){var{status:D,statusText:y}=L;throw new V9(y||"fetch, bad network response",D,L)}q.loading.first=C,q.total=N9(L.headers)||q.total;var S=(b=G.callbacks)==null?void 0:b.onProgress;if(S&&T(Y.highWaterMark))return G.loadProgressively(L,q,J,Y.highWaterMark,S);if(V)return L.arrayBuffer();if(J.responseType==="json")return L.json();return L.text()}).then(function(L){var b,C,D=G.response;if(!D)throw new Error("loader destroyed");self.clearTimeout(G.requestTimeout),q.loading.end=Math.max(self.performance.now(),q.loading.first);var y=L[z];if(y)q.loaded=q.total=y;var S={url:D.url,data:L,code:D.status},v=(b=G.callbacks)==null?void 0:b.onProgress;if(v&&!T(Y.highWaterMark))v(q,J,L,D);(C=G.callbacks)==null||C.onSuccess(S,q,J,D)}).catch(function(L){var b;if(self.clearTimeout(G.requestTimeout),q.aborted)return;var C=!L?0:L.code||0,D=!L?null:L.message;(b=G.callbacks)==null||b.onError({code:C,text:D},J,L?L.details:null,q)})},W.getCacheAge=function Z(){var J=null;if(this.response){var Y=this.response.headers.get("age");J=Y?parseFloat(Y):null}return J},W.getResponseHeader=function Z(J){return this.response?this.response.headers.get(J):null},W.loadProgressively=function Z(J,Y,Q,G,q){if(G===void 0)G=0;var H=new G7,V=J.body.getReader(),z=function A(){return V.read().then(function(E){if(E.done){if(H.dataLength)q(Y,Q,H.flush().buffer,J);return Promise.resolve(new ArrayBuffer(0))}var I=E.value,$=I.length;if(Y.loaded+=$,$<G||H.dataLength){if(H.push(I),H.dataLength>=G)q(Y,Q,H.flush().buffer,J)}else q(Y,Q,I.buffer,J);return z()}).catch(function(){return Promise.reject()})};return z()},X}();function q9(X,W){var Z={method:"GET",mode:"cors",credentials:"same-origin",signal:W,headers:new self.Headers(B({},X.headers))};if(X.rangeEnd)Z.headers.set("Range","bytes="+X.rangeStart+"-"+String(X.rangeEnd-1));return Z}function H9(X){var W=K9.exec(X);if(W)return parseInt(W[2])-parseInt(W[1])+1}function N9(X){var W=X.get("Content-Range");if(W){var Z=H9(W);if(T(Z))return Z}var J=X.get("Content-Length");if(J)return parseInt(J)}function U9(X,W){return new self.Request(X.url,W)}var V9=function(X){function W(Z,J,Y){var Q=X.call(this,Z)||this;return Q.code=void 0,Q.details=void 0,Q.code=J,Q.details=Y,Q}return R(W,X),W}(t(Error)),z9=/^age:\s*[\d.]+\s*$/im,UZ=function(){function X(Z){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=Z?Z.xhrSetup||null:null,this.stats=new hJ,this.retryDelay=0}var W=X.prototype;return W.destroy=function Z(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},W.abortInternal=function Z(){var J=this.loader;if(self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),J){if(J.onreadystatechange=null,J.onprogress=null,J.readyState!==4)this.stats.aborted=!0,J.abort()}},W.abort=function Z(){var J;if(this.abortInternal(),(J=this.callbacks)!=null&&J.onAbort)this.callbacks.onAbort(this.stats,this.context,this.loader)},W.load=function Z(J,Y,Q){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=J,this.config=Y,this.callbacks=Q,this.loadInternal()},W.loadInternal=function Z(){var J=this,Y=this.config,Q=this.context;if(!Y||!Q)return;var G=this.loader=new self.XMLHttpRequest,q=this.stats;q.loading.first=0,q.loaded=0,q.aborted=!1;var H=this.xhrSetup;if(H)Promise.resolve().then(function(){if(J.loader!==G||J.stats.aborted)return;return H(G,Q.url)}).catch(function(V){if(J.loader!==G||J.stats.aborted)return;return G.open("GET",Q.url,!0),H(G,Q.url)}).then(function(){if(J.loader!==G||J.stats.aborted)return;J.openAndSendXhr(G,Q,Y)}).catch(function(V){var z;(z=J.callbacks)==null||z.onError({code:G.status,text:V.message},Q,G,q);return});else this.openAndSendXhr(G,Q,Y)},W.openAndSendXhr=function Z(J,Y,Q){if(!J.readyState)J.open("GET",Y.url,!0);var G=Y.headers,q=Q.loadPolicy,H=q.maxTimeToFirstByteMs,V=q.maxLoadTimeMs;if(G)for(var z in G)J.setRequestHeader(z,G[z]);if(Y.rangeEnd)J.setRequestHeader("Range","bytes="+Y.rangeStart+"-"+(Y.rangeEnd-1));J.onreadystatechange=this.readystatechange.bind(this),J.onprogress=this.loadprogress.bind(this),J.responseType=Y.responseType,self.clearTimeout(this.requestTimeout),Q.timeout=H&&T(H)?H:V,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),Q.timeout),J.send()},W.readystatechange=function Z(){var J=this.context,Y=this.loader,Q=this.stats;if(!J||!Y)return;var G=Y.readyState,q=this.config;if(Q.aborted)return;if(G>=2){if(Q.loading.first===0){if(Q.loading.first=Math.max(self.performance.now(),Q.loading.start),q.timeout!==q.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),q.timeout=q.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),q.loadPolicy.maxLoadTimeMs-(Q.loading.first-Q.loading.start))}if(G===4){self.clearTimeout(this.requestTimeout),Y.onreadystatechange=null,Y.onprogress=null;var H=Y.status,V=Y.responseType==="text"?Y.responseText:null;if(H>=200&&H<300){var z=V!=null?V:Y.response;if(z!=null){var A,E;Q.loading.end=Math.max(self.performance.now(),Q.loading.first);var I=Y.responseType==="arraybuffer"?z.byteLength:z.length;Q.loaded=Q.total=I,Q.bwEstimate=Q.total*8000/(Q.loading.end-Q.loading.first);var $=(A=this.callbacks)==null?void 0:A.onProgress;if($)$(Q,J,z,Y);var L={url:Y.responseURL,data:z,code:H};(E=this.callbacks)==null||E.onSuccess(L,Q,J,Y);return}}var b=q.loadPolicy.errorRetry,C=Q.retry,D={url:J.url,data:void 0,code:H};if(qJ(b,C,!1,D))this.retry(b);else{var y;v0.error(H+" while loading "+J.url),(y=this.callbacks)==null||y.onError({code:H,text:Y.statusText},J,Y,Q)}}}},W.loadtimeout=function Z(){if(!this.config)return;var J=this.config.loadPolicy.timeoutRetry,Y=this.stats.retry;if(qJ(J,Y,!0))this.retry(J);else{var Q;v0.warn("timeout while loading "+((Q=this.context)==null?void 0:Q.url));var G=this.callbacks;if(G)this.abortInternal(),G.onTimeout(this.stats,this.context,this.loader)}},W.retry=function Z(J){var Y=this.context,Q=this.stats;this.retryDelay=lJ(J,Q.retry),Q.retry++,v0.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(Y==null?void 0:Y.url)+", retrying "+Q.retry+"/"+J.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},W.loadprogress=function Z(J){var Y=this.stats;if(Y.loaded=J.loaded,J.lengthComputable)Y.total=J.total},W.getCacheAge=function Z(){var J=null;if(this.loader&&z9.test(this.loader.getAllResponseHeaders())){var Y=this.loader.getResponseHeader("age");J=Y?parseFloat(Y):null}return J},W.getResponseHeader=function Z(J){if(this.loader&&new RegExp("^"+J+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders()))return this.loader.getResponseHeader(J);return null},X}(),VZ={maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:null,errorRetry:null},j9=f(f({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60000000,maxFragLookUpTolerance:0.25,maxBufferHole:0.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:0.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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:5000,fpsDroppedMonitoringThreshold:0.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:UZ,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:MX,bufferController:hX,capLevelController:gX,errorController:xX,fpsController:X7,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:500000,abrEwmaDefaultEstimateMax:5000000,abrBandWidthFactor:0.95,abrBandWidthUpFactor:0.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,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,certLoadPolicy:{default:VZ},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1000,maxRetryDelayMs:8000}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:120000,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1000,maxRetryDelayMs:8000}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},interstitialAssetListLoadPolicy:{default:VZ},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1000,manifestLoadingMaxRetryTimeout:64000,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1000,levelLoadingMaxRetryTimeout:64000,fragLoadingTimeOut:20000,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1000,fragLoadingMaxRetryTimeout:64000},A9()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Z7,interstitialsController:void 0});function A9(){return{cueHandler:r8,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function O9(X,W,Z){if((W.liveSyncDurationCount||W.liveMaxLatencyDurationCount)&&(W.liveSyncDuration||W.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(W.liveMaxLatencyDurationCount!==void 0&&(W.liveSyncDurationCount===void 0||W.liveMaxLatencyDurationCount<=W.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(W.liveMaxLatencyDuration!==void 0&&(W.liveSyncDuration===void 0||W.liveMaxLatencyDuration<=W.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var J=KQ(X),Y=["manifest","level","frag"],Q=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return Y.forEach(function(G){var q=(G==="level"?"playlist":G)+"LoadPolicy",H=W[q]===void 0,V=[];if(Q.forEach(function(z){var A=G+"Loading"+z,E=W[A];if(E!==void 0&&H){V.push(A);var I=J[q].default;switch(W[q]={default:I},z){case"TimeOut":I.maxLoadTimeMs=E,I.maxTimeToFirstByteMs=E;break;case"MaxRetry":I.errorRetry.maxNumRetry=E,I.timeoutRetry.maxNumRetry=E;break;case"RetryDelay":I.errorRetry.retryDelayMs=E,I.timeoutRetry.retryDelayMs=E;break;case"MaxRetryTimeout":I.errorRetry.maxRetryDelayMs=E,I.timeoutRetry.maxRetryDelayMs=E;break}}}),V.length)Z.warn('hls.js config: "'+V.join('", "')+'" setting(s) are deprecated, use "'+q+'": '+O1(W[q]))}),f(f({},J),W)}function KQ(X){if(X&&typeof X==="object"){if(Array.isArray(X))return X.map(KQ);return Object.keys(X).reduce(function(W,Z){return W[Z]=KQ(X[Z]),W},{})}return X}function F9(X,W){var Z=X.loader;if(Z!==NZ&&Z!==UZ)W.log("[config]: Custom loader detected, cannot enable progressive streaming"),X.progressive=!1;else{var J=W9();if(J)X.loader=NZ,X.progressive=!0,X.enableSoftwareAES=!0,W.log("[config]: Progressive streaming enabled, using FetchLoader")}}var B1={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},E9=function(){function X(Z){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=0.2,this.hls=void 0,this.hasGaps=!1,this.hls=Z,this._registerListeners()}var W=X.prototype;return W._registerListeners=function Z(){var J=this.hls;J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.BUFFER_APPENDED,this.onBufferAppended,this),J.on(M.FRAG_BUFFERED,this.onFragBuffered,this),J.on(M.FRAG_LOADED,this.onFragLoaded,this)},W._unregisterListeners=function Z(){var J=this.hls;J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.BUFFER_APPENDED,this.onBufferAppended,this),J.off(M.FRAG_BUFFERED,this.onFragBuffered,this),J.off(M.FRAG_LOADED,this.onFragLoaded,this)},W.destroy=function Z(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},W.getAppendedFrag=function Z(J,Y){var Q=this.activePartLists[Y];if(Q)for(var G=Q.length;G--;){var q=Q[G];if(!q)break;var H=q.end;if(q.start<=J&&H!==null&&J<=H)return q}return this.getBufferedFrag(J,Y)},W.getBufferedFrag=function Z(J,Y){return this.getFragAtPos(J,Y,!0)},W.getFragAtPos=function Z(J,Y,Q){var G=this.fragments,q=Object.keys(G);for(var H=q.length;H--;){var V=G[q[H]];if((V==null?void 0:V.body.type)===Y&&(!Q||V.buffered)){var z=V.body;if(z.start<=J&&J<=z.end)return z}}return null},W.detectEvictedFragments=function Z(J,Y,Q,G,q){var H=this;if(this.timeRanges)this.timeRanges[J]=Y;var V=(G==null?void 0:G.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(z){var A=H.fragments[z];if(!A)return;if(V>=A.body.sn)return;if(!A.buffered&&(!A.loaded||q)){if(A.body.type===Q)H.removeFragment(A.body);return}var E=A.range[J];if(!E)return;if(E.time.length===0){H.removeFragment(A.body);return}E.time.some(function(I){var $=!H.isTimeBuffered(I.startPTS,I.endPTS,Y);if($)H.removeFragment(A.body);return $})})},W.detectPartialFragments=function Z(J){var Y=this,Q=this.timeRanges;if(!Q||J.frag.sn==="initSegment")return;var G=J.frag,q=BY(G),H=this.fragments[q];if(!H||H.buffered&&G.gap)return;var V=!G.relurl;if(Object.keys(Q).forEach(function(A){var E=G.elementaryStreams[A];if(!E)return;var I=Q[A],$=V||E.partial===!0;H.range[A]=Y.getBufferedTimes(G,J.part,$,I)}),H.loaded=null,Object.keys(H.range).length){H.buffered=!0;var z=H.body.endList=G.endList||H.body.endList;if(z)this.endListFragments[H.body.type]=H;if(!OJ(H))this.removeParts(G.sn-1,G.type)}else this.removeFragment(H.body)},W.removeParts=function Z(J,Y){var Q=this.activePartLists[Y];if(!Q)return;this.activePartLists[Y]=Q.filter(function(G){return G.fragment.sn>=J})},W.fragBuffered=function Z(J,Y){var Q=BY(J),G=this.fragments[Q];if(!G&&Y){if(G=this.fragments[Q]={body:J,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},J.gap)this.hasGaps=!0}if(G)G.loaded=null,G.buffered=!0},W.getBufferedTimes=function Z(J,Y,Q,G){var q={time:[],partial:Q},H=J.start,V=J.end,z=J.minEndPTS||V,A=J.maxStartPTS||H;for(var E=0;E<G.length;E++){var I=G.start(E)-this.bufferPadding,$=G.end(E)+this.bufferPadding;if(A>=I&&z<=$){q.time.push({startPTS:Math.max(H,G.start(E)),endPTS:Math.min(V,G.end(E))});break}else if(H<$&&V>I){var L=Math.max(H,G.start(E)),b=Math.min(V,G.end(E));if(b>L)q.partial=!0,q.time.push({startPTS:L,endPTS:b})}else if(V<=I)break}return q},W.getPartialFragment=function Z(J){var Y=null,Q,G,q,H=0,V=this.bufferPadding,z=this.fragments;return Object.keys(z).forEach(function(A){var E=z[A];if(!E)return;if(OJ(E)){if(G=E.body.start-V,q=E.body.end+V,J>=G&&J<=q){if(Q=Math.min(J-G,q-J),H<=Q)Y=E.body,H=Q}}}),Y},W.isEndListAppended=function Z(J){var Y=this.endListFragments[J];return Y!==void 0&&(Y.buffered||OJ(Y))},W.getState=function Z(J){var Y=BY(J),Q=this.fragments[Y];if(Q)if(!Q.buffered)return B1.APPENDING;else if(OJ(Q))return B1.PARTIAL;else return B1.OK;return B1.NOT_LOADED},W.isTimeBuffered=function Z(J,Y,Q){var G,q;for(var H=0;H<Q.length;H++){if(G=Q.start(H)-this.bufferPadding,q=Q.end(H)+this.bufferPadding,J>=G&&Y<=q)return!0;if(Y<=G)return!1}return!1},W.onManifestLoading=function Z(){this.removeAllFragments()},W.onFragLoaded=function Z(J,Y){if(Y.frag.sn==="initSegment"||Y.frag.bitrateTest)return;var Q=Y.frag,G=Y.part?null:Y,q=BY(Q);this.fragments[q]={body:Q,appendedPTS:null,loaded:G,buffered:!1,range:Object.create(null)}},W.onBufferAppended=function Z(J,Y){var{frag:Q,part:G,timeRanges:q,type:H}=Y;if(Q.sn==="initSegment")return;var V=Q.type;if(G){var z=this.activePartLists[V];if(!z)this.activePartLists[V]=z=[];z.push(G)}this.timeRanges=q;var A=q[H];this.detectEvictedFragments(H,A,V,G)},W.onFragBuffered=function Z(J,Y){this.detectPartialFragments(Y)},W.hasFragment=function Z(J){var Y=BY(J);return!!this.fragments[Y]},W.hasFragments=function Z(J){var Y=this.fragments,Q=Object.keys(Y);if(!J)return Q.length>0;for(var G=Q.length;G--;){var q=Y[Q[G]];if((q==null?void 0:q.body.type)===J)return!0}return!1},W.hasParts=function Z(J){var Y;return!!((Y=this.activePartLists[J])!=null&&Y.length)},W.removeFragmentsInRange=function Z(J,Y,Q,G,q){var H=this;if(G&&!this.hasGaps)return;Object.keys(this.fragments).forEach(function(V){var z=H.fragments[V];if(!z)return;var A=z.body;if(A.type!==Q||G&&!A.gap)return;if(A.start<Y&&A.end>J&&(z.buffered||q))H.removeFragment(A)})},W.removeFragment=function Z(J){var Y=BY(J);J.clearElementaryStreamInfo();var Q=this.activePartLists[J.type];if(Q){var G=J.sn;this.activePartLists[J.type]=Q.filter(function(q){return q.fragment.sn!==G})}if(delete this.fragments[Y],J.endList)delete this.endListFragments[J.type]},W.removeAllFragments=function Z(){var J,Y;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var Q=(J=this.hls)==null?void 0:(Y=J.latestLevelDetails)==null?void 0:Y.partList;if(Q)Q.forEach(function(G){return G.clearElementaryStreamInfo()})},X}();function OJ(X){var W,Z,J;return X.buffered&&(X.body.gap||((W=X.range.video)==null?void 0:W.partial)||((Z=X.range.audio)==null?void 0:Z.partial)||((J=X.range.audiovideo)==null?void 0:J.partial))}function BY(X){return X.type+"_"+X.level+"_"+X.sn}var zZ=Math.pow(2,17),B9=function(){function X(Z){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=Z}var W=X.prototype;return W.destroy=function Z(){if(this.loader)this.loader.destroy(),this.loader=null},W.abort=function Z(){if(this.loader)this.loader.abort()},W.load=function Z(J,Y){var Q=this,G=J.url;if(!G)return Promise.reject(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,error:new Error("Fragment does not have a "+(G?"part list":"url")),networkDetails:null}));this.abort();var q=this.config,H=q.fLoader,V=q.loader;return new Promise(function(z,A){if(Q.loader)Q.loader.destroy();if(J.gap)if(J.tagList.some(function(C){return C[0]==="GAP"})){A(AZ(J));return}else J.gap=!1;var E=Q.loader=H?new H(q):new V(q),I=jZ(J);J.loader=E;var $=O2(q.fragLoadPolicy.default),L={loadPolicy:$,timeout:$.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:J.sn==="initSegment"?1/0:zZ};J.stats=E.stats;var b={onSuccess:function C(D,y,S,v){Q.resetLoader(J,E);var p=D.data;if(S.resetIV&&J.decryptdata)J.decryptdata.iv=new Uint8Array(p.slice(0,16)),p=p.slice(16);z({frag:J,part:null,payload:p,networkDetails:v})},onError:function C(D,y,S,v){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,response:f({url:G,data:void 0},D),error:new Error("HTTP Error "+D.code+" "+D.text),networkDetails:S,stats:v}))},onAbort:function C(D,y,S){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.INTERNAL_ABORTED,fatal:!1,frag:J,error:new Error("Aborted"),networkDetails:S,stats:D}))},onTimeout:function C(D,y,S){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_TIMEOUT,fatal:!1,frag:J,error:new Error("Timeout after "+L.timeout+"ms"),networkDetails:S,stats:D}))}};if(Y)b.onProgress=function(C,D,y,S){return Y({frag:J,part:null,payload:y,networkDetails:S})};E.load(I,L,b)})},W.loadPart=function Z(J,Y,Q){var G=this;this.abort();var q=this.config,H=q.fLoader,V=q.loader;return new Promise(function(z,A){if(G.loader)G.loader.destroy();if(J.gap||Y.gap){A(AZ(J,Y));return}var E=G.loader=H?new H(q):new V(q),I=jZ(J,Y);J.loader=E;var $=O2(q.fragLoadPolicy.default),L={loadPolicy:$,timeout:$.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:zZ};Y.stats=E.stats,E.load(I,L,{onSuccess:function b(C,D,y,S){G.resetLoader(J,E),G.updateStatsFromPart(J,Y);var v={frag:J,part:Y,payload:C.data,networkDetails:S};Q(v),z(v)},onError:function b(C,D,y,S){G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,part:Y,response:f({url:I.url,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:y,stats:S}))},onAbort:function b(C,D,y){J.stats.aborted=Y.stats.aborted,G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.INTERNAL_ABORTED,fatal:!1,frag:J,part:Y,error:new Error("Aborted"),networkDetails:y,stats:C}))},onTimeout:function b(C,D,y){G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_TIMEOUT,fatal:!1,frag:J,part:Y,error:new Error("Timeout after "+L.timeout+"ms"),networkDetails:y,stats:C}))}})})},W.updateStatsFromPart=function Z(J,Y){var Q=J.stats,G=Y.stats,q=G.total;if(Q.loaded+=G.loaded,q){var H=Math.round(J.duration/Y.duration),V=Math.min(Math.round(Q.loaded/q),H),z=H-V,A=z*Math.round(Q.loaded/V);Q.total=Q.loaded+A}else Q.total=Math.max(Q.loaded,Q.total);var E=Q.loading,I=G.loading;if(E.start)E.first+=I.first-I.start;else E.start=I.start,E.first=I.first;E.end=I.end},W.resetLoader=function Z(J,Y){if(J.loader=null,this.loader===Y)self.clearTimeout(this.partLoadTimeout),this.loader=null;Y.destroy()},X}();function jZ(X,W){if(W===void 0)W=null;var Z=W||X,J={frag:X,part:W,responseType:"arraybuffer",url:Z.url,headers:{},rangeStart:0,rangeEnd:0},Y=Z.byteRangeStartOffset,Q=Z.byteRangeEndOffset;if(T(Y)&&T(Q)){var G,q=Y,H=Q;if(X.sn==="initSegment"&&w9((G=X.decryptdata)==null?void 0:G.method)){var V=Q-Y;if(V%16)H=Q+(16-V%16);if(Y!==0)J.resetIV=!0,q=Y-16}J.rangeStart=q,J.rangeEnd=H}return J}function AZ(X,W){var Z=new Error("GAP "+(X.gap?"tag":"attribute")+" found"),J={type:n.MEDIA_ERROR,details:h.FRAG_GAP,fatal:!1,frag:X,error:Z,networkDetails:null};if(W)J.part=W;return(W?W:X).stats.aborted=!0,new e1(J)}function w9(X){return X==="AES-128"||X==="AES-256"}var e1=function(X){function W(Z){var J=X.call(this,Z.error.message)||this;return J.data=void 0,J.data=Z,J}return R(W,X),W}(t(Error)),OZ=function(X){function W(J,Y){var Q=X.call(this,J,Y)||this;return Q._boundTick=void 0,Q._tickTimer=null,Q._tickInterval=null,Q._tickCallCount=0,Q._boundTick=Q.tick.bind(Q),Q}R(W,X);var Z=W.prototype;return Z.destroy=function J(){this.onHandlerDestroying(),this.onHandlerDestroyed()},Z.onHandlerDestroying=function J(){this.clearNextTick(),this.clearInterval()},Z.onHandlerDestroyed=function J(){},Z.hasInterval=function J(){return!!this._tickInterval},Z.hasNextTick=function J(){return!!this._tickTimer},Z.setInterval=function J(Y){if(!this._tickInterval)return this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,Y),!0;return!1},Z.clearInterval=function J(){if(this._tickInterval)return self.clearInterval(this._tickInterval),this._tickInterval=null,!0;return!1},Z.clearNextTick=function J(){if(this._tickTimer)return self.clearTimeout(this._tickTimer),this._tickTimer=null,!0;return!1},Z.tick=function J(){if(this._tickCallCount++,this._tickCallCount===1){if(this.doTick(),this._tickCallCount>1)this.tickImmediate();this._tickCallCount=0}},Z.tickImmediate=function J(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},Z.doTick=function J(){},W}(d0),FZ=function X(W,Z,J,Y,Q,G){if(Y===void 0)Y=0;if(Q===void 0)Q=-1;if(G===void 0)G=!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=FJ(),this.buffering={audio:FJ(),video:FJ(),audiovideo:FJ()},this.level=W,this.sn=Z,this.id=J,this.size=Y,this.part=Q,this.partial=G};function FJ(){return{start:0,executeStart:0,executeEnd:0,end:0}}function gY(X,W){for(var Z=0,J=X.length;Z<J;Z++){var Y;if(((Y=X[Z])==null?void 0:Y.cc)===W)return X[Z]}return null}function R9(X,W){if(X){if(W.startCC<X.endCC&&W.endCC>X.startCC)return!0}return!1}function EZ(X,W){if(X){var Z=X.start+W;X.start=X.startPTS=Z,X.endPTS=Z+X.duration}}function BZ(X,W){var Z=W.fragments;for(var J=0,Y=Z.length;J<Y;J++)EZ(Z[J],X);if(W.fragmentHint)EZ(W.fragmentHint,X);W.alignedSliding=!0}function $9(X,W){if(!X)return;if(I9(W,X),!W.alignedSliding&&X)L9(W,X);if(!W.alignedSliding&&X&&!W.skippedSegments)k2(X,W,!1)}function I9(X,W){if(!R9(W,X))return;var Z=Math.min(W.endCC,X.endCC),J=gY(W.fragments,Z),Y=gY(X.fragments,Z);if(!J||!Y)return;v0.log("Aligning playlist at start of dicontinuity sequence "+Z);var Q=J.start-Y.start;BZ(Q,X)}function L9(X,W){if(!X.hasProgramDateTime||!W.hasProgramDateTime)return;var Z=X.fragments,J=W.fragments;if(!Z.length||!J.length)return;var Y,Q,G=Math.min(W.endCC,X.endCC);if(W.startCC<G&&X.startCC<G)Y=gY(J,G),Q=gY(Z,G);if(!Y||!Q)Y=J[Math.floor(J.length/2)],Q=gY(Z,Y.cc)||Z[Math.floor(Z.length/2)];var q=Y.programDateTime,H=Q.programDateTime;if(!q||!H)return;var V=(H-q)/1000-(Q.start-Y.start);BZ(V,X)}var b9={toString:function X(W){var Z="",J=W.length;for(var Y=0;Y<J;Y++)Z+="["+W.start(Y).toFixed(3)+"-"+W.end(Y).toFixed(3)+"]";return Z}},X0={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},M9=function(X){function W(J,Y,Q,G,q){var H=X.call(this,G,J.logger)||this;return H.hls=void 0,H.fragPrevious=null,H.fragCurrent=null,H.fragmentTracker=void 0,H.transmuxer=null,H._state=X0.STOPPED,H.playlistType=void 0,H.media=null,H.mediaBuffer=null,H.config=void 0,H.bitrateTest=!1,H.lastCurrentTime=0,H.nextLoadPosition=0,H.startPosition=0,H.startTimeOffset=null,H.retryDate=0,H.levels=null,H.fragmentLoader=void 0,H.keyLoader=void 0,H.levelLastLoaded=null,H.startFragRequested=!1,H.decrypter=void 0,H.initPTS=[],H.buffering=!0,H.loadingParts=!1,H.loopSn=void 0,H.onMediaSeeking=function(){var V=H,z=V.config,A=V.fragCurrent,E=V.media,I=V.mediaBuffer,$=V.state,L=E?E.currentTime:0,b=k0.bufferInfo(I?I:E,L,z.maxBufferHole);if(H.log("media seeking to "+(T(L)?L.toFixed(3):L)+", state: "+$),H.state===X0.ENDED)H.resetLoadingState();else if(A){var C=z.maxFragLookUpTolerance,D=A.start-C,y=A.start+A.duration+C;if(!b.len||y<b.start||D>b.end){var S=L>y;if(L<D||S){if(S&&A.loader)H.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),A.abortRequests(),H.resetLoadingState();H.fragPrevious=null}}}if(E){H.fragmentTracker.removeFragmentsInRange(L,1/0,H.playlistType,!0);var v=H.lastCurrentTime;if(L>v)H.lastCurrentTime=L;if(!H.loadingParts){var p=Math.max(b.end,L),g=H.shouldLoadParts(H.getLevelDetails(),p);if(g)H.log("LL-Part loading ON after seeking to "+L.toFixed(2)+" with buffer @"+p.toFixed(2)),H.loadingParts=g}}if(!H.hls.hasEnoughToStart&&!b.len)H.log("setting startPosition to "+L+" because of seek before start"),H.nextLoadPosition=H.startPosition=L;H.tickImmediate()},H.onMediaEnded=function(){H.log("setting startPosition to 0 because media ended"),H.startPosition=H.lastCurrentTime=0},H.playlistType=q,H.hls=J,H.fragmentLoader=new B9(J.config),H.keyLoader=Q,H.fragmentTracker=Y,H.config=J.config,H.decrypter=new eJ(J.config),H}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;Y.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.ERROR,this.onError,this)},Z.doTick=function J(){this.onTickEnd()},Z.onTickEnd=function J(){},Z.startLoad=function J(Y){},Z.stopLoad=function J(){if(this.state===X0.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var Y=this.fragCurrent;if(Y!=null&&Y.loader)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=X0.STOPPED},Z.pauseBuffering=function J(){this.buffering=!1},Z.resumeBuffering=function J(){this.buffering=!0},Z._streamEnded=function J(Y,Q){if(Q.live||!this.media)return!1;var G=Y.end||0,q=this.config.timelineOffset||0;if(G<=q)return!1;var H=Y.nextStart,V=H&&H>q&&H<Q.edge;if(V)return!1;if(this.media.currentTime<Y.start)return!1;var z=Q.partList;if(z!=null&&z.length){var A=z[z.length-1],E=k0.isBuffered(this.media,A.start+A.duration/2);return E}var I=Q.fragments[Q.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(I)},Z.getLevelDetails=function J(){if(this.levels&&this.levelLastLoaded!==null){var Y;return(Y=this.levelLastLoaded)==null?void 0:Y.details}},Z.onMediaAttached=function J(Y,Q){var G=this.media=this.mediaBuffer=Q.media;G.removeEventListener("seeking",this.onMediaSeeking),G.removeEventListener("ended",this.onMediaEnded),G.addEventListener("seeking",this.onMediaSeeking),G.addEventListener("ended",this.onMediaEnded);var q=this.config;if(this.levels&&q.autoStartLoad&&this.state===X0.STOPPED)this.startLoad(q.startPosition)},Z.onMediaDetaching=function J(Y,Q){var G=!!Q.transferMedia,q=this.media;if(q===null)return;if(q.ended)this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0;if(q.removeEventListener("seeking",this.onMediaSeeking),q.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!G)this.keyLoader.detach();if(this.media=this.mediaBuffer=null,this.loopSn=void 0,G){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},Z.onManifestLoading=function J(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},Z.onError=function J(Y,Q){},Z.onManifestLoaded=function J(Y,Q){this.startTimeOffset=Q.startTimeOffset},Z.onHandlerDestroying=function J(){if(this.stopLoad(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;X.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},Z.onHandlerDestroyed=function J(){if(this.state=X0.STOPPED,this.fragmentLoader)this.fragmentLoader.destroy();if(this.keyLoader)this.keyLoader.destroy();if(this.decrypter)this.decrypter.destroy();this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,X.prototype.onHandlerDestroyed.call(this)},Z.loadFragment=function J(Y,Q,G){this.startFragRequested=!0,this._loadFragForPlayback(Y,Q,G)},Z._loadFragForPlayback=function J(Y,Q,G){var q=this,H=function V(z){var A=z.frag;if(q.fragContextChanged(A)){q.warn(A.type+" sn: "+A.sn+(z.part?" part: "+z.part.index:"")+" of "+q.fragInfo(A,!1,z.part)+") was dropped during download."),q.fragmentTracker.removeFragment(A);return}A.stats.chunkCount++,q._handleFragmentLoadProgress(z)};this._doFragLoad(Y,Q,G,H).then(function(V){if(!V)return;var z=q.state,A=V.frag;if(q.fragContextChanged(A)){if(z===X0.FRAG_LOADING||!q.fragCurrent&&z===X0.PARSING)q.fragmentTracker.removeFragment(A),q.state=X0.IDLE;return}if("payload"in V)q.log("Loaded "+A.type+" sn: "+A.sn+" of "+q.playlistLabel()+" "+A.level),q.hls.trigger(M.FRAG_LOADED,V);q._handleFragmentLoadComplete(V)}).catch(function(V){if(q.state===X0.STOPPED||q.state===X0.ERROR)return;q.warn("Frag error: "+((V==null?void 0:V.message)||V)),q.resetFragmentLoading(Y)})},Z.clearTrackerIfNeeded=function J(Y){var Q,G=this.fragmentTracker,q=G.getState(Y);if(q===B1.APPENDING){var H=Y.type,V=this.getFwdBufferInfo(this.mediaBuffer,H),z=Math.max(Y.duration,V?V.len:this.config.maxBufferLength),A=this.backtrackFragment,E=A?Y.sn-A.sn:0;if(E===1||this.reduceMaxBufferLength(z,Y.duration))G.removeFragment(Y)}else if(((Q=this.mediaBuffer)==null?void 0:Q.buffered.length)===0)G.removeAllFragments();else if(G.hasParts(Y.type)){if(G.detectPartialFragments({frag:Y,part:null,stats:Y.stats,id:Y.type}),G.getState(Y)===B1.PARTIAL)G.removeFragment(Y)}},Z.checkLiveUpdate=function J(Y){if(Y.updated&&!Y.live){var Q=Y.fragments[Y.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:Q,part:null,stats:Q.stats,id:Q.type})}if(!Y.fragments[0])Y.deltaUpdateFailed=!0},Z.waitForLive=function J(Y){var Q=Y.details;return(Q==null?void 0:Q.live)&&Q.type!=="EVENT"&&(this.levelLastLoaded!==Y||Q.expired)},Z.flushMainBuffer=function J(Y,Q,G){if(G===void 0)G=null;if(!(Y-Q))return;var q={startOffset:Y,endOffset:Q,type:G};this.hls.trigger(M.BUFFER_FLUSHING,q)},Z._loadInitSegment=function J(Y,Q){var G=this;this._doFragLoad(Y,Q).then(function(q){var H=q==null?void 0:q.frag;if(!H||G.fragContextChanged(H)||!G.levels)throw new Error("init load aborted");return q}).then(function(q){var H=G.hls,V=q.frag,z=q.payload,A=V.decryptdata;if(z&&z.byteLength>0&&A!=null&&A.key&&A.iv&&vY(A.method)){var E=self.performance.now();return G.decrypter.decrypt(new Uint8Array(z),A.key.buffer,A.iv.buffer,I2(A.method)).catch(function(I){throw H.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_DECRYPT_ERROR,fatal:!1,error:I,reason:I.message,frag:V}),I}).then(function(I){var $=self.performance.now();return H.trigger(M.FRAG_DECRYPTED,{frag:V,payload:I,stats:{tstart:E,tdecrypt:$}}),q.payload=I,G.completeInitSegmentLoad(q)})}return G.completeInitSegmentLoad(q)}).catch(function(q){if(G.state===X0.STOPPED||G.state===X0.ERROR)return;G.warn(q),G.resetFragmentLoading(Y)})},Z.completeInitSegmentLoad=function J(Y){var Q=this.levels;if(!Q)throw new Error("init load aborted, missing levels");var G=Y.frag.stats;if(this.state!==X0.STOPPED)this.state=X0.IDLE;Y.frag.data=new Uint8Array(Y.payload),G.parsing.start=G.buffering.start=self.performance.now(),G.parsing.end=G.buffering.end=self.performance.now(),this.tick()},Z.fragContextChanged=function J(Y){var Q=this.fragCurrent;return!Y||!Q||Y.sn!==Q.sn||Y.level!==Q.level},Z.fragBufferedComplete=function J(Y,Q){var G=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+Y.type+" sn: "+Y.sn+(Q?" part: "+Q.index:"")+" of "+this.fragInfo(Y,!1,Q)+" > buffer:"+(G?b9.toString(k0.getBuffered(G)):"(detached)")+")"),d1(Y)){var q;if(Y.type!==G0.SUBTITLE){var H=Y.elementaryStreams;if(!Object.keys(H).some(function(z){return!!H[z]})){this.state=X0.IDLE;return}}var V=(q=this.levels)==null?void 0:q[Y.level];if(V!=null&&V.fragmentError)this.log("Resetting level fragment error count of "+V.fragmentError+" on frag buffered"),V.fragmentError=0}this.state=X0.IDLE},Z._handleFragmentLoadComplete=function J(Y){var Q=this.transmuxer;if(!Q)return;var{frag:G,part:q,partsLoaded:H}=Y,V=!H||H.length===0||H.some(function(A){return!A}),z=new FZ(G.level,G.sn,G.stats.chunkCount+1,0,q?q.index:-1,!V);Q.flush(z)},Z._handleFragmentLoadProgress=function J(Y){},Z._doFragLoad=function J(Y,Q,G,q){var H,V=this;if(G===void 0)G=null;this.fragCurrent=Y;var z=Q==null?void 0:Q.details;if(!this.levels||!z)throw new Error("frag load aborted, missing level"+(z?"":" detail")+"s");var A=null;if(Y.encrypted&&!((H=Y.decryptdata)!=null&&H.key)){if(this.log("Loading key for "+Y.sn+" of ["+z.startSN+"-"+z.endSN+"], "+this.playlistLabel()+" "+Y.level),this.state=X0.KEY_LOADING,this.fragCurrent=Y,A=this.keyLoader.load(Y).then(function(S){if(!V.fragContextChanged(S.frag)){if(V.hls.trigger(M.KEY_LOADED,S),V.state===X0.KEY_LOADING)V.state=X0.IDLE;return S}}),this.hls.trigger(M.KEY_LOADING,{frag:Y}),this.fragCurrent===null)A=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))}else if(!Y.encrypted&&z.encryptedFragments.length)this.keyLoader.loadClear(Y,z.encryptedFragments);var E=this.fragPrevious;if(d1(Y)&&(!E||Y.sn!==E.sn)){var I=this.shouldLoadParts(Q.details,Y.end);if(I!==this.loadingParts)this.log("LL-Part loading "+(I?"ON":"OFF")+" loading sn "+(E==null?void 0:E.sn)+"->"+Y.sn),this.loadingParts=I}if(G=Math.max(Y.start,G||0),this.loadingParts&&d1(Y)){var $=z.partList;if($&&q){if(G>Y.end&&z.fragmentHint)Y=z.fragmentHint;var L=this.getNextPart($,Y,G);if(L>-1){var b=$[L];Y=this.fragCurrent=b.fragment,this.log("Loading "+Y.type+" sn: "+Y.sn+" part: "+b.index+" ("+L+"/"+($.length-1)+") of "+this.fragInfo(Y,!1,b)+") cc: "+Y.cc+" ["+z.startSN+"-"+z.endSN+"], target: "+parseFloat(G.toFixed(3))),this.nextLoadPosition=b.start+b.duration,this.state=X0.FRAG_LOADING;var C;if(A)C=A.then(function(S){if(!S||V.fragContextChanged(S.frag))return null;return V.doFragPartsLoad(Y,b,Q,q)}).catch(function(S){return V.handleFragLoadError(S)});else C=this.doFragPartsLoad(Y,b,Q,q).catch(function(S){return V.handleFragLoadError(S)});if(this.hls.trigger(M.FRAG_LOADING,{frag:Y,part:b,targetBufferTime:G}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts"));return C}else if(!Y.url||this.loadedEndOfParts($,G))return Promise.resolve(null)}}if(d1(Y)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+G.toFixed(2)),this.loadingParts=!1;else if(!Y.url)return Promise.resolve(null);if(this.log("Loading "+Y.type+" sn: "+Y.sn+" of "+this.fragInfo(Y,!1)+") cc: "+Y.cc+" "+(z?"["+z.startSN+"-"+z.endSN+"]":"")+", target: "+parseFloat(G.toFixed(3))),T(Y.sn)&&!this.bitrateTest)this.nextLoadPosition=Y.start+Y.duration;this.state=X0.FRAG_LOADING;var D=this.config.progressive,y;if(D&&A)y=A.then(function(S){if(!S||V.fragContextChanged(S==null?void 0:S.frag))return null;return V.fragmentLoader.load(Y,q)}).catch(function(S){return V.handleFragLoadError(S)});else y=Promise.all([this.fragmentLoader.load(Y,D?q:void 0),A]).then(function(S){var v=S[0];if(!D&&v&&q)q(v);return v}).catch(function(S){return V.handleFragLoadError(S)});if(this.hls.trigger(M.FRAG_LOADING,{frag:Y,targetBufferTime:G}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING"));return y},Z.doFragPartsLoad=function J(Y,Q,G,q){var H=this;return new Promise(function(V,z){var A,E=[],I=(A=G.details)==null?void 0:A.partList,$=function L(b){H.fragmentLoader.loadPart(Y,b,q).then(function(C){E[b.index]=C;var D=C.part;H.hls.trigger(M.FRAG_LOADED,C);var y=u2(G.details,Y.sn,b.index+1)||m2(I,Y.sn,b.index+1);if(y)$(y);else return V({frag:Y,part:D,partsLoaded:E})}).catch(z)};$(Q)})},Z.handleFragLoadError=function J(Y){if("data"in Y){var Q=Y.data;if(Y.data&&Q.details===h.INTERNAL_ABORTED)this.handleFragLoadAborted(Q.frag,Q.part);else this.hls.trigger(M.ERROR,Q)}else this.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,err:Y,error:Y,fatal:!0});return null},Z._handleTransmuxerFlush=function J(Y){var Q=this.getCurrentContext(Y);if(!Q||this.state!==X0.PARSING){if(!this.fragCurrent&&this.state!==X0.STOPPED&&this.state!==X0.ERROR)this.state=X0.IDLE;return}var{frag:G,part:q,level:H}=Q,V=self.performance.now();if(G.stats.parsing.end=V,q)q.stats.parsing.end=V;var z=this.getLevelDetails(),A=z&&G.sn>z.endSN,E=A||this.shouldLoadParts(z,G.end);if(E!==this.loadingParts)this.log("LL-Part loading "+(E?"ON":"OFF")+" after parsing segment ending @"+G.end.toFixed(2)),this.loadingParts=E;this.updateLevelTiming(G,q,H,Y.partial)},Z.shouldLoadParts=function J(Y,Q){if(this.config.lowLatencyMode){if(!Y)return this.loadingParts;if(Y!=null&&Y.partList){var G,q=Y.partList[0],H=q.end+(((G=Y.fragmentHint)==null?void 0:G.duration)||0);if(Q>=H){var V,z=this.hls.hasEnoughToStart?((V=this.media)==null?void 0:V.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(z>q.start-q.fragment.duration)return!0}}}return!1},Z.getCurrentContext=function J(Y){var Q=this.levels,G=this.fragCurrent,q=Y.level,H=Y.sn,V=Y.part;if(!(Q!=null&&Q[q]))return this.warn("Levels object was unset while buffering fragment "+H+" of "+this.playlistLabel()+" "+q+". The current chunk will not be buffered."),null;var z=Q[q],A=z.details,E=V>-1?u2(A,H,V):null,I=E?E.fragment:J7(A,H,G);if(!I)return null;if(G&&G!==I)I.stats=G.stats;return{frag:I,part:E,level:z}},Z.bufferFragmentData=function J(Y,Q,G,q,H){var V;if(!Y||this.state!==X0.PARSING)return;var{data1:z,data2:A}=Y,E=z;if(z&&A)E=v1(z,A);if(!((V=E)!=null&&V.length))return;var I={type:Y.type,frag:Q,part:G,chunkMeta:q,parent:Q.type,data:E};if(this.hls.trigger(M.BUFFER_APPENDING,I),Y.dropped&&Y.independent&&!G){if(H)return;this.flushBufferGap(Q)}},Z.flushBufferGap=function J(Y){var Q=this.media;if(!Q)return;if(!k0.isBuffered(Q,Q.currentTime)){this.flushMainBuffer(0,Y.start);return}var G=Q.currentTime,q=k0.bufferInfo(Q,G,0),H=Y.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,H*0.25),z=Math.max(Math.min(Y.start-V,q.end-V),G+V);if(Y.start-z>V)this.flushMainBuffer(z,Y.start)},Z.getFwdBufferInfo=function J(Y,Q){var G,q=this.getLoadPosition();if(!T(q))return null;var H=this.lastCurrentTime>q,V=H||(G=this.media)!=null&&G.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(Y,q,Q,V)},Z.getFwdBufferInfoAtPos=function J(Y,Q,G,q){var H=k0.bufferInfo(Y,Q,q);if(H.len===0&&H.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(Q,G);if(V&&(H.nextStart<=V.end||V.gap)){var z=Math.max(Math.min(H.nextStart,V.end)-Q,q);return k0.bufferInfo(Y,Q,z)}}return H},Z.getMaxBufferLength=function J(Y){var Q=this.config,G;if(Y)G=Math.max(8*Q.maxBufferSize/Y,Q.maxBufferLength);else G=Q.maxBufferLength;return Math.min(G,Q.maxMaxBufferLength)},Z.reduceMaxBufferLength=function J(Y,Q){var G=this.config,q=Math.max(Math.min(Y-Q,G.maxBufferLength),Q),H=Math.max(Y-Q*3,G.maxMaxBufferLength/2,q);if(H>=q)return G.maxMaxBufferLength=H,this.warn("Reduce max buffer length to "+H+"s"),!0;return!1},Z.getAppendedFrag=function J(Y,Q){var G;if(Q===void 0)Q=G0.MAIN;var q=(G=this.fragmentTracker)==null?void 0:G.getAppendedFrag(Y,Q);if(q&&"fragment"in q)return q.fragment;return q},Z.getNextFragment=function J(Y,Q){var G=Q.fragments,q=G.length;if(!q)return null;var H=this.config,V=G[0].start,z=H.lowLatencyMode&&!!Q.partList,A=null;if(Q.live){var E=H.initialLiveManifestSize;if(q<E)return this.warn("Not enough fragments to start playback (have: "+q+", need: "+E+")"),null;if(!Q.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||Y<V){var I;if(z&&!this.loadingParts)this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0;A=this.getInitialLiveFragment(Q,G);var $=this.hls.startPosition,L=this.hls.liveSyncPosition,b=A?($!==-1&&$>=V?$:L)||A.start:Y;this.log("Setting startPosition to "+b+" to match start frag at live edge. mainStart: "+$+" liveSyncPosition: "+L+" frag.start: "+((I=A)==null?void 0:I.start)),this.startPosition=this.nextLoadPosition=b}}else if(Y<=V)A=G[0];if(!A){var C=this.loadingParts?Q.partEnd:Q.fragmentEnd;A=this.getFragmentAtPosition(Y,C,Q)}var D=this.filterReplacedPrimary(A,Q);if(!D&&A){var y=A.sn-Q.startSN;D=this.filterReplacedPrimary(G[y+1]||null,Q)}return this.mapToInitFragWhenRequired(D)},Z.isLoopLoading=function J(Y,Q){var G=this.fragmentTracker.getState(Y);return(G===B1.OK||G===B1.PARTIAL&&!!Y.gap)&&this.nextLoadPosition>Q},Z.getNextFragmentLoopLoading=function J(Y,Q,G,q,H){var V=null;if(Y.gap){if(V=this.getNextFragment(this.nextLoadPosition,Q),V&&!V.gap&&G.nextStart){var z=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,G.nextStart,q,0);if(z!==null&&G.len+z.len>=H){var A=V.sn;if(this.loopSn!==A)this.log('buffer full after gaps in "'+q+'" playlist starting at sn: '+A),this.loopSn=A;return null}}}return this.loopSn=void 0,V},Z.filterReplacedPrimary=function J(Y,Q){if(!Y)return Y;if(wZ(this.hls.config));return Y},Z.mapToInitFragWhenRequired=function J(Y){if(Y!=null&&Y.initSegment&&!(Y!=null&&Y.initSegment.data)&&!this.bitrateTest)return Y.initSegment;return Y},Z.getNextPart=function J(Y,Q,G){var q=-1,H=!1,V=!0;for(var z=0,A=Y.length;z<A;z++){var E=Y[z];if(V=V&&!E.independent,q>-1&&G<E.start)break;var I=E.loaded;if(I)q=-1;else if((H||E.independent||V)&&E.fragment===Q)q=z;H=I}return q},Z.loadedEndOfParts=function J(Y,Q){var G=Y[Y.length-1];return G&&Q>G.start&&G.loaded},Z.getInitialLiveFragment=function J(Y,Q){var G=this.fragPrevious,q=null;if(G){if(Y.hasProgramDateTime)this.log("Live playlist, switching playlist, load frag with same PDT: "+G.programDateTime),q=DX(Q,G.endProgramDateTime,this.config.maxFragLookUpTolerance);if(!q){var H=G.sn+1;if(H>=Y.startSN&&H<=Y.endSN){var V=Q[H-Y.startSN];if(G.cc===V.cc)q=V,this.log("Live playlist, switching playlist, load frag with next SN: "+q.sn)}if(!q){if(q=yX(Q,G.cc),q)this.log("Live playlist, switching playlist, load frag with same CC: "+q.sn)}}}else{var z=this.hls.liveSyncPosition;if(z!==null)q=this.getFragmentAtPosition(z,this.bitrateTest?Y.fragmentEnd:Y.edge,Y)}return q},Z.getFragmentAtPosition=function J(Y,Q,G){var q=this.config,H=this.fragPrevious,V=G.fragments,z=G.endSN,A=G.fragmentHint,E=q.maxFragLookUpTolerance,I=G.partList,$=!!(this.loadingParts&&I!=null&&I.length&&A);if($&&A&&!this.bitrateTest&&I[I.length-1].fragment.sn===A.sn)V=V.concat(A),z=A.sn;var L;if(Y<Q){var b,C=Y<this.lastCurrentTime,D=C||Y>Q-E||(b=this.media)!=null&&b.paused||!this.startFragRequested?0:E;L=cJ(H,V,Y,D)}else L=V[V.length-1];if(L){var y=L.sn-G.startSN,S=this.fragmentTracker.getState(L);if(S===B1.OK||S===B1.PARTIAL&&L.gap)H=L;if(H&&L.sn===H.sn&&(!$||I[0].fragment.sn>L.sn||!G.live&&!$)){var v=H&&L.level===H.level;if(v){var p=V[y+1];if(L.sn<z&&this.fragmentTracker.getState(p)!==B1.OK)L=p;else L=null}}}return L},Z.alignPlaylists=function J(Y,Q,G){var q=Y.fragments.length;if(!q)return this.warn("No fragments in live playlist"),0;var H=Y.fragmentStart,V=!Q,z=Y.alignedSliding&&T(H);if(V||!z&&!H){$9(G,Y);var A=Y.fragmentStart;return this.log("Live playlist sliding: "+A.toFixed(2)+" start-sn: "+(Q?Q.startSN:"na")+"->"+Y.startSN+" fragments: "+q),A}return H},Z.waitForCdnTuneIn=function J(Y){var Q=3;return Y.live&&Y.canBlockReload&&Y.partTarget&&Y.tuneInGoal>Math.max(Y.partHoldBack,Y.partTarget*Q)},Z.setStartPosition=function J(Y,Q){var G=this.startPosition;if(G<Q)G=-1;var q=this.timelineOffset;if(G===-1){var H=this.startTimeOffset!==null,V=H?this.startTimeOffset:Y.startTimeOffset;if(V!==null&&T(V)){if(G=Q+V,V<0)G+=Y.edge;G=Math.min(Math.max(Q,G),Q+Y.totalduration),this.log("Setting startPosition to "+G+" for start time offset "+V+" found in "+(H?"multivariant":"media")+" playlist"),this.startPosition=G}else if(Y.live)G=this.hls.liveSyncPosition||Q,this.log("Setting startPosition to -1 to start at live edge "+G),this.startPosition=-1;else this.log("setting startPosition to 0 by default"),this.startPosition=G=0;this.lastCurrentTime=G+q}this.nextLoadPosition=G+q},Z.getLoadPosition=function J(){var Y,Q=this.media,G=0;if((Y=this.hls)!=null&&Y.hasEnoughToStart&&Q)G=Q.currentTime;else if(this.nextLoadPosition>=0)G=this.nextLoadPosition;return G},Z.handleFragLoadAborted=function J(Y,Q){if(this.transmuxer&&Y.type===this.playlistType&&d1(Y)&&Y.stats.aborted)this.warn("Fragment "+Y.sn+(Q?" part "+Q.index:"")+" of "+this.playlistLabel()+" "+Y.level+" was aborted"),this.resetFragmentLoading(Y)},Z.resetFragmentLoading=function J(Y){if(!this.fragCurrent||!this.fragContextChanged(Y)&&this.state!==X0.FRAG_LOADING_WAITING_RETRY)this.state=X0.IDLE},Z.onFragmentOrKeyLoadError=function J(Y,Q){if(Q.chunkMeta&&!Q.frag){var G=this.getCurrentContext(Q.chunkMeta);if(G)Q.frag=G.frag}var q=Q.frag;if(!q||q.type!==Y||!this.levels)return;if(this.fragContextChanged(q)){var H;this.warn("Frag load error must match current frag to retry "+q.url+" > "+((H=this.fragCurrent)==null?void 0:H.url));return}var V=Q.details===h.FRAG_GAP;if(V)this.fragmentTracker.fragBuffered(q,!0);var z=Q.errorAction,A=z||{},E=A.action,I=A.flags,$=A.retryCount,L=$===void 0?0:$,b=A.retryConfig,C=!!z&&!!b,D=C&&E===U1.RetryRequest,y=C&&!z.resolved&&I===h1.MoveAllAlternatesMatchingHost;if(!D&&y&&d1(q)&&!q.endList)this.resetFragmentErrors(Y),this.treatAsGap(q),z.resolved=!0;else if((D||y)&&L<b.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var S=lJ(b,L);this.warn("Fragment "+q.sn+" of "+Y+" "+q.level+" errored with "+Q.details+", retrying loading "+(L+1)+"/"+b.maxNumRetry+" in "+S+"ms"),z.resolved=!0,this.retryDate=self.performance.now()+S,this.state=X0.FRAG_LOADING_WAITING_RETRY}else if(b&&z)if(this.resetFragmentErrors(Y),L<b.maxNumRetry){if(!V&&E!==U1.RemoveAlternatePermanently)z.resolved=!0}else{this.warn(Q.details+" reached or exceeded max retry ("+L+")");return}else if(E===U1.SendAlternateToPenaltyBox)this.state=X0.WAITING_LEVEL;else this.state=X0.ERROR;this.tickImmediate()},Z.reduceLengthAndFlushBuffer=function J(Y){if(this.state===X0.PARSING||this.state===X0.PARSED){var{frag:Q,parent:G}=Y,q=this.getFwdBufferInfo(this.mediaBuffer,G),H=q&&q.len>0.5;if(H)this.reduceMaxBufferLength(q.len,(Q==null?void 0:Q.duration)||10);var V=!H;if(V)this.warn("Buffer full error while media.currentTime is not buffered, flush "+G+" buffer");if(Q)this.fragmentTracker.removeFragment(Q),this.nextLoadPosition=Q.start;return this.resetLoadingState(),V}return!1},Z.resetFragmentErrors=function J(Y){if(Y===G0.AUDIO)this.fragCurrent=null;if(!this.hls.hasEnoughToStart)this.startFragRequested=!1;if(this.state!==X0.STOPPED)this.state=X0.IDLE},Z.afterBufferFlushed=function J(Y,Q,G){if(!Y)return;var q=k0.getBuffered(Y);if(this.fragmentTracker.detectEvictedFragments(Q,q,G),this.state===X0.ENDED)this.resetLoadingState()},Z.resetLoadingState=function J(){if(this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==X0.STOPPED)this.state=X0.IDLE},Z.resetStartWhenNotLoaded=function J(Y){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var Q=Y?Y.details:null;if(Q!=null&&Q.live)this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(Q,Q.fragmentStart),this.resetLoadingState();else this.nextLoadPosition=this.startPosition}},Z.resetWhenMissingContext=function J(Y){this.warn("The loading context changed while buffering fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},Z.removeUnbufferedFrags=function J(Y){if(Y===void 0)Y=0;this.fragmentTracker.removeFragmentsInRange(Y,1/0,this.playlistType,!1,!0)},Z.updateLevelTiming=function J(Y,Q,G,q){var H=this,V=G.details;if(!V){this.warn("level.details undefined");return}var z=Object.keys(Y.elementaryStreams).reduce(function(I,$){var L=Y.elementaryStreams[$];if(L){var b=L.endPTS-L.startPTS;if(b<=0)return H.warn("Could not parse fragment "+Y.sn+" "+$+" duration reliably ("+b+")"),I||!1;var C=q?0:v2(V,Y,L.startPTS,L.endPTS,L.startDTS,L.endDTS);return H.hls.trigger(M.LEVEL_PTS_UPDATED,{details:V,level:G,drift:C,type:$,frag:Y,start:L.startPTS,end:L.endPTS}),!0}return I},!1);if(!z){var A;if(G.fragmentError===0)this.treatAsGap(Y,G);if(((A=this.transmuxer)==null?void 0:A.error)===null){var E=new Error("Found no media in fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(E.message),this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,error:E,frag:Y,reason:"Found no media in msn "+Y.sn+" of "+this.playlistLabel()+' "'+G.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=X0.PARSED,this.log("Parsed "+Y.type+" sn: "+Y.sn+(Q?" part: "+Q.index:"")+" of "+this.fragInfo(Y,!1,Q)+")"),this.hls.trigger(M.FRAG_PARSED,{frag:Y,part:Q})},Z.playlistLabel=function J(){return this.playlistType===G0.MAIN?"level":"track"},Z.fragInfo=function J(Y,Q,G){var q,H;if(Q===void 0)Q=!0;return this.playlistLabel()+" "+Y.level+" ("+(G?"part":"frag")+":["+((q=Q&&!G?Y.startPTS:(G||Y).start)!=null?q:NaN).toFixed(3)+"-"+((H=Q&&!G?Y.endPTS:(G||Y).end)!=null?H:NaN).toFixed(3)+"]"+(G&&Y.type==="main"?"INDEPENDENT="+(G.independent?"YES":"NO"):"")},Z.treatAsGap=function J(Y,Q){if(Q)Q.fragmentError++;Y.gap=!0,this.fragmentTracker.removeFragment(Y),this.fragmentTracker.fragBuffered(Y,!0)},Z.resetTransmuxer=function J(){var Y;(Y=this.transmuxer)==null||Y.reset()},Z.recoverWorkerError=function J(Y){if(Y.event==="demuxerWorker"){if(this.fragmentTracker.removeAllFragments(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},N(W,[{key:"startPositionValue",get:function J(){var Y=this.nextLoadPosition,Q=this.startPosition;if(Q===-1&&Y)return Y;return Q}},{key:"bufferingEnabled",get:function J(){return this.buffering}},{key:"inFlightFrag",get:function J(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function J(){var Y=this.config.timelineOffset;if(Y){var Q;return((Q=this.getLevelDetails())==null?void 0:Q.appliedTimelineOffset)||Y}return 0}},{key:"primaryPrefetch",get:function J(){if(wZ(this.hls.config));return!1}},{key:"state",get:function J(){return this._state},set:function J(Y){var Q=this._state;if(Q!==Y)this._state=Y,this.log(Q+"->"+Y)}}])}(OZ);function wZ(X){return!1}function uY(X,W,Z){wY(X,W,Z),X.addEventListener(W,Z)}function wY(X,W,Z){X.removeEventListener(W,Z)}var EJ=2,C9=0.1,D9=0.05,S9=100,P9=function(X){function W(J,Y){var Q=X.call(this,"gap-controller",J.logger)||this;return Q.hls=null,Q.fragmentTracker=null,Q.media=null,Q.mediaSource=void 0,Q.nudgeRetry=0,Q.stallReported=!1,Q.stalled=null,Q.moved=!1,Q.seeking=!1,Q.buffered={},Q.lastCurrentTime=0,Q.ended=0,Q.waiting=0,Q.onMediaPlaying=function(){Q.ended=0,Q.waiting=0},Q.onMediaWaiting=function(){var G;if((G=Q.media)!=null&&G.seeking)return;Q.waiting=self.performance.now(),Q.tick()},Q.onMediaEnded=function(){if(Q.hls){var G;Q.ended=((G=Q.media)==null?void 0:G.currentTime)||1,Q.hls.trigger(M.MEDIA_ENDED,{stalled:!1})}},Q.hls=J,Q.fragmentTracker=Y,Q.registerListeners(),Q}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;if(Y)Y.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.BUFFER_APPENDED,this.onBufferAppended,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(Y)Y.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.BUFFER_APPENDED,this.onBufferAppended,this)},Z.destroy=function J(){X.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},Z.onMediaAttached=function J(Y,Q){this.setInterval(S9),this.mediaSource=Q.mediaSource;var G=this.media=Q.media;uY(G,"playing",this.onMediaPlaying),uY(G,"waiting",this.onMediaWaiting),uY(G,"ended",this.onMediaEnded)},Z.onMediaDetaching=function J(Y,Q){this.clearInterval();var G=this.media;if(G)wY(G,"playing",this.onMediaPlaying),wY(G,"waiting",this.onMediaWaiting),wY(G,"ended",this.onMediaEnded),this.media=null;this.mediaSource=void 0},Z.onBufferAppended=function J(Y,Q){this.buffered=Q.timeRanges},Z.tick=function J(){var Y;if(!((Y=this.media)!=null&&Y.readyState)||!this.hasBuffered)return;var Q=this.media.currentTime;this.poll(Q,this.lastCurrentTime),this.lastCurrentTime=Q},Z.poll=function J(Y,Q){var G,q,H=(G=this.hls)==null?void 0:G.config;if(!H)return;var V=this.media,z=this.stalled;if(!V)return;var A=V.seeking,E=this.seeking&&!A,I=!this.seeking&&A,$=V.paused&&!A||V.ended||V.playbackRate===0;if(this.seeking=A,Y!==Q){if(Q)this.ended=0;if(this.moved=!0,!A){if(this.nudgeRetry=0,H.nudgeOnVideoHole&&!$&&Y>Q)this.nudgeOnVideoHole(Y,Q)}if(this.waiting===0)this.stallResolved(Y);return}if(I||E){if(E)this.stallResolved(Y);return}if($){if(this.nudgeRetry=0,this.stallResolved(Y),!this.ended&&V.ended&&this.hls)this.ended=Y||1,this.hls.trigger(M.MEDIA_ENDED,{stalled:!1});return}if(!k0.getBuffered(V).length){this.nudgeRetry=0;return}var L=k0.bufferInfo(V,Y,0),b=L.nextStart||0,C=this.fragmentTracker;if(A&&C&&this.hls){var D=RZ(this.hls.inFlightFragments,Y),y=L.len>EJ,S=!b||D||b-Y>EJ&&!C.getPartialFragment(Y);if(y||S)return;this.moved=!1}var v=(q=this.hls)==null?void 0:q.latestLevelDetails;if(!this.moved&&this.stalled!==null&&C){var p=L.len>0;if(!p&&!b)return;var g=Math.max(b,L.start||0)-Y,m=!!(v!=null&&v.live),r=m?v.targetduration*2:EJ,o=C.getPartialFragment(Y);if(g>0&&(g<=r||o)){if(!V.paused)this._trySkipBufferHole(o);return}}var c=H.detectStallWithCurrentTimeMs,d=self.performance.now(),e=this.waiting;if(z===null){if(e>0&&d-e<c)this.stalled=e;else this.stalled=d;return}var H0=d-z;if(!A&&(H0>=c||e)&&this.hls){var Q0;if(((Q0=this.mediaSource)==null?void 0:Q0.readyState)==="ended"&&!(v!=null&&v.live)&&Math.abs(Y-((v==null?void 0:v.edge)||0))<1){if(this.ended)return;this.ended=Y||1,this.hls.trigger(M.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(L),!this.media||!this.hls)return}var J0=k0.bufferInfo(V,Y,H.maxBufferHole);this._tryFixBufferStall(J0,H0)},Z.stallResolved=function J(Y){var Q=this.stalled;if(Q&&this.hls){if(this.stalled=null,this.stallReported){var G=self.performance.now()-Q;this.log("playback not stuck anymore @"+Y+", after "+Math.round(G)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(M.STALL_RESOLVED,{})}}},Z.nudgeOnVideoHole=function J(Y,Q){var G,q=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(G=this.buffered.audio)!=null&&G.length&&q&&q.length>1&&Y>q.end(0)){var H=k0.bufferedInfo(k0.timeRangesToArray(this.buffered.audio),Y,0);if(H.len>1&&Q>=H.start){var V=k0.timeRangesToArray(q),z=k0.bufferedInfo(V,Q,0).bufferedIndex;if(z>-1&&z<V.length-1){var A=k0.bufferedInfo(V,Y,0).bufferedIndex,E=V[z].end,I=V[z+1].start;if((A===-1||A>z)&&I-E<1&&Y-E<2){var $=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+Y+" hole: "+E+" -> "+I+" buffered index: "+A);this.warn($.message),this.media.currentTime+=0.000001;var L=this.fragmentTracker.getPartialFragment(Y)||void 0,b=k0.bufferInfo(this.media,Y,0);this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:$,reason:$.message,frag:L,buffer:b.len,bufferInfo:b})}}}}},Z._tryFixBufferStall=function J(Y,Q){var G,q,H=this.fragmentTracker,V=this.media,z=(G=this.hls)==null?void 0:G.config;if(!V||!H||!z)return;var A=V.currentTime,E=(q=this.hls)==null?void 0:q.latestLevelDetails,I=H.getPartialFragment(A);if(I||E!=null&&E.live&&A<E.fragmentStart){var $=this._trySkipBufferHole(I);if($||!this.media)return}var L=Y.buffered;if((L&&L.length>1&&Y.len>z.maxBufferHole||Y.nextStart&&Y.nextStart-A<z.maxBufferHole)&&(Q>z.highBufferWatchdogPeriod*1000||this.waiting))this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(Y)},Z._reportStall=function J(Y){var Q=this.hls,G=this.media,q=this.stallReported,H=this.stalled;if(!q&&H!==null&&G&&Q){this.stallReported=!0;var V=new Error("Playback stalling at @"+G.currentTime+" due to low buffer ("+O1(Y)+")");this.warn(V.message),Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_STALLED_ERROR,fatal:!1,error:V,buffer:Y.len,bufferInfo:Y,stalled:{start:H}})}},Z._trySkipBufferHole=function J(Y){var Q,G=this.fragmentTracker,q=this.media,H=(Q=this.hls)==null?void 0:Q.config;if(!q||!G||!H)return 0;var V=q.currentTime,z=k0.bufferInfo(q,V,0),A=V<z.start?z.start:z.nextStart;if(A&&this.hls){var E=z.len<=H.maxBufferHole,I=z.len>0&&z.len<1&&q.readyState<3,$=A-V;if($>0&&(E||I)){if($>H.maxBufferHole){var L=!1;if(V===0){var b=G.getAppendedFrag(0,G0.MAIN);if(b&&A<b.end)L=!0}if(!L){var C=Y||G.getAppendedFrag(V,G0.MAIN);if(C){var D;if(!((D=this.hls.loadLevelObj)!=null&&D.details))return 0;var y=RZ(this.hls.inFlightFragments,A);if(y)return 0;var S=!1,v=C.end;while(v<A){var p=G.getPartialFragment(v);if(p)v+=p.duration;else{S=!0;break}}if(S)return 0}}}var g=Math.max(A+D9,V+C9);if(this.warn("skipping hole, adjusting currentTime from "+V+" to "+g),this.moved=!0,q.currentTime=g,!(Y!=null&&Y.gap)){var m=new Error("fragment loaded with buffer holes, seeking from "+V+" to "+g);this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,frag:Y||void 0,buffer:z.len,bufferInfo:z})}return g}}return 0},Z._tryNudgeBuffer=function J(Y){var Q=this.hls,G=this.media,q=this.nudgeRetry,H=Q==null?void 0:Q.config;if(!G||!H)return 0;var V=G.currentTime;if(this.nudgeRetry++,q<H.nudgeMaxRetry){var z=V+(q+1)*H.nudgeOffset,A=new Error("Nudging 'currentTime' from "+V+" to "+z);this.warn(A.message),G.currentTime=z,Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_NUDGE_ON_STALL,error:A,fatal:!1,buffer:Y.len,bufferInfo:Y})}else{var E=new Error("Playhead still not moving while enough data buffered @"+V+" after "+H.nudgeMaxRetry+" nudges");this.error(E.message),Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_STALLED_ERROR,error:E,fatal:!0,buffer:Y.len,bufferInfo:Y})}},N(W,[{key:"hasBuffered",get:function J(){return Object.keys(this.buffered).length>0}}])}(OZ);function RZ(X,W){var Z=$Z(X.main);if(Z&&Z.start<=W)return Z;var J=$Z(X.audio);if(J&&J.start<=W)return J;return null}function $Z(X){if(!X)return null;switch(X.state){case X0.IDLE:case X0.STOPPED:case X0.ENDED:case X0.ERROR:return null}return X.frag}function y9(X,W){var Z;try{Z=new Event("addtrack")}catch(J){Z=document.createEvent("Event"),Z.initEvent("addtrack",!1,!1)}Z.track=X,W.dispatchEvent(Z)}function T9(X,W){var Z=X.mode;if(Z==="disabled")X.mode="hidden";if(X.cues)for(var J=X.cues.length;J--;){if(W)X.cues[J].removeEventListener("enter",W);X.removeCue(X.cues[J])}if(Z==="disabled")X.mode=Z}function x9(X,W,Z,J){var Y=X.mode;if(Y==="disabled")X.mode="hidden";if(X.cues&&X.cues.length>0){var Q=h9(X.cues,W,Z);for(var G=0;G<Q.length;G++)if(!J||J(Q[G]))X.removeCue(Q[G])}if(Y==="disabled")X.mode=Y}function v9(X,W){if(W<=X[0].startTime)return 0;var Z=X.length-1;if(W>X[Z].endTime)return-1;var J=0,Y=Z,Q;while(J<=Y)if(Q=Math.floor((Y+J)/2),W<X[Q].startTime)Y=Q-1;else if(W>X[Q].startTime&&J<Z)J=Q+1;else return Q;return X[J].startTime-W<W-X[Y].startTime?J:Y}function h9(X,W,Z){var J=[],Y=v9(X,W);if(Y>-1)for(var Q=Y,G=X.length;Q<G;Q++){var q=X[Q];if(q.startTime>=W&&q.endTime<=Z)J.push(q);else if(q.startTime>Z)return J}return J}var k9=0.25;function qQ(){if(typeof self==="undefined")return;return self.VTTCue||self.TextTrackCue}function IZ(X,W,Z,J,Y){var Q=new X(W,Z,"");try{if(Q.value=J,Y)Q.type=Y}catch(G){Q=new X(W,Z,O1(Y?f({type:Y},J):J))}return Q}var BJ=function(){var X=qQ();try{X&&new X(0,Number.POSITIVE_INFINITY,"")}catch(W){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function g9(X){return Uint8Array.from(X.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var u9=function(){function X(Z){var J=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){if(!J.hls)return;J.hls.trigger(M.EVENT_CUE_ENTER,{})},this.hls=Z,this._registerListeners()}var W=X.prototype;return W.destroy=function Z(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},W._registerListeners=function Z(){var J=this.hls;J.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),J.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),J.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.on(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},W._unregisterListeners=function Z(){var J=this.hls;J.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),J.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),J.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.off(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},W.onMediaAttaching=function Z(J,Y){var Q;if(this.media=Y.media,((Q=Y.overrides)==null?void 0:Q.cueRemoval)===!1)this.removeCues=!1},W.onMediaAttached=function Z(){var J=this.hls.latestLevelDetails;if(J)this.updateDateRangeCues(J)},W.onMediaDetaching=function Z(J,Y){this.media=null;var Q=!!Y.transferMedia;if(Q)return;if(this.id3Track){if(this.removeCues)T9(this.id3Track,this.onEventCueEnter);this.id3Track=null}this.dateRangeCuesAppended={}},W.onManifestLoading=function Z(){this.dateRangeCuesAppended={}},W.createTrack=function Z(J){var Y=this.getID3Track(J.textTracks);return Y.mode="hidden",Y},W.getID3Track=function Z(J){if(!this.media)return;for(var Y=0;Y<J.length;Y++){var Q=J[Y];if(Q.kind==="metadata"&&Q.label==="id3")return y9(Q,this.media),Q}return this.media.addTextTrack("metadata","id3")},W.onFragParsingMetadata=function Z(J,Y){if(!this.media)return;var Q=this.hls.config,G=Q.enableEmsgMetadataCues,q=Q.enableID3MetadataCues;if(!G&&!q)return;var H=Y.samples;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var V=qQ();if(!V)return;for(var z=0;z<H.length;z++){var A=H[z].type;if(A===b1.emsg&&!G||!q)continue;var E=s2(H[z].data);if(E){var I=H[z].pts,$=I+H[z].duration;if($>BJ)$=BJ;var L=$-I;if(L<=0)$=I+k9;for(var b=0;b<E.length;b++){var C=E[b];if(!r2(C)){this.updateId3CueEnds(I,A);var D=IZ(V,I,$,C,A);if(D)this.id3Track.addCue(D)}}}}},W.updateId3CueEnds=function Z(J,Y){var Q,G=(Q=this.id3Track)==null?void 0:Q.cues;if(G)for(var q=G.length;q--;){var H=G[q];if(H.type===Y&&H.startTime<J&&H.endTime===BJ)H.endTime=J}},W.onBufferFlushing=function Z(J,Y){var{startOffset:Q,endOffset:G,type:q}=Y,H=this.id3Track,V=this.hls;if(!V)return;var z=V.config,A=z.enableEmsgMetadataCues,E=z.enableID3MetadataCues;if(H&&(A||E)){var I;if(q==="audio")I=function $(L){return L.type===b1.audioId3&&E};else if(q==="video")I=function $(L){return L.type===b1.emsg&&A};else I=function $(L){return L.type===b1.audioId3&&E||L.type===b1.emsg&&A};x9(H,Q,G,I)}},W.onLevelUpdated=function Z(J,Y){var Q=Y.details;this.updateDateRangeCues(Q,!0)},W.onLevelPtsUpdated=function Z(J,Y){if(Math.abs(Y.drift)>0.01)this.updateDateRangeCues(Y.details)},W.updateDateRangeCues=function Z(J,Y){var Q=this;if(!this.media||!J.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;var G=this.id3Track,q=J.dateRanges,H=Object.keys(q),V=this.dateRangeCuesAppended;if(G&&Y){var z;if((z=G.cues)!=null&&z.length){var A=Object.keys(V).filter(function(D){return!H.includes(D)}),E=function D(){var y=A[I],S=V[y].cues;delete V[y],Object.keys(S).forEach(function(v){try{var p=S[v];p.removeEventListener("enter",Q.onEventCueEnter),G.removeCue(p)}catch(g){}})};for(var I=A.length;I--;)E()}else V=this.dateRangeCuesAppended={}}var $=J.fragments[J.fragments.length-1];if(H.length===0||!T($==null?void 0:$.programDateTime))return;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var L=qQ(),b=function D(){var y=H[C],S=q[y],v=S.startTime,p=V[y],g=(p==null?void 0:p.cues)||{},m=(p==null?void 0:p.durationKnown)||!1,r=BJ,o=S.duration,c=S.endDate;if(c&&o!==null)r=v+o,m=!0;else if(S.endOnNext&&!m){var d=H.reduce(function(O0,g0){if(g0!==S.id){var T0=q[g0];if(T0.class===S.class&&T0.startDate>S.startDate&&(!O0||S.startDate<O0.startDate))return T0}return O0},null);if(d)r=d.startTime,m=!0}var e=Object.keys(S.attr);for(var H0=0;H0<e.length;H0++){var Q0=e[H0];if(!_X(Q0))continue;var J0=g[Q0];if(J0){if(m&&!p.durationKnown)J0.endTime=r;else if(Math.abs(J0.startTime-v)>0.01)J0.startTime=v,J0.endTime=r}else if(L){var N0=S.attr[Q0];if(pX(Q0))N0=g9(N0);var V0={key:Q0,data:N0},j0=IZ(L,v,r,V0,b1.dateRange);if(j0)j0.id=y,Q.id3Track.addCue(j0),g[Q0]=j0}}V[y]={cues:g,dateRange:S,durationKnown:m}};for(var C=0;C<H.length;C++)b()},X}(),m9=function(){function X(Z){var J=this;this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var{media:Y,levelDetails:Q}=J;if(!Y||!Q)return;J.currentTime=Y.currentTime;var G=J.computeLatency();if(G===null)return;J._latency=G;var q=J.config,H=q.lowLatencyMode,V=q.maxLiveSyncPlaybackRate;if(!H||V===1||!Q.live)return;var z=J.targetLatency;if(z===null)return;var A=G-z,E=Math.min(J.maxLatency,z+Q.targetduration),I=A<E;if(I&&A>0.05&&J.forwardBufferLength>1){var $=Math.min(2,Math.max(1,V)),L=Math.round(2/(1+Math.exp(-0.75*A-J.edgeStalled))*20)/20,b=Math.min($,Math.max(1,L));J.changeMediaPlaybackRate(Y,b)}else if(Y.playbackRate!==1&&Y.playbackRate!==0)J.changeMediaPlaybackRate(Y,1)},this.hls=Z,this.config=Z.config,this.registerListeners()}var W=X.prototype;return W.destroy=function Z(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},W.registerListeners=function Z(){var J=this.hls;if(!J)return;J.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.on(M.ERROR,this.onError,this)},W.unregisterListeners=function Z(){var J=this.hls;if(!J)return;J.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.off(M.ERROR,this.onError,this)},W.onMediaAttached=function Z(J,Y){this.media=Y.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},W.onMediaDetaching=function Z(){if(this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null},W.onManifestLoading=function Z(){this._latency=null,this.stallCount=0},W.onLevelUpdated=function Z(J,Y){var Q=Y.details;if(Q.advanced)this.onTimeupdate();if(!Q.live&&this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate)},W.onError=function Z(J,Y){var Q;if(Y.details!==h.BUFFER_STALLED_ERROR)return;if(this.stallCount++,this.hls&&(Q=this.levelDetails)!=null&&Q.live)this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency")},W.changeMediaPlaybackRate=function Z(J,Y){var Q,G;if(J.playbackRate===Y)return;(Q=this.hls)==null||Q.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((G=this.targetLatency)==null?void 0:G.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+J.playbackRate+" to "+Y),J.playbackRate=Y},W.estimateLiveEdge=function Z(){var J=this.levelDetails;if(J===null)return null;return J.edge+J.age},W.computeLatency=function Z(){var J=this.estimateLiveEdge();if(J===null)return null;return J-this.currentTime},N(X,[{key:"levelDetails",get:function Z(){var J;return((J=this.hls)==null?void 0:J.latestLevelDetails)||null}},{key:"latency",get:function Z(){return this._latency||0}},{key:"maxLatency",get:function Z(){var J=this.config;if(J.liveMaxLatencyDuration!==void 0)return J.liveMaxLatencyDuration;var Y=this.levelDetails;return Y?J.liveMaxLatencyDurationCount*Y.targetduration:0}},{key:"targetLatency",get:function Z(){var J=this.levelDetails;if(J===null||this.hls===null)return null;var{holdBack:Y,partHoldBack:Q,targetduration:G}=J,q=this.config,H=q.liveSyncDuration,V=q.liveSyncDurationCount,z=q.lowLatencyMode,A=this.hls.userConfig,E=z?Q||Y:Y;if(this._targetLatencyUpdated||A.liveSyncDuration||A.liveSyncDurationCount||E===0)E=H!==void 0?H:V*G;var I=G;return E+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,I)},set:function Z(J){this.stallCount=0,this.config.liveSyncDuration=J,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function Z(){var J=this.estimateLiveEdge(),Y=this.targetLatency;if(J===null||Y===null)return null;var Q=this.levelDetails;if(Q===null)return null;var G=Q.edge,q=J-Y-this.edgeStalled,H=G-Q.totalduration,V=G-(this.config.lowLatencyMode&&Q.partTarget||Q.targetduration);return Math.min(Math.max(H,q),V)}},{key:"drift",get:function Z(){var J=this.levelDetails;if(J===null)return 1;return J.drift}},{key:"edgeStalled",get:function Z(){var J=this.levelDetails;if(J===null)return 0;var Y=(this.config.lowLatencyMode&&J.partTarget||J.targetduration)*3;return Math.max(J.age-Y,0)}},{key:"forwardBufferLength",get:function Z(){var J=this.media,Y=this.levelDetails;if(!J||!Y)return 0;var Q=J.buffered.length;return(Q?J.buffered.end(Q-1):Y.edge)-this.currentTime}}])}(),_9=function(X){function W(J,Y){var Q=X.call(this,Y,J.logger)||this;return Q.hls=void 0,Q.canLoad=!1,Q.timer=-1,Q.hls=J,Q}R(W,X);var Z=W.prototype;return Z.destroy=function J(){this.clearTimer(),this.hls=this.log=this.warn=null},Z.clearTimer=function J(){if(this.timer!==-1)self.clearTimeout(this.timer),this.timer=-1},Z.startLoad=function J(){this.canLoad=!0,this.loadPlaylist()},Z.stopLoad=function J(){this.canLoad=!1,this.clearTimer()},Z.switchParams=function J(Y,Q,G){var q=Q==null?void 0:Q.renditionReports;if(q){var H=-1;for(var V=0;V<q.length;V++){var z=q[V],A=void 0;try{A=new self.URL(z.URI,Q.url).href}catch(C){this.warn("Could not construct new URL for Rendition Report: "+C),A=z.URI||""}if(A===Y){H=V;break}else if(A===Y.substring(0,A.length))H=V}if(H!==-1){var E=q[H],I=parseInt(E["LAST-MSN"])||(Q==null?void 0:Q.lastPartSn),$=parseInt(E["LAST-PART"])||(Q==null?void 0:Q.lastPartIndex);if(this.hls.config.lowLatencyMode){var L=Math.min(Q.age-Q.partTarget,Q.targetduration);if($>=0&&L>Q.partTarget)$+=1}var b=G&&K2(G);return new q2(I,$>=0?$:void 0,b)}}},Z.loadPlaylist=function J(Y){this.clearTimer()},Z.loadingPlaylist=function J(Y,Q){this.clearTimer()},Z.shouldLoadPlaylist=function J(Y){return this.canLoad&&!!Y&&!!Y.url&&(!Y.details||Y.details.live)},Z.getUrlWithDirectives=function J(Y,Q){if(Q)try{return Q.addDirectives(Y)}catch(G){this.warn("Could not construct new URL with HLS Delivery Directives: "+G)}return Y},Z.playlistLoaded=function J(Y,Q,G){var{details:q,stats:H}=Q,V=self.performance.now(),z=H.loading.first?Math.max(0,V-H.loading.first):0;q.advancedDateTime=Date.now()-z;var A=this.hls.config.timelineOffset;if(A!==q.appliedTimelineOffset){var E=Math.max(A||0,0);q.appliedTimelineOffset=E,q.fragments.forEach(function(O0){O0.start=O0.playlistOffset+E})}if(q.live||G!=null&&G.live){var I="levelInfo"in Q?Q.levelInfo:Q.track;if(q.reloaded(G),G&&q.fragments.length>0){rX(G,q);var $=q.playlistParsingError;if($){this.warn($);var L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var b,C=Q.networkDetails;L.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_PARSING_ERROR,fatal:!1,url:q.url,error:$,reason:$.message,level:Q.level||void 0,parent:(b=q.fragments[0])==null?void 0:b.type,networkDetails:C,stats:H});return}q.playlistParsingError=null}}if(q.requestScheduled===-1)q.requestScheduled=H.loading.start;var D=this.hls.mainForwardBufferInfo,y=D?D.end-D.len:0,S=(q.edge-y)*1000,v=g2(q,S);if(q.requestScheduled+v<V)q.requestScheduled=V;else q.requestScheduled+=v;if(this.log("live playlist "+Y+" "+(q.advanced?"REFRESHED "+q.lastPartSn+"-"+q.lastPartIndex:q.updated?"UPDATED":"MISSED")),!this.canLoad||!q.live)return;var p,g=void 0,m=void 0;if(q.canBlockReload&&q.endSN&&q.advanced){var r=this.hls.config.lowLatencyMode,o=q.lastPartSn,c=q.endSN,d=q.lastPartIndex,e=d!==-1,H0=o===c;if(e)if(H0)g=c+1,m=r?0:d;else g=o,m=r?d+1:q.maxPartIndex;else g=c+1;var Q0=q.age,J0=Q0+q.ageHeader,N0=Math.min(J0-q.partTarget,q.targetduration*1.5);if(N0>0){if(J0>q.targetduration*3)this.log("Playlist last advanced "+Q0.toFixed(2)+"s ago. Omitting segment and part directives."),g=void 0,m=void 0;else if(G!=null&&G.tuneInGoal&&J0-q.partTarget>G.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+G.tuneInGoal+" to: "+N0+" with playlist age: "+q.age),N0=0;else{var V0=Math.floor(N0/q.targetduration);if(g+=V0,m!==void 0){var j0=Math.round(N0%q.targetduration/q.partTarget);m+=j0}this.log("CDN Tune-in age: "+q.ageHeader+"s last advanced "+Q0.toFixed(2)+"s goal: "+N0+" skip sn "+V0+" to part "+m)}q.tuneInGoal=N0}if(p=this.getDeliveryDirectives(q,Q.deliveryDirectives,g,m),r||!H0){q.requestScheduled=V,this.loadingPlaylist(I,p);return}}else if(q.canBlockReload||q.canSkipUntil)p=this.getDeliveryDirectives(q,Q.deliveryDirectives,g,m);if(p&&g!==void 0&&q.canBlockReload)q.requestScheduled=H.loading.first+Math.max(v-z*2,v/2);this.scheduleLoading(I,p,q)}else this.clearTimer()},Z.scheduleLoading=function J(Y,Q,G){var q=this,H=G||Y.details;if(!H){this.loadingPlaylist(Y,Q);return}var V=self.performance.now(),z=H.requestScheduled;if(V>=z){this.loadingPlaylist(Y,Q);return}var A=z-V;this.log("reload live playlist "+(Y.name||Y.bitrate+"bps")+" in "+Math.round(A)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return q.loadingPlaylist(Y,Q)},A)},Z.getDeliveryDirectives=function J(Y,Q,G,q){var H=K2(Y);if(Q!=null&&Q.skip&&Y.deltaUpdateFailed)G=Q.msn,q=Q.part,H=WJ.No;return new q2(G,q,H)},Z.checkRetry=function J(Y){var Q=this,G=Y.details,q=KJ(Y),H=Y.errorAction,V=H||{},z=V.action,A=V.retryCount,E=A===void 0?0:A,I=V.retryConfig,$=!!H&&!!I&&(z===U1.RetryRequest||!H.resolved&&z===U1.SendAlternateToPenaltyBox);if($){var L;if(E>=I.maxNumRetry)return!1;if(q&&(L=Y.context)!=null&&L.deliveryDirectives)this.warn("Retrying playlist loading "+(E+1)+"/"+I.maxNumRetry+' after "'+G+'" without delivery-directives'),this.loadPlaylist();else{var b=lJ(I,E);this.clearTimer(),this.timer=self.setTimeout(function(){return Q.loadPlaylist()},b),this.warn("Retrying playlist loading "+(E+1)+"/"+I.maxNumRetry+' after "'+G+'" in '+b+"ms")}Y.levelRetry=!0,H.resolved=!0}return $},W}(d0),p9=function(X){function W(J,Y){var Q=X.call(this,J,"level-controller")||this;return Q._levels=[],Q._firstLevel=-1,Q._maxAutoLevel=-1,Q._startLevel=void 0,Q.currentLevel=null,Q.currentLevelIndex=-1,Q.manualLevelIndex=-1,Q.steering=void 0,Q.onParsedComplete=void 0,Q.steering=Y,Q._registerListeners(),Q}R(W,X);var Z=W.prototype;return Z._registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.on(M.ERROR,this.onError,this)},Z._unregisterListeners=function J(){var Y=this.hls;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.off(M.ERROR,this.onError,this)},Z.destroy=function J(){this._unregisterListeners(),this.steering=null,this.resetLevels(),X.prototype.destroy.call(this)},Z.stopLoad=function J(){var Y=this._levels;Y.forEach(function(Q){Q.loadError=0,Q.fragmentError=0}),X.prototype.stopLoad.call(this)},Z.resetLevels=function J(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},Z.onManifestLoading=function J(Y,Q){this.resetLevels()},Z.onManifestLoaded=function J(Y,Q){var G=this,q=this.hls.config.preferManagedMediaSource,H=[],V={},z={},A=!1,E=!1,I=!1;Q.levels.forEach(function($){var L,b=$.attrs,C=$.audioCodec,D=$.videoCodec;if(C)$.audioCodec=C=ZJ(C,q)||void 0;if(((L=D)==null?void 0:L.indexOf("avc1"))===0)D=$.videoCodec=FX(D);var{width:y,height:S,unknownCodecs:v}=$,p=v?v.length:0;if(v)for(var g=p;g--;){var m=v[g];if(G.isAudioSupported(m))$.audioCodec=C=C?C+","+m:m,p--,OY.audio[C.substring(0,4)]=2;else if(G.isVideoSupported(m))$.videoCodec=D=D?D+","+m:m,p--,OY.video[D.substring(0,4)]=2}if(A||(A=!!(y&&S)),E||(E=!!D),I||(I=!!C),p||C&&!G.isAudioSupported(C)||D&&!G.isVideoSupported(D)){G.log('Some or all CODECS not supported "'+b.CODECS+'"');return}var r=b.CODECS,o=b["FRAME-RATE"],c=b["HDCP-LEVEL"],d=b["PATHWAY-ID"],e=b.RESOLUTION,H0=b["VIDEO-RANGE"],Q0=(d||".")+"-",J0=""+Q0+$.bitrate+"-"+e+"-"+o+"-"+r+"-"+H0+"-"+c;if(!V[J0]){var N0=G.createLevel($);V[J0]=N0,z[J0]=1,H.push(N0)}else if(V[J0].uri!==$.url&&!$.attrs["PATHWAY-ID"]){var V0=z[J0]+=1;$.attrs["PATHWAY-ID"]=new Array(V0+1).join(".");var j0=G.createLevel($);V[J0]=j0,H.push(j0)}else V[J0].addGroupId("audio",b.AUDIO),V[J0].addGroupId("text",b.SUBTITLES)}),this.filterAndSortMediaOptions(H,Q,A,E,I)},Z.createLevel=function J(Y){var Q=new H2(Y),G=Y.supplemental;if(G!=null&&G.videoCodec&&!this.isVideoSupported(G.videoCodec)){var q=new Error('SUPPLEMENTAL-CODECS not supported "'+G.videoCodec+'"');this.log(q.message),Q.supportedResult=cQ.getUnsupportedResult(q,[])}return Q},Z.isAudioSupported=function J(Y){return _J(Y,"audio",this.hls.config.preferManagedMediaSource)},Z.isVideoSupported=function J(Y){return _J(Y,"video",this.hls.config.preferManagedMediaSource)},Z.filterAndSortMediaOptions=function J(Y,Q,G,q,H){var V=this,z=[],A=[],E=Y;if((G||q)&&H)E=E.filter(function(g){var{videoCodec:m,videoRange:r,width:o,height:c}=g;return(!!m||!!(o&&c))&&wX(r)});if(E.length===0){Promise.resolve().then(function(){if(V.hls){var g="no level with compatible codecs found in manifest",m=g;if(Q.levels.length)m="one or more CODECS in variant not supported: "+O1(Q.levels.map(function(o){return o.attrs.CODECS}).filter(function(o,c,d){return d.indexOf(o)===c})),V.warn(m),g+=" ("+m+")";var r=new Error(g);V.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:Q.url,error:r,reason:m})}});return}if(Q.audioTracks)z=Q.audioTracks.filter(function(g){return!g.audioCodec||V.isAudioSupported(g.audioCodec)}),LZ(z);if(Q.subtitles)A=Q.subtitles,LZ(A);var I=E.slice(0);E.sort(function(g,m){if(g.attrs["HDCP-LEVEL"]!==m.attrs["HDCP-LEVEL"])return(g.attrs["HDCP-LEVEL"]||"")>(m.attrs["HDCP-LEVEL"]||"")?1:-1;if(G&&g.height!==m.height)return g.height-m.height;if(g.frameRate!==m.frameRate)return g.frameRate-m.frameRate;if(g.videoRange!==m.videoRange)return GJ.indexOf(g.videoRange)-GJ.indexOf(m.videoRange);if(g.videoCodec!==m.videoCodec){var r=X2(g.videoCodec),o=X2(m.videoCodec);if(r!==o)return o-r}if(g.uri===m.uri&&g.codecSet!==m.codecSet){var c=QJ(g.codecSet),d=QJ(m.codecSet);if(c!==d)return d-c}if(g.averageBitrate!==m.averageBitrate)return g.averageBitrate-m.averageBitrate;return 0});var $=I[0];if(this.steering){if(E=this.steering.filterParsedLevels(E),E.length!==I.length){for(var L=0;L<I.length;L++)if(I[L].pathwayId===E[0].pathwayId){$=I[L];break}}}this._levels=E;for(var b=0;b<E.length;b++)if(E[b]===$){var C;this._firstLevel=b;var D=$.bitrate,y=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+E.length+" level(s) found, first bitrate: "+D),((C=this.hls.userConfig)==null?void 0:C.abrEwmaDefaultEstimate)===void 0){var S=Math.min(D,this.hls.config.abrEwmaDefaultEstimateMax);if(S>y&&y===this.hls.abrEwmaDefaultEstimate)this.hls.bandwidthEstimate=S}break}var v=H&&!q,p={levels:E,audioTracks:z,subtitleTracks:A,sessionData:Q.sessionData,sessionKeys:Q.sessionKeys,firstLevel:this._firstLevel,stats:Q.stats,audio:H,video:q,altAudio:!v&&z.some(function(g){return!!g.url})};this.hls.trigger(M.MANIFEST_PARSED,p)},Z.onError=function J(Y,Q){if(Q.fatal||!Q.context)return;if(Q.context.type===Z0.LEVEL&&Q.context.level===this.level)this.checkRetry(Q)},Z.onFragBuffered=function J(Y,Q){var G=Q.frag;if(G!==void 0&&G.type===G0.MAIN){var q=G.elementaryStreams;if(!Object.keys(q).some(function(V){return!!q[V]}))return;var H=this._levels[G.level];if(H!=null&&H.loadError)this.log("Resetting level error count of "+H.loadError+" on frag buffered"),H.loadError=0}},Z.onLevelLoaded=function J(Y,Q){var G,q=Q.level,H=Q.details,V=Q.levelInfo;if(!V){var z;if(this.warn("Invalid level index "+q),(z=Q.deliveryDirectives)!=null&&z.skip)H.deltaUpdateFailed=!0;return}if(V===this.currentLevel||Q.withoutMultiVariant){if(V.fragmentError===0)V.loadError=0;var A=V.details;if(A===Q.details&&A.advanced)A=void 0;this.playlistLoaded(q,Q,A)}else if((G=Q.deliveryDirectives)!=null&&G.skip)H.deltaUpdateFailed=!0},Z.loadPlaylist=function J(Y){if(X.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel))this.scheduleLoading(this.currentLevel,Y)},Z.loadingPlaylist=function J(Y,Q){X.prototype.loadingPlaylist.call(this,Y,Q);var G=this.getUrlWithDirectives(Y.uri,Q),q=this.currentLevelIndex,H=Y.attrs["PATHWAY-ID"],V=Y.details,z=V==null?void 0:V.age;this.log("Loading level index "+q+((Q==null?void 0:Q.msn)!==void 0?" at sn "+Q.msn+" part "+Q.part:"")+(H?" Pathway "+H:"")+(z&&V.live?" age "+z.toFixed(1)+(V.type?" "+V.type||"":""):"")+" "+G),this.hls.trigger(M.LEVEL_LOADING,{url:G,level:q,levelInfo:Y,pathwayId:Y.attrs["PATHWAY-ID"],id:0,deliveryDirectives:Q||null})},Z.removeLevel=function J(Y){var Q=this,G;if(this._levels.length===1)return;var q=this._levels.filter(function(V,z){if(z!==Y)return!0;if(Q.steering)Q.steering.removeLevel(V);if(V===Q.currentLevel){if(Q.currentLevel=null,Q.currentLevelIndex=-1,V.details)V.details.fragments.forEach(function(A){return A.level=-1})}return!1});if(_2(q),this._levels=q,this.currentLevelIndex>-1&&(G=this.currentLevel)!=null&&G.details)this.currentLevelIndex=this.currentLevel.details.fragments[0].level;if(this.manualLevelIndex>-1)this.manualLevelIndex=this.currentLevelIndex;var H=q.length-1;if(this._firstLevel=Math.min(this._firstLevel,H),this._startLevel)this._startLevel=Math.min(this._startLevel,H);this.hls.trigger(M.LEVELS_UPDATED,{levels:q})},Z.onLevelsUpdated=function J(Y,Q){var G=Q.levels;this._levels=G},Z.checkMaxAutoUpdated=function J(){var Y=this.hls,Q=Y.autoLevelCapping,G=Y.maxAutoLevel,q=Y.maxHdcpLevel;if(this._maxAutoLevel!==G)this._maxAutoLevel=G,this.hls.trigger(M.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:Q,levels:this.levels,maxAutoLevel:G,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:q})},N(W,[{key:"levels",get:function J(){if(this._levels.length===0)return null;return this._levels}},{key:"loadLevelObj",get:function J(){return this.currentLevel}},{key:"level",get:function J(){return this.currentLevelIndex},set:function J(Y){var Q=this._levels;if(Q.length===0)return;if(Y<0||Y>=Q.length){var G=new Error("invalid level idx"),q=Y<0;if(this.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.LEVEL_SWITCH_ERROR,level:Y,fatal:q,error:G,reason:G.message}),q)return;Y=Math.min(Y,Q.length-1)}var H=this.currentLevelIndex,V=this.currentLevel,z=V?V.attrs["PATHWAY-ID"]:void 0,A=Q[Y],E=A.attrs["PATHWAY-ID"];if(this.currentLevelIndex=Y,this.currentLevel=A,H===Y&&V&&z===E)return;this.log("Switching to level "+Y+" ("+(A.height?A.height+"p ":"")+(A.videoRange?A.videoRange+" ":"")+(A.codecSet?A.codecSet+" ":"")+"@"+A.bitrate+")"+(E?" with Pathway "+E:"")+" from level "+H+(z?" with Pathway "+z:""));var I={level:Y,attrs:A.attrs,details:A.details,bitrate:A.bitrate,averageBitrate:A.averageBitrate,maxBitrate:A.maxBitrate,realBitrate:A.realBitrate,width:A.width,height:A.height,codecSet:A.codecSet,audioCodec:A.audioCodec,videoCodec:A.videoCodec,audioGroups:A.audioGroups,subtitleGroups:A.subtitleGroups,loaded:A.loaded,loadError:A.loadError,fragmentError:A.fragmentError,name:A.name,id:A.id,uri:A.uri,url:A.url,urlId:0,audioGroupIds:A.audioGroupIds,textGroupIds:A.textGroupIds};this.hls.trigger(M.LEVEL_SWITCHING,I);var $=A.details;if(!$||$.live){var L=this.switchParams(A.uri,V==null?void 0:V.details,$);this.loadPlaylist(L)}}},{key:"manualLevel",get:function J(){return this.manualLevelIndex},set:function J(Y){if(this.manualLevelIndex=Y,this._startLevel===void 0)this._startLevel=Y;if(Y!==-1)this.level=Y}},{key:"firstLevel",get:function J(){return this._firstLevel},set:function J(Y){this._firstLevel=Y}},{key:"startLevel",get:function J(){if(this._startLevel===void 0){var Y=this.hls.config.startLevel;if(Y!==void 0)return Y;return this.hls.firstAutoLevel}return this._startLevel},set:function J(Y){this._startLevel=Y}},{key:"pathways",get:function J(){if(this.steering)return this.steering.pathways();return[]}},{key:"pathwayPriority",get:function J(){if(this.steering)return this.steering.pathwayPriority;return null},set:function J(Y){if(this.steering){var Q=this.steering.pathways(),G=Y.filter(function(q){return Q.indexOf(q)!==-1});if(Y.length<1){this.warn("pathwayPriority "+Y+" should contain at least one pathway from list: "+Q);return}this.steering.pathwayPriority=G}}},{key:"nextLoadLevel",get:function J(){if(this.manualLevelIndex!==-1)return this.manualLevelIndex;else return this.hls.nextAutoLevel},set:function J(Y){if(this.level=Y,this.manualLevelIndex===-1)this.hls.nextAutoLevel=Y}}])}(_9);function LZ(X){var W={};X.forEach(function(Z){var J=Z.groupId||"";Z.id=W[J]=W[J]||0,W[J]++})}var HQ=[];if(typeof F!=="undefined"&&F)f9();function f9(){self.addEventListener("message",function(X){var W=X.data,Z=W.instanceNo;if(Z===void 0)return;var J=HQ[Z];if(W.cmd==="reset"){if(delete HQ[W.resetNo],J)J.destroy();W.cmd="init"}if(W.cmd==="init"){var Y=JSON.parse(W.config),Q=new h0;Q.on(M.FRAG_DECRYPTED,RY),Q.on(M.ERROR,RY);var G=e0(Y.debug,W.id);c9(G,Z),HQ[Z]=new GQ(Q,W.typeSupported,Y,"",W.id,G),RY("init",null,Z);return}if(!J)return;switch(W.cmd){case"configure":{J.configure(W.config);break}case"demux":{var q=J.push(W.data,W.decryptdata,W.chunkMeta,W.state);if(VY(q))q.then(function(z){NQ(self,z,Z)}).catch(function(z){RY(M.ERROR,{instanceNo:Z,type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:W.chunkMeta,fatal:!1,error:z,err:z,reason:"transmuxer-worker push error"},Z)});else NQ(self,q,Z);break}case"flush":{var H=W.chunkMeta,V=J.flush(H);if(VY(V))V.then(function(z){MZ(self,z,H,Z)}).catch(function(z){RY(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:W.chunkMeta,fatal:!1,error:z,err:z,reason:"transmuxer-worker flush error"},Z)});else MZ(self,V,H,Z);break}}})}function NQ(X,W,Z){if(l9(W.remuxResult))return!1;var J=[],Y=W.remuxResult,Q=Y.audio,G=Y.video;if(Q)bZ(J,Q);if(G)bZ(J,G);return X.postMessage({event:"transmuxComplete",data:W,instanceNo:Z},J),!0}function bZ(X,W){if(W.data1)X.push(W.data1.buffer);if(W.data2)X.push(W.data2.buffer)}function MZ(X,W,Z,J){var Y=W.reduce(function(Q,G){return NQ(X,G,J)||Q},!1);if(!Y)X.postMessage({event:"transmuxComplete",data:W[0],instanceNo:J});X.postMessage({event:"flush",data:Z,instanceNo:J})}function RY(X,W,Z){self.postMessage({event:X,data:W,instanceNo:Z})}function c9(X,W){var Z=function Y(Q){var G=function q(H){RY("workerLog",{logType:Q,message:H},W)};X[Q]=G};for(var J in X)Z(J)}function l9(X){return!X.audio&&!X.video&&!X.text&&!X.id3&&!X.initSegment}var mY="1.6.0",$Y={};function d9(){return typeof j==="function"}function n9(){var X=$Y[mY];if(X)return X.clientCount++,X;var W=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+j.toString()+")(true);"],{type:"text/javascript"}),Z=self.URL.createObjectURL(W),J=new self.Worker(Z),Y={worker:J,objectURL:Z,clientCount:1};return $Y[mY]=Y,Y}function o9(X){var W=$Y[X];if(W)return W.clientCount++,W;var Z=new self.URL(X,self.location.href).href,J=new self.Worker(Z),Y={worker:J,scriptURL:Z,clientCount:1};return $Y[X]=Y,Y}function i9(X){var W=$Y[X||mY];if(W){var Z=W.clientCount--;if(Z===1){var{worker:J,objectURL:Y}=W;if(delete $Y[X||mY],Y)self.URL.revokeObjectURL(Y);J.terminate()}}}var CZ=0,s9=function(){function X(Z,J,Y,Q){var G=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=CZ++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(I){var $=I.data,L=G.hls;if(!L||!($!=null&&$.event)||$.instanceNo!==G.instanceNo)return;switch($.event){case"init":{var b,C=(b=G.workerContext)==null?void 0:b.objectURL;if(C)self.URL.revokeObjectURL(C);break}case"transmuxComplete":{G.handleTransmuxComplete($.data);break}case"flush":{G.onFlush($.data);break}case"workerLog":{if(L.logger[$.data.logType])L.logger[$.data.logType]($.data.message);break}default:{$.data=$.data||{},$.data.frag=G.frag,$.data.part=G.part,$.data.id=G.id,L.trigger($.event,$.data);break}}},this.onWorkerError=function(I){if(!G.hls)return;var $=new Error(I.message+" ("+I.filename+":"+I.lineno+")");G.hls.config.enableWorker=!1,G.hls.logger.warn('Error in "'+G.id+'" Web Worker, fallback to inline'),G.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:$})};var q=Z.config;this.hls=Z,this.id=J,this.useWorker=!!q.enableWorker,this.onTransmuxComplete=Y,this.onFlush=Q;var H=function I($,L){if(L=L||{},L.frag=G.frag||void 0,$===M.ERROR)L=L,L.parent=G.id,L.part=G.part,G.error=L.error;G.hls.trigger($,L)};this.observer=new h0,this.observer.on(M.FRAG_DECRYPTED,H),this.observer.on(M.ERROR,H);var V=G2(q.preferManagedMediaSource);if(this.useWorker&&typeof Worker!=="undefined"){var z=this.hls.logger,A=q.workerPath||d9();if(A){try{if(q.workerPath)z.log("loading Web Worker "+q.workerPath+' for "'+J+'"'),this.workerContext=o9(q.workerPath);else z.log('injecting Web Worker for "'+J+'"'),this.workerContext=n9();var E=this.workerContext.worker;E.addEventListener("message",this.onWorkerMessage),E.addEventListener("error",this.onWorkerError),E.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:V,id:J,config:O1(q)})}catch(I){z.warn('Error setting up "'+J+'" Web Worker, fallback to inline',I),this.terminateWorker(),this.error=null,this.transmuxer=new GQ(this.observer,V,q,"",J,Z.logger)}return}}this.transmuxer=new GQ(this.observer,V,q,"",J,Z.logger)}var W=X.prototype;return W.reset=function Z(){if(this.frag=null,this.part=null,this.workerContext){var J=this.instanceNo;this.instanceNo=CZ++;var Y=this.hls.config,Q=G2(Y.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:J,typeSupported:Q,id:this.id,config:O1(Y)})}},W.terminateWorker=function Z(){if(this.workerContext){var J=this.workerContext.worker;this.workerContext=null,J.removeEventListener("message",this.onWorkerMessage),J.removeEventListener("error",this.onWorkerError),i9(this.hls.config.workerPath)}},W.destroy=function Z(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var J=this.transmuxer;if(J)J.destroy(),this.transmuxer=null}var Y=this.observer;if(Y)Y.removeAllListeners();this.frag=null,this.part=null,this.observer=null,this.hls=null},W.push=function Z(J,Y,Q,G,q,H,V,z,A,E){var I,$,L=this;A.transmuxing.start=self.performance.now();var b=this.instanceNo,C=this.transmuxer,D=H?H.start:q.start,y=q.decryptdata,S=this.frag,v=!(S&&q.cc===S.cc),p=!(S&&A.level===S.level),g=S?A.sn-S.sn:-1,m=this.part?A.part-this.part.index:-1,r=g===0&&A.id>1&&A.id===(S==null?void 0:S.stats.chunkCount),o=!p&&(g===1||g===0&&(m===1||r&&m<=0)),c=self.performance.now();if(p||g||q.stats.parsing.start===0)q.stats.parsing.start=c;if(H&&(m||!o))H.stats.parsing.start=c;var d=!(S&&((I=q.initSegment)==null?void 0:I.url)===(($=S.initSegment)==null?void 0:$.url)),e=new G9(v,o,z,p,D,d);if(!o||v||d){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+q.type+" sn: "+A.sn+(A.part>-1?" part: "+A.part:"")+" "+(this.id===G0.MAIN?"level":"track")+": "+A.level+" id: "+A.id+`
22
+ discontinuity: `+v+`
23
+ trackSwitch: `+p+`
24
+ contiguous: `+o+`
25
+ accurateTimeOffset: `+z+`
26
+ timeOffset: `+D+`
27
+ initSegmentChange: `+d);var H0=new X9(Q,G,Y,V,E);this.configureTransmuxer(H0)}if(this.frag=q,this.part=H,this.workerContext)this.workerContext.worker.postMessage({instanceNo:b,cmd:"demux",data:J,decryptdata:y,chunkMeta:A,state:e},J instanceof ArrayBuffer?[J]:[]);else if(C){var Q0=C.push(J,y,A,e);if(VY(Q0))Q0.then(function(J0){L.handleTransmuxComplete(J0)}).catch(function(J0){L.transmuxerError(J0,A,"transmuxer-interface push error")});else this.handleTransmuxComplete(Q0)}},W.flush=function Z(J){var Y=this;J.transmuxing.start=self.performance.now();var Q=this.instanceNo,G=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Q,cmd:"flush",chunkMeta:J});else if(G){var q=G.flush(J);if(VY(q))q.then(function(H){Y.handleFlushResult(H,J)}).catch(function(H){Y.transmuxerError(H,J,"transmuxer-interface flush error")});else this.handleFlushResult(q,J)}},W.transmuxerError=function Z(J,Y,Q){if(!this.hls)return;this.error=J,this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:Y,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:J,err:J,reason:Q})},W.handleFlushResult=function Z(J,Y){var Q=this;J.forEach(function(G){Q.handleTransmuxComplete(G)}),this.onFlush(Y)},W.configureTransmuxer=function Z(J){var Y=this.instanceNo,Q=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Y,cmd:"configure",config:J});else if(Q)Q.configure(J)},W.handleTransmuxComplete=function Z(J){J.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(J)},X}();function DZ(){return self.SourceBuffer||self.WebKitSourceBuffer}function SZ(){var X=XY();if(!X)return!1;var W=DZ();return!W||W.prototype&&typeof W.prototype.appendBuffer==="function"&&typeof W.prototype.remove==="function"}function r9(){if(!SZ())return!1;var X=XY();return typeof(X==null?void 0:X.isTypeSupported)==="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(W){return X.isTypeSupported(xY(W,"video"))})||["mp4a.40.2","fLaC"].some(function(W){return X.isTypeSupported(xY(W,"audio"))}))}function a9(){var X,W=DZ();return typeof(W==null?void 0:(X=W.prototype)==null?void 0:X.changeType)==="function"}var t9=100,e9=function(X){function W(J,Y,Q){var G=X.call(this,J,Y,Q,"stream-controller",G0.MAIN)||this;return G.audioCodecSwap=!1,G.level=-1,G._forceStartLoad=!1,G._hasEnoughToStart=!1,G.altAudio=0,G.audioOnly=!1,G.fragPlaying=null,G.fragLastKbps=0,G.couldBacktrack=!1,G.backtrackFragment=null,G.audioCodecSwitch=!1,G.videoBuffer=null,G.onMediaPlaying=function(){G.tick()},G.onMediaSeeked=function(){var q=G.media,H=q?q.currentTime:null;if(H===null||!T(H))return;if(G.log("Media seeked to "+H.toFixed(3)),!G.getBufferedFrag(H))return;var V=G.getFwdBufferInfoAtPos(q,H,G0.MAIN,0);if(V===null||V.len===0){G.warn("Main forward buffer length at "+H+' on "seeked" event '+(V?V.len:"empty")+")");return}G.tick()},G.registerListeners(),G}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){X.prototype.registerListeners.call(this);var Y=this.hls;Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.LEVEL_LOADING,this.onLevelLoading,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.on(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.on(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.on(M.BUFFER_CREATED,this.onBufferCreated,this),Y.on(M.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this)},Z.unregisterListeners=function J(){X.prototype.unregisterListeners.call(this);var Y=this.hls;Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.off(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.off(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.off(M.BUFFER_CREATED,this.onBufferCreated,this),Y.off(M.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this)},Z.onHandlerDestroying=function J(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),X.prototype.onHandlerDestroying.call(this)},Z.startLoad=function J(Y,Q){if(this.levels){var G=this.lastCurrentTime,q=this.hls;if(this.stopLoad(),this.setInterval(t9),this.level=-1,!this.startFragRequested){var H=q.startLevel;if(H===-1)if(q.config.testBandwidth&&this.levels.length>1)H=0,this.bitrateTest=!0;else H=q.firstAutoLevel;q.nextLoadLevel=H,this.level=q.loadLevel,this._hasEnoughToStart=!!Q}if(G>0&&Y===-1&&!Q)this.log("Override startPosition with lastCurrentTime @"+G.toFixed(3)),Y=G;this.state=X0.IDLE,this.nextLoadPosition=this.lastCurrentTime=Y+this.timelineOffset,this.startPosition=Q?-1:Y,this.tick()}else this._forceStartLoad=!0,this.state=X0.STOPPED},Z.stopLoad=function J(){this._forceStartLoad=!1,X.prototype.stopLoad.call(this)},Z.doTick=function J(){switch(this.state){case X0.WAITING_LEVEL:{var Y=this.levels,Q=this.level,G=Y==null?void 0:Y[Q],q=G==null?void 0:G.details;if(q&&(!q.live||this.levelLastLoaded===G&&!this.waitForLive(G))){if(this.waitForCdnTuneIn(q))break;this.state=X0.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=X0.IDLE;break}break}case X0.FRAG_LOADING_WAITING_RETRY:{var H,V=self.performance.now(),z=this.retryDate;if(!z||V>=z||(H=this.media)!=null&&H.seeking){var A=this.levels,E=this.level,I=A==null?void 0:A[E];this.resetStartWhenNotLoaded(I||null),this.state=X0.IDLE}}break}if(this.state===X0.IDLE)this.doTickIdle();this.onTickEnd()},Z.onTickEnd=function J(){var Y;if(X.prototype.onTickEnd.call(this),(Y=this.media)!=null&&Y.readyState&&this.media.seeking===!1)this.lastCurrentTime=this.media.currentTime;this.checkFragmentChanged()},Z.doTickIdle=function J(){var Y=this.hls,Q=this.levelLastLoaded,G=this.levels,q=this.media;if(Q===null||!q&&!this.primaryPrefetch&&(this.startFragRequested||!Y.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;var H=this.buffering?Y.nextLoadLevel:Y.loadLevel;if(!(G!=null&&G[H]))return;var V=G[H],z=this.getMainFwdBufferInfo();if(z===null)return;var A=this.getLevelDetails();if(A&&this._streamEnded(z,A)){var E={};if(this.altAudio===2)E.type="video";this.hls.trigger(M.BUFFER_EOS,E),this.state=X0.ENDED;return}if(!this.buffering)return;if(Y.loadLevel!==H&&Y.manualLevel===-1)this.log("Adapting to level "+H+" from level "+this.level);this.level=Y.nextLoadLevel=H;var I=V.details;if(!I||this.state===X0.WAITING_LEVEL||this.waitForLive(V)){this.level=H,this.state=X0.WAITING_LEVEL,this.startFragRequested=!1;return}var $=z.len,L=this.getMaxBufferLength(V.maxBitrate);if($>=L)return;if(this.backtrackFragment&&this.backtrackFragment.start>z.end)this.backtrackFragment=null;var b=this.backtrackFragment?this.backtrackFragment.start:z.end,C=this.getNextFragment(b,I);if(this.couldBacktrack&&!this.fragPrevious&&C&&d1(C)&&this.fragmentTracker.getState(C)!==B1.OK){var D,y=((D=this.backtrackFragment)!=null?D:C).sn,S=y-I.startSN,v=I.fragments[S-1];if(v&&C.cc===v.cc)C=v,this.fragmentTracker.removeFragment(v)}else if(this.backtrackFragment&&z.len)this.backtrackFragment=null;if(C&&this.isLoopLoading(C,b)){var p=C.gap;if(!p){var g=this.audioOnly&&!this.altAudio?i0.AUDIO:i0.VIDEO,m=(g===i0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(m)this.afterBufferFlushed(m,g,G0.MAIN)}C=this.getNextFragmentLoopLoading(C,I,z,G0.MAIN,L)}if(!C)return;if(C.initSegment&&!C.initSegment.data&&!this.bitrateTest)C=C.initSegment;this.loadFragment(C,V,b)},Z.loadFragment=function J(Y,Q,G){var q=this.fragmentTracker.getState(Y);if(q===B1.NOT_LOADED||q===B1.PARTIAL)if(!d1(Y))this._loadInitSegment(Y,Q);else if(this.bitrateTest)this.log("Fragment "+Y.sn+" of level "+Y.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(Y,Q);else X.prototype.loadFragment.call(this,Y,Q,G);else this.clearTrackerIfNeeded(Y)},Z.getBufferedFrag=function J(Y){return this.fragmentTracker.getBufferedFrag(Y,G0.MAIN)},Z.followingBufferedFrag=function J(Y){if(Y)return this.getBufferedFrag(Y.end+0.5);return null},Z.immediateLevelSwitch=function J(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},Z.nextLevelSwitch=function J(){var Y=this.levels,Q=this.media;if(Q!=null&&Q.readyState){var G,q=this.getAppendedFrag(Q.currentTime);if(q&&q.start>1)this.flushMainBuffer(0,q.start-1);var H=this.getLevelDetails();if(H!=null&&H.live){var V=this.getMainFwdBufferInfo();if(!V||V.len<H.targetduration*2)return}if(!Q.paused&&Y){var z=this.hls.nextLoadLevel,A=Y[z],E=this.fragLastKbps;if(E&&this.fragCurrent)G=this.fragCurrent.duration*A.maxBitrate/(1000*E)+1;else G=0}else G=0;var I=this.getBufferedFrag(Q.currentTime+G);if(I){var $=this.followingBufferedFrag(I);if($){this.abortCurrentFrag();var L=$.maxStartPTS?$.maxStartPTS:$.start,b=$.duration,C=Math.max(I.end,L+Math.min(Math.max(b-this.config.maxFragLookUpTolerance,b*(this.couldBacktrack?0.5:0.125)),b*(this.couldBacktrack?0.75:0.25)));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},Z.abortCurrentFrag=function J(){var Y=this.fragCurrent;if(this.fragCurrent=null,this.backtrackFragment=null,Y)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);switch(this.state){case X0.KEY_LOADING:case X0.FRAG_LOADING:case X0.FRAG_LOADING_WAITING_RETRY:case X0.PARSING:case X0.PARSED:this.state=X0.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},Z.flushMainBuffer=function J(Y,Q){X.prototype.flushMainBuffer.call(this,Y,Q,this.altAudio===2?"video":null)},Z.onMediaAttached=function J(Y,Q){X.prototype.onMediaAttached.call(this,Y,Q);var G=Q.media;uY(G,"playing",this.onMediaPlaying),uY(G,"seeked",this.onMediaSeeked)},Z.onMediaDetaching=function J(Y,Q){var G=this.media;if(G)wY(G,"playing",this.onMediaPlaying),wY(G,"seeked",this.onMediaSeeked);this.videoBuffer=null,this.fragPlaying=null,X.prototype.onMediaDetaching.call(this,Y,Q);var q=!!Q.transferMedia;if(q)return;this._hasEnoughToStart=!1},Z.onManifestLoading=function J(){X.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},Z.onManifestParsed=function J(Y,Q){var G=!1,q=!1;if(Q.levels.forEach(function(H){var V=H.audioCodec;if(V)G=G||V.indexOf("mp4a.40.2")!==-1,q=q||V.indexOf("mp4a.40.5")!==-1}),this.audioCodecSwitch=G&&q&&!a9(),this.audioCodecSwitch)this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC");this.levels=Q.levels,this.startFragRequested=!1},Z.onLevelLoading=function J(Y,Q){var G=this.levels;if(!G||this.state!==X0.IDLE)return;var q=Q.levelInfo;if(!q.details||q.details.live&&(this.levelLastLoaded!==q||q.details.expired)||this.waitForCdnTuneIn(q.details))this.state=X0.WAITING_LEVEL},Z.onLevelLoaded=function J(Y,Q){var G,q=this.levels,H=this.startFragRequested,V=Q.level,z=Q.details,A=z.totalduration;if(!q){this.warn("Levels were reset while loading level "+V);return}this.log("Level "+V+" loaded ["+z.startSN+","+z.endSN+"]"+(z.lastPartSn?"[part-"+z.lastPartSn+"-"+z.lastPartIndex+"]":"")+", cc ["+z.startCC+", "+z.endCC+"] duration:"+A);var E=Q.levelInfo,I=this.fragCurrent;if(I&&(this.state===X0.FRAG_LOADING||this.state===X0.FRAG_LOADING_WAITING_RETRY)){if(I.level!==Q.level&&I.loader)this.abortCurrentFrag()}var $=0;if(z.live||(G=E.details)!=null&&G.live){var L;if(this.checkLiveUpdate(z),z.deltaUpdateFailed)return;$=this.alignPlaylists(z,E.details,(L=this.levelLastLoaded)==null?void 0:L.details)}if(E.details=z,this.levelLastLoaded=E,!H)this.setStartPosition(z,$);if(this.hls.trigger(M.LEVEL_UPDATED,{details:z,level:V}),this.state===X0.WAITING_LEVEL){if(this.waitForCdnTuneIn(z))return;this.state=X0.IDLE}if(H&&z.live)this.synchronizeToLiveEdge(z);this.tick()},Z.synchronizeToLiveEdge=function J(Y){var Q=this.config,G=this.media;if(!G)return;var q=this.hls.liveSyncPosition,H=this.getLoadPosition(),V=Y.fragmentStart,z=Y.edge,A=H>=V-Q.maxFragLookUpTolerance&&H<=z;if(q!==null&&G.duration>q&&(H<q||!A)){var E=Q.liveMaxLatencyDuration!==void 0?Q.liveMaxLatencyDuration:Q.liveMaxLatencyDurationCount*Y.targetduration;if(!A&&G.readyState<4||H<z-E){if(!this._hasEnoughToStart)this.nextLoadPosition=q;if(G.readyState)this.warn("Playback: "+H.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+q.toFixed(3)),G.currentTime=q}}},Z._handleFragmentLoadProgress=function J(Y){var Q,G=Y.frag,q=Y.part,H=Y.payload,V=this.levels;if(!V){this.warn("Levels were reset while fragment load was in progress. Fragment "+G.sn+" of level "+G.level+" will not be buffered");return}var z=V[G.level];if(!z){this.warn("Level "+G.level+" not found on progress");return}var A=z.details;if(!A){this.warn("Dropping fragment "+G.sn+" of level "+G.level+" after level details were reset"),this.fragmentTracker.removeFragment(G);return}var E=z.videoCodec,I=A.PTSKnown||!A.live,$=(Q=G.initSegment)==null?void 0:Q.data,L=this._getAudioCodec(z),b=this.transmuxer=this.transmuxer||new s9(this.hls,G0.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),C=q?q.index:-1,D=C!==-1,y=new FZ(G.level,G.sn,G.stats.chunkCount,H.byteLength,C,D),S=this.initPTS[G.cc];b.push(H,$,L,E,G,q,A.totalduration,I,y,S)},Z.onAudioTrackSwitching=function J(Y,Q){var G=this,q=this.hls,H=this.altAudio===2,V=V2(Q.url,q);if(!V){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var z=this.fragCurrent;if(z)this.log("Switching to main audio track, cancel main fragment load"),z.abortRequests(),this.fragmentTracker.removeFragment(z);this.resetTransmuxer(),this.resetLoadingState()}else if(this.audioOnly)this.resetTransmuxer();if(H){this.fragmentTracker.removeAllFragments(),q.once(M.BUFFER_FLUSHED,function(){var A;(A=G.hls)==null||A.trigger(M.AUDIO_TRACK_SWITCHED,Q)}),q.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}q.trigger(M.AUDIO_TRACK_SWITCHED,Q)}else this.altAudio=1},Z.onAudioTrackSwitched=function J(Y,Q){var G=V2(Q.url,this.hls);if(G){var q=this.videoBuffer;if(q&&this.mediaBuffer!==q)this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=q}this.altAudio=G?2:0,this.tick()},Z.onBufferCreated=function J(Y,Q){var G=Q.tracks,q,H,V=!1;for(var z in G){var A=G[z];if(A.id==="main"){if(H=z,q=A,z==="video"){var E=G[z];if(E)this.videoBuffer=E.buffer}}else V=!0}if(V&&q)this.log("Alternate track found, use "+H+".buffered to schedule main fragment loading"),this.mediaBuffer=q.buffer;else this.mediaBuffer=this.media},Z.onFragBuffered=function J(Y,Q){var{frag:G,part:q}=Q,H=G.type===G0.MAIN;if(H){if(this.fragContextChanged(G)){if(this.warn("Fragment "+G.sn+(q?" p: "+q.index:"")+" of level "+G.level+" finished buffering, but was aborted. state: "+this.state),this.state===X0.PARSED)this.state=X0.IDLE;return}var V=q?q.stats:G.stats;if(this.fragLastKbps=Math.round(8*V.total/(V.buffering.end-V.loading.first)),d1(G))this.fragPrevious=G;this.fragBufferedComplete(G,q)}var z=this.media;if(!z)return;if(!this._hasEnoughToStart&&k0.getBuffered(z).length)this._hasEnoughToStart=!0,this.seekToStartPos();if(H)this.tick()},Z.onError=function J(Y,Q){var G;if(Q.fatal){this.state=X0.ERROR;return}switch(Q.details){case h.FRAG_GAP:case h.FRAG_PARSING_ERROR:case h.FRAG_DECRYPT_ERROR:case h.FRAG_LOAD_ERROR:case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_ERROR:case h.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G0.MAIN,Q);break;case h.LEVEL_LOAD_ERROR:case h.LEVEL_LOAD_TIMEOUT:case h.LEVEL_PARSING_ERROR:if(!Q.levelRetry&&this.state===X0.WAITING_LEVEL&&((G=Q.context)==null?void 0:G.type)===Z0.LEVEL)this.state=X0.IDLE;break;case h.BUFFER_ADD_CODEC_ERROR:case h.BUFFER_APPEND_ERROR:if(Q.parent!=="main")return;this.resetLoadingState();break;case h.BUFFER_FULL_ERROR:if(Q.parent!=="main")return;if(this.reduceLengthAndFlushBuffer(Q))this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case h.INTERNAL_EXCEPTION:this.recoverWorkerError(Q);break}},Z.onFragLoadEmergencyAborted=function J(){if(this.state=X0.IDLE,!this._hasEnoughToStart)this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime;this.tickImmediate()},Z.onBufferFlushed=function J(Y,Q){var G=Q.type;if(G!==i0.AUDIO||!this.altAudio){var q=(G===i0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(q)this.afterBufferFlushed(q,G,G0.MAIN),this.tick()}},Z.onLevelsUpdated=function J(Y,Q){if(this.level>-1&&this.fragCurrent){if(this.level=this.fragCurrent.level,this.level===-1)this.resetWhenMissingContext(this.fragCurrent)}this.levels=Q.levels},Z.swapAudioCodec=function J(){this.audioCodecSwap=!this.audioCodecSwap},Z.seekToStartPos=function J(){var Y=this.media;if(!Y)return;var Q=Y.currentTime,G=this.startPosition;if(G>=0&&Q<G){if(Y.seeking){this.log("could not seek to "+G+", already seeking at "+Q);return}var q=this.timelineOffset;if(q&&G)G+=q;var H=this.getLevelDetails(),V=k0.getBuffered(Y),z=V.length?V.start(0):0,A=z-G,E=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(A>0&&(A<E||this.loadingParts&&A<2*((H==null?void 0:H.partTarget)||0)))this.log("adjusting start position by "+A+" to match buffer start"),G+=A,this.startPosition=G;if(Q<G)this.log("seek to target start position "+G+" from current time "+Q+" buffer start "+z),Y.currentTime=G}},Z._getAudioCodec=function J(Y){var Q=this.config.defaultAudioCodec||Y.audioCodec;if(this.audioCodecSwap&&Q)if(this.log("Swapping audio codec"),Q.indexOf("mp4a.40.5")!==-1)Q="mp4a.40.2";else Q="mp4a.40.5";return Q},Z._loadBitrateTestFrag=function J(Y,Q){var G=this;Y.bitrateTest=!0,this._doFragLoad(Y,Q).then(function(q){var H=G.hls,V=q==null?void 0:q.frag;if(!V||G.fragContextChanged(V))return;Q.fragmentError=0,G.state=X0.IDLE,G.startFragRequested=!1,G.bitrateTest=!1;var z=V.stats;z.parsing.start=z.parsing.end=z.buffering.start=z.buffering.end=self.performance.now(),H.trigger(M.FRAG_LOADED,q),V.bitrateTest=!1})},Z._handleTransmuxComplete=function J(Y){var Q,G=this.playlistType,q=this.hls,H=Y.remuxResult,V=Y.chunkMeta,z=this.getCurrentContext(V);if(!z){this.resetWhenMissingContext(V);return}var{frag:A,part:E,level:I}=z,$=H.video,L=H.text,b=H.id3,C=H.initSegment,D=I.details,y=this.altAudio?void 0:H.audio;if(this.fragContextChanged(A)){this.fragmentTracker.removeFragment(A);return}if(this.state=X0.PARSING,C){if(C!=null&&C.tracks){var S=A.initSegment||A;this._bufferInitSegment(I,C.tracks,S,V),q.trigger(M.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:G,tracks:C.tracks})}var{initPTS:v,timescale:p}=C;if(T(v))this.initPTS[A.cc]={baseTime:v,timescale:p},q.trigger(M.INIT_PTS_FOUND,{frag:A,id:G,initPTS:v,timescale:p})}if($&&D){var g=D.fragments[A.sn-1-D.startSN],m=A.sn===D.startSN,r=!g||A.cc>g.cc;if(H.independent!==!1){var{startPTS:o,endPTS:c,startDTS:d,endDTS:e}=$;if(E)E.elementaryStreams[$.type]={startPTS:o,endPTS:c,startDTS:d,endDTS:e};else{if($.firstKeyFrame&&$.independent&&V.id===1&&!r)this.couldBacktrack=!0;if($.dropped&&$.independent){var H0=this.getMainFwdBufferInfo(),Q0=(H0?H0.end:this.getLoadPosition())+this.config.maxBufferHole,J0=$.firstKeyFramePTS?$.firstKeyFramePTS:o;if(!m&&Q0<J0-this.config.maxBufferHole&&!r){this.backtrack(A);return}else if(r)A.gap=!0;A.setElementaryStreamInfo($.type,A.start,c,A.start,e,!0)}else if(m&&o-(D.appliedTimelineOffset||0)>EJ)A.gap=!0}if(A.setElementaryStreamInfo($.type,o,c,d,e),this.backtrackFragment)this.backtrackFragment=A;this.bufferFragmentData($,A,E,V,m||r)}else if(m||r)A.gap=!0;else{this.backtrack(A);return}}if(y){var{startPTS:N0,endPTS:V0,startDTS:j0,endDTS:O0}=y;if(E)E.elementaryStreams[i0.AUDIO]={startPTS:N0,endPTS:V0,startDTS:j0,endDTS:O0};A.setElementaryStreamInfo(i0.AUDIO,N0,V0,j0,O0),this.bufferFragmentData(y,A,E,V)}if(D&&b!=null&&(Q=b.samples)!=null&&Q.length){var g0={id:G,frag:A,details:D,samples:b.samples};q.trigger(M.FRAG_PARSING_METADATA,g0)}if(D&&L){var T0={id:G,frag:A,details:D,samples:L.samples};q.trigger(M.FRAG_PARSING_USERDATA,T0)}},Z._bufferInitSegment=function J(Y,Q,G,q){var H=this;if(this.state!==X0.PARSING)return;if(this.audioOnly=!!Q.audio&&!Q.video,this.altAudio&&!this.audioOnly)delete Q.audio;var{audio:V,video:z,audiovideo:A}=Q;if(V){var E=XJ(V.codec,Y.audioCodec);if(E==="mp4a")E="mp4a.40.5";var I=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(E)if(E.indexOf("mp4a.40.5")!==-1)E="mp4a.40.2";else E="mp4a.40.5";var $=V.metadata;if($&&"channelCount"in $&&($.channelCount||1)!==1&&I.indexOf("firefox")===-1)E="mp4a.40.5"}if(E&&E.indexOf("mp4a.40.5")!==-1&&I.indexOf("android")!==-1&&V.container!=="audio/mpeg")E="mp4a.40.2",this.log("Android: force audio codec to "+E);if(Y.audioCodec&&Y.audioCodec!==E)this.log('Swapping manifest audio codec "'+Y.audioCodec+'" for "'+E+'"');V.levelCodec=E,V.id=G0.MAIN,this.log("Init audio buffer, container:"+V.container+", codecs[selected/level/parsed]=["+(E||"")+"/"+(Y.audioCodec||"")+"/"+V.codec+"]"),delete Q.audiovideo}if(z){z.levelCodec=Y.videoCodec,z.id=G0.MAIN;var L=z.codec;if((L==null?void 0:L.length)===4)switch(L){case"hvc1":case"hev1":z.codec="hvc1.1.6.L120.90";break;case"av01":z.codec="av01.0.04M.08";break;case"avc1":z.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+z.container+", codecs[level/parsed]=["+(Y.videoCodec||"")+"/"+L+"]"+(z.codec!==L?" parsed-corrected="+z.codec:"")+(z.supplemental?" supplemental="+z.supplemental:"")),delete Q.audiovideo}if(A)this.log("Init audiovideo buffer, container:"+A.container+", codecs[level/parsed]=["+Y.codecs+"/"+A.codec+"]"),delete Q.video,delete Q.audio;var b=Object.keys(Q);if(b.length){if(this.hls.trigger(M.BUFFER_CODECS,Q),!this.hls)return;b.forEach(function(C){var D=Q[C],y=D.initSegment;if(y!=null&&y.byteLength)H.hls.trigger(M.BUFFER_APPENDING,{type:C,data:y,frag:G,part:null,chunkMeta:q,parent:G.type})})}this.tickImmediate()},Z.getMainFwdBufferInfo=function J(){var Y=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(Y,G0.MAIN)},Z.backtrack=function J(Y){this.couldBacktrack=!0,this.backtrackFragment=Y,this.resetTransmuxer(),this.flushBufferGap(Y),this.fragmentTracker.removeFragment(Y),this.fragPrevious=null,this.nextLoadPosition=Y.start,this.state=X0.IDLE},Z.checkFragmentChanged=function J(){var Y=this.media,Q=null;if(Y&&Y.readyState>1&&Y.seeking===!1){var G=Y.currentTime;if(k0.isBuffered(Y,G))Q=this.getAppendedFrag(G);else if(k0.isBuffered(Y,G+0.1))Q=this.getAppendedFrag(G+0.1);if(Q){this.backtrackFragment=null;var q=this.fragPlaying,H=Q.level;if(!q||Q.sn!==q.sn||q.level!==H){if(this.fragPlaying=Q,this.hls.trigger(M.FRAG_CHANGED,{frag:Q}),!q||q.level!==H)this.hls.trigger(M.LEVEL_SWITCHED,{level:H})}}}},N(W,[{key:"hasEnoughToStart",get:function J(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function J(){var Y=this.levels,Q=this.level,G=Y==null?void 0:Y[Q];if(!G)return this.config.maxBufferLength;return this.getMaxBufferLength(G.maxBitrate)}},{key:"nextLevel",get:function J(){var Y=this.nextBufferedFrag;if(Y)return Y.level;return-1}},{key:"currentFrag",get:function J(){var Y;if(this.fragPlaying)return this.fragPlaying;var Q=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(T(Q))return this.getAppendedFrag(Q);return null}},{key:"currentProgramDateTime",get:function J(){var Y,Q=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(T(Q)){var G=this.getLevelDetails(),q=this.currentFrag||(G?cJ(null,G.fragments,Q):null);if(q){var H=q.programDateTime;if(H!==null){var V=H+(Q-q.start)*1000;return new Date(V)}}}return null}},{key:"currentLevel",get:function J(){var Y=this.currentFrag;if(Y)return Y.level;return-1}},{key:"nextBufferedFrag",get:function J(){var Y=this.currentFrag;if(Y)return this.followingBufferedFrag(Y);return null}},{key:"forceStartLoad",get:function J(){return this._forceStartLoad}}])}(M9),YG=function(){function X(Z){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=Z}var W=X.prototype;return W.abort=function Z(J){for(var Y in this.keyUriToKeyInfo){var Q=this.keyUriToKeyInfo[Y].loader;if(Q){var G;if(J&&J!==((G=Q.context)==null?void 0:G.frag.type))return;Q.abort()}}},W.detach=function Z(){for(var J in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[J];if(Y.mediaKeySessionContext||Y.decryptdata.isCommonEncryption)delete this.keyUriToKeyInfo[J]}},W.destroy=function Z(){this.detach();for(var J in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[J].loader;if(Y)Y.destroy()}this.keyUriToKeyInfo={}},W.createKeyLoadError=function Z(J,Y,Q,G,q){if(Y===void 0)Y=h.KEY_LOAD_ERROR;return new e1({type:n.NETWORK_ERROR,details:Y,fatal:!1,frag:J,response:q,error:Q,networkDetails:G})},W.loadClear=function Z(J,Y){var Q=this;if(this.emeController&&this.config.emeEnabled){var{sn:G,cc:q}=J,H=function z(){var A=Y[V];if(q<=A.cc&&(G==="initSegment"||A.sn==="initSegment"||G<A.sn))return Q.emeController.selectKeySystemFormat(A).then(function(E){A.setKeyFormat(E)}),1};for(var V=0;V<Y.length;V++)if(H())break}},W.load=function Z(J){var Y=this;if(!J.decryptdata&&J.encrypted&&this.emeController&&this.config.emeEnabled)return this.emeController.selectKeySystemFormat(J).then(function(Q){return Y.loadInternal(J,Q)});return this.loadInternal(J)},W.loadInternal=function Z(J,Y){var Q,G;if(Y)J.setKeyFormat(Y);var q=J.decryptdata;if(!q){var H=new Error(Y?"Expected frag.decryptdata to be defined after setting format "+Y:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(J,h.KEY_LOAD_ERROR,H))}var V=q.uri;if(!V)return Promise.reject(this.createKeyLoadError(J,h.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+V+'"')));var z=this.keyUriToKeyInfo[V];if((Q=z)!=null&&Q.decryptdata.key)return q.key=z.decryptdata.key,Promise.resolve({frag:J,keyInfo:z});if((G=z)!=null&&G.keyLoadPromise){var A;switch((A=z.mediaKeySessionContext)==null?void 0:A.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return z.keyLoadPromise.then(function(E){return q.key=E.keyInfo.decryptdata.key,{frag:J,keyInfo:z}})}}switch(z=this.keyUriToKeyInfo[V]={decryptdata:q,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},q.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if(q.keyFormat==="identity")return this.loadKeyHTTP(z,J);return this.loadKeyEME(z,J);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(z,J);default:return Promise.reject(this.createKeyLoadError(J,h.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+q.method+'"')))}},W.loadKeyEME=function Z(J,Y){var Q={frag:Y,keyInfo:J};if(this.emeController&&this.config.emeEnabled){var G=this.emeController.loadKey(Q);if(G)return(J.keyLoadPromise=G.then(function(q){return J.mediaKeySessionContext=q,Q})).catch(function(q){throw J.keyLoadPromise=null,q})}return Promise.resolve(Q)},W.loadKeyHTTP=function Z(J,Y){var Q=this,G=this.config,q=G.loader,H=new q(G);return Y.keyLoader=J.loader=H,J.keyLoadPromise=new Promise(function(V,z){var A={keyInfo:J,frag:Y,responseType:"arraybuffer",url:J.decryptdata.uri},E=G.keyLoadPolicy.default,I={loadPolicy:E,timeout:E.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},$={onSuccess:function L(b,C,D,y){var{frag:S,keyInfo:v,url:p}=D;if(!S.decryptdata||v!==Q.keyUriToKeyInfo[p])return z(Q.createKeyLoadError(S,h.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),y));v.decryptdata.key=S.decryptdata.key=new Uint8Array(b.data),S.keyLoader=null,v.loader=null,V({frag:S,keyInfo:v})},onError:function L(b,C,D,y){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.KEY_LOAD_ERROR,new Error("HTTP Error "+b.code+" loading key "+b.text),D,f({url:A.url,data:void 0},b)))},onTimeout:function L(b,C,D){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),D))},onAbort:function L(b,C,D){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.INTERNAL_ABORTED,new Error("key loading aborted"),D))}};H.load(A,I,$)})},W.resetLoader=function Z(J){var{frag:Y,keyInfo:Q,url:G}=J,q=Q.loader;if(Y.keyLoader===q)Y.keyLoader=null,Q.loader=null;if(delete this.keyUriToKeyInfo[G],q)q.destroy()},X}();function PZ(X){var W=X.type;switch(W){case Z0.AUDIO_TRACK:return G0.AUDIO;case Z0.SUBTITLE_TRACK:return G0.SUBTITLE;default:return G0.MAIN}}function UQ(X,W){var Z=X.url;if(Z===void 0||Z.indexOf("data:")===0)Z=W.url;return Z}var JG=function(){function X(Z){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=Z,this.registerListeners()}var W=X.prototype;return W.startLoad=function Z(J){},W.stopLoad=function Z(){this.destroyInternalLoaders()},W.registerListeners=function Z(){var J=this.hls;J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.LEVEL_LOADING,this.onLevelLoading,this),J.on(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),J.on(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),J.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this)},W.unregisterListeners=function Z(){var J=this.hls;J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.LEVEL_LOADING,this.onLevelLoading,this),J.off(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),J.off(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),J.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this)},W.createInternalLoader=function Z(J){var Y=this.hls.config,Q=Y.pLoader,G=Y.loader,q=Q||G,H=new q(Y);return this.loaders[J.type]=H,H},W.getInternalLoader=function Z(J){return this.loaders[J.type]},W.resetInternalLoader=function Z(J){if(this.loaders[J])delete this.loaders[J]},W.destroyInternalLoaders=function Z(){for(var J in this.loaders){var Y=this.loaders[J];if(Y)Y.destroy();this.resetInternalLoader(J)}},W.destroy=function Z(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},W.onManifestLoading=function Z(J,Y){var Q=Y.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Z0.MANIFEST,url:Q,deliveryDirectives:null,levelOrTrack:null})},W.onLevelLoading=function Z(J,Y){var{id:Q,level:G,pathwayId:q,url:H,deliveryDirectives:V,levelInfo:z}=Y;this.load({id:Q,level:G,pathwayId:q,responseType:"text",type:Z0.LEVEL,url:H,deliveryDirectives:V,levelOrTrack:z})},W.onAudioTrackLoading=function Z(J,Y){var{id:Q,groupId:G,url:q,deliveryDirectives:H,track:V}=Y;this.load({id:Q,groupId:G,level:null,responseType:"text",type:Z0.AUDIO_TRACK,url:q,deliveryDirectives:H,levelOrTrack:V})},W.onSubtitleTrackLoading=function Z(J,Y){var{id:Q,groupId:G,url:q,deliveryDirectives:H,track:V}=Y;this.load({id:Q,groupId:G,level:null,responseType:"text",type:Z0.SUBTITLE_TRACK,url:q,deliveryDirectives:H,levelOrTrack:V})},W.onLevelsUpdated=function Z(J,Y){var Q=this.loaders[Z0.LEVEL];if(Q){var G=Q.context;if(G&&!Y.levels.some(function(q){return q===G.levelOrTrack}))Q.abort(),delete this.loaders[Z0.LEVEL]}},W.load=function Z(J){var Y,Q=this,G=this.hls.config,q=this.getInternalLoader(J);if(q){var H=this.hls.logger,V=q.context;if(V&&V.levelOrTrack===J.levelOrTrack&&(V.url===J.url||V.deliveryDirectives&&!J.deliveryDirectives)){if(V.url===J.url)H.log("[playlist-loader]: ignore "+J.url+" ongoing request");else H.log("[playlist-loader]: ignore "+J.url+" in favor of "+V.url);return}H.log("[playlist-loader]: aborting previous loader for type: "+J.type),q.abort()}var z;if(J.type===Z0.MANIFEST)z=G.manifestLoadPolicy.default;else z=B({},G.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null});if(q=this.createInternalLoader(J),T((Y=J.deliveryDirectives)==null?void 0:Y.part)){var A;if(J.type===Z0.LEVEL&&J.level!==null)A=this.hls.levels[J.level].details;else if(J.type===Z0.AUDIO_TRACK&&J.id!==null)A=this.hls.audioTracks[J.id].details;else if(J.type===Z0.SUBTITLE_TRACK&&J.id!==null)A=this.hls.subtitleTracks[J.id].details;if(A){var{partTarget:E,targetduration:I}=A;if(E&&I){var $=Math.max(E*3,I*0.8)*1000;z=B({},z,{maxTimeToFirstByteMs:Math.min($,z.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min($,z.maxTimeToFirstByteMs)})}}}var L=z.errorRetry||z.timeoutRetry||{},b={loadPolicy:z,timeout:z.maxLoadTimeMs,maxRetry:L.maxNumRetry||0,retryDelay:L.retryDelayMs||0,maxRetryDelay:L.maxRetryDelayMs||0},C={onSuccess:function D(y,S,v,p){var g=Q.getInternalLoader(v);Q.resetInternalLoader(v.type);var m=y.data;if(m.indexOf("#EXTM3U")!==0){Q.handleManifestParsingError(y,v,new Error("no EXTM3U delimiter"),p||null,S);return}if(S.parsing.start=performance.now(),hY.isMediaPlaylist(m)||v.type!==Z0.MANIFEST)Q.handleTrackOrLevelPlaylist(y,S,v,p||null,g);else Q.handleMasterPlaylist(y,S,v,p)},onError:function D(y,S,v,p){Q.handleNetworkError(S,v,!1,y,p)},onTimeout:function D(y,S,v){Q.handleNetworkError(S,v,!0,void 0,y)}};q.load(J,b,C)},W.checkAutostartLoad=function Z(){if(!this.hls)return;var J=this.hls,Y=J.config,Q=Y.autoStartLoad,G=Y.startPosition,q=J.forceStartLoad;if(Q||q)this.hls.logger.log((Q?"auto":"force")+" startLoad with configured startPosition "+G),this.hls.startLoad(G)},W.handleMasterPlaylist=function Z(J,Y,Q,G){var q=this.hls,H=J.data,V=UQ(J,Q),z=hY.parseMasterPlaylist(H,V);if(z.playlistParsingError){this.handleManifestParsingError(J,Q,z.playlistParsingError,G,Y);return}var{contentSteering:A,levels:E,sessionData:I,sessionKeys:$,startTimeOffset:L,variableList:b}=z;this.variableList=b;var C=hY.parseMasterPlaylistMedia(H,V,z),D=C.AUDIO,y=D===void 0?[]:D,S=C.SUBTITLES,v=C["CLOSED-CAPTIONS"];if(y.length){var p=y.some(function(g){return!g.url});if(!p&&E[0].audioCodec&&!E[0].attrs.AUDIO)this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Q1({}),bitrate:0,url:""})}q.trigger(M.MANIFEST_LOADED,{levels:E,audioTracks:y,subtitles:S,captions:v,contentSteering:A,url:V,stats:Y,networkDetails:G,sessionData:I,sessionKeys:$,startTimeOffset:L,variableList:b})},W.handleTrackOrLevelPlaylist=function Z(J,Y,Q,G,q){var H=this.hls,V=Q.id,z=Q.level,A=Q.type,E=UQ(J,Q),I=T(z)?z:T(V)?V:0,$=PZ(Q),L=hY.parseLevelPlaylist(J.data,E,I,$,0,this.variableList);if(A===Z0.MANIFEST){var b={attrs:new Q1({}),bitrate:0,details:L,name:"",url:E};L.requestScheduled=Y.loading.start+g2(L,0),H.trigger(M.MANIFEST_LOADED,{levels:[b],audioTracks:[],url:E,stats:Y,networkDetails:G,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}Y.parsing.end=performance.now(),Q.levelDetails=L,this.handlePlaylistLoaded(L,J,Y,Q,G,q)},W.handleManifestParsingError=function Z(J,Y,Q,G,q){this.hls.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.MANIFEST_PARSING_ERROR,fatal:Y.type===Z0.MANIFEST,url:J.url,err:Q,error:Q,reason:Q.message,response:J,context:Y,networkDetails:G,stats:q})},W.handleNetworkError=function Z(J,Y,Q,G,q){if(Q===void 0)Q=!1;var H="A network "+(Q?"timeout":"error"+(G?" (status "+G.code+")":""))+" occurred while loading "+J.type;if(J.type===Z0.LEVEL)H+=": "+J.level+" id: "+J.id;else if(J.type===Z0.AUDIO_TRACK||J.type===Z0.SUBTITLE_TRACK)H+=" id: "+J.id+' group-id: "'+J.groupId+'"';var V=new Error(H);this.hls.logger.warn("[playlist-loader]: "+H);var z=h.UNKNOWN,A=!1,E=this.getInternalLoader(J);switch(J.type){case Z0.MANIFEST:z=Q?h.MANIFEST_LOAD_TIMEOUT:h.MANIFEST_LOAD_ERROR,A=!0;break;case Z0.LEVEL:z=Q?h.LEVEL_LOAD_TIMEOUT:h.LEVEL_LOAD_ERROR,A=!1;break;case Z0.AUDIO_TRACK:z=Q?h.AUDIO_TRACK_LOAD_TIMEOUT:h.AUDIO_TRACK_LOAD_ERROR,A=!1;break;case Z0.SUBTITLE_TRACK:z=Q?h.SUBTITLE_TRACK_LOAD_TIMEOUT:h.SUBTITLE_LOAD_ERROR,A=!1;break}if(E)this.resetInternalLoader(J.type);var I={type:n.NETWORK_ERROR,details:z,fatal:A,url:J.url,loader:E,context:J,error:V,networkDetails:Y,stats:q};if(G){var $=(Y==null?void 0:Y.url)||J.url;I.response=f({url:$,data:void 0},G)}this.hls.trigger(M.ERROR,I)},W.handlePlaylistLoaded=function Z(J,Y,Q,G,q,H){var V=this.hls,z=G.type,A=G.level,E=G.id,I=G.groupId,$=G.deliveryDirectives,L=UQ(Y,G),b=PZ(G),C=typeof G.level==="number"&&b===G0.MAIN?A:void 0;if(!J.fragments.length){var D=J.playlistParsingError=new Error("No Segments found in Playlist");V.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_EMPTY_ERROR,fatal:!1,url:L,error:D,reason:D.message,response:Y,context:G,level:C,parent:b,networkDetails:q,stats:Q});return}if(!J.targetduration)J.playlistParsingError=new Error("Missing Target Duration");var y=J.playlistParsingError;if(y){if(this.hls.logger.warn(y),!V.config.ignorePlaylistParsingErrors){V.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_PARSING_ERROR,fatal:!1,url:L,error:y,reason:y.message,response:Y,context:G,level:C,parent:b,networkDetails:q,stats:Q});return}J.playlistParsingError=null}if(J.live&&H){if(H.getCacheAge)J.ageHeader=H.getCacheAge()||0;if(!H.getCacheAge||isNaN(J.ageHeader))J.ageHeader=0}switch(z){case Z0.MANIFEST:case Z0.LEVEL:V.trigger(M.LEVEL_LOADED,{details:J,levelInfo:G.levelOrTrack||V.levels[0],level:C||0,id:E||0,stats:Q,networkDetails:q,deliveryDirectives:$,withoutMultiVariant:z===Z0.MANIFEST});break;case Z0.AUDIO_TRACK:V.trigger(M.AUDIO_TRACK_LOADED,{details:J,track:G.levelOrTrack,id:E||0,groupId:I||"",stats:Q,networkDetails:q,deliveryDirectives:$});break;case Z0.SUBTITLE_TRACK:V.trigger(M.SUBTITLE_TRACK_LOADED,{details:J,track:G.levelOrTrack,id:E||0,groupId:I||"",stats:Q,networkDetails:q,deliveryDirectives:$});break}},X}(),QG={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ZG(X,W){return{supported:!1,configurations:W,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:X}}var yZ={};function XG(X,W,Z){var{videoCodec:J,audioCodec:Y}=X;if(!J&&!Y||!Z)return Promise.resolve(QG);var Q=[];if(J){var G={width:X.width,height:X.height,bitrate:Math.ceil(Math.max(X.bitrate*0.9,X.averageBitrate)),framerate:X.frameRate||30},q=X.videoRange;if(q!=="SDR")G.transferFunction=q.toLowerCase();var H=J.split(","),V=navigator.userAgent;if(H.some(function(z){return mJ(z)})&&J2())return Promise.resolve(ZG(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+V+")"),Q));Q.push.apply(Q,H.map(function(z){return{type:"media-source",video:f(f({},G),{},{contentType:xY(EX(z),"video")})}}))}if(Y&&X.audioGroups)X.audioGroups.forEach(function(z){var A;if(!z)return;(A=W.groups[z])==null||A.tracks.forEach(function(E){if(E.groupId===z){var I=E.channels||"",$=parseFloat(I);if(T($)&&$>2)Q.push.apply(Q,Y.split(",").map(function(L){return{type:"media-source",audio:{contentType:xY(L,"audio"),channels:""+$}}}))}})});return Promise.all(Q.map(function(z){var A=GG(z);return yZ[A]||(yZ[A]=Z.decodingInfo(z))})).then(function(z){return{supported:!z.some(function(A){return!A.supported}),configurations:Q,decodingInfoResults:z}}).catch(function(z){return{supported:!1,configurations:Q,decodingInfoResults:[],error:z}})}function GG(X){var{audio:W,video:Z}=X,J=Z||W;if(J){var Y=W2(J.contentType);if(Z)return"r"+Z.height+"x"+Z.width+"f"+Math.ceil(Z.framerate)+(Z.transferFunction||"sd")+"_"+Y+"_"+Math.ceil(Z.bitrate/1e5);if(W)return"c"+W.channels+(W.spatialRendering?"s":"n")+"_"+Y}return""}var TZ=function(){function X(Z){if(Z===void 0)Z={};this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new h0,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var J=this.logger=e0(Z.debug||!1,"Hls instance",Z.assetPlayerId),Y=this.config=O9(X.DefaultConfig,Z,J);if(this.userConfig=Z,Y.progressive)F9(Y,J);var{abrController:Q,bufferController:G,capLevelController:q,errorController:H,fpsController:V}=Y,z=new H(this),A=this.abrController=new Q(this),E=new E9(this),I=Y.interstitialsController,$=I?this.interstitialsController=new I(this,X):null,L=this.bufferController=new G(this,E),b=this.capLevelController=new q(this),C=new V(this),D=new JG(this),y=Y.contentSteeringController,S=y?new y(this):null,v=this.levelController=new p9(this,S),p=new u9(this),g=new YG(this.config),m=this.streamController=new e9(this,E,g),r=this.gapController=new P9(this,E);b.setStreamController(m),C.setStreamController(m);var o=[D,v,m];if($)o.splice(1,0,$);if(S)o.splice(1,0,S);this.networkControllers=o;var c=[A,L,r,b,C,p,E];this.audioTrackController=this.createController(Y.audioTrackController,o);var d=Y.audioStreamController;if(d)o.push(this.audioStreamController=new d(this,E,g));this.subtitleTrackController=this.createController(Y.subtitleTrackController,o);var e=Y.subtitleStreamController;if(e)o.push(this.subtititleStreamController=new e(this,E,g));this.createController(Y.timelineController,c),g.emeController=this.emeController=this.createController(Y.emeController,c),this.cmcdController=this.createController(Y.cmcdController,c),this.latencyController=this.createController(m9,c),this.coreComponents=c,o.push(z);var H0=z.onErrorOut;if(typeof H0==="function")this.on(M.ERROR,H0,z);this.on(M.MANIFEST_LOADED,D.onManifestLoaded,D)}X.isMSESupported=function Z(){return SZ()},X.isSupported=function Z(){return r9()},X.getMediaSource=function Z(){return XY()};var W=X.prototype;return W.createController=function Z(J,Y){if(J){var Q=new J(this);if(Y)Y.push(Q);return Q}return null},W.on=function Z(J,Y,Q){if(Q===void 0)Q=this;this._emitter.on(J,Y,Q)},W.once=function Z(J,Y,Q){if(Q===void 0)Q=this;this._emitter.once(J,Y,Q)},W.removeAllListeners=function Z(J){this._emitter.removeAllListeners(J)},W.off=function Z(J,Y,Q,G){if(Q===void 0)Q=this;this._emitter.off(J,Y,Q,G)},W.listeners=function Z(J){return this._emitter.listeners(J)},W.emit=function Z(J,Y,Q){return this._emitter.emit(J,Y,Q)},W.trigger=function Z(J,Y){if(this.config.debug)return this.emit(J,J,Y);else try{return this.emit(J,J,Y)}catch(G){if(this.logger.error("An internal error happened while handling event "+J+'. Error message: "'+G.message+'". Here is a stacktrace:',G),!this.triggeringException){this.triggeringException=!0;var Q=J===M.ERROR;this.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,fatal:Q,event:J,error:G}),this.triggeringException=!1}}return!1},W.listenerCount=function Z(J){return this._emitter.listenerCount(J)},W.destroy=function Z(){this.logger.log("destroy"),this.trigger(M.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(Y){return Y.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(Y){return Y.destroy()}),this.coreComponents.length=0;var J=this.config;J.xhrSetup=J.fetchSetup=void 0,this.userConfig=null},W.attachMedia=function Z(J){if(!J||"media"in J&&!J.media){var Y=new Error("attachMedia failed: invalid argument ("+J+")");this.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.ATTACH_MEDIA_ERROR,fatal:!0,error:Y});return}if(this.logger.log("attachMedia"),this._media)this.logger.warn("media must be detached before attaching"),this.detachMedia();var Q="media"in J,G=Q?J.media:J,q=Q?J:{media:G};this._media=G,this.trigger(M.MEDIA_ATTACHING,q)},W.detachMedia=function Z(){this.logger.log("detachMedia"),this.trigger(M.MEDIA_DETACHING,{}),this._media=null},W.transferMedia=function Z(){this._media=null;var J=this.bufferController.transferMedia();return this.trigger(M.MEDIA_DETACHING,{transferMedia:J}),J},W.loadSource=function Z(J){this.stopLoad();var Y=this.media,Q=this._url,G=this._url=t0.buildAbsoluteURL(self.location.href,J,{alwaysNormalize:!0});if(this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+G),Y&&Q&&(Q!==G||this.bufferController.hasSourceTypes()))this.detachMedia(),this.attachMedia(Y);this.trigger(M.MANIFEST_LOADING,{url:J})},W.startLoad=function Z(J,Y){if(J===void 0)J=-1;this.logger.log("startLoad("+(J+(Y?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var Q=0;Q<this.networkControllers.length;Q++)if(this.networkControllers[Q].startLoad(J,Y),!this.started||!this.networkControllers)break},W.stopLoad=function Z(){this.logger.log("stopLoad"),this.started=!1;for(var J=0;J<this.networkControllers.length;J++)if(this.networkControllers[J].stopLoad(),this.started||!this.networkControllers)break},W.resumeBuffering=function Z(){if(!this.bufferingEnabled)this.logger.log("resume buffering"),this.networkControllers.forEach(function(J){if(J.resumeBuffering)J.resumeBuffering()})},W.pauseBuffering=function Z(){if(this.bufferingEnabled)this.logger.log("pause buffering"),this.networkControllers.forEach(function(J){if(J.pauseBuffering)J.pauseBuffering()})},W.swapAudioCodec=function Z(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},W.recoverMediaError=function Z(){this.logger.log("recoverMediaError");var J=this._media,Y=J==null?void 0:J.currentTime;if(this.detachMedia(),J){if(this.attachMedia(J),Y)this.startLoad(Y)}},W.removeLevel=function Z(J){this.levelController.removeLevel(J)},W.setAudioOption=function Z(J){var Y;return((Y=this.audioTrackController)==null?void 0:Y.setAudioOption(J))||null},W.setSubtitleOption=function Z(J){var Y;return((Y=this.subtitleTrackController)==null?void 0:Y.setSubtitleOption(J))||null},W.getMediaDecodingInfo=function Z(J,Y){if(Y===void 0)Y=this.allAudioTracks;var Q=U2(Y);return XG(J,Q,navigator.mediaCapabilities)},N(X,[{key:"url",get:function Z(){return this._url}},{key:"hasEnoughToStart",get:function Z(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function Z(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function Z(){return this.started}},{key:"bufferingEnabled",get:function Z(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function Z(){var J,Y=(J={},J[G0.MAIN]=this.streamController.inFlightFrag,J);if(this.audioStreamController)Y[G0.AUDIO]=this.audioStreamController.inFlightFrag;if(this.subtititleStreamController)Y[G0.SUBTITLE]=this.subtititleStreamController.inFlightFrag;return Y}},{key:"sessionId",get:function Z(){var J=this._sessionId;if(!J)J=this._sessionId=K0();return J}},{key:"levels",get:function Z(){var J=this.levelController.levels;return J?J:[]}},{key:"latestLevelDetails",get:function Z(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function Z(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function Z(){return this.streamController.currentLevel},set:function Z(J){this.logger.log("set currentLevel:"+J),this.levelController.manualLevel=J,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function Z(){return this.streamController.nextLevel},set:function Z(J){this.logger.log("set nextLevel:"+J),this.levelController.manualLevel=J,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function Z(){return this.levelController.level},set:function Z(J){this.logger.log("set loadLevel:"+J),this.levelController.manualLevel=J}},{key:"nextLoadLevel",get:function Z(){return this.levelController.nextLoadLevel},set:function Z(J){this.levelController.nextLoadLevel=J}},{key:"firstLevel",get:function Z(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function Z(J){this.logger.log("set firstLevel:"+J),this.levelController.firstLevel=J}},{key:"startLevel",get:function Z(){var J=this.levelController.startLevel;if(J===-1&&this.abrController.forcedAutoLevel>-1)return this.abrController.forcedAutoLevel;return J},set:function Z(J){if(this.logger.log("set startLevel:"+J),J!==-1)J=Math.max(J,this.minAutoLevel);this.levelController.startLevel=J}},{key:"capLevelToPlayerSize",get:function Z(){return this.config.capLevelToPlayerSize},set:function Z(J){var Y=!!J;if(Y!==this.config.capLevelToPlayerSize){if(Y)this.capLevelController.startCapping();else this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch();this.config.capLevelToPlayerSize=Y}}},{key:"autoLevelCapping",get:function Z(){return this._autoLevelCapping},set:function Z(J){if(this._autoLevelCapping!==J)this.logger.log("set autoLevelCapping:"+J),this._autoLevelCapping=J,this.levelController.checkMaxAutoUpdated()}},{key:"bandwidthEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.getEstimate()},set:function Z(J){this.abrController.resetEstimator(J)}},{key:"abrEwmaDefaultEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.defaultEstimate}},{key:"ttfbEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.getEstimateTTFB()}},{key:"maxHdcpLevel",get:function Z(){return this._maxHdcpLevel},set:function Z(J){if(BX(J)&&this._maxHdcpLevel!==J)this._maxHdcpLevel=J,this.levelController.checkMaxAutoUpdated()}},{key:"autoLevelEnabled",get:function Z(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function Z(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function Z(){var J=this.levels,Y=this.config.minAutoBitrate;if(!J)return 0;var Q=J.length;for(var G=0;G<Q;G++)if(J[G].maxBitrate>=Y)return G;return 0}},{key:"maxAutoLevel",get:function Z(){var J=this.levels,Y=this.autoLevelCapping,Q=this.maxHdcpLevel,G;if(Y===-1&&J!=null&&J.length)G=J.length-1;else G=Y;if(Q)for(var q=G;q--;){var H=J[q].attrs["HDCP-LEVEL"];if(H&&H<=Q)return q}return G}},{key:"firstAutoLevel",get:function Z(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function Z(){return this.abrController.nextAutoLevel},set:function Z(J){this.abrController.nextAutoLevel=J}},{key:"playingDate",get:function Z(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function Z(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function Z(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function Z(){var J=this.audioTrackController;return J?J.allAudioTracks:[]}},{key:"audioTracks",get:function Z(){var J=this.audioTrackController;return J?J.audioTracks:[]}},{key:"audioTrack",get:function Z(){var J=this.audioTrackController;return J?J.audioTrack:-1},set:function Z(J){var Y=this.audioTrackController;if(Y)Y.audioTrack=J}},{key:"allSubtitleTracks",get:function Z(){var J=this.subtitleTrackController;return J?J.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleTracks:[]}},{key:"subtitleTrack",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleTrack:-1},set:function Z(J){var Y=this.subtitleTrackController;if(Y)Y.subtitleTrack=J}},{key:"media",get:function Z(){return this._media}},{key:"subtitleDisplay",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleDisplay:!1},set:function Z(J){var Y=this.subtitleTrackController;if(Y)Y.subtitleDisplay=J}},{key:"lowLatencyMode",get:function Z(){return this.config.lowLatencyMode},set:function Z(J){this.config.lowLatencyMode=J}},{key:"liveSyncPosition",get:function Z(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function Z(){return this.latencyController.latency}},{key:"maxLatency",get:function Z(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function Z(){return this.latencyController.targetLatency},set:function Z(J){this.latencyController.targetLatency=J}},{key:"drift",get:function Z(){return this.latencyController.drift}},{key:"forceStartLoad",get:function Z(){return this.streamController.forceStartLoad}},{key:"pathways",get:function Z(){return this.levelController.pathways}},{key:"pathwayPriority",get:function Z(){return this.levelController.pathwayPriority},set:function Z(J){this.levelController.pathwayPriority=J}},{key:"bufferedToEnd",get:function Z(){var J;return!!((J=this.bufferController)!=null&&J.bufferedToEnd)}},{key:"interstitialsManager",get:function Z(){var J;return((J=this.interstitialsController)==null?void 0:J.interstitialsManager)||null}}],[{key:"version",get:function Z(){return mY}},{key:"Events",get:function Z(){return M}},{key:"MetadataSchema",get:function Z(){return b1}},{key:"ErrorTypes",get:function Z(){return n}},{key:"ErrorDetails",get:function Z(){return h}},{key:"DefaultConfig",get:function Z(){if(!X.defaultConfig)return j9;return X.defaultConfig},set:function Z(J){X.defaultConfig=J}}])}();return TZ.defaultConfig=void 0,TZ})})(!1)});function fZ(j,F){var K=Object.keys(j);if(Object.getOwnPropertySymbols){var U=Object.getOwnPropertySymbols(j);F&&(U=U.filter(function(N){return Object.getOwnPropertyDescriptor(j,N).enumerable})),K.push.apply(K,U)}return K}function y1(j){for(var F=1;F<arguments.length;F++){var K=arguments[F]!=null?arguments[F]:{};F%2?fZ(Object(K),!0).forEach(function(U){F0(j,U,K[U])}):Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(K)):fZ(Object(K)).forEach(function(U){Object.defineProperty(j,U,Object.getOwnPropertyDescriptor(K,U))})}return j}function S0(){S0=function(){return j};var j={},F=Object.prototype,K=F.hasOwnProperty,U=Object.defineProperty||function(T,u,_){T[u]=_.value},N=typeof Symbol=="function"?Symbol:{},O=N.iterator||"@@iterator",B=N.asyncIterator||"@@asyncIterator",w=N.toStringTag||"@@toStringTag";function R(T,u,_){return Object.defineProperty(T,u,{value:_,enumerable:!0,configurable:!0,writable:!0}),T[u]}try{R({},"")}catch(T){R=function(u,_,n){return u[_]=n}}function P(T,u,_,n){var h=u&&u.prototype instanceof f?u:f,M=Object.create(h.prototype),Z0=new E0(n||[]);return U(M,"_invoke",{value:W0(T,_,Z0)}),M}function x(T,u,_){try{return{type:"normal",arg:T.call(u,_)}}catch(n){return{type:"throw",arg:n}}}j.wrap=P;var k={};function f(){}function l(){}function s(){}var Y0={};R(Y0,O,function(){return this});var t=Object.getPrototypeOf,K0=t&&t(t(y0([])));K0&&K0!==F&&K.call(K0,O)&&(Y0=K0);var q0=s.prototype=f.prototype=Object.create(Y0);function R0(T){["next","throw","return"].forEach(function(u){R(T,u,function(_){return this._invoke(u,_)})})}function U0(T,u){function _(h,M,Z0,G0){var C0=x(T[h],T,M);if(C0.type!=="throw"){var u0=C0.arg,d0=u0.value;return d0&&typeof d0=="object"&&K.call(d0,"__await")?u.resolve(d0.__await).then(function(M0){_("next",M0,Z0,G0)},function(M0){_("throw",M0,Z0,G0)}):u.resolve(d0).then(function(M0){u0.value=M0,Z0(u0)},function(M0){return _("throw",M0,Z0,G0)})}G0(C0.arg)}var n;U(this,"_invoke",{value:function(h,M){function Z0(){return new u(function(G0,C0){_(h,M,G0,C0)})}return n=n?n.then(Z0,Z0):Z0()}})}function W0(T,u,_){var n="suspendedStart";return function(h,M){if(n==="executing")throw new Error("Generator is already running");if(n==="completed"){if(h==="throw")throw M;return t0()}for(_.method=h,_.arg=M;;){var Z0=_.delegate;if(Z0){var G0=z0(Z0,_);if(G0){if(G0===k)continue;return G0}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(n==="suspendedStart")throw n="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);n="executing";var C0=x(T,u,_);if(C0.type==="normal"){if(n=_.done?"completed":"suspendedYield",C0.arg===k)continue;return{value:C0.arg,done:_.done}}C0.type==="throw"&&(n="completed",_.method="throw",_.arg=C0.arg)}}}function z0(T,u){var _=u.method,n=T.iterator[_];if(n===void 0)return u.delegate=null,_==="throw"&&T.iterator.return&&(u.method="return",u.arg=void 0,z0(T,u),u.method==="throw")||_!=="return"&&(u.method="throw",u.arg=new TypeError("The iterator does not provide a '"+_+"' method")),k;var h=x(n,T.iterator,u.arg);if(h.type==="throw")return u.method="throw",u.arg=h.arg,u.delegate=null,k;var M=h.arg;return M?M.done?(u[T.resultName]=M.value,u.next=T.nextLoc,u.method!=="return"&&(u.method="next",u.arg=void 0),u.delegate=null,k):M:(u.method="throw",u.arg=new TypeError("iterator result is not an object"),u.delegate=null,k)}function h0(T){var u={tryLoc:T[0]};1 in T&&(u.catchLoc=T[1]),2 in T&&(u.finallyLoc=T[2],u.afterLoc=T[3]),this.tryEntries.push(u)}function l0(T){var u=T.completion||{};u.type="normal",delete u.arg,T.completion=u}function E0(T){this.tryEntries=[{tryLoc:"root"}],T.forEach(h0,this),this.reset(!0)}function y0(T){if(T){var u=T[O];if(u)return u.call(T);if(typeof T.next=="function")return T;if(!isNaN(T.length)){var _=-1,n=function h(){for(;++_<T.length;)if(K.call(T,_))return h.value=T[_],h.done=!1,h;return h.value=void 0,h.done=!0,h};return n.next=n}}return{next:t0}}function t0(){return{value:void 0,done:!0}}return l.prototype=s,U(q0,"constructor",{value:s,configurable:!0}),U(s,"constructor",{value:l,configurable:!0}),l.displayName=R(s,w,"GeneratorFunction"),j.isGeneratorFunction=function(T){var u=typeof T=="function"&&T.constructor;return!!u&&(u===l||(u.displayName||u.name)==="GeneratorFunction")},j.mark=function(T){return Object.setPrototypeOf?Object.setPrototypeOf(T,s):(T.__proto__=s,R(T,w,"GeneratorFunction")),T.prototype=Object.create(q0),T},j.awrap=function(T){return{__await:T}},R0(U0.prototype),R(U0.prototype,B,function(){return this}),j.AsyncIterator=U0,j.async=function(T,u,_,n,h){h===void 0&&(h=Promise);var M=new U0(P(T,u,_,n),h);return j.isGeneratorFunction(u)?M:M.next().then(function(Z0){return Z0.done?Z0.value:M.next()})},R0(q0),R(q0,w,"Generator"),R(q0,O,function(){return this}),R(q0,"toString",function(){return"[object Generator]"}),j.keys=function(T){var u=Object(T),_=[];for(var n in u)_.push(n);return _.reverse(),function h(){for(;_.length;){var M=_.pop();if(M in u)return h.value=M,h.done=!1,h}return h.done=!0,h}},j.values=y0,E0.prototype={constructor:E0,reset:function(T){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(l0),!T)for(var u in this)u.charAt(0)==="t"&&K.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=void 0)},stop:function(){this.done=!0;var T=this.tryEntries[0].completion;if(T.type==="throw")throw T.arg;return this.rval},dispatchException:function(T){if(this.done)throw T;var u=this;function _(C0,u0){return M.type="throw",M.arg=T,u.next=C0,u0&&(u.method="next",u.arg=void 0),!!u0}for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n],M=h.completion;if(h.tryLoc==="root")return _("end");if(h.tryLoc<=this.prev){var Z0=K.call(h,"catchLoc"),G0=K.call(h,"finallyLoc");if(Z0&&G0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0);if(this.prev<h.finallyLoc)return _(h.finallyLoc)}else if(Z0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0)}else{if(!G0)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return _(h.finallyLoc)}}}},abrupt:function(T,u){for(var _=this.tryEntries.length-1;_>=0;--_){var n=this.tryEntries[_];if(n.tryLoc<=this.prev&&K.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var h=n;break}}h&&(T==="break"||T==="continue")&&h.tryLoc<=u&&u<=h.finallyLoc&&(h=null);var M=h?h.completion:{};return M.type=T,M.arg=u,h?(this.method="next",this.next=h.finallyLoc,k):this.complete(M)},complete:function(T,u){if(T.type==="throw")throw T.arg;return T.type==="break"||T.type==="continue"?this.next=T.arg:T.type==="return"?(this.rval=this.arg=T.arg,this.method="return",this.next="end"):T.type==="normal"&&u&&(this.next=u),k},finish:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.finallyLoc===T)return this.complete(_.completion,_.afterLoc),l0(_),k}},catch:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.tryLoc===T){var n=_.completion;if(n.type==="throw"){var h=n.arg;l0(_)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(T,u,_){return this.delegate={iterator:y0(T),resultName:u,nextLoc:_},this.method==="next"&&(this.arg=void 0),k}},j}function cZ(j,F,K,U,N,O,B){try{var w=j[O](B),R=w.value}catch(P){K(P);return}if(w.done)F(R);else Promise.resolve(R).then(U,N)}function G1(j){return function(){var F=this,K=arguments;return new Promise(function(U,N){var O=j.apply(F,K);function B(R){cZ(O,U,N,B,w,"next",R)}function w(R){cZ(O,U,N,B,w,"throw",R)}B(void 0)})}}function LY(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function lZ(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,oZ(U.key),U)}}function bY(j,F,K){if(F)lZ(j.prototype,F);if(K)lZ(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function F0(j,F,K){if(F=oZ(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function dZ(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)OQ(j,F)}function IJ(j){return IJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},IJ(j)}function OQ(j,F){return OQ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},OQ(j,F)}function RG(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function x0(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function $G(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return x0(j)}function nZ(j){var F=RG();return function K(){var U=IJ(j),N;if(F){var O=IJ(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return $G(this,N)}}function IG(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function oZ(j){var F=IG(j,"string");return typeof F==="symbol"?F:String(F)}function sZ(j,F){var K=Object.keys(j);if(Object.getOwnPropertySymbols){var U=Object.getOwnPropertySymbols(j);F&&(U=U.filter(function(N){return Object.getOwnPropertyDescriptor(j,N).enumerable})),K.push.apply(K,U)}return K}function qY(j){for(var F=1;F<arguments.length;F++){var K=arguments[F]!=null?arguments[F]:{};F%2?sZ(Object(K),!0).forEach(function(U){i(j,U,K[U])}):Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(K)):sZ(Object(K)).forEach(function(U){Object.defineProperty(j,U,Object.getOwnPropertyDescriptor(K,U))})}return j}function r0(){r0=function(){return j};var j={},F=Object.prototype,K=F.hasOwnProperty,U=Object.defineProperty||function(T,u,_){T[u]=_.value},N=typeof Symbol=="function"?Symbol:{},O=N.iterator||"@@iterator",B=N.asyncIterator||"@@asyncIterator",w=N.toStringTag||"@@toStringTag";function R(T,u,_){return Object.defineProperty(T,u,{value:_,enumerable:!0,configurable:!0,writable:!0}),T[u]}try{R({},"")}catch(T){R=function(u,_,n){return u[_]=n}}function P(T,u,_,n){var h=u&&u.prototype instanceof f?u:f,M=Object.create(h.prototype),Z0=new E0(n||[]);return U(M,"_invoke",{value:W0(T,_,Z0)}),M}function x(T,u,_){try{return{type:"normal",arg:T.call(u,_)}}catch(n){return{type:"throw",arg:n}}}j.wrap=P;var k={};function f(){}function l(){}function s(){}var Y0={};R(Y0,O,function(){return this});var t=Object.getPrototypeOf,K0=t&&t(t(y0([])));K0&&K0!==F&&K.call(K0,O)&&(Y0=K0);var q0=s.prototype=f.prototype=Object.create(Y0);function R0(T){["next","throw","return"].forEach(function(u){R(T,u,function(_){return this._invoke(u,_)})})}function U0(T,u){function _(h,M,Z0,G0){var C0=x(T[h],T,M);if(C0.type!=="throw"){var u0=C0.arg,d0=u0.value;return d0&&typeof d0=="object"&&K.call(d0,"__await")?u.resolve(d0.__await).then(function(M0){_("next",M0,Z0,G0)},function(M0){_("throw",M0,Z0,G0)}):u.resolve(d0).then(function(M0){u0.value=M0,Z0(u0)},function(M0){return _("throw",M0,Z0,G0)})}G0(C0.arg)}var n;U(this,"_invoke",{value:function(h,M){function Z0(){return new u(function(G0,C0){_(h,M,G0,C0)})}return n=n?n.then(Z0,Z0):Z0()}})}function W0(T,u,_){var n="suspendedStart";return function(h,M){if(n==="executing")throw new Error("Generator is already running");if(n==="completed"){if(h==="throw")throw M;return t0()}for(_.method=h,_.arg=M;;){var Z0=_.delegate;if(Z0){var G0=z0(Z0,_);if(G0){if(G0===k)continue;return G0}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(n==="suspendedStart")throw n="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);n="executing";var C0=x(T,u,_);if(C0.type==="normal"){if(n=_.done?"completed":"suspendedYield",C0.arg===k)continue;return{value:C0.arg,done:_.done}}C0.type==="throw"&&(n="completed",_.method="throw",_.arg=C0.arg)}}}function z0(T,u){var _=u.method,n=T.iterator[_];if(n===void 0)return u.delegate=null,_==="throw"&&T.iterator.return&&(u.method="return",u.arg=void 0,z0(T,u),u.method==="throw")||_!=="return"&&(u.method="throw",u.arg=new TypeError("The iterator does not provide a '"+_+"' method")),k;var h=x(n,T.iterator,u.arg);if(h.type==="throw")return u.method="throw",u.arg=h.arg,u.delegate=null,k;var M=h.arg;return M?M.done?(u[T.resultName]=M.value,u.next=T.nextLoc,u.method!=="return"&&(u.method="next",u.arg=void 0),u.delegate=null,k):M:(u.method="throw",u.arg=new TypeError("iterator result is not an object"),u.delegate=null,k)}function h0(T){var u={tryLoc:T[0]};1 in T&&(u.catchLoc=T[1]),2 in T&&(u.finallyLoc=T[2],u.afterLoc=T[3]),this.tryEntries.push(u)}function l0(T){var u=T.completion||{};u.type="normal",delete u.arg,T.completion=u}function E0(T){this.tryEntries=[{tryLoc:"root"}],T.forEach(h0,this),this.reset(!0)}function y0(T){if(T){var u=T[O];if(u)return u.call(T);if(typeof T.next=="function")return T;if(!isNaN(T.length)){var _=-1,n=function h(){for(;++_<T.length;)if(K.call(T,_))return h.value=T[_],h.done=!1,h;return h.value=void 0,h.done=!0,h};return n.next=n}}return{next:t0}}function t0(){return{value:void 0,done:!0}}return l.prototype=s,U(q0,"constructor",{value:s,configurable:!0}),U(s,"constructor",{value:l,configurable:!0}),l.displayName=R(s,w,"GeneratorFunction"),j.isGeneratorFunction=function(T){var u=typeof T=="function"&&T.constructor;return!!u&&(u===l||(u.displayName||u.name)==="GeneratorFunction")},j.mark=function(T){return Object.setPrototypeOf?Object.setPrototypeOf(T,s):(T.__proto__=s,R(T,w,"GeneratorFunction")),T.prototype=Object.create(q0),T},j.awrap=function(T){return{__await:T}},R0(U0.prototype),R(U0.prototype,B,function(){return this}),j.AsyncIterator=U0,j.async=function(T,u,_,n,h){h===void 0&&(h=Promise);var M=new U0(P(T,u,_,n),h);return j.isGeneratorFunction(u)?M:M.next().then(function(Z0){return Z0.done?Z0.value:M.next()})},R0(q0),R(q0,w,"Generator"),R(q0,O,function(){return this}),R(q0,"toString",function(){return"[object Generator]"}),j.keys=function(T){var u=Object(T),_=[];for(var n in u)_.push(n);return _.reverse(),function h(){for(;_.length;){var M=_.pop();if(M in u)return h.value=M,h.done=!1,h}return h.done=!0,h}},j.values=y0,E0.prototype={constructor:E0,reset:function(T){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(l0),!T)for(var u in this)u.charAt(0)==="t"&&K.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=void 0)},stop:function(){this.done=!0;var T=this.tryEntries[0].completion;if(T.type==="throw")throw T.arg;return this.rval},dispatchException:function(T){if(this.done)throw T;var u=this;function _(C0,u0){return M.type="throw",M.arg=T,u.next=C0,u0&&(u.method="next",u.arg=void 0),!!u0}for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n],M=h.completion;if(h.tryLoc==="root")return _("end");if(h.tryLoc<=this.prev){var Z0=K.call(h,"catchLoc"),G0=K.call(h,"finallyLoc");if(Z0&&G0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0);if(this.prev<h.finallyLoc)return _(h.finallyLoc)}else if(Z0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0)}else{if(!G0)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return _(h.finallyLoc)}}}},abrupt:function(T,u){for(var _=this.tryEntries.length-1;_>=0;--_){var n=this.tryEntries[_];if(n.tryLoc<=this.prev&&K.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var h=n;break}}h&&(T==="break"||T==="continue")&&h.tryLoc<=u&&u<=h.finallyLoc&&(h=null);var M=h?h.completion:{};return M.type=T,M.arg=u,h?(this.method="next",this.next=h.finallyLoc,k):this.complete(M)},complete:function(T,u){if(T.type==="throw")throw T.arg;return T.type==="break"||T.type==="continue"?this.next=T.arg:T.type==="return"?(this.rval=this.arg=T.arg,this.method="return",this.next="end"):T.type==="normal"&&u&&(this.next=u),k},finish:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.finallyLoc===T)return this.complete(_.completion,_.afterLoc),l0(_),k}},catch:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.tryLoc===T){var n=_.completion;if(n.type==="throw"){var h=n.arg;l0(_)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(T,u,_){return this.delegate={iterator:y0(T),resultName:u,nextLoc:_},this.method==="next"&&(this.arg=void 0),k}},j}function s1(j){return s1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(F){return typeof F}:function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},s1(j)}function rZ(j,F,K,U,N,O,B){try{var w=j[O](B),R=w.value}catch(P){K(P);return}if(w.done)F(R);else Promise.resolve(R).then(U,N)}function C1(j){return function(){var F=this,K=arguments;return new Promise(function(U,N){var O=j.apply(F,K);function B(R){rZ(O,U,N,B,w,"next",R)}function w(R){rZ(O,U,N,B,w,"throw",R)}B(void 0)})}}function f0(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function aZ(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,Q8(U.key),U)}}function c0(j,F,K){if(F)aZ(j.prototype,F);if(K)aZ(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function i(j,F,K){if(F=Q8(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function u1(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)cY(j,F)}function KY(j){return KY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},KY(j)}function cY(j,F){return cY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},cY(j,F)}function eZ(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function bJ(j,F,K){if(eZ())bJ=Reflect.construct.bind();else bJ=function U(N,O,B){var w=[null];w.push.apply(w,O);var R=Function.bind.apply(N,w),P=new R;if(B)cY(P,B.prototype);return P};return bJ.apply(null,arguments)}function MG(j){return Function.toString.call(j).indexOf("[native code]")!==-1}function zY(j){var F=typeof Map==="function"?new Map:void 0;return zY=function K(U){if(U===null||!MG(U))return U;if(typeof U!=="function")throw new TypeError("Super expression must either be null or a function");if(typeof F!=="undefined"){if(F.has(U))return F.get(U);F.set(U,N)}function N(){return bJ(U,arguments,KY(this).constructor)}return N.prototype=Object.create(U.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),cY(N,U)},zY(j)}function CG(j,F){if(j==null)return{};var K={},U=Object.keys(j),N,O;for(O=0;O<U.length;O++){if(N=U[O],F.indexOf(N)>=0)continue;K[N]=j[N]}return K}function Y8(j,F){if(j==null)return{};var K=CG(j,F),U,N;if(Object.getOwnPropertySymbols){var O=Object.getOwnPropertySymbols(j);for(N=0;N<O.length;N++){if(U=O[N],F.indexOf(U)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(j,U))continue;K[U]=j[U]}}return K}function A0(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function DG(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return A0(j)}function m1(j){var F=eZ();return function K(){var U=KY(j),N;if(F){var O=KY(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return DG(this,N)}}function SG(j,F){while(!Object.prototype.hasOwnProperty.call(j,F))if(j=KY(j),j===null)break;return j}function fY(){if(typeof Reflect!=="undefined"&&Reflect.get)fY=Reflect.get.bind();else fY=function j(F,K,U){var N=SG(F,K);if(!N)return;var O=Object.getOwnPropertyDescriptor(N,K);if(O.get)return O.get.call(arguments.length<3?F:U);return O.value};return fY.apply(this,arguments)}function PG(j,F){if(!j)return;if(typeof j==="string")return tZ(j,F);var K=Object.prototype.toString.call(j).slice(8,-1);if(K==="Object"&&j.constructor)K=j.constructor.name;if(K==="Map"||K==="Set")return Array.from(j);if(K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K))return tZ(j,F)}function tZ(j,F){if(F==null||F>j.length)F=j.length;for(var K=0,U=new Array(F);K<F;K++)U[K]=j[K];return U}function J8(j,F){var K=typeof Symbol!=="undefined"&&j[Symbol.iterator]||j["@@iterator"];if(!K){if(Array.isArray(j)||(K=PG(j))||F&&j&&typeof j.length==="number"){if(K)j=K;var U=0,N=function(){};return{s:N,n:function(){if(U>=j.length)return{done:!0};return{done:!1,value:j[U++]}},e:function(R){throw R},f:N}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
28
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var O=!0,B=!1,w;return{s:function(){K=K.call(j)},n:function(){var R=K.next();return O=R.done,R},e:function(R){B=!0,w=R},f:function(){try{if(!O&&K.return!=null)K.return()}finally{if(B)throw w}}}}function yG(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function Q8(j){var F=yG(j,"string");return typeof F==="symbol"?F:String(F)}var J1=function(){function j(){f0(this,j)}return c0(j,null,[{key:"start",value:function F(K){if(!K||!K.length)return 0;if(K.length===1&&K.end(0)-K.start(0)<0.000001)return 0;if(K.length===1&&K.start(0)<0)return 0;return K.start(0)}},{key:"end",value:function F(K){if(!K||!K.length)return 0;if(K.length===1&&K.end(0)-K.start(0)<0.000001)return 0;return K.end(K.length-1)}},{key:"get",value:function F(K){if(!K)return;try{return K.buffered}catch(U){}}},{key:"buffers",value:function F(K,U){if(!K||!K.length)return[];var N=[];for(var O=0,B=K.length;O<B;O++){var w=N.length;if(!w||!U)N.push([K.start(O),K.end(O)]);else{var R=N[w-1],P=R[1],x=K.start(O);if(x-P<=U){var k=K.end(O);if(k>P)R[1]=k}else N.push([K.start(O),K.end(O)])}}return N}},{key:"totalLength",value:function F(K){if(!K||!K.length)return 0;return K.reduce(function(U,N){return U+=N[1]-N[0]},0)}},{key:"info",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!K||!K.length)return{start:0,end:0,buffers:[]};var O=0,B=0,w=0,R=0,P=0,x=0,k=0,f=j.buffers(K,N);for(var l=0,s=f.length;l<s;l++){var Y0=f[l];if(U+N>=Y0[0]&&U<=Y0[1])O=Y0[0],B=Y0[1],w=l;else if(U+N<Y0[0]){R=Y0[0],P=Y0[1];break}else if(U+N>Y0[1])x=Y0[0],k=Y0[1]}return{start:O,end:B,index:w,buffers:f,nextStart:R,nextEnd:P,prevStart:x,prevEnd:k,currentTime:U,behind:U-O,remaining:B?B-U:0,length:j.totalLength&&j.totalLength(f)}}},{key:"isBuffered",value:function F(K,U){if(K){var N=j.get(K);if(N!==null&&N!==void 0&&N.length){for(var O=0;O<N.length;O++)if(U>=N.start(O)&&U<=N.end(O))return!0}}return!1}}]),j}();var Z8=typeof window!=="undefined";var L1,P0={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},MJ=(L1={},i(L1,P0.MANIFEST,{HLS:1100,DASH:1200}),i(L1,P0.NETWORK,2100),i(L1,P0.NETWORK_TIMEOUT,2101),i(L1,P0.NETWORK_FORBIDDEN,2103),i(L1,P0.NETWORK_NOTFOUND,2104),i(L1,P0.NETWROK_RANGE_NOT_SATISFIABLE,2116),i(L1,P0.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),i(L1,P0.REMUX,{FMP4:4100,MP4:4200}),i(L1,P0.MEDIA,{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}),i(L1,P0.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),i(L1,P0.OTHER,8000),i(L1,P0.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),L1),A1=function(j){u1(K,j);var F=m1(K);function K(U,N,O,B,w){var R;if(f0(this,K),R=F.call(this,w||(O===null||O===void 0?void 0:O.message)),R.errorType=U===P0.NETWORK_TIMEOUT?P0.NETWORK:U,R.originError=O,R.ext=B,R.errorCode=MJ[U][N]||MJ[U],R.errorMessage=R.message,!R.errorCode)R.errorType=P0.OTHER,R.errorCode=MJ[R.errorType];return R}return c0(K,null,[{key:"create",value:function U(N,O,B,w,R){if(N instanceof K)return N;else if(N instanceof Error)B=N,N="";if(!N)N=P0.OTHER;return new K(N,O,B,w,R)}},{key:"network",value:function U(N){var O;return new K(N!==null&&N!==void 0&&N.isTimeout?P0.NETWORK_TIMEOUT:P0.NETWORK,null,N instanceof Error?N:null,{url:N===null||N===void 0?void 0:N.url,response:N===null||N===void 0?void 0:N.response,httpCode:N===null||N===void 0?void 0:(O=N.response)===null||O===void 0?void 0:O.status})}}]),K}(zY(Error));var dY={DEBUG:1,LOG:2,WARN:3,ERROR:4},TG=204800,xG=["Boolean","Number","String","Undefined","Null","Date","Object"],D1=function(){function j(F,K){f0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(K===null||K===void 0?void 0:K.logCacheLevel)||3,this.logMaxSize=(K===null||K===void 0?void 0:K.logMaxSize)||TG,this.logSize=0,this.logTextArray=[]}return c0(j,[{key:"debug",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[dY.DEBUG].concat(N)),j.disabled)return;(K=console).debug.apply(K,["[".concat(lY(),"]"),this._prefix].concat(N))}},{key:"log",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[dY.LOG].concat(N)),j.disabled)return;(K=console).log.apply(K,["[".concat(lY(),"]"),this._prefix].concat(N))}},{key:"warn",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[dY.WARN].concat(N)),j.disabled)return;(K=console).warn.apply(K,["[".concat(lY(),"]"),this._prefix].concat(N))}},{key:"error",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[dY.ERROR].concat(N)),j.disabled)return;(K=console).error.apply(K,["[".concat(lY(),"]"),this._prefix].concat(N))}},{key:"logCache",value:function F(K){if(K<this.logCacheLevel)return;var U="";try{for(var N=arguments.length,O=new Array(N>1?N-1:0),B=1;B<N;B++)O[B-1]=arguments[B];var w=O.map(function(P){return X8(P)});U="[".concat(lY(),"]")+this._prefix+JSON.stringify(w)}catch(P){return}if(K>=this.logCacheLevel)this.logSize+=U.length,this.logTextArray.push(U);if(this.logSize>this.logMaxSize){var R=this.logTextArray.shift();this.logSize-=R.length}}},{key:"getLogCache",value:function F(){var K=this.logTextArray.join(`
29
+ `);return this.reset(),K}},{key:"reset",value:function F(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function F(){var K;if(j.disabled)return;console.group(this._prefix),(K=console).table.apply(K,arguments),console.groupEnd()}},{key:"setLogLevel",value:function F(K){this.logCacheLevel=K}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();i(D1,"disabled",!0);function lY(){return new Date().toLocaleString()}function vG(j){if(s1(j)!=="object")return j;var F=Object.prototype.toString.call(j).slice(8,-1);switch(F){case"Array":case"Uint8Array":case"ArrayBuffer":return F+"["+j.length+"]";case"Object":return"{}";default:return F}}function X8(j,F,K){if(!K)K=1;if(!F)F=2;var U={};if(!j||s1(j)!=="object")return j;var N=Object.prototype.toString.call(j).slice(8,-1);if(!xG.includes(N))return N;if(K>F)return;for(var O in j)if(Object.prototype.hasOwnProperty.call(j,O))if(K===F)U[O]=vG(j[O]);else if(s1(j[O])==="object")U[O]=X8(j[O],F,K+1);else U[O]=j[O];return U}function HY(){var j,F,K=new Promise(function(U,N){j=U,F=N});return K.used=!1,K.resolve=function(){return K.used=!0,j.apply(void 0,arguments)},K.reject=function(){return K.used=!0,F.apply(void 0,arguments)},K}function jY(){try{return parseInt(performance.now(),10)}catch(j){return new Date().getTime()}}var G8={stringify:function j(F){try{return JSON.stringify(F)}catch(K){return""}},parse:function j(F){try{return JSON.parse(F)}catch(K){return}}};function W8(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{if(!Z8)return null;if(j&&typeof ManagedMediaSource!=="undefined")return ManagedMediaSource;return window.MediaSource}catch(F){}}function EQ(j){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(j))}function hG(j){var F=[];if(j instanceof TimeRanges)for(var K=0;K<j.length;K++)F.push({start:j.start(K),end:j.end(K)});return F}var CJ={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var NY=function(){function j(F,K){var U=this;if(f0(this,j),i(this,"media",null),i(this,"mediaSource",null),i(this,"_openPromise",HY()),i(this,"_queue",Object.create(null)),i(this,"_sourceBuffer",Object.create(null)),i(this,"_mseFullFlag",{}),i(this,"_st",0),i(this,"_opst",0),i(this,"_logger",null),i(this,"_config",null),i(this,"_url",null),i(this,"_onStartStreaming",function(){U._logger.debug("startstreaming")}),i(this,"_onEndStreaming",function(){U._logger.debug("endstreaming")}),i(this,"_onSBUpdateEnd",function(N){var O=U._queue[N];if(O){var B=O[0];if((B===null||B===void 0?void 0:B.opName)!==CJ.UPDATE_DURATION)O.shift();if(B){var w,R,P=jY()-U._opst;U._logger.debug("UpdateEnd(".concat(N,"/").concat(B.opName,")"),G8.stringify(hG((w=U._sourceBuffer[N])===null||w===void 0?void 0:w.buffered)),P,B.context),B.promise.resolve({name:B.opName,context:B.context,costtime:P});var x=(R=B.context)===null||R===void 0?void 0:R.callback;if(x&&typeof x==="function")x(B.context);U._startQueue(N)}}}),i(this,"_onSBUpdateError",function(N,O){var B=U._queue[N];if(B){var w=B[0];if(w)U._logger.error("UpdateError",N,w.opName,w.context),w.promise.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_APPEND_BUFFER,O))}}),this._config=Object.assign(j.getDefaultConfig(),K),F)this.bindMedia(F);if(this._logger=new D1("MSE"),this._config.openLog)D1.enable()}return c0(j,[{key:"isOpened",get:function F(){var K;return((K=this.mediaSource)===null||K===void 0?void 0:K.readyState)==="open"}},{key:"hasOpTasks",get:function F(){var K=this,U=!1;return Object.keys(this._queue).forEach(function(N){var O=K._queue[N];if(Array.isArray(O))U||(U=O.length>0)}),U}},{key:"url",get:function F(){return this._url}},{key:"duration",get:function F(){var K;return((K=this.mediaSource)===null||K===void 0?void 0:K.duration)||-1}},{key:"isEnded",get:function F(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function F(){return EQ(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function F(K){return K?this._mseFullFlag[K]:this._mseFullFlag[j.VIDEO]}},{key:"updateDuration",value:function F(K){var U=this,N=this.mediaSource&&this.mediaSource.duration>K;if(this.mediaSource&&this.mediaSource.duration>K){var O=0;if(Object.keys(this._sourceBuffer).forEach(function(B){try{O=Math.max(U.bufferEnd(B)||0,O)}catch(w){}}),K<O)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(U.isEnded){U._logger.debug("setDuration but ended");return}if(U.mediaSource)U.mediaSource.duration=K,U._logger.debug("setDuration",K)},CJ.UPDATE_DURATION,{isReduceDuration:N})}},{key:"open",value:function F(){var K=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var U=this.mediaSource,N=function O(){var B=jY()-K._st;K._logger.debug("sourceopen",B),U.removeEventListener("sourceopen",O),K._openPromise.resolve({costtime:B})};U.addEventListener("sourceopen",N),this._openPromise=HY()}return this._openPromise}},{key:"bindMedia",value:function(){var F=C1(r0().mark(function U(N){var O=this,B,w,R,P;return r0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(!(this.mediaSource||this.media)){k.next=3;break}return k.next=3,this.unbindMedia();case 3:if(B=W8(this._config.preferMMS),!(!N||!B)){k.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:if(this.media=N,w=this.mediaSource=new B,R=EQ(w),this._st=jY(),P=function f(){var l=jY()-O._st;O._logger.debug("sourceopen"),w.removeEventListener("sourceopen",f),URL.revokeObjectURL(N.src),O._openPromise.resolve({costtime:l})},w.addEventListener("sourceopen",P),R)w.addEventListener("startstreaming",this._onStartStreaming),w.addEventListener("endstreaming",this._onEndStreaming);return this._url=URL.createObjectURL(w),N.src=this._url,N.disableRemotePlayback=R,k.abrupt("return",this._openPromise);case 17:case"end":return k.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"unbindMedia",value:function(){var F=C1(r0().mark(function U(){var N=this,O,B,w;return r0().wrap(function R(P){while(!0)switch(P.prev=P.next){case 0:if(!this._openPromise.used)this._openPromise.resolve();if(O=this.mediaSource,O){if(Object.keys(this._queue).forEach(function(x){var k=N._queue[x];if(k)k.forEach(function(f){var l,s;return(l=f.promise)===null||l===void 0?void 0:(s=l.resolve)===null||s===void 0?void 0:s.call(l)})}),B=!!this.media&&this.media.readyState>=1,w=O.readyState==="open",B&&w)try{O.endOfStream()}catch(x){}if(Object.keys(this._sourceBuffer).forEach(function(x){try{O.removeSourceBuffer(N._sourceBuffer[x])}catch(k){}}),EQ(O))O.removeEventListener("startstreaming",this._onStartStreaming),O.removeEventListener("endstreaming",this._onEndStreaming)}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(x){}this.media=null}this.mediaSource=null,this._openPromise=HY(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return P.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"createSource",value:function F(K,U){if(this._sourceBuffer[K]||!this.mediaSource)return;var N;try{N=this._sourceBuffer[K]=this.mediaSource.addSourceBuffer(U)}catch(O){throw new A1(P0.MEDIA,P0.SUB_TYPES.MSE_ADD_SB,O)}N.mimeType=U,N.addEventListener("updateend",this._onSBUpdateEnd.bind(this,K)),N.addEventListener("error",this._onSBUpdateError.bind(this,K))}},{key:"changeType",value:function F(K,U){var N=this,O=this._sourceBuffer[K];if(!this.mediaSource||!O||O.mimeType===U)return Promise.resolve();if(typeof O.changeType!=="function")return Promise.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function")));return this._enqueueOp(K,function(){try{O.changeType(U)}catch(B){throw new A1(P0.MEDIA,P0.SUB_TYPES.MSE_CHANGE_TYPE,B)}O.mimeType=U,N._onSBUpdateEnd(K)},"changeType",{mimeType:U})}},{key:"createOrChangeSource",value:function F(K,U){return this.createSource(K,U),this.changeType(K,U)}},{key:"append",value:function F(K,U,N){var O=this;if(!U||!U.byteLength)return Promise.resolve();if(!this._sourceBuffer[K])return Promise.resolve();return this._enqueueOp(K,function(){var B;if(!O.mediaSource||O.media.error)return;O._logger.debug("MSE APPEND START",N),O._opst=jY(),(B=O._sourceBuffer[K])===null||B===void 0||B.appendBuffer(U)},CJ.APPEND,N)}},{key:"remove",value:function F(K,U,N,O){var B=this,w=!1;if(this._mseFullFlag[K])w=!0;return this._enqueueOp(K,function(){if(!B.mediaSource||B.media.error)return;var R=B._sourceBuffer[K];if(U>=N||!R){B._onSBUpdateEnd(K);return}B._opst=jY(),B._logger.debug("MSE REMOVE START",K,U,N,O),R.remove(U,N)},CJ.REMOVE,O,w)}},{key:"clearBuffer",value:function F(K,U){var N=this,O;return Object.keys(this._sourceBuffer).forEach(function(B){O=N.remove(B,K,U)}),O||Promise.resolve()}},{key:"clearAllBuffer",value:function F(){var K=this,U;return Object.keys(this._sourceBuffer).forEach(function(N){var O=K._sourceBuffer[N];U=K.remove(N,0,J1.end(J1.get(O)))}),U}},{key:"clearOpQueues",value:function F(K,U){var N;this._logger.debug("MSE clearOpQueue START");var O=this._queue[K];if(U&&O){this._queue[K]=[];return}if(!O||!O[K]||O.length<5)return;var B=[];O.forEach(function(w){if(w.context&&w.context.isinit)B.push(w)}),this._queue[K]=O.slice(0,2),B.length>0&&(N=this._queue[K]).push.apply(N,B)}},{key:"endOfStream",value:function F(K){var U=this;if(!this.mediaSource||this.mediaSource.readyState!=="open")return Promise.resolve();return this._enqueueBlockingOp(function(){var N=U.mediaSource;if(!N||N.readyState!=="open")return;if(U._logger.debug("MSE endOfStream START"),K)N.endOfStream(K);else N.endOfStream()},"endOfStream")}},{key:"setLiveSeekableRange",value:function F(K,U){var N=this.mediaSource;if(K<0||U<K||!(N!==null&&N!==void 0&&N.setLiveSeekableRange)||N.readyState!=="open")return;N.setLiveSeekableRange(K,U)}},{key:"getSourceBuffer",value:function F(K){return this._sourceBuffer[K]}},{key:"buffered",value:function F(K){return J1.get(this._sourceBuffer[K])}},{key:"bufferStart",value:function F(K){return J1.start(this.buffered(K))}},{key:"bufferEnd",value:function F(K){return J1.end(this.buffered(K))}},{key:"_enqueueOp",value:function F(K,U,N,O,B){var w=this;if(!this.mediaSource)return Promise.resolve();var R=this._queue[K]=this._queue[K]||[],P={exec:U,promise:HY(),opName:N,context:O};if(B)R.splice(0,0,P),this._mseFullFlag[K]=!1,this._startQueue(K);else R.push(P);if(this.isOpened||this.isEnded){if(R.length===1)this._startQueue(K)}else this._openPromise.then(function(){if(R.length===1)w._startQueue(K)});return P.promise}},{key:"_enqueueBlockingOp",value:function(){var F=C1(r0().mark(function U(N,O,B){var w=this,R,P;return r0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(this.mediaSource){k.next=2;break}return k.abrupt("return",Promise.resolve());case 2:if(R=Object.keys(this._sourceBuffer),R.length){k.next=5;break}return k.abrupt("return",N());case 5:return P=[],R.forEach(function(f){var l=w._queue[f],s=HY();if(P.push(s),l.push({exec:function Y0(){s.resolve()},promise:s,opName:O,context:B}),l.length===1)w._startQueue(f)}),k.abrupt("return",Promise.all(P).then(function(){try{return N()}finally{R.forEach(function(f){var l=w._queue[f],s=w._sourceBuffer[f];if(l===null||l===void 0||l.shift(),!s||!s.updating)w._startQueue(f)})}}));case 8:case"end":return k.stop()}},U,this)}));function K(U,N,O){return F.apply(this,arguments)}return K}()},{key:"_startQueue",value:function F(K){var U=this._queue[K];if(U){var N=U[0];if(N&&!this._mseFullFlag[K])try{N.exec()}catch(w){if(w&&w.message&&w.message.indexOf("SourceBuffer is full")>=0){var O;if(this._mseFullFlag[K]=!0,N.context&&s1(N.context)==="object")N.context.isFull=!0;this._logger.error("[MSE error], context,",N.context," ,name,",N.opName,",err,SourceBuffer is full"),N===null||N===void 0||(O=N.promise)===null||O===void 0||O.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_FULL,w))}else{var B;this._logger.error(w),N===null||N===void 0||(B=N.promise)===null||B===void 0||B.reject(w.constructor===A1?w:new A1(P0.MEDIA,P0.SUB_TYPES.MSE_OTHER,w)),U.shift(),this._startQueue(K)}}}}},{key:"setTimeoffset",value:function F(K,U,N){var O=this;return this._enqueueOp(K,function(){if(U<0)U+=0.001;O._sourceBuffer[K].timestampOffset=U,O._onSBUpdateEnd(K)},"setTimeoffset",N)}},{key:"abort",value:function F(K,U){var N=this;if(!this.isOpened)return Promise.resolve();return this._enqueueOp(K,function(){N._sourceBuffer[K].abort(),N._onSBUpdateEnd(K)},"abort",U)}}],[{key:"isSupported",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',U=W8();if(!U)return!1;try{return U.isTypeSupported(K)}catch(N){return this._logger.error(K,N),!1}}},{key:"isMMSOnly",value:function F(){return typeof ManagedMediaSource!=="undefined"&&typeof MediaSource==="undefined"}},{key:"getDefaultConfig",value:function F(){return{openLog:!1,preferMMS:!1}}}]),j}();i(NY,"VIDEO","video");i(NY,"AUDIO","audio");var _1={FETCH:"fetch",XHR:"xhr"},UY={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var T1=function(j){u1(K,j);var F=m1(K);function K(U,N,O,B){var w;return f0(this,K),w=F.call(this,B),i(A0(w),"retryCount",0),i(A0(w),"isTimeout",!1),i(A0(w),"loaderType",_1.FETCH),i(A0(w),"startTime",0),i(A0(w),"endTime",0),i(A0(w),"options",{}),w.url=U,w.request=N,w.response=O,w}return c0(K)}(zY(Error));var K8=Object.prototype.toString;function q8(j){return j!==null&&s1(j)==="object"}function BQ(j){if(K8.call(j)!=="[object Object]")return!1;var F=Object.getPrototypeOf(j);return F===null||F===Object.prototype}function H8(j){return K8.call(j)==="[object Date]"}function DJ(j){if(!j||j[0]===null||j[0]===void 0||j[0]===0&&(j[1]===null||j[1]===void 0))return;var F="bytes="+j[0]+"-";if(j[1])F+=j[1];return F}function N8(j){return encodeURIComponent(j).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function SJ(j,F){if(!j)return;if(!F)return j;var K,U=Object.keys(F).map(function(O){if(K=F[O],K===null||K===void 0)return;if(Array.isArray(K))O=O+"[]";else K=[K];return K.map(function(B){if(H8(B))B=B.toISOString();else if(q8(B))B=JSON.stringify(B);return"".concat(N8(O),"=").concat(N8(B))}).join("&")}).filter(Boolean).join("&");if(U){var N=j.indexOf("#");if(N!==-1)j=j.slice(0,N);j+=(j.indexOf("?")===-1?"?":"&")+U}return j}function nY(j,F,K,U,N,O,B,w,R,P,x){if(N=N!==null&&N!==void 0?parseFloat(N):null,U=parseInt(U||"0",10),Number.isNaN(U))U=0;var k={range:R,vid:P,index:w,contentLength:U,age:N,startTime:O,firstByteTime:B,endTime:Date.now(),priOptions:x};return{data:j,done:F,options:k,response:K}}function oY(j,F){return Math.round(j*8*1000/F/1024)}var w0={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var V8=IY(MY(),1),U8=2097152,iY=function(j){u1(K,j);var F=m1(K);function K(){var U;return f0(this,K),U=F.call(this),i(A0(U),"_abortController",null),i(A0(U),"_timeoutTimer",null),i(A0(U),"_reader",null),i(A0(U),"_response",null),i(A0(U),"_aborted",!1),i(A0(U),"_index",-1),i(A0(U),"_range",null),i(A0(U),"_receivedLength",0),i(A0(U),"_running",!1),i(A0(U),"_logger",null),i(A0(U),"_vid",""),i(A0(U),"_onProcessMinLen",0),i(A0(U),"_onCancel",null),i(A0(U),"_priOptions",null),U}return c0(K,[{key:"load",value:function U(N){var O,B=this,w=N.url,R=N.vid,P=N.timeout,x=N.responseType,k=N.onProgress,f=N.index,l=N.onTimeout,s=N.onCancel,Y0=N.range,t=N.transformResponse,K0=N.request,q0=N.params,R0=N.logger,U0=N.method,W0=N.headers,z0=N.body,h0=N.mode,l0=N.credentials,E0=N.cache,y0=N.redirect,t0=N.referrer,T=N.referrerPolicy,u=N.onProcessMinLen,_=N.priOptions;this._logger=R0,this._aborted=!1,this._onProcessMinLen=u,this._onCancel=s,this._abortController=typeof AbortController!=="undefined"&&new AbortController,this._running=!0,this._index=f,this._range=Y0||[0,0],this._vid=R||w,this._priOptions=_||{};var n={method:U0,headers:W0,body:z0,mode:h0,credentials:l0,cache:E0,redirect:y0,referrer:t0,referrerPolicy:T,signal:(O=this._abortController)===null||O===void 0?void 0:O.signal},h=!1;clearTimeout(this._timeoutTimer),w=SJ(w,q0);var M=DJ(Y0);if(M){if(K0)W0=K0.headers;else W0=n.headers=n.headers||(Headers?new Headers:{});if(Headers&&W0 instanceof Headers)W0.append("Range",M);else W0.Range=M}if(P)this._timeoutTimer=setTimeout(function(){if(h=!0,B.cancel(),l){var G0=new T1(w,n,null,"timeout");G0.isTimeout=!0,l(G0,{index:B._index,range:B._range,vid:B._vid,priOptions:B._priOptions})}},P);var Z0=Date.now();return this._logger.debug("[fetch load start], index,",f,",range,",Y0),new Promise(function(G0,C0){fetch(K0||w,K0?void 0:n).then(function(){var u0=C1(r0().mark(function d0(M0){var PY,P1,yY,TY;return r0().wrap(function tY(e0){while(!0)switch(e0.prev=e0.next){case 0:if(clearTimeout(B._timeoutTimer),B._response=M0,!(B._aborted||!B._running)){e0.next=4;break}return e0.abrupt("return");case 4:if(t)M0=t(M0,w)||M0;if(M0.ok){e0.next=7;break}throw new T1(w,n,M0,"bad network response");case 7:if(PY=Date.now(),x!==UY.TEXT){e0.next=15;break}return e0.next=11,M0.text();case 11:P1=e0.sent,B._running=!1,e0.next=37;break;case 15:if(x!==UY.JSON){e0.next=22;break}return e0.next=18,M0.json();case 18:P1=e0.sent,B._running=!1,e0.next=37;break;case 22:if(!k){e0.next=29;break}return B.resolve=G0,B.reject=C0,B._loadChunk(M0,k,Z0,PY),e0.abrupt("return");case 29:return e0.next=31,M0.arrayBuffer();case 31:P1=e0.sent,P1=new Uint8Array(P1),B._running=!1,yY=Date.now()-Z0,TY=oY(P1.byteLength,yY),B.emit(w0.REAL_TIME_SPEED,{speed:TY,len:P1.byteLength,time:yY,vid:B._vid,index:B._index,range:B._range,priOptions:B._priOptions});case 37:B._logger.debug("[fetch load end], index,",f,",range,",Y0),G0(nY(P1,!0,M0,M0.headers.get("Content-Length"),M0.headers.get("age"),Z0,PY,f,Y0,B._vid,B._priOptions));case 39:case"end":return e0.stop()}},d0)}));return function(d0){return u0.apply(this,arguments)}}()).catch(function(u0){var d0;if(clearTimeout(B._timeoutTimer),B._running=!1,B._aborted&&!h)return;u0=u0 instanceof T1?u0:new T1(w,n,null,(d0=u0)===null||d0===void 0?void 0:d0.message),u0.startTime=Z0,u0.endTime=Date.now(),u0.isTimeout=h,u0.options={index:B._index,range:B._range,vid:B._vid,priOptions:B._priOptions},C0(u0)})})}},{key:"cancel",value:function(){var U=C1(r0().mark(function O(){return r0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!this._aborted){w.next=2;break}return w.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){w.next=14;break}if(w.prev=5,!this._reader){w.next=9;break}return w.next=9,this._reader.cancel();case 9:w.next=13;break;case 11:w.prev=11,w.t0=w.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(R){}this._abortController=null}if(this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return w.stop()}},O,this,[[5,11]])}));function N(){return U.apply(this,arguments)}return N}()},{key:"_loadChunk",value:function U(N,O,B,w){var R=this;if(!N.body||!N.body.getReader){this._running=!1;var P=new T1(N.url,"",N,"onProgress of bad response.body.getReader");P.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(P);return}if(this._onProcessMinLen>0)this._cache=new Uint8Array(U8),this._writeIdx=0;var x=this._reader=N.body.getReader(),k,f,l,s=function(){var Y0=C1(r0().mark(function t(){var K0,q0,R0,U0,W0,z0,h0,l0;return r0().wrap(function E0(y0){while(!0)switch(y0.prev=y0.next){case 0:return f=Date.now(),y0.prev=1,y0.next=4,x.read();case 4:k=y0.sent,l=Date.now(),y0.next=13;break;case 8:if(y0.prev=8,y0.t0=y0.catch(1),l=Date.now(),!R._aborted)R._running=!1,y0.t0.options={index:R._index,range:R._range,vid:R._vid,priOptions:R._priOptions},R.reject(y0.t0);return y0.abrupt("return");case 13:if(q0=((K0=R._range)===null||K0===void 0?void 0:K0.length)>0?R._range[0]:0,R0=q0+R._receivedLength,!R._aborted){y0.next=19;break}return R._running=!1,O(void 0,!1,{range:[R0,R0],vid:R._vid,index:R._index,startTime:f,endTime:l,st:B,firstByteTime:w,priOptions:R._priOptions},N),y0.abrupt("return");case 19:if(U0=k.value?k.value.byteLength:0,R._receivedLength+=U0,R._logger.debug("【fetchLoader,onProgress call】,task,",R._range,", start,",R0,", end,",q0+R._receivedLength,", done,",k.done),R._onProcessMinLen>0){if(R._writeIdx+U0>=R._onProcessMinLen||k.done)W0=new Uint8Array(R._writeIdx+U0),W0.set(R._cache.slice(0,R._writeIdx),0),U0>0&&W0.set(k.value,R._writeIdx),R._writeIdx=0,R._logger.debug("【fetchLoader,onProgress enough】,done,",k.done,",len,",W0.byteLength,", writeIdx,",R._writeIdx);else if(U0>0&&R._writeIdx+U0<U8)R._cache.set(k.value,R._writeIdx),R._writeIdx+=U0,R._logger.debug("【fetchLoader,onProgress cache】,len,",U0,", writeIdx,",R._writeIdx);else if(U0>0)z0=new Uint8Array(R._writeIdx+U0+2048),R._logger.debug("【fetchLoader,onProgress extra start】,size,",R._writeIdx+U0+2048,", datalen,",U0,", writeIdx,",R._writeIdx),z0.set(R._cache.slice(0,R._writeIdx),0),U0>0&&z0.set(k.value,R._writeIdx),R._writeIdx+=U0,delete R._cache,R._cache=z0,R._logger.debug("【fetchLoader,onProgress extra end】,len,",U0,", writeIdx,",R._writeIdx)}else W0=k.value;if(W0&&W0.byteLength>0||k.done)O(W0,k.done,{range:[R._range[0]+R._receivedLength-(W0?W0.byteLength:0),R._range[0]+R._receivedLength],vid:R._vid,index:R._index,startTime:f,endTime:l,st:B,firstByteTime:w,priOptions:R._priOptions},N);if(!k.done)s();else h0=Date.now()-B,l0=oY(R._receivedLength,h0),R.emit(w0.REAL_TIME_SPEED,{speed:l0,len:R._receivedLength,time:h0,vid:R._vid,index:R._index,range:R._range,priOptions:R._priOptions}),R._running=!1,R._logger.debug("[fetchLoader onProgress end],task,",R._range,",done,",k.done),R.resolve(nY(k,!0,N,N.headers.get("Content-Length"),N.headers.get("age"),B,w,R._index,R._range,R._vid,R._priOptions));case 25:case"end":return y0.stop()}},t,null,[[1,8]])}));return function t(){return Y0.apply(this,arguments)}}();s()}},{key:"receiveLen",get:function U(){return this._receivedLength}},{key:"running",get:function U(){return this._running},set:function U(N){this._running=N}}],[{key:"isSupported",value:function U(){return typeof fetch!=="undefined"}}]),K}(V8.default);function z8(j){return qY({loaderType:_1.FETCH,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:UY.TEXT,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},j)}var j8=IY(MY(),1),A8=function(j){u1(K,j);var F=m1(K);function K(){var U;return f0(this,K),U=F.call(this),i(A0(U),"_xhr",null),i(A0(U),"_aborted",!1),i(A0(U),"_timeoutTimer",null),i(A0(U),"_range",null),i(A0(U),"_receivedLength",0),i(A0(U),"_url",null),i(A0(U),"_onProgress",null),i(A0(U),"_index",-1),i(A0(U),"_headers",null),i(A0(U),"_currentChunkSizeKB",384),i(A0(U),"_timeout",null),i(A0(U),"_xhr",null),i(A0(U),"_withCredentials",null),i(A0(U),"_startTime",-1),i(A0(U),"_loadCompleteResolve",null),i(A0(U),"_loadCompleteReject",null),i(A0(U),"_runing",!1),i(A0(U),"_logger",!1),i(A0(U),"_vid",""),i(A0(U),"_responseType",void 0),i(A0(U),"_credentials",void 0),i(A0(U),"_method",void 0),i(A0(U),"_transformResponse",void 0),i(A0(U),"_firstRtt",void 0),i(A0(U),"_onCancel",null),i(A0(U),"_priOptions",null),U}return c0(K,[{key:"load",value:function U(N){var O=this;clearTimeout(this._timeoutTimer),this._logger=N.logger,this._range=N.range,this._onProgress=N.onProgress,this._index=N.index,this._headers=N.headers,this._withCredentials=N.credentials==="include"||N.credentials==="same-origin",this._body=N.body||null,N.method&&(this._method=N.method),this._timeout=N.timeout||null,this._runing=!0,this._vid=N.vid||N.url,this._responseType=N.responseType,this._firstRtt=-1,this._onTimeout=N.onTimeout,this._onCancel=N.onCancel,this._request=N.request,this._priOptions=N.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=SJ(N.url,N.params);var B=Date.now();return new Promise(function(w,R){O._loadCompleteResolve=w,O._loadCompleteReject=R,O._startLoad()}).catch(function(w){if(clearTimeout(O._timeoutTimer),O._runing=!1,O._aborted)return;throw w=w instanceof T1?w:new T1(O._url,O._request),w.startTime=B,w.endTime=Date.now(),w.options={index:O._index,vid:O._vid,priOptions:O._priOptions},w})}},{key:"_startLoad",value:function U(){var N=null;if(this._responseType===UY.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var O=this._currentChunkSizeKB*1024,B=this._range[0]+this._receivedLength,w=this._range[1];if(O<this._range[1]-B)w=B+O;N=[B,w],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",N)}else N=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",N);this._internalOpen(N)}},{key:"_internalOpen",value:function U(N){var O=this;try{this._startTime=Date.now();var B=this._xhr=new XMLHttpRequest;B.open(this._method||"GET",this._url,!0),B.responseType=this._responseType,this._timeout&&(B.timeout=this._timeout),B.withCredentials=this._withCredentials,B.onload=this._onLoad.bind(this),B.onreadystatechange=this._onReadyStatechange.bind(this),B.onerror=function(P){var x,k,f;O._running=!1;var l=new T1(O._url,O._request,P===null||P===void 0?void 0:(x=P.currentTarget)===null||x===void 0?void 0:x.response,"xhr.onerror.status:"+(P===null||P===void 0?void 0:(k=P.currentTarget)===null||k===void 0?void 0:k.status)+",statusText,"+(P===null||P===void 0?void 0:(f=P.currentTarget)===null||f===void 0?void 0:f.statusText));l.options={index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions},O._loadCompleteReject(l)},B.ontimeout=function(P){O.cancel();var x=new T1(O._url,O._request,{status:408},"timeout");if(O._onTimeout)x.isTimeout=!0,O._onTimeout(x,{index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions});x.options={index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions},O._loadCompleteReject(x)};var w=this._headers||{},R=DJ(N);if(R)w.Range=R;if(w)Object.keys(w).forEach(function(P){B.setRequestHeader(P,w[P])});this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",N),B.send(this._body)}catch(P){P.options={index:this._index,range:N,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(P)}}},{key:"_onReadyStatechange",value:function U(N){var O=N.target;if(O.readyState===2)this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function U(N){var O,B=N.target.status;if(B<200||B>299){var w=new T1(this._url,null,qY(qY({},N.target.response),{},{status:B}),"bad response,status:"+B);return w.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(w)}var R=null,P=!1,x,k=((O=this._range)===null||O===void 0?void 0:O.length)>0?this._range[0]:0;if(this._responseType===UY.ARRAY_BUFFER){var f,l=new Uint8Array(N.target.response);if(x=k+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var s=Date.now()-this._startTime,Y0=oY(this._receivedLength,s);this.emit(w0.REAL_TIME_SPEED,{speed:Y0,len:this._receivedLength,time:s,vid:this._vid,index:this._index,range:[x,k+this._receivedLength],priOptions:this._priOptions})}if(R=l,((f=this._range)===null||f===void 0?void 0:f.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0])P=!1;else P=!0;this._logger.debug("[xhr load done->], tast :",this._range,", start",x,"end ",k+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",P)}else P=!0,R=N.target.response;var t={ok:B>=200&&B<300,status:B,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};if(this._transformResponse)t=this._transformResponse(t,this._url)||t;if(this._onProgress)this._onProgress(R,P,{index:this._index,vid:this._vid,range:[x,k+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},t);if(!P)this._startLoad();else this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(nY(this._onProgress?null:R,P,t,t.headers["content-length"],t.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))}},{key:"cancel",value:function U(){if(this._aborted)return;if(this._aborted=!0,this._runing=!1,fY(KY(K.prototype),"removeAllListeners",this).call(this),this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});if(this._xhr)return this._xhr.abort()}},{key:"receiveLen",get:function U(){return this._receivedLength}},{key:"running",get:function U(){return this._running},set:function U(N){this._running=N}},{key:"_getHeaders",value:function U(N){var O=N.getAllResponseHeaders().trim().split(`\r
30
+ `),B={},w=J8(O),R;try{for(w.s();!(R=w.n()).done;){var P=R.value,x=P.split(": ");B[x[0].toLowerCase()]=x.slice(1).join(": ")}}catch(k){w.e(k)}finally{w.f()}return B}}],[{key:"isSupported",value:function U(){return typeof XMLHttpRequest!=="undefined"}}]),K}(j8.default);var kG=["retry","retryDelay","onRetryError","transformError"],O8=function(){function j(F,K){f0(this,j),this.promise=HY(),this.alive=!!K.onProgress,!K.logger&&(K.logger=new D1("Loader")),this._loaderType=F,this._loader=F===_1.FETCH&&typeof fetch!=="undefined"?new iY:new A8,this._config=K,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=K.retryCheckFunc,this._logger=K.logger}return c0(j,[{key:"exec",value:function F(){var K=this,U=this._config,N=U.retry,O=U.retryDelay,B=U.onRetryError,w=U.transformError,R=Y8(U,kG),P=function(){var x=C1(r0().mark(function k(){var f,l,s;return r0().wrap(function Y0(t){while(!0)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,K._loader.load(R);case 3:f=t.sent,K.promise.resolve(f),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),K._loader.running=!1,K._logger.debug("[task request catch err]",t.t0),!K._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=K._loaderType,t.t0.retryCount=K._retryCount,l=t.t0,w)l=w(l)||l;if(B&&K._retryCount>0)B(l,K._retryCount,{index:R.index,vid:R.vid,range:R.range,priOptions:R.priOptions});if(K._retryCount++,s=!0,K._retryCheckFunc)s=K._retryCheckFunc(t.t0);if(!(s&&K._retryCount<=N)){t.next=26;break}return clearTimeout(K._retryTimer),K._logger.debug("[task request setTimeout],retry",K._retryCount,",retry range,",R.range),K._retryTimer=setTimeout(P,O),t.abrupt("return");case 26:K.promise.reject(l);case 27:case"end":return t.stop()}},k,null,[[0,7]])}));return function k(){return x.apply(this,arguments)}}();return P(),this.promise}},{key:"cancel",value:function(){var F=C1(r0().mark(function U(){return r0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,O.abrupt("return",this._loader.cancel());case 4:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"running",get:function F(){return this._loader&&this._loader.running}},{key:"loader",get:function F(){return this._loader}}]),j}();function wQ(j){return j&&!j.paused&&!j.ended&&j.playbackRate!==0&&j.readyState!==0}function RQ(j){if(!j)return{};if(typeof j.getVideoPlaybackQuality==="function"){var F=j.getVideoPlaybackQuality();return{droppedVideoFrames:F.droppedVideoFrames||F.corruptedVideoFrames,totalVideoFrames:F.totalVideoFrames,creationTime:F.creationTime}}return{droppedVideoFrames:j.webkitDroppedFrameCount,totalVideoFrames:j.webkitDecodedFrameCount,creationTime:performance.now()}}function $Q(){for(var j=arguments.length,F=new Array(j),K=0;K<j;K++)F[K]=arguments[K];if(F=F.filter(Boolean),F.length<2)return F[0];var U=new Uint8Array(F.reduce(function(O,B){return O+B.byteLength},0)),N=0;return F.forEach(function(O){U.set(O,N),N+=O.byteLength}),U}function IQ(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(F){return setTimeout(F,j)})}var F8=IY(MY(),1),LQ=function(j){u1(K,j);var F=m1(K);function K(U){var N;if(f0(this,K),N=F.call(this,U),i(A0(N),"type",_1.FETCH),i(A0(N),"_queue",[]),i(A0(N),"_alive",[]),i(A0(N),"_currentTask",null),i(A0(N),"_finnalUrl",""),i(A0(N),"_config",void 0),N._config=z8(U),N._config.loaderType===_1.XHR||!iY.isSupported())N.type=_1.XHR;return N.log=U.logger,N}return c0(K,[{key:"isFetch",value:function U(){return this.type===_1.FETCH}},{key:"load",value:function U(N){var O=this,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof N==="string"||!N)B.url=N||B.url||this._config.url;else B=N;if(B=Object.assign({},this._config,B),B.params)B.params=Object.assign({},B.params);if(B.headers&&BQ(B.headers))B.headers=Object.assign({},B.headers);if(B.body&&BQ(B.body))B.body=Object.assign({},B.body);if(B.transformRequest)B=B.transformRequest(B)||B;B.logger=this.log;var w=new O8(this.type,B);if(w.loader.on(w0.REAL_TIME_SPEED,function(R){O.emit(w0.REAL_TIME_SPEED,R)}),this._queue.push(w),this._queue.length===1&&(!this._currentTask||!this._currentTask.running))this._processTask();return w.promise}},{key:"cancel",value:function(){var U=C1(r0().mark(function O(){var B;return r0().wrap(function w(R){while(!0)switch(R.prev=R.next){case 0:if(B=this._queue.map(function(P){return P.cancel()}).concat(this._alive.map(function(P){return P.cancel()})),this._currentTask)B.push(this._currentTask.cancel());return this._queue=[],this._alive=[],R.next=6,Promise.all(B);case 6:return R.next=8,IQ();case 8:case"end":return R.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_processTask",value:function U(){var N=this;if(this._currentTask=this._queue.shift(),!this._currentTask)return;if(this._currentTask.alive)this._alive.push(this._currentTask);var O=this._currentTask.exec().catch(function(B){});if(!(O&&typeof O.finally==="function"))return;O.finally(function(){var B,w;if((B=N._currentTask)!==null&&B!==void 0&&B.alive&&((w=N._alive)===null||w===void 0?void 0:w.length)>0)N._alive=N._alive.filter(function(R){return R&&R!==N._currentTask});N._processTask()})}}],[{key:"isFetchSupport",value:function U(){return iY.isSupported()}}]),K}(F8.default);var bQ=function(){function j(){f0(this,j),i(this,"_prevCurrentTime",0)}return c0(j,[{key:"do",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,N=arguments.length>2?arguments[2]:void 0,O=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!K)return;var B=K.currentTime,w=0;if(this._prevCurrentTime===B){var R=J1.info(J1.get(K),B);if(!R.buffers.length)return;if(N&&R.nextStart||R.nextStart&&R.nextStart-B<U)w=R.nextStart+0.1;else if(R.end&&R.end-B>O&&!K.seeking)w=B+0.1}if(this._prevCurrentTime=B,w&&B!==w)K.currentTime=w}}]),j}();var MQ=function(){function j(F){var K=this;f0(this,j),i(this,"_seiSet",new Set),this.emitter=F,F.on(w0.SEI,function(U){if(U)K._seiSet.add(U)})}return c0(j,[{key:"throw",value:function F(K,U){var N=this;if(K===null||K===void 0||!this._seiSet.size)return;var O=K-0.2,B=K+0.2,w=[];if(this._seiSet.forEach(function(R){if(R.time>=O&&R.time<=B)w.push(R)}),w.forEach(function(R){N._seiSet.delete(R),N.emitter.emit(w0.SEI_IN_TIME,R)}),!U)return;this._seiSet.forEach(function(R){if(R.time<K-5)N._seiSet.delete(R)})}},{key:"reset",value:function F(){this._seiSet.clear()}}]),j}();var gG=1000,uG=50,mG=3,_G=3000,CQ=function(){function j(F){f0(this,j),i(this,"_chunkSpeed",0),i(this,"_chunkCache",[]),i(this,"_speeds",[]),i(this,"_totalSize",0),i(this,"_totalCost",0),this._opts=F||{}}return c0(j,[{key:"addRecord",value:function F(K,U){if(!K||!U)return;this._speeds.push(8000*K/U),this._speeds=this._speeds.slice(-mG)}},{key:"addChunkRecord",value:function F(K,U){var N,O;if(!K||!U||K<(((N=this._opts)===null||N===void 0?void 0:N.skipChunkSize)||gG))return;this._totalSize+=K,this._totalCost+=U,this._chunkSpeed=8000*K/U,this._chunkCache.push({size:K,duration:U,timestamp:performance.now()});var B=((O=this._opts)===null||O===void 0?void 0:O.chunkCountForSpeed)||uG;if(this._chunkCache.length>B)this._chunkCache=this._chunkCache.slice(-B)}},{key:"getAvgSpeed",value:function F(){var K;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(w,R){return w+=R})/this._speeds.length;var U=this._chunkCache[this._chunkCache.length-1],N=performance.now()-U.timestamp;if(N>(((K=this._opts)===null||K===void 0?void 0:K.longtimeNoReceived)||_G))this._chunkCache.push({size:0,duration:N,timestamp:performance.now()});var O=this._chunkCache.reduce(function(w,R){return w+=R.size},0),B=this._chunkCache.reduce(function(w,R){return w+=R.duration},0);return 8000*O/B}},{key:"getLatestSpeed",value:function F(){if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds[this._speeds.length-1];return this._chunkSpeed}},{key:"getTotalSize",value:function F(){return this._totalSize}},{key:"getTotalCost",value:function F(){return this._totalCost}},{key:"reset",value:function F(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),j}();var EK=IY(MY(),1);var E8=function(){function j(F){f0(this,j),i(this,"encodeType",""),i(this,"audioCodec",""),i(this,"videoCodec",""),i(this,"domain",""),i(this,"fps",0),i(this,"bitrate",0),i(this,"width",0),i(this,"height",0),i(this,"samplerate",0),i(this,"channelCount",0),i(this,"gop",0),i(this,"_bitsAccumulateSize",0),i(this,"_bitsAccumulateDuration",0),i(this,"_startGopId",-1),this._timescale=F}return c0(j,[{key:"getStats",value:function F(){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 F(K){this.encodeType=K}},{key:"setFpsFromScriptData",value:function F(K){var U,N=K.data,O=N===null||N===void 0?void 0:(U=N.onMetaData)===null||U===void 0?void 0:U.framerate;if(O&&O>0&&O<100)this.fps=O}},{key:"setVideoMeta",value:function F(K){if(this.width=K.width,this.height=K.height,this.videoCodec=K.codec,this.encodeType=K.codecType,K.fpsNum&&K.fpsDen){var U=K.fpsNum/K.fpsDen;if(U>0&&U<100)this.fps=U}}},{key:"setAudioMeta",value:function F(K){this.audioCodec=K.codec,this.samplerate=K.sampleRate,this.channelCount=K.channelCount}},{key:"setDomain",value:function F(K){this.domain=K.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function F(K){var U=this;if(!this.fps||this.fps>=100){if(K.length){var N=K.reduce(function(O,B){return O+=B.duration},0)/K.length;this.fps=Math.round(this._timescale/N)}}K.forEach(function(O){if(U._startGopId===-1)U._startGopId=O.gopId;if(O.gopId===U._startGopId)U.gop++;if(U._bitsAccumulateDuration+=O.duration/(U._timescale/1000),U._bitsAccumulateSize+=O.units.reduce(function(B,w){return B+=w.length},0),U._bitsAccumulateDuration>=1000)U.bitrate=U._bitsAccumulateSize*8,U._bitsAccumulateDuration=0,U._bitsAccumulateSize=0})}}]),j}(),DQ=function(){function j(F){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1000;f0(this,j),i(this,"_core",null),i(this,"_samples",[]),this._core=F,this._timescale=K,this._stats=new E8(K),this._bindEvents()}return c0(j,[{key:"getStats",value:function F(){var K,U,N,O,B,w,R,P,x,k,f,l=((K=this._core)===null||K===void 0?void 0:K.media)||{},s=l.currentTime,Y0=s===void 0?0:s,t=l.decodeFps,K0=t===void 0?0:t;return qY(qY({},this._stats.getStats()),{},{downloadSpeed:((U=this._core)===null||U===void 0?void 0:(N=U.speedInfo)===null||N===void 0?void 0:N.call(U).speed)||0,avgSpeed:((O=this._core)===null||O===void 0?void 0:(B=O.speedInfo)===null||B===void 0?void 0:B.call(O).avgSpeed)||0,totalReceivedByte:((w=this._core)===null||w===void 0?void 0:(R=w.speedInfo)===null||R===void 0?void 0:R.call(w).totalSize)||0,totalReceivedCost:((P=this._core)===null||P===void 0?void 0:(x=P.speedInfo)===null||x===void 0?void 0:x.call(P).totalCost)||0,currentTime:Y0,bufferEnd:((k=this._core)===null||k===void 0?void 0:(f=k.bufferInfo())===null||f===void 0?void 0:f.remaining)||0,decodeFps:K0})}},{key:"_bindEvents",value:function F(){var K=this;this._core.on(w0.DEMUXED_TRACK,function(U){var N=U.videoTrack;return K._stats.updateBitrate(N.samples)}),this._core.on(w0.FLV_SCRIPT_DATA,function(U){K._stats.setFpsFromScriptData(U)}),this._core.on(w0.METADATA_PARSED,function(U){if(U.type==="video")K._stats.setVideoMeta(U.track);else K._stats.setAudioMeta(U.track)}),this._core.on(w0.TTFB,function(U){K._stats.setDomain(U.responseUrl)})}},{key:"reset",value:function F(){this._samples=[],this._stats=new E8(this._timescale)}}]),j}();var d8=IY(MY(),1);function pG(j,F){var K=j==null?null:typeof Symbol!="undefined"&&j[Symbol.iterator]||j["@@iterator"];if(K!=null){var U,N,O,B,w=[],R=!0,P=!1;try{if(O=(K=K.call(j)).next,F===0){if(Object(K)!==K)return;R=!1}else for(;!(R=(U=O.call(K)).done)&&(w.push(U.value),w.length!==F);R=!0);}catch(x){P=!0,N=x}finally{try{if(!R&&K.return!=null&&(B=K.return(),Object(B)!==B))return}finally{if(P)throw N}}return w}}function I0(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function B8(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,$8(U.key),U)}}function L0(j,F,K){if(F)B8(j.prototype,F);if(K)B8(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function a(j,F,K){if(F=$8(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function yQ(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)SQ(j,F)}function PJ(j){return PJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},PJ(j)}function SQ(j,F){return SQ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},SQ(j,F)}function fG(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function cG(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function lG(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return cG(j)}function TQ(j){var F=fG();return function K(){var U=PJ(j),N;if(F){var O=PJ(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return lG(this,N)}}function w8(j,F){return nG(j)||pG(j,F)||R8(j,F)||sG()}function p1(j){return dG(j)||oG(j)||R8(j)||iG()}function dG(j){if(Array.isArray(j))return PQ(j)}function nG(j){if(Array.isArray(j))return j}function oG(j){if(typeof Symbol!=="undefined"&&j[Symbol.iterator]!=null||j["@@iterator"]!=null)return Array.from(j)}function R8(j,F){if(!j)return;if(typeof j==="string")return PQ(j,F);var K=Object.prototype.toString.call(j).slice(8,-1);if(K==="Object"&&j.constructor)K=j.constructor.name;if(K==="Map"||K==="Set")return Array.from(j);if(K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K))return PQ(j,F)}function PQ(j,F){if(F==null||F>j.length)F=j.length;for(var K=0,U=new Array(F);K<F;K++)U[K]=j[K];return U}function iG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
31
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
32
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rG(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function $8(j){var F=rG(j,"string");return typeof F==="symbol"?F:String(F)}var f1={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},YY={AV1:"av1",AVC:"avc",HEVC:"hevc"},o0={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus",MP3:"mp3"},E1={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var I8=function(){function j(){I0(this,j),a(this,"id",1),a(this,"type",f1.VIDEO),a(this,"codecType",YY.AVC),a(this,"pid",-1),a(this,"hvcC",void 0),a(this,"codec",""),a(this,"timescale",0),a(this,"formatTimescale",0),a(this,"sequenceNumber",0),a(this,"baseMediaDecodeTime",0),a(this,"baseDts",0),a(this,"duration",0),a(this,"warnings",[]),a(this,"samples",[]),a(this,"pps",[]),a(this,"sps",[]),a(this,"vps",[]),a(this,"fpsNum",0),a(this,"fpsDen",0),a(this,"sarRatio",[]),a(this,"width",0),a(this,"height",0),a(this,"nalUnitSize",4),a(this,"present",!1),a(this,"isVideoEncryption",!1),a(this,"isAudioEncryption",!1),a(this,"isVideo",!0),a(this,"lastKeyFrameDts",0),a(this,"kid",null),a(this,"pssh",null),a(this,"ext",void 0)}return L0(j,[{key:"reset",value:function F(){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 F(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function F(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function F(){if(this.samples.length>0){var K=this.samples[0],U=this.samples[this.samples.length-1];return U.dts-K.dts+U.duration}return 0}},{key:"exist",value:function F(){if(/av01/.test(this.codec))return!0;return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function F(){return!!this.samples.length}},{key:"isEncryption",get:function F(){return this.isVideoEncryption}}]),j}();var L8=function(){function j(){I0(this,j),a(this,"id",2),a(this,"type",f1.AUDIO),a(this,"codecType",o0.AAC),a(this,"pid",-1),a(this,"codec",""),a(this,"container",""),a(this,"sequenceNumber",0),a(this,"sampleDuration",0),a(this,"timescale",0),a(this,"formatTimescale",0),a(this,"baseMediaDecodeTime",0),a(this,"duration",0),a(this,"warnings",[]),a(this,"samples",[]),a(this,"baseDts",0),a(this,"sampleSize",16),a(this,"sampleRate",0),a(this,"channelCount",0),a(this,"objectType",0),a(this,"sampleRateIndex",0),a(this,"config",[]),a(this,"present",!1),a(this,"isVideoEncryption",!1),a(this,"isAudioEncryption",!1),a(this,"kid",null),a(this,"ext",void 0)}return L0(j,[{key:"reset",value:function F(){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 F(){return!!(this.sampleRate&&this.channelCount&&(this.codec||this.container)&&(this.codecType===o0.AAC||this.codecType===o0.G711PCMA||this.codecType===o0.G711PCMU||this.codecType===o0.OPUS||this.codecType===o0.MP3))}},{key:"hasSample",value:function F(){return!!this.samples.length}},{key:"isEncryption",get:function F(){return this.isAudioEncryption}},{key:"firstDts",get:function F(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function F(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function F(){if(this.samples.length>0){var K=this.samples[0],U=this.samples[this.samples.length-1];return U.dts-K.dts+U.duration}return 0}}]),j}();var b8=function(){function j(F,K,U){if(I0(this,j),a(this,"flag",{}),a(this,"keyframe",!1),a(this,"gopId",0),a(this,"duration",0),a(this,"size",0),a(this,"units",[]),a(this,"chromaFormat",420),this.originPts=this.pts=F,this.originDts=this.dts=K,U)this.units=U}return L0(j,[{key:"cts",get:function F(){return this.pts-this.dts}},{key:"setToKeyframe",value:function F(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),j}();var CY=L0(function j(F,K,U,N){if(I0(this,j),a(this,"duration",1024),a(this,"flag",{dependsOn:2,isNonSyncSample:0}),a(this,"keyframe",!0),this.originPts=this.pts=this.dts=F,this.data=K,this.size=K.byteLength,this.sampleOffset=N,U)this.duration=U});var M8=L0(function j(F,K){I0(this,j),a(this,"time",0),this.data=F,this.originPts=this.pts=K}),C8=function(j){yQ(K,j);var F=TQ(K);function K(){return I0(this,K),F.apply(this,arguments)}return L0(K)}(M8),D8=function(j){yQ(K,j);var F=TQ(K);function K(){return I0(this,K),F.apply(this,arguments)}return L0(K)}(M8),S8=function(){function j(){I0(this,j),a(this,"id",3),a(this,"type",f1.METADATA),a(this,"timescale",0),a(this,"flvScriptSamples",[]),a(this,"seiSamples",[])}return L0(j,[{key:"exist",value:function F(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function F(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function F(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),j}();var AY=function(){function j(F){I0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]")}return L0(j,[{key:"warn",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).warn.apply(K,[this._prefix].concat(N))}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();a(AY,"disabled",!0);var yJ=typeof window!=="undefined",xQ=yJ&&navigator.userAgent.toLocaleLowerCase(),P8=yJ&&/^((?!chrome|android).)*safari/.test(xQ),y8=yJ&&xQ.includes("firefox"),T8=yJ&&xQ.includes("android");var DY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"getRateIndexByRate",value:function F(K){return j.FREQ.indexOf(K)}},{key:"parseADTS",value:function F(K,U){var N=K.length,O=0;while(O+2<N){if(K[O]===255&&(K[O+1]&246)===240)break;O++}if(O>=N)return;var B=O,w=[],R=(K[O+2]&60)>>>2,P=j.FREQ[R];if(!P)throw new Error("Invalid sampling index: ".concat(R));var x=((K[O+2]&192)>>>6)+1,k=(K[O+2]&1)<<2|(K[O+3]&192)>>>6,f=j._getConfig(R,k,x),l=f.config,s=f.codec,Y0,t,K0=0,q0=j.getFrameDuration(P);while(O+7<N){if(K[O]!==255||(K[O+1]&246)!==240){O++;continue}if(t=(K[O+3]&3)<<11|K[O+4]<<3|(K[O+5]&224)>>5,!t||N-O<t)break;Y0=(~K[O+1]&1)*2,w.push({pts:U+K0*q0,data:K.subarray(O+7+Y0,O+t)}),K0++,O+=t}return{skip:B,remaining:O>=N?void 0:K.subarray(O),frames:w,samplingFrequencyIndex:R,sampleRate:P,objectType:x,channelCount:k,codec:s,config:l,originCodec:"mp4a.40.".concat(x)}}},{key:"parseAudioSpecificConfig",value:function F(K){if(!K.length)return;var U=K[0]>>>3,N=(K[0]&7)<<1|K[1]>>>7,O=(K[1]&120)>>>3,B=j.FREQ[N];if(!B)return;var w=j._getConfig(N,O,U),R=w.config,P=w.codec;return{samplingFrequencyIndex:N,sampleRate:B,objectType:U,channelCount:O,config:R,codec:P,originCodec:"mp4a.40.".concat(U)}}},{key:"getFrameDuration",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000;return 1024*U/K}},{key:"_getConfig",value:function F(K,U,N){var O=[],B,w;if(y8)if(K>=6)B=5,w=K-3;else B=2,w=K;else if(T8)B=2,w=K;else if(B=5,w=K,K>=6)w=K-3;else if(U===1)B=2,w=K;if(O[0]=B<<3,O[0]|=(K&14)>>1,O[1]=(K&1)<<7,O[1]|=U<<3,B===5)O[1]|=(w&14)>>1,O[2]=(w&1)<<7,O[2]|=8,O[3]=0;return{config:O,codec:"mp4a.40.".concat(B)}}},{key:"getSilentFrame",value:function F(K,U){switch(K){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===5)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(U===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(U===1)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(U===2)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(U===3)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]);break}}}]),j}();a(DY,"FREQ",[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350]);var sY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"getFrameDuration",value:function F(K){return 20}},{key:"parseHeaderPackets",value:function F(K){if(!K.length)return;var U=new DataView(K.buffer,K.byteOffset,K.byteLength),N="";for(var O=0;O<8;O++)N+=String.fromCodePoint(K[O]);if(N!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var B=K[9];console.log("Pre-skip",K[10],K[11]);var w=U.getUint32(12,!0),R=U.getInt16(16,!0);if(!w)return;var P="opus",x="opus",k=new Uint8Array(K.buffer,K.byteOffset+8,K.byteLength-8);return{outputGain:R,sampleRate:w,channelCount:B,config:k,codec:P,originCodec:x}}}]),j}();var aG=500,x8=3,vQ=1000,hQ=5000,tG=1000,eG=200,v8=5000,h8=5,k8=function(){function j(F,K,U){I0(this,j),this.videoTrack=F,this.audioTrack=K,this.metadataTrack=U,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 L0(j,[{key:"fix",value:function F(){var K=this,U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;U=Math.round(U*1000);var B=this.videoTrack,w=this.audioTrack;if(N||!O)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;if(N&&!O)this._baseDtsInited=!1;if(!this._baseDtsInited)this._calculateBaseDts(w,B);if(!O&&U)this._audioNextPts=this._videoNextDts=U;var R=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(R)this._resetBaseDtsWhenStreamBreaked();if(this._fixAudio(w),this._keyFrameInNextChunk=!1,this._fixVideo(B),this.metadataTrack.exist()){var P=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(x){x.pts=x.originPts-K._baseDts,x.time=Math.max(0,x.pts)/P}),this.metadataTrack.flvScriptSamples.forEach(function(x){x.pts=x.originPts-K._baseDts,x.time=Math.max(0,x.pts)/P})}if(B.samples.length)B.baseMediaDecodeTime=B.samples[0].dts;if(w.samples.length)w.baseMediaDecodeTime=w.samples[0].pts*w.timescale/1000}},{key:"_fixVideo",value:function F(K){var U=this,N=K.samples;if(!N.length)return;N.forEach(function(q0){if(q0.dts-=U._baseDts,q0.pts-=U._baseDts,q0.keyframe)U._keyFrameInNextChunk=!0});var O;if(K.fpsNum&&K.fpsDen)O=K.timescale*(K.fpsDen/K.fpsNum);else if(K.length>1){var B=K.samples[0],w=K.samples[N.length-1];O=Math.floor((w.dts-B.dts)/(N.length-1))}else O=this._lastVideoDuration||40;var R=N.pop();if(this._videoLastSample)N.unshift(this._videoLastSample);if(this._videoLastSample=R,!N.length)return;if(this._videoNextDts===void 0){var P=N[0];this._videoNextDts=P.dts}var x=N.length,k=0,f=N[0],l=this._videoNextDts-f.dts;if(Math.abs(l)>eG){if(Math.abs(f.dts-this._lastVideoExceptionChunkFirstDtsDot)>v8){var s;this._lastVideoExceptionChunkFirstDtsDot=f.dts,K.warnings.push({type:E1.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:f.dts,nextSampleDts:(s=N[1])===null||s===void 0?void 0:s.dts,sampleDuration:l})}if(this._videoTimestampBreak>=h8)this._videoNextDts=f.dts,this._videoTimestampBreak=0;else if(f.dts+=l,f.pts+=l,!this.audioTrack.exist())this._videoTimestampBreak=1}for(var Y0=0;Y0<x;Y0++){var t=N[Y0].dts,K0=N[Y0+1];if(Y0<x-1)k=K0.dts-t;else if(R)k=R.dts-t;else k=O;if(k>tG||k<0){if(this._videoTimestampBreak++,Math.abs(t-this._lastVideoExceptionLargeGapDot)>v8)this._lastVideoExceptionLargeGapDot=t,K.warnings.push({type:E1.LARGE_VIDEO_GAP,time:t/K.timescale,dts:t,originDts:N[Y0].originDts,nextDts:this._videoNextDts,sampleDuration:k,refSampleDuration:O});k=O}N[Y0].duration=k,this._videoNextDts+=k,this._lastVideoDuration=k}}},{key:"_fixAudio",value:function F(K){var U=this,N=K.samples;if(!N.length)return;N.forEach(function(O){O.dts=O.pts-=U._baseDts}),this._doFixAudioInternal(K,N,1000)}},{key:"_calculateBaseDts",value:function F(K,U){var N=K.samples,O=U.samples;if(!N.length&&!O.length)return!1;var B=1/0,w=1/0;if(N.length)K.baseDts=B=N[0].pts;if(O.length)U.baseDts=w=O[0].dts;this._baseDts=Math.min(B,w);var R=w-B;if(Number.isFinite(R)&&Math.abs(R)>aG)U.warnings.push({type:E1.LARGE_AV_SHIFT,videoBaseDts:w,audioBasePts:B,baseDts:this._baseDts,delta:R});return this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function F(){var K=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!K)return;if(!this.audioTrack.exist())this._baseDts-=this._videoNextDts;else if(!this.videoTrack.exist())this._baseDts-=this._audioNextPts;else this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts);this._videoTimestampBreak=0,this._audioTimestampBreak=0}},{key:"_doFixAudioInternal",value:function F(K,U,N){if(!K.sampleDuration)switch(K.codecType){case o0.AAC:{K.sampleDuration=DY.getFrameDuration(K.timescale,N);break}case o0.OPUS:{K.sampleDuration=sY.getFrameDuration(K.samples,N);break}case o0.G711PCMA:case o0.G711PCMU:{K.sampleDuration=this._getG711Duration(K);break}default:console.error("can't fix audio codecType:",K.codecType);break}var O=K.sampleDuration,B=K.codecType===o0.OPUS?20:K.codecType===o0.AAC?1024:O*K.timescale/1000;if(this._audioNextPts===void 0){var w=U[0];this._audioNextPts=w.pts}for(var R=0;R<U.length;R++){var P=this._audioNextPts,x=U[R],k=x.pts-P;if(R===0&&this._audioTimestampBreak>=h8&&this._keyFrameInNextChunk)P=this._audioNextPts=x.dts,k=0,this._audioTimestampBreak=0;if(!this._audioTimestampBreak&&k>=x8*O&&k<=vQ&&!P8){var f=this._getSilentFrame(K)||U[0].data.subarray(),l=Math.floor(k/O);if(Math.abs(x.pts-this._lastAudioExceptionGapDot)>hQ)this._lastAudioExceptionGapDot=x.pts,K.warnings.push({type:E1.AUDIO_FILLED,pts:x.pts,originPts:x.originPts,count:l,nextPts:P,refSampleDuration:O});for(var s=0;s<l;s++){var Y0=new CY(Math.floor(this._audioNextPts+O)-Math.floor(this._audioNextPts),f,B);Y0.originPts=Math.floor(this._baseDts+P),U.splice(R,0,Y0),this._audioNextPts+=O,R++}R--}else if(k<=-x8*O&&k>=-1*vQ){if(Math.abs(x.pts-this._lastAudioExceptionOverlapDot)>hQ)this._lastAudioExceptionOverlapDot=x.pts,K.warnings.push({type:E1.AUDIO_DROPPED,pts:x.pts,originPts:x.originPts,nextPts:P,refSampleDuration:O});U.splice(R,1),R--}else{if(Math.abs(k)>vQ){if(this._audioTimestampBreak++,Math.abs(x.pts-this._lastAudioExceptionLargeGapDot)>hQ)this._lastAudioExceptionLargeGapDot=x.pts,K.warnings.push({type:E1.LARGE_AUDIO_GAP,time:x.pts/1000,pts:x.pts,originPts:x.originPts,nextPts:P,sampleDuration:k,refSampleDuration:O})}if(K.codecType===o0.OPUS){var t=U[U.length-1];if(t)t.duration=x.pts-t.pts}else x.dts=x.pts=P,x.duration=B;this._audioNextPts+=O}}}},{key:"_getG711Duration",value:function F(K){var{sampleSize:U,channelCount:N,sampleRate:O}=K,B=K.samples[0];if(!B)return;return B.data.byteLength*2/N/(U/8)/O*1000}},{key:"_getSilentFrame",value:function F(K){if(K.codecType===o0.AAC)return DY.getSilentFrame(K.codec,K.channelCount);return new Uint8Array(8*K.sampleDuration*K.channelCount)}}]),j}();function S1(){for(var j=arguments.length,F=new Array(j),K=0;K<j;K++)F[K]=arguments[K];F=F.filter(Boolean);var U=new Uint8Array(F.reduce(function(O,B){return O+B.byteLength},0)),N=0;return F.forEach(function(O){U.set(O,N),N+=O.byteLength}),U}var Nq=Math.pow(2,32);function SY(j){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(j[F]<<24>>>0)+(j[F+1]<<16)+(j[F+2]<<8)+(j[F+3]||0)}function g8(j){var F="avc1.",K;for(var U=0;U<3;U++){if(K=j[U].toString(16),K.length<2)K="0".concat(K);F+=K}return F}function kQ(j){if(!Array.isArray(j)){var F=[],K="";for(var U=0;U<j.length;U++)if(U%2)K=j[U-1]+j[U],F.push(parseInt(K,16)),K="";return F}return j.map(function(N){return parseInt(N,16)})}var JY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseAnnexB",value:function F(K){var U=K.byteLength-1,N=0;do{if(K[U]===0)N++;else break;U--}while(U>0);if(N>=3)K=K.subarray(0,U+1);var O=K.length,B=2,w=0;while(K[B]!==null&&K[B]!==void 0&&K[B]!==1)B++;if(B++,w=B+2,w>=O)return[];var R=[];while(w<O)switch(K[w]){case 0:if(K[w-1]!==0){w+=2;break}else if(K[w-2]!==0){w++;break}else if(w<O-1&&K[w+1]!==1){w++;break}if(B!==w-2)R.push(K.subarray(B,w-2));do w++;while(K[w]!==1&&w<O);B=w+1,w=B+2;break;case 1:if(K[w-1]!==0||K[w-2]!==0){w+=3;break}if(B!==w-2)R.push(K.subarray(B,w-2));B=w+1,w=B+2;break;default:w+=3;break}if(B<O)R.push(K.subarray(B));return R}},{key:"parseAvcC",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(K.length<4)return;var N=K.length,O=[],B=0,w;while(B+U<N){if(w=SY(K,B),U===3)w>>>=8;if(B+=U,!w)continue;if(B+w>N)break;O.push(K.subarray(B,B+w)),B+=w}return O}},{key:"parseSEI",value:function F(K,U){var N=K.length,O=U?2:1,B=0,w=0,R="";while(K[O]===255)B+=255,O++;B+=K[O++];while(K[O]===255)w+=255,O++;if(w+=K[O++],B===5&&N>O+16)for(var P=0;P<16;P++)R+=K[O].toString(16),O++;return{payload:K.subarray(O,O+w),type:B,size:w,uuid:R}}},{key:"removeEPB",value:function F(K){var U=K.byteLength,N=[],O=1;while(O<U-2)if(K[O]===0&&K[O+1]===0&&K[O+2]===3)N.push(O+2),O+=2;else O++;if(!N.length)return K;var B=U-N.length,w=new Uint8Array(B),R=0;for(O=0;O<B;R++,O++){if(R===N[0])R++,N.shift();w[O]=K[R]}return w}}]),j}();var rY=function(){function j(F){if(I0(this,j),a(this,"_bytesAvailable",void 0),a(this,"_bitsAvailable",0),a(this,"_word",0),!F)throw new Error("ExpGolomb data params is required");if(this._data=F,this._bytesAvailable=F.byteLength,this._bytesAvailable)this._loadWord()}return L0(j,[{key:"bitsAvailable",get:function F(){return this._bitsAvailable}},{key:"_loadWord",value:function F(){var K=this._data.byteLength-this._bytesAvailable,U=Math.min(4,this._bytesAvailable);if(U===0)throw new Error("No bytes available");var N=new Uint8Array(4);N.set(this._data.subarray(K,K+U)),this._word=new DataView(N.buffer).getUint32(0),this._bitsAvailable=U*8,this._bytesAvailable-=U}},{key:"skipBits",value:function F(K){if(this._bitsAvailable>K)this._word<<=K,this._bitsAvailable-=K;else{K-=this._bitsAvailable;var U=Math.floor(K/8);K-=U*8,this._bytesAvailable-=U,this._loadWord(),this._word<<=K,this._bitsAvailable-=K}}},{key:"readBits",value:function F(K){if(K>32)throw new Error("Cannot read more than 32 bits");var U=Math.min(this._bitsAvailable,K),N=this._word>>>32-U;if(this._bitsAvailable-=U,this._bitsAvailable>0)this._word<<=U;else if(this._bytesAvailable>0)this._loadWord();if(U=K-U,U>0&&this._bitsAvailable)return N<<U|this.readBits(U);return N}},{key:"skipLZ",value:function F(){var K;for(K=0;K<this._bitsAvailable;++K)if((this._word&2147483648>>>K)!==0)return this._word<<=K,this._bitsAvailable-=K,K;return this._loadWord(),K+this.skipLZ()}},{key:"skipUEG",value:function F(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function F(){var K=this.skipLZ();return this.readBits(K+1)-1}},{key:"readEG",value:function F(){var K=this.readUEG();if(1&K)return 1+K>>>1;return-1*(K>>>1)}},{key:"readBool",value:function F(){return this.readBits(1)===1}},{key:"readUByte",value:function F(){return this.readBits(8)}},{key:"skipScalingList",value:function F(K){var U=8,N=8,O;for(var B=0;B<K;B++){if(N!==0)O=this.readEG(),N=(U+O+256)%256;U=N===0?U:N}}}]),j}();var u8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseAVCDecoderConfigurationRecord",value:function F(K){if(K.length<7)return;var U=(K[4]&3)+1,N,O=[],B=[],w=6,R=K[5]&31,P;for(var x=0;x<R;x++){if(P=K[w]<<8|K[w+1],w+=2,!P)continue;var k=K.subarray(w,w+P);if(w+=P,O.push(k),!N)N=j.parseSPS(JY.removeEPB(k))}var f=K[w];w++;var l;for(var s=0;s<f;s++){if(l=K[w]<<8|K[w+1],w+=2,!l)continue;B.push(K.subarray(w,w+l)),w+=l}return{sps:N,spsArr:O,ppsArr:B,nalUnitSize:U}}},{key:"parseSPS",value:function F(K){var U=new rY(K);U.readUByte();var N=U.readUByte(),O=U.readUByte(),B=U.readUByte();U.skipUEG();var w=420;if(N===100||N===110||N===122||N===244||N===44||N===83||N===86||N===118||N===128||N===138||N===144){var R=U.readUEG();if(R<=3)w=[0,420,422,444][R];if(R===3)U.skipBits(1);if(U.skipUEG(),U.skipUEG(),U.skipBits(1),U.readBool()){var P=R!==3?8:12;for(var x=0;x<P;x++)if(U.readBool())if(x<6)U.skipScalingList(16);else U.skipScalingList(64)}}U.skipUEG();var k=U.readUEG();if(k===0)U.readUEG();else if(k===1){U.skipBits(1),U.skipUEG(),U.skipUEG();var f=U.readUEG();for(var l=0;l<f;l++)U.skipUEG()}U.skipUEG(),U.skipBits(1);var s=U.readUEG(),Y0=U.readUEG(),t=U.readBits(1);if(t===0)U.skipBits(1);U.skipBits(1);var K0=0,q0=0,R0=0,U0=0;if(U.readBool())K0=U.readUEG(),q0=U.readUEG(),R0=U.readUEG(),U0=U.readUEG();var W0,z0,h0,l0,E0;if(U.readBool()){if(U.readBool()){var y0=U.readUByte();switch(y0){case 1:W0=[1,1];break;case 2:W0=[12,11];break;case 3:W0=[10,11];break;case 4:W0=[16,11];break;case 5:W0=[40,33];break;case 6:W0=[24,11];break;case 7:W0=[20,11];break;case 8:W0=[32,11];break;case 9:W0=[80,33];break;case 10:W0=[18,11];break;case 11:W0=[15,11];break;case 12:W0=[64,33];break;case 13:W0=[160,99];break;case 14:W0=[4,3];break;case 15:W0=[3,2];break;case 16:W0=[2,1];break;case 255:{W0=[U.readUByte()<<8|U.readUByte(),U.readUByte()<<8|U.readUByte()];break}}}if(U.readBool())U.readBool();if(U.readBool()){if(U.readBits(4),U.readBool())U.readBits(24)}if(U.readBool())U.readUEG(),U.readUEG();if(U.readBool()){var t0=U.readBits(32),T=U.readBits(32);z0=U.readBool(),h0=T,l0=t0*2,E0=h0/l0}}return{codec:g8(K.subarray(1,4)),profileIdc:N,profileCompatibility:O,levelIdc:B,chromaFormat:w,width:Math.ceil((s+1)*16-2*(K0+q0)),height:(2-t)*(Y0+1)*16-(t?2:4)*(R0+U0),sarRatio:W0,fpsNum:h0,fpsDen:l0,fps:E0,fixedFrame:z0}}}]),j}();var m8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(K.length<23)return;U=U||{};var N=(K[21]&3)+1,O,B,w=[],R=[],P=[],x=23,k=K[22],f,l,s;for(var Y0=0;Y0<k;Y0++){f=K[x]&63,l=K[x+1]<<8|K[x+2],x+=3;for(var t=0;t<l;t++){if(s=K[x]<<8|K[x+1],x+=2,!s)continue;switch(f){case 32:{var K0=K.subarray(x,x+s);if(!O)O=j.parseVPS(JY.removeEPB(K0),U);P.push(K0)}break;case 33:{var q0=K.subarray(x,x+s);if(!B)B=j.parseSPS(JY.removeEPB(q0),U);w.push(q0)}break;case 34:R.push(K.subarray(x,x+s));break}x+=s}}return{hvcC:U,sps:B,spsArr:w,ppsArr:R,vpsArr:P,nalUnitSize:N}}},{key:"parseVPS",value:function F(K,U){U=U||{};var N=new rY(K);N.readUByte(),N.readUByte(),N.readBits(12);var O=N.readBits(3);return U.numTemporalLayers=Math.max(U.numTemporalLayers||0,O+1),N.readBits(17),j._parseProfileTierLevel(N,O,U),U}},{key:"parseSPS",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};U=U||{};var N=new rY(K);N.readUByte(),N.readUByte(),N.readBits(4);var O=N.readBits(3);U.numTemporalLayers=Math.max(O+1,U.numTemporalLayers||0),U.temporalIdNested=N.readBits(1),j._parseProfileTierLevel(N,O,U),N.readUEG();var B=U.chromaFormatIdc=N.readUEG(),w=420;if(B<=3)w=[0,420,422,444][B];var R=0;if(B===3)R=N.readBits(1);var P=N.readUEG(),x=N.readUEG(),k=N.readBits(1),f,l,s,Y0;if(k===1)f=N.readUEG(),l=N.readUEG(),s=N.readUEG(),Y0=N.readUEG();if(U.bitDepthLumaMinus8=N.readUEG(),U.bitDepthChromaMinus8=N.readUEG(),k===1){var t=(B===1||B===2)&&R===0?2:1,K0=B===1&&R===0?2:1;P-=t*(l+f),x-=K0*(Y0+s)}return{codec:"hev1.1.6.L93.B0",width:P,height:x,chromaFormat:w,hvcC:U}}},{key:"_parseProfileTierLevel",value:function F(K,U,N){var O=N.generalTierFlag||0;N.generalProfileSpace=K.readBits(2),N.generalTierFlag=Math.max(K.readBits(1),O),N.generalProfileIdc=Math.max(K.readBits(5),N.generalProfileIdc||0),N.generalProfileCompatibilityFlags=K.readBits(32),N.generalConstraintIndicatorFlags=[K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8)];var B=K.readBits(8);if(O<N.generalTierFlag)N.generalLevelIdc=B;else N.generalLevelIdc=Math.max(B,N.generalLevelIdc||0);var w=[],R=[];if(U>K.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(U));for(var P=0;P<U;P++)w[P]=K.readBits(1),R[P]=K.readBits(1);if(U>0)K.readBits((8-U)*2);for(var x=0;x<U;x++){if(w[x]!==0)K.readBits(2),K.readBits(1),K.readBits(5),K.readBits(16),K.readBits(16),K.readBits(4),K.readBits(16),K.readBits(16),K.readBits(12);if(R[x]!==0)K.readBits(8)}}}]),j}();var gQ=function(){function j(){I0(this,j)}return L0(j,null,[{key:"decode",value:function F(K){var U=[],N=K,O=0,B=K.length;while(O<B){if(N[O]<128){U.push(String.fromCharCode(N[O])),++O;continue}else if(N[O]<192);else if(N[O]<224){if(j._checkContinuation(N,O,1)){var w=(N[O]&31)<<6|N[O+1]&63;if(w>=128){U.push(String.fromCharCode(w&65535)),O+=2;continue}}}else if(N[O]<240){if(j._checkContinuation(N,O,2)){var R=(N[O]&15)<<12|(N[O+1]&63)<<6|N[O+2]&63;if(R>=2048&&(R&63488)!==55296){U.push(String.fromCharCode(R&65535)),O+=3;continue}}}else if(N[O]<248){if(j._checkContinuation(N,O,3)){var P=(N[O]&7)<<18|(N[O+1]&63)<<12|(N[O+2]&63)<<6|N[O+3]&63;if(P>65536&&P<1114112){P-=65536,U.push(String.fromCharCode(P>>>10|55296)),U.push(String.fromCharCode(P&1023|56320)),O+=4;continue}}}U.push(String.fromCharCode(65533)),++O}return U.join("")}},{key:"_checkContinuation",value:function F(K,U,N){var O=K;if(U+N<O.length){while(N--)if((O[++U]&192)!==128)return!1;return!0}else return!1}}]),j}();var _8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parse",value:function F(K){if(K.length<3)return;var U={},N=j._parseValue(new DataView(K.buffer,K.byteOffset,K.byteLength)),O=j._parseValue(new DataView(K.buffer,K.byteOffset+N.size,K.byteLength-N.size));return U[N.data]=O.data,U}},{key:"_parseValue",value:function F(K){var U=K.byteLength,N=K.getUint8(0),O=1,B=!1,w;switch(N){case 0:w=K.getFloat64(1),O+=8;break;case 1:{w=!!K.getUint8(1),O+=1;break}case 2:{var R=j._parseString(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O)),P=R.data,x=R.size;w=P,O+=x}break;case 3:{w={};var k=0;if((K.getUint32(U-4)&16777215)===9)k=3;while(O<U-4){var f=j._parseObject(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O-k)),l=f.size,s=f.data,Y0=f.isEnd;if(Y0)break;w[s.name]=s.value,O+=l}if(O<=U-3){var t=K.getUint32(O-1)&16777215;if(t===9)O+=3}}break;case 8:{w={},O+=4;var K0=0;if((K.getUint32(U-4)&16777215)===9)K0=3;while(O<U-8){var q0=j._parseObject(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O-K0)),R0=q0.size,U0=q0.data,W0=q0.isEnd;if(W0)break;w[U0.name]=U0.value,O+=R0}if(O<=U-3){var z0=K.getUint32(O-1)&16777215;if(z0===9)O+=3}}break;case 9:w=void 0,O=1,B=!0;break;case 10:{w=[];var h0=K.getUint32(1);O+=4;for(var l0=0;l0<h0;l0++){var E0=j._parseValue(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O)),y0=E0.data,t0=E0.size;w.push(y0),O+=t0}}break;case 11:{var T=K.getFloat64(O)+K.getInt16(O+8)*60000;w=new Date(T),O+=10}break;case 12:{var u=K.getUint32(1);if(O+=4,w="",u>0)w=gQ.decode(new Uint8Array(K.buffer,K.byteOffset+O,u));O+=u}break;default:O=U;break}return{data:w,size:O,isEnd:B}}},{key:"_parseString",value:function F(K){var U=K.getUint16(0),N="";if(U>0)N=gQ.decode(new Uint8Array(K.buffer,K.byteOffset+2,U));return{data:N,size:2+U}}},{key:"_parseObject",value:function F(K){if(K.byteLength<3)return;var U=j._parseString(K),N=j._parseValue(new DataView(K.buffer,K.byteOffset+U.size,K.byteLength-U.size));return{data:{name:U.data,value:N.data},size:U.size+N.size,isEnd:N.isEnd}}}]),j}();var c1={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var l1=new AY("FlvDemuxer"),TJ=function(){function j(F,K,U){I0(this,j),a(this,"_headerParsed",!1),a(this,"_remainingData",null),a(this,"_gopId",0),a(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=F||new I8,this.audioTrack=K||new L8,this.metadataTrack=U||new S8,this._fixer=new k8(this.videoTrack,this.audioTrack,this.metadataTrack)}return L0(j,[{key:"demux",value:function F(K){var U,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,B=arguments.length>3?arguments[3]:void 0,w=this.audioTrack,R=this.videoTrack,P=this.metadataTrack;if(N||!O)this._remainingData=null;if(N)this._headerParsed=!1;if(N)R.reset(),w.reset(),P.reset();else if(R.samples=[],w.samples=[],P.seiSamples=[],P.flvScriptSamples=[],R.warnings=[],w.warnings=[],this._remainingData)K=S1(this._remainingData,K),this._remainingData=null;if(!K.length)return{videoTrack:R,audioTrack:w,metadataTrack:P};var x=0;if(!this._headerParsed){if(!j.probe(K))throw new Error("Invalid flv file");w.present=(K[4]&4)>>>2!==0,R.present=(K[4]&1)!==0,this._headerParsed=!0,x=SY(K,5)+4}var k=K.length,f,l,s,Y0,t;while(x+15<k){if(f=K[x],l=K[x+1]<<16|K[x+2]<<8|K[x+3],x+15+l>k)break;if(s=(K[x+7]<<24>>>0)+(K[x+4]<<16)+(K[x+5]<<8)+K[x+6],x+=11,Y0=K.subarray(x,x+l),f===8)this._parseAudio(Y0,s);else if(f===9){if(B)this.seamlessLoadingSwitching=!0;this._parseVideo(Y0,s)}else if(f===18)this._parseScript(Y0,s);else l1.warn("Invalid tag type: ".concat(f));if(x+=l,t=SY(K,x),t!==11+l)l1.warn("Invalid PrevTagSize ".concat(t," (").concat(11+l,")"));x+=4}if(x<k)this._remainingData=K.subarray(x);if(w.formatTimescale=R.formatTimescale=R.timescale=P.timescale=1000,w.timescale=w.codecType===o0.OPUS?1000:w.sampleRate||0,!w.exist()&&w.hasSample())w.reset();if(!R.exist()&&R.hasSample())R.reset();var K0=P.flvScriptSamples[P.flvScriptSamples.length-1],q0=K0===null||K0===void 0?void 0:(U=K0.data)===null||U===void 0?void 0:U.onMetaData;if(q0){if(R!==null&&R!==void 0&&R.exist()){if(q0.hasOwnProperty("duration"))R.duration=q0.duration*1000;if(q0.hasOwnProperty("width")&&q0.hasOwnProperty("height"))R.width=q0.width,R.height=q0.height}if(w!==null&&w!==void 0&&w.exist()){if(q0.hasOwnProperty("duration"))w.duration=q0.duration*1000}}return{videoTrack:R,audioTrack:w,metadataTrack:P}}},{key:"fix",value:function F(K,U,N){return this._fixer.fix(K,U,N),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function F(K,U,N,O,B){return this.demux(K,U,N,B),this.fix(O,U,N)}},{key:"_parseAudio",value:function F(K,U){if(!K.length)return;var N=(K[0]&240)>>>4,O=this.audioTrack;if(N!==c1.AAC&&N!==c1.G711A&&N!==c1.G711M&&N!==c1.OPUS){l1.warn("Unsupported sound format: ".concat(N)),O.reset();return}if(N!==c1.AAC&&N!==c1.OPUS){var B=(K[0]&12)>>2,w=(K[0]&2)>>1,R=K[0]&1;O.sampleRate=j.AUDIO_RATE[B],O.sampleSize=w?16:8,O.channelCount=R+1}switch(N){case c1.G711A:case c1.G711M:this._parseG711(K,U,N);break;case c1.AAC:this._parseAac(K,U);break;case c1.OPUS:this._parseOpus(K,U);break}}},{key:"_parseOpus",value:function F(K,U){var N=this.audioTrack,O=K[1];switch(N.codecType=o0.OPUS,O){case 0:{var B=sY.parseHeaderPackets(K.subarray(2));if(B)N.codec=B.codec,N.channelCount=B.channelCount,N.sampleRate=B.sampleRate,N.config=B.config,N.sampleDuration=sY.getFrameDuration([],N.timescale);else N.reset(),l1.warn("Cannot parse AudioSpecificConfig",K);break}case 1:{if(U===void 0||U===null)return;var w=new CY(U,K.subarray(2),N.sampleDuration);N.samples.push(w);break}default:l1.warn("Unknown OpusPacketType: ".concat(O))}}},{key:"_parseG711",value:function F(K,U,N){var O=this.audioTrack,B=K.subarray(1);if(B.byteLength<1)return;var w=new CY(U,B);O.codecType=N===7?o0.G711PCMA:o0.G711PCMU,O.sampleRate=8000,O.codec=O.codecType,O.samples.push(w)}},{key:"_parseAac",value:function F(K,U){var N=this.audioTrack;if(N.codecType=o0.AAC,K[1]===0){var O=DY.parseAudioSpecificConfig(K.subarray(2));if(O)N.codec=O.codec,N.channelCount=O.channelCount,N.sampleRate=O.sampleRate,N.config=O.config,N.objectType=O.objectType,N.sampleRateIndex=O.samplingFrequencyIndex;else N.reset(),l1.warn("Cannot parse AudioSpecificConfig",K)}else if(K[1]===1){if(U===void 0||U===null)return;N.samples.push(new CY(U,K.subarray(2)))}else l1.warn("Unknown AACPacketType: ".concat(K[1]))}},{key:"_parseVideo",value:function F(K,U){var N=this;if(K.length<6)return;var O=(K[0]&240)>>>4,B=K[0]&15,w=this.videoTrack;if(B!==7&&B!==12){w.reset(),l1.warn("Unsupported codecId: ".concat(B));return}var R=B===12;w.codecType=R?YY.HEVC:YY.AVC;var P=K[1],x=(K[2]<<16|K[3]<<8|K[4])<<8>>8;if(P===0){var k=K.subarray(5),f=R?m8.parseHEVCDecoderConfigurationRecord(k):u8.parseAVCDecoderConfigurationRecord(k);if(f){var{hvcC:l,sps:s,ppsArr:Y0,spsArr:t,vpsArr:K0,nalUnitSize:q0}=f;if(l)w.hvcC=w.hvcC||l;if(s)w.codec=s.codec,w.width=s.width,w.height=s.height,w.sarRatio=s.sarRatio,w.fpsNum=s.fpsNum,w.fpsDen=s.fpsDen;if(t.length)w.sps=t;if(Y0.length)w.pps=Y0;if(K0&&K0.length)w.vps=K0;if(q0)w.nalUnitSize=q0}else l1.warn("Cannot parse ".concat(R?"HEVC":"AVC","DecoderConfigurationRecord"),K)}else if(P===1){var R0=JY.parseAvcC(K.subarray(5),w.nalUnitSize);if(R0=this._checkAddMetaNalToUnits(R,R0,w),R0&&R0.length){var U0=new b8(U+x,U,R0);if(this.seamlessLoadingSwitching&&U<w.lastKeyFrameDts)return;if(this.seamlessLoadingSwitching=!1,O===1)U0.setToKeyframe(),w.lastKeyFrameDts=U;if(w.samples.push(U0),R0.forEach(function(W0){var z0=R?W0[0]>>>1&63:W0[0]&31;switch(z0){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!R&&z0!==5||R&&z0===5)break;U0.setToKeyframe();break;case 6:case 39:case 40:if(!R&&z0!==6||R&&z0===6)break;N.metadataTrack.seiSamples.push(new D8(JY.parseSEI(JY.removeEPB(W0),R),U+x));break}}),U0.keyframe)this._gopId++;U0.gopId=this._gopId}else l1.warn("Cannot parse NALUs",K)}else if(P===2);else l1.warn("Unknown AVCPacketType: ".concat(P))}},{key:"_checkAddMetaNalToUnits",value:function F(K,U,N){if(!K||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,U;var O=U.map(function(B){return B[0]>>>1&63});if(O.includes(32))return this._needAddMetaBeforeKeyFrameNal=!1,U;return U.unshift(N.pps[0]),U.unshift(N.sps[0]),U.unshift(N.vps[0]),U.filter(Boolean)}},{key:"_parseScript",value:function F(K,U){this.metadataTrack.flvScriptSamples.push(new C8(_8.parse(K),U))}}],[{key:"probe",value:function F(K){if(K[0]!==70||K[1]!==76||K[2]!==86||K[3]!==1)return!1;return SY(K,5)>=9}}]),j}();a(TJ,"AUDIO_RATE",[5500,11000,22000,44000]);function YW(j){var F=0;for(var K=arguments.length,U=new Array(K>1?K-1:0),N=1;N<K;N++)U[N-1]=arguments[N];U.forEach(function(w){F+=w.length});var O=new j(F),B=0;return U.forEach(function(w){O.set(w,B),B+=w.length}),O}var N1=function(){function j(){I0(this,j),this.buffer=new Uint8Array(0)}return L0(j,[{key:"write",value:function F(){var K=this;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];N.forEach(function(B){if(B)K.buffer=YW(Uint8Array,K.buffer,B);else window.console.warn(B)})}}],[{key:"writeUint16",value:function F(K){return new Uint8Array([K>>8&255,K&255])}},{key:"writeUint32",value:function F(K){return new Uint8Array([K>>24,K>>16&255,K>>8&255,K&255])}}]),j}();var p8=Math.pow(2,32)-1,b0=function(){function j(){I0(this,j)}return L0(j,null,[{key:"box",value:function F(K){for(var U=arguments.length,N=new Array(U>1?U-1:0),O=1;O<U;O++)N[O-1]=arguments[O];N=N.filter(Boolean);var B=8+N.reduce(function(P,x){return P+x.byteLength},0),w=new Uint8Array(B);w[0]=B>>24&255,w[1]=B>>16&255,w[2]=B>>8&255,w[3]=B&255,w.set(K,4);var R=8;return N.forEach(function(P){w.set(P,R),R+=P.byteLength}),w}},{key:"ftyp",value:function F(K){var U=K.find(function(N){return N.type===f1.VIDEO&&N.codecType===YY.HEVC});return U?j.FTYPHEV1:j.FTYPAVC1}},{key:"initSegment",value:function F(K){var U=j.ftyp(K),N=S1(U,j.moov(K));return N}},{key:"pssh",value:function F(K){var U=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],kQ(K.kid),[0,0,0,0]));return j.box(j.types.pssh,U)}},{key:"moov",value:function F(K){if(K[0].useEME&&(K[0].encv||K[0].enca)){if(!K[0].pssh)K[0].pssh={kid:K[0].kid};var U=this.pssh(K[0].pssh);return j.box.apply(j,[j.types.moov,j.mvhd(K[0].mvhdDurtion||K[0].duration,K[0].mvhdTimecale||K[0].timescale),j.mvex(K)].concat(p1(K.map(function(N){return j.trak(N)})),[U]))}else return j.box.apply(j,[j.types.moov,j.mvhd(K[0].mvhdDurtion||K[0].duration,K[0].mvhdTimecale||K[0].timescale)].concat(p1(K.map(function(N){return j.trak(N)})),[j.mvex(K)]))}},{key:"mvhd",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,N=j.box(j.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,K>>24&255,K>>16&255,K>>8&255,K&255,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 N}},{key:"trak",value:function F(K){var U=j.box(j.types.trak,j.tkhd(K.id,K.tkhdDuration||0,K.width,K.height),j.mdia(K));return U}},{key:"tkhd",value:function F(K,U){var N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,O=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,B=j.box(j.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,K>>24&255,K>>16&255,K>>8&255,K&255,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,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,N>>8&255,N&255,0,0,O>>8&255,O&255,0,0]));return B}},{key:"mdia",value:function F(K){var U=j.box(j.types.mdia,j.mdhd(K.duration,K.timescale),j.hdlr(K.type),j.minf(K));return U}},{key:"mdhd",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,N=j.box(j.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,K>>24&255,K>>16&255,K>>8&255,K&255,85,196,0,0]));return N}},{key:"hdlr",value:function F(K){var U=j.box(j.types.hdlr,j.HDLR_TYPES[K]);return U}},{key:"minf",value:function F(K){var U=j.box(j.types.minf,K.type===f1.VIDEO?j.VMHD:j.SMHD,j.DINF,j.stbl(K));return U}},{key:"stbl",value:function F(K){var U=[];if(K&&K.ext)K.ext.stss&&U.push(j.stss(K.ext.stss.entries));var N=j.box(j.types.stbl,j.stsd(K),j.STTS,U[0],j.STSC,j.STSZ,j.STCO);return N}},{key:"stsd",value:function F(K){var U;if(K.type==="audio")if(K.useEME&&K.enca)U=j.enca(K);else if(K.codecType===o0.OPUS)U=j.opus(K);else U=j.mp4a(K);else if(K.useEME&&K.encv)U=j.encv(K);else if(K.av1C)U=j.av01(K);else U=j.avc1hev1(K);var N=j.box(j.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),U);return N}},{key:"enca",value:function F(K){var U=K.enca.channelCount,N=K.enca.sampleRate,O=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U,0,16,0,0,0,0,N>>8&255,N&255,0,0]),B=j.esds(K.config),w=j.sinf(K.enca);return j.box(j.types.enca,O,B,w)}},{key:"encv",value:function F(K){var U,N,O=K.sps.length>0?K.sps[0]:[],B=K.pps.length>0?K.pps[0]:[],w=K.width,R=K.height,P=K.sarRatio[0],x=K.sarRatio[1],k=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,w>>8&255,w&255,R>>8&255,R&255,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]),f=new Uint8Array((U=(N=[1,O[1],O[2],O[3],255,225,O.length>>>8&255,O.length&255]).concat.apply(N,p1(O)).concat([1,B.length>>>8&255,B.length&255])).concat.apply(U,p1(B))),l=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),s=j.sinf(K.encv),Y0=new Uint8Array([P>>24,P>>16&255,P>>8&255,P&255,x>>24,x>>16&255,x>>8&255,x&255]);return j.box(j.types.encv,k,j.box(j.types.avcC,f),j.box(j.types.btrt,l),s,j.box(j.types.pasp,Y0))}},{key:"schi",value:function F(K){var U=new Uint8Array([]),N=j.tenc(K);return j.box(j.types.schi,U,N)}},{key:"tenc",value:function F(K){var U=new Uint8Array([0,0,0,0,0,0,K.default_IsEncrypted&255,K.default_IV_size&255].concat(kQ(K.default_KID)));return j.box(j.types.tenc,U)}},{key:"sinf",value:function F(K){var U=new Uint8Array([]),N=new Uint8Array([K.data_format.charCodeAt(0),K.data_format.charCodeAt(1),K.data_format.charCodeAt(2),K.data_format.charCodeAt(3)]),O=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),B=j.schi(K);return j.box(j.types.sinf,U,j.box(j.types.frma,N),j.box(j.types.schm,O),B)}},{key:"av01",value:function F(K){return j.box(j.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,K.width>>8&255,K.width&255,K.height>>8&255,K.height&255,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]),K.av1C,K.colr)}},{key:"avc1hev1",value:function F(K){var U=K.codecType===YY.HEVC,N=U?j.types.hvc1:j.types.avc1,O=U?j.hvcC(K):j.avcC(K),B=[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,K.width>>8&255,K.width&255,K.height>>8&255,K.height&255,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]),O];if(U)B.push(j.box(j.types.fiel,new Uint8Array([1,0])));else if(K.sarRatio&&K.sarRatio.length>1)B.push(j.pasp(K.sarRatio));return j.box.apply(j,[N].concat(B))}},{key:"avcC",value:function F(K){var U,N,O=[],B=[],w;return K.sps.forEach(function(R){w=R.byteLength,O.push(w>>>8&255),O.push(w&255),O.push.apply(O,p1(R))}),K.pps.forEach(function(R){w=R.byteLength,B.push(w>>>8&255),B.push(w&255),B.push.apply(B,p1(R))}),j.box(j.types.avcC,new Uint8Array((U=(N=[1,O[3],O[4],O[5],255,224|K.sps.length]).concat.apply(N,O).concat([K.pps.length])).concat.apply(U,B)))}},{key:"hvcC",value:function F(K){var U=K.hvcC;if(U instanceof ArrayBuffer||U instanceof Uint8Array)return U;var{vps:N,sps:O,pps:B}=K,w;if(U){var{generalProfileCompatibilityFlags:R,generalConstraintIndicatorFlags:P}=U,x=(N.length&&1)+(O.length&&1)+(B.length&&1);w=[1,U.generalProfileSpace<<6|U.generalTierFlag<<5|U.generalProfileIdc,R>>>24,R>>>16,R>>>8,R,P[0],P[1],P[2],P[3],P[4],P[5],U.generalLevelIdc,240,0,252,U.chromaFormatIdc|252,U.bitDepthLumaMinus8|248,U.bitDepthChromaMinus8|248,0,0,U.numTemporalLayers<<3|U.temporalIdNested<<2|3,x];var k=function f(l){var s;w.push(l.length>>8,l.length),(s=w).push.apply(s,p1(l))};if(N.length)w.push(160,0,N.length),N.forEach(k);if(O.length)w.push(161,0,O.length),O.forEach(k);if(B.length)w.push(162,0,B.length),B.forEach(k)}else w=[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 j.box(j.types.hvcC,new Uint8Array(w))}},{key:"pasp",value:function F(K){var U=w8(K,2),N=U[0],O=U[1];return j.box(j.types.pasp,new Uint8Array([N>>24,N>>16&255,N>>8&255,N&255,O>>24,O>>16&255,O>>8&255,O&255]))}},{key:"mp4a",value:function F(K){return j.box(j.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,K.channelCount,0,16,0,0,0,0,K.sampleRate>>8&255,K.sampleRate&255,0,0]),K.config.length?j.esds(K.config):void 0)}},{key:"esds",value:function F(K){var U=K.length,N=j.box(j.types.esds,new Uint8Array([0,0,0,0,3,23+U,0,0,0,4,15+U,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([U]).concat(K).concat([6,1,2])));return N}},{key:"opus",value:function F(K){var U=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,K.channelCount,0,16,0,0,0,0,K.sampleRate>>8&255,K.sampleRate&255,0,0]),N=K.config.length?j.dOps(K):[];return j.box(j.types.Opus,U,N)}},{key:"dOps",value:function F(K){if(K.config)return K.config[4]=K.sampleRate>>>24&255,K.config[5]=K.sampleRate>>>16&255,K.config[6]=K.sampleRate>>>8&255,K.config[7]=K.sampleRate&255,j.box(j.types.dOps,K.config)}},{key:"mvex",value:function F(K){var U=j.box.apply(j,[j.types.mvex].concat(p1(K.map(function(N){return j.trex(N.id)}))));return U}},{key:"trex",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return U}},{key:"trex1",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return U}},{key:"trex2",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return U}},{key:"moof",value:function F(K){var U=j.box.apply(j,[j.types.moof,j.mfhd(K[0].samples?K[0].samples[0].gopId:0)].concat(p1(K.map(function(N){return j.traf(N)}))));return U}},{key:"mfhd",value:function F(K){var U=j.box(j.types.mfhd,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255]));return U}},{key:"traf",value:function F(K){var U=j.tfhd(K.id),N=j.tfdt(K,K.baseMediaDecodeTime),O=0,B;if(K.isVideo&&K.videoSenc)B=K.videoSenc,B.forEach(function(u){if(O=O+8,u.subsamples&&u.subsamples.length)O=O+2,O=O+u.subsamples.length*6});if(K.videoSencLength=O,!K.useEME||!K.isVideoEncryption&&!K.isAudioEncryption){var w=j.sdtp(K),R=76;return j.box(j.types.traf,U,N,w,j.trun(K.samples,w.byteLength+R))}else if(K.isVideoEncryption)if(K.isVideo){var P=j.saiz(K),x=j.saio(K),k=j.trun1(K),f=j.senc(K),l=j.box(j.types.traf,U,N,P,x,k,f);return l}else if(!K.isAudioEncryption){var s=j.sbgp(),Y0=j.trun1(K);return j.box(j.types.traf,U,N,s,Y0)}else{var t=j.sbgp(),K0=j.saiz(K),q0=j.saio(K),R0=j.senc(K),U0=j.trun1(K),W0=j.box(j.types.traf,U,N,t,K0,q0,R0,U0);return W0}else if(K.isVideo){var z0=j.trun1(K);return j.box(j.types.traf,U,N,z0)}else{var h0=j.sbgp(),l0=j.saiz(K),E0=j.saio(K),y0=j.senc(K),t0=j.trun1(K),T=j.box(j.types.traf,U,N,h0,l0,E0,y0,t0);return T}}},{key:"sdtp",value:function F(K){var U=new N1;return K.samples.forEach(function(N){U.write(new Uint8Array(K.isVideo?[N.keyframe?32:16]:[16]))}),j.box(j.types.sdtp,this.extension(0,0),U.buffer)}},{key:"trun1",value:function F(K){var U=new N1,N=N1.writeUint32(K.samples.length),O=null;if(K.isVideo){var B=K.videoSencLength;if(O=N1.writeUint32(K.samples.length*16+B+149),!K.isVideoEncryption&&K.isAudioEncryption)O=N1.writeUint32(K.samples.length*16+92)}else{var w=K.samples.length*12+124;if(K.isAudioEncryption)w=K.samples.length*12+8*K.audioSenc.length+177;O=N1.writeUint32(w)}return K.samples.forEach(function(R){if(U.write(N1.writeUint32(R.duration)),U.write(N1.writeUint32(R.size)),U.write(N1.writeUint32(R.keyframe?33554432:65536)),K.isVideo)U.write(N1.writeUint32(R.cts?R.cts:0))}),j.box(j.types.trun,this.extension(0,K.flags),N,O,U.buffer)}},{key:"senc",value:function F(K){var U=new N1,N=K.samples.length,O=K.isVideo?16:8,B=K.isVideo?2:0,w=[],R=0;if(K.isVideo)w=K.videoSenc,R=K.videoSencLength;else w=K.audioSenc;return R=R||O*N,U.write(N1.writeUint32(16+R),j.types.senc,this.extension(0,B)),U.write(N1.writeUint32(N)),w.forEach(function(P){for(var x=0;x<P.InitializationVector.length;x++)U.write(new Uint8Array([P.InitializationVector[x]]));if(P.subsamples&&P.subsamples.length)U.write(N1.writeUint16(P.subsamples.length)),P.subsamples.forEach(function(k){U.write(N1.writeUint16(k.BytesOfClearData)),U.write(N1.writeUint32(k.BytesOfProtectedData))})}),U.buffer}},{key:"saio",value:function F(K){var U=K.samples.length*12+141;if(!K.isVideo&&K.isAudioEncryption)U=149;var N=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255]);return j.box(j.types.saio,N)}},{key:"saiz",value:function F(K){var U=K.samples.length,N=new Uint8Array([0,0,0,0,16,U>>24&255,U>>16&255,U>>8&255,U&255]);return j.box(j.types.saiz,N)}},{key:"sbgp",value:function F(){var K=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return j.box(j.types.sbgp,this.extension(0,0),K)}},{key:"extension",value:function F(K,U){return new Uint8Array([K,U>>16&255,U>>8&255,U&255])}},{key:"tfhd",value:function F(K){return j.box(j.types.tfhd,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255]))}},{key:"tfdt",value:function F(K,U){var N=Math.floor(U/(p8+1)),O=Math.floor(U%(p8+1));if(K.useEME&&(K.isVideoEncryption||K.isAudioEncryption))return j.box(j.types.tfdt,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]));else return j.box(j.types.tfdt,new Uint8Array([1,0,0,0,N>>24,N>>16&255,N>>8&255,N&255,O>>24,O>>16&255,O>>8&255,O&255]))}},{key:"trun",value:function F(K,U){var N=K.length,O=12+16*N;U+=8+O;var B=new Uint8Array(O);B.set([0,0,15,1,N>>>24&255,N>>>16&255,N>>>8&255,N&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255],0);for(var w=0;w<N;w++){var R=K[w],P=R.duration,x=R.size,k=R.flag,f=k===void 0?{}:k,l=R.cts,s=l===void 0?0:l;B.set([P>>>24&255,P>>>16&255,P>>>8&255,P&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255,f.isLeading<<2|(f.dependsOn===null||f.dependsOn===void 0?1:f.dependsOn),f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|(f.isNonSyncSample===null||f.isNonSyncSample===void 0?1:f.isNonSyncSample),f.degradationPriority&61440,f.degradationPriority&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*w)}return j.box(j.types.trun,B)}},{key:"moovMP4",value:function F(K){return j.box.apply(j,[j.types.moov,j.mvhd(K[0].duration,K[0].timescale)].concat(p1(K.map(function(U){return j.trackMP4(U)}))))}},{key:"trackMP4",value:function F(K){return j.box(j.types.trak,j.tkhd(K.id,K.duration,K.width,K.height),j.mdiaMP4(K))}},{key:"mdiaMP4",value:function F(K){return j.box(j.types.mdia,j.mdhd(K.duration,K.timescale),j.hdlr(K.type),j.minfMP4(K))}},{key:"minfMP4",value:function F(K){return j.box(j.types.minf,K.type===f1.VIDEO?j.VMHD:j.SMHD,j.DINF,j.stblMP4(K))}},{key:"stblMP4",value:function F(K){var U=K.ext,N=[j.stsd(K),j.stts(U.stts),j.stsc(U.stsc),j.stsz(U.stsz),j.stco(U.stco)];if(U.stss.length)N.push(j.stss(U.stss));if(U.ctts.length)N.push(j.ctts(U.ctts));return j.box.apply(j,[j.types.stbl].concat(N))}},{key:"stts",value:function F(K){var U=K.length,N=new Uint8Array(8*U),O=0;return K.forEach(function(B){var{value:w,count:R}=B;N.set([R>>24,R>>16&255,R>>8&255,R&255,w>>24,w>>16&255,w>>8&255,w&255],O),O+=8}),j.box(j.types.stts,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stsc",value:function F(K){var U=K.length,N=new Uint8Array(12*U),O=0;return K.forEach(function(B){var{firstChunk:w,samplesPerChunk:R,sampleDescIndex:P}=B;N.set([w>>24,w>>16&255,w>>8&255,w&255,R>>24,R>>16&255,R>>8&255,R&255,P>>24,P>>16&255,P>>8&255,P&255],O),O+=12}),j.box(j.types.stsc,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stsz",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stsz,S1(new Uint8Array([0,0,0,0,0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stco",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stco,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stss",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stss,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"ctts",value:function F(K){var U=K.length,N=new Uint8Array(8*U),O=0;return K.forEach(function(B){var{value:w,count:R}=B;N.set([R>>24,R>>16&255,R>>8&255,R&255,w>>24,w>>16&255,w>>8&255,w&255],O),O+=8}),j.box(j.types.ctts,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"styp",value:function F(){return j.box(j.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function F(K){var U=K.timescale,N=K.samples[0].duration,O=N*K.samples.length,B=K.samples[0].sampleOffset*N,w=8;K.samples.forEach(function(f){w+=f.size});var R=0;if(K.isVideo){var P=0,x;if(K.videoSenc)x=K.videoSenc;if(K.isVideo)x.forEach(function(f){if(P=P+8,f.subsamples&&f.subsamples.length)P=P+2,P=P+f.subsamples.length*6});if(K.videoSencLength=P,R=w+141+K.samples.length*16+P,K.useEME&&K.isAudioEncryption&&!K.isVideoEncryption)R=w+K.samples.length*16+84}else if(R=w+116+K.samples.length*12,K.useEME&&K.isAudioEncryption)R=w+169+K.samples.length*12+8*K.audioSenc.length;var k=new Uint8Array([0,0,0,0,0,0,0,K.id&255,U>>24&255,U>>16&255,U>>8&255,U&255,B>>24&255,B>>16&255,B>>8&255,B&255,0,0,0,0,0,0,0,1,0,R>>16&255,R>>8&255,R&255,O>>24&255,O>>16&255,O>>8&255,O&255,144,0,0,0]);return j.box(j.types.sidx,k)}},{key:"mdat",value:function F(K){var U=j.box(j.types.mdat,K);return U}}]),j}();a(b0,"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(j,F){return j[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.charCodeAt(3)],j},Object.create(null)));a(b0,"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])});a(b0,"FTYPAVC1",b0.box(b0.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));a(b0,"FTYPHEV1",b0.box(b0.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));a(b0,"DINF",b0.box(b0.types.dinf,b0.box(b0.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));a(b0,"VMHD",b0.box(b0.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));a(b0,"SMHD",b0.box(b0.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));a(b0,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));a(b0,"STTS",b0.box(b0.types.stts,b0.StblTable));a(b0,"STSC",b0.box(b0.types.stsc,b0.StblTable));a(b0,"STSZ",b0.box(b0.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));a(b0,"STCO",b0.box(b0.types.stco,b0.StblTable));var uQ=function(){function j(F,K){I0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]"),j.disabled=K}return L0(j,[{key:"debug",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).debug.apply(K,[this._prefix].concat(N))}},{key:"log",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).log.apply(K,[this._prefix].concat(N))}},{key:"warn",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).warn.apply(K,[this._prefix].concat(N))}},{key:"error",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).error.apply(K,[this._prefix].concat(N))}},{key:"table",value:function F(){var K;if(j.disabled)return;console.group(this._prefix),(K=console).table.apply(K,arguments),console.groupEnd()}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();a(uQ,"disabled",!0);var mQ=function(){function j(F,K,U){I0(this,j),this.videoTrack=F,this.audioTrack=K;var N=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=N&&Number(N[1])<50,this.log=new uQ("FMP4Remuxer",U&&U.openLog?!U.openLog:!0)}return L0(j,[{key:"remux",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=this.videoTrack,O=this.audioTrack,B=N.exist(),w=O.exist(),R,P,x,k=[];if(K)if(U&&U.initMerge){if(B)k.push(this.videoTrack);if(w)k.push(this.audioTrack);x=b0.initSegment(k)}else{if(B)R=b0.initSegment([this.videoTrack]);if(w)P=b0.initSegment([this.audioTrack])}var f,l;if(B&&N.hasSample())f=this._remuxVideo();if(w&&O.hasSample())l=this._remuxAudio();return N.samples=[],O.samples=[],{initSegment:x,videoInitSegment:R,audioInitSegment:P,videoSegment:f,audioSegment:l}}},{key:"_remuxVideo",value:function F(){var K=this.videoTrack;if(this.forceFirstIDR)K.samples[0].flag={dependsOn:2,isNonSyncSample:0};var U=K.samples,N=/av01/.test(K.codec),O=0;if(N)U.forEach(function(R0){O+=R0.data.byteLength});else U.forEach(function(R0){O+=R0.units.reduce(function(U0,W0){return U0+W0.byteLength},0),O+=R0.units.length*4});var B=new Uint8Array(O);if(N)for(var w=0,R=U.length,P=0,x;w<R;w++)x=U[w],B.set(x.data,P),x.size=x.data.byteLength,P+=x.size;else{var k=new DataView(B.buffer),f=function R0(U0,W0){W0=U[l];var z0=0;W0.units.forEach(function(h0){k.setUint32(U0,h0.byteLength),U0+=4,B.set(h0,U0),U0+=h0.byteLength,z0+=4+h0.byteLength}),W0.size=z0,Y0=U0,t=W0};for(var l=0,s=U.length,Y0=0,t;l<s;l++)f(Y0,t)}var K0=b0.mdat(B),q0=b0.moof([K]);return S1(q0,K0)}},{key:"_remuxAudio",value:function F(){var K=this.audioTrack,U=new Uint8Array(K.samples.reduce(function(B,w){return B+w.size},0));K.samples.reduce(function(B,w){return U.set(w.data,B),B+w.size},0);var N=b0.mdat(U),O=b0.moof([K]);return S1(O,N)}},{key:"reset",value:function F(){this.videoTrack.reset(),this.audioTrack.reset()}}]),j}();var f8=function(){function j(){LY(this,j),F0(this,"_ttfb",0),F0(this,"_demuxStart",0),F0(this,"_demuxEnd",0),F0(this,"_demuxCost",0),F0(this,"_remuxStart",0),F0(this,"_remuxEnd",0),F0(this,"_remuxCost",0),F0(this,"_appendStart",0),F0(this,"_appendEnd",0),F0(this,"_appendCost",0)}return bY(j,[{key:"set",value:function F(K,U){this["_".concat(K)]=U}},{key:"start",value:function F(K){this["_".concat(K,"Start")]=Date.now()}},{key:"end",value:function F(K){this["_".concat(K,"End")]=Date.now(),this["_".concat(K,"Cost")]=this["_".concat(K,"Cost")]+(this["_".concat(K,"End")]-this["_".concat(K,"Start")])}},{key:"transferCost",get:function F(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),j}(),QY={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var ZY=new D1("BufferService"),c8=function(){function j(F,K){var U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(LY(this,j),F0(this,"flv",null),F0(this,"_demuxer",new TJ),F0(this,"_remuxer",null),F0(this,"_mse",null),F0(this,"_softVideo",null),F0(this,"_sourceCreated",!1),F0(this,"_needInitSegment",!0),F0(this,"_discontinuity",!0),F0(this,"_contiguous",!1),F0(this,"_initSegmentId",""),F0(this,"_cachedBuffer",null),F0(this,"_demuxStartTime",0),F0(this,"_opts",null),this.flv=F,this._opts=U,K)this._softVideo=K;else this._remuxer=new mQ(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new NY(null,{preferMMS:typeof U.preferMMS==="boolean"?U.preferMMS:!!U.perferMMS}),this._mse.bindMedia(F.media)}return bY(j,[{key:"baseDts",get:function F(){var K,U;return(K=this._demuxer)===null||K===void 0?void 0:(U=K._fixer)===null||U===void 0?void 0:U._baseDts}},{key:"blobUrl",get:function F(){var K;return(K=this._mse)===null||K===void 0?void 0:K.url}},{key:"isFull",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:NY.VIDEO;return this._mse.isFull(K)}},{key:"seamlessSwitch",value:function F(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function F(K){this._contiguous=!1,this._demuxStartTime=K}},{key:"reset",value:function(){var F=G1(S0().mark(function U(){var N,O=arguments;return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(N=O.length>0&&O[0]!==void 0?O[0]:!1,!(this._mse&&!N)){w.next=6;break}return w.next=4,this._mse.unbindMedia();case 4:return w.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 w.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"resetSeamlessSwitchStats",value:function F(){if(this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer)this._demuxer.seamlessLoadingSwitching=!1}},{key:"endOfStream",value:function(){var F=G1(S0().mark(function U(){return S0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:if(!this._mse){O.next=7;break}if(!this._sourceCreated){O.next=5;break}return O.next=4,this._mse.endOfStream();case 4:this.flv.emit(w0.BUFFEREOS);case 5:O.next=8;break;case 7:if(this._softVideo)this._softVideo.endOfStream();case 8:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"updateDuration",value:function(){var F=G1(S0().mark(function U(N){return S0().wrap(function O(B){while(!0)switch(B.prev=B.next){case 0:if(!this._mse){B.next=7;break}if(this._mse.isOpened){B.next=4;break}return B.next=4,this._mse.open();case 4:return ZY.debug("update duration",N),B.next=7,this._mse.updateDuration(N);case 7:case"end":return B.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"destroy",value:function(){var F=G1(S0().mark(function U(){return S0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:if(!this._mse){O.next=3;break}return O.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"appendBuffer",value:function(){var F=G1(S0().mark(function U(N){var O=this,B,w,R,P,x,k,f,l,s,Y0,t,K0,q0,R0,U0,W0,z0,h0;return S0().wrap(function l0(E0){while(!0)switch(E0.prev=E0.next){case 0:if(B=!1,this._cachedBuffer)N=$Q(this._cachedBuffer,N),this._cachedBuffer=null;if(w=this._demuxer,!(!N||!N.length||!w)){E0.next=5;break}return E0.abrupt("return");case 5:E0.prev=5,this.flv._transferCost.start(QY.DEMUX),w.demuxAndFix(N,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(QY.DEMUX),E0.next=15;break;case 12:throw E0.prev=12,E0.t0=E0.catch(5),new A1(P0.DEMUX,P0.SUB_TYPES.FLV,E0.t0);case 15:if(R=w.videoTrack,P=w.audioTrack,x=w.metadataTrack,!this.seamlessLoadingSwitch){E0.next=25;break}if(k=R.samples.findIndex(function(y0){return y0.originDts===R.lastKeyFrameDts}),!(k>=0)){E0.next=25;break}return R.samples.splice(k),E0.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,N=null,B=!0;case 25:if(f=R.exist(),l=P.exist(),this._opts.onlyAudio)f=!1,R.present=!1;if(this._opts.onlyVideo)l=!1,P.present=!1;if(!(!f&&R.present||!l&&P.present)){E0.next=42;break}if(s=0,Y0=f?R:l?P:void 0,Y0&&Y0.samples.length)s=(Y0.samples[Y0.samples.length-1].originPts-Y0.samples[0].originPts)/Y0.timescale*1000;if(!(s>this._opts.analyzeDuration)){E0.next=40;break}ZY.warn("analyze duration exceeded, ".concat(s,"ms"),Y0),R.present=f,P.present=l,this.flv.emit(w0.ANALYZE_DURATION_EXCEEDED,{duration:s}),E0.next=42;break;case 40:return this._cachedBuffer=N,E0.abrupt("return");case 42:if(t=R.type,K0=P.type,this._fireEvents(R,P,x),!B)this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0;if(q0=this._mse,R0=function y0(){var t0;if((t0=O.flv)!==null&&t0!==void 0&&t0.emit){var T;(T=O.flv)===null||T===void 0||T.emit(w0.APPEND_BUFFER,{})}},this.flv.emit(w0.DEMUXED_TRACK,{videoTrack:R}),U0="".concat(R.codec,"/").concat(R.width,"/").concat(R.height,"/").concat(P.codec,"/").concat(P.config),U0!==this._initSegmentId)this._needInitSegment=!0,this._initSegmentId=U0,this._emitMetaParsedEvent(R,P);if(!q0){E0.next=83;break}if(this._sourceCreated){E0.next=59;break}return E0.next=55,q0.open();case 55:if(f)ZY.log("codec: video/mp4;codecs=".concat(R.codec)),q0.createSource(t,"video/mp4;codecs=".concat(R.codec));if(l)ZY.log("codec: audio/mp4;codecs=".concat(P.codec)),q0.createSource(K0,"audio/mp4;codecs=".concat(P.codec));this._sourceCreated=!0,this.flv.emit(w0.SOURCEBUFFER_CREATED);case 59:if(E0.prev=59,this._needInitSegment&&!this._opts.mseLowLatency)R.duration=this._opts.durationForMSELowLatencyOff*R.timescale,P.duration=this._opts.durationForMSELowLatencyOff*l.timescale;this.flv._transferCost.start(QY.REMUX),W0=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(QY.REMUX),E0.next=69;break;case 66:throw E0.prev=66,E0.t1=E0.catch(59),new A1(P0.REMUX,P0.SUB_TYPES.FMP4,E0.t1);case 69:if(!(this._needInitSegment&&!W0.videoInitSegment&&!W0.audioInitSegment)){E0.next=71;break}return E0.abrupt("return");case 71:if(this._needInitSegment=!1,z0=[],W0.videoInitSegment)z0.push(q0.append(t,W0.videoInitSegment));if(W0.audioInitSegment)z0.push(q0.append(K0,W0.audioInitSegment));if(W0.videoSegment)z0.push(q0.append(t,W0.videoSegment));if(W0.audioSegment)z0.push(q0.append(K0,W0.audioSegment));return this.flv._transferCost.start(QY.APPEND),h0=Promise.all(z0),h0.then(R0).then(function(){O.flv._transferCost.end(QY.APPEND),R0()}),E0.abrupt("return",h0);case 83:if(this._softVideo)this._softVideo.appendBuffer(R,P),R0();case 84:case"end":return E0.stop()}},U,this,[[5,12],[59,66]])}));function K(U){return F.apply(this,arguments)}return K}()},{key:"evictBuffer",value:function(){var F=G1(S0().mark(function U(N){var O=this,B,w,R,P;return S0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(B=this.flv.media,!(!this._mse||!this._demuxer||!B||!N||N<0)){k.next=3;break}return k.abrupt("return");case 3:if(w=B.currentTime,R=w-N,!(R<=0)){k.next=7;break}return k.abrupt("return");case 7:if(P=J1.start(J1.get(B)),!(P+1>=R)){k.next=10;break}return k.abrupt("return");case 10:return k.abrupt("return",this._mse.clearBuffer(0,R).then(function(){return O.flv.emit(w0.REMOVE_BUFFER,{removeEnd:R})}));case 11:case"end":return k.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"_emitMetaParsedEvent",value:function F(K,U){if(K.exist())this.flv.emit(w0.METADATA_PARSED,{type:"video",track:K,meta:{codec:K.codec,timescale:K.timescale,width:K.width,height:K.height,sarRatio:K.sarRatio,baseDts:K.baseDts}});if(U.exist())this.flv.emit(w0.METADATA_PARSED,{type:"audio",track:U,meta:{codec:U.codec,channelCount:U.channelCount,sampleRate:U.sampleRate,timescale:U.timescale,baseDts:U.baseDts}});ZY.debug("track parsed",K,U)}},{key:"_fireEvents",value:function F(K,U,N){var O=this;ZY.debug("videoTrack samples count: ".concat(K.samples.length,", audioTrack samples count: ").concat(U.samples.length)),N.flvScriptSamples.forEach(function(B){O.flv.emit(w0.FLV_SCRIPT_DATA,B),ZY.debug("flvScriptData",B)}),K.samples.forEach(function(B){if(B.keyframe)O.flv.emit(w0.KEYFRAME,{pts:B.originPts})}),K.warnings.forEach(function(B){var w;switch(B.type){case E1.LARGE_AV_SHIFT:w=w0.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case E1.LARGE_VIDEO_GAP:w=w0.LARGE_VIDEO_DTS_GAP_DETECT;break;case E1.LARGE_VIDEO_GAP_BETWEEN_CHUNK:w=w0.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}if(w)O.flv.emit(w0.STREAM_EXCEPTION,y1(y1({},B),{},{type:w}));ZY.warn("video exception",B)}),U.warnings.forEach(function(B){var w;switch(B.type){case E1.LARGE_AUDIO_GAP:w=w0.LARGE_AUDIO_DTS_GAP_DETECT;break;case E1.AUDIO_FILLED:w=w0.AUDIO_GAP_DETECT;break;case E1.AUDIO_DROPPED:w=w0.AUDIO_OVERLAP_DETECT;break}if(w)O.flv.emit(w0.STREAM_EXCEPTION,y1(y1({},B),{},{type:w}));ZY.warn("audio exception",B)}),N.seiSamples.forEach(function(B){O.flv.emit(w0.SEI,y1(y1({},B),{},{sei:{code:B.data.type,content:B.data.payload,dts:B.pts}}))})}}]),j}();function l8(j){var F=y1({retryCount:3,retryDelay:1000,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5000,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:20000,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1000,longtimeNoReceived:3000,enableStartGapJump:!0},j);if(F.isLive){if(F.preloadTime){if(!F.maxLatency)F.maxLatency=F.preloadTime*2;if(!F.targetLatency)F.targetLatency=F.preloadTime;if(F.disconnectTime===null||F.disconnectTime===void 0)F.disconnectTime=F.maxLatency}}return F}function _Q(j,F){var K=0,U=j.length-1,N=0,O=0,B=U;if(F<j[0])K=0,O=B+1;while(O<=B)if(N=O+Math.floor((B-O)/2),N===U||F>=j[N]&&F<j[N+1]){K=N;break}else if(j[N]<F)O=N+1;else B=N-1;return K}var r1=new D1("flv"),xJ=0.1,JW=0.3,aY=function(j){dZ(K,j);var F=nZ(K);function K(U){var N;if(LY(this,K),N=F.call(this),F0(x0(N),"media",null),F0(x0(N),"_loading",!1),F0(x0(N),"_opts",null),F0(x0(N),"_bufferService",null),F0(x0(N),"_gapService",null),F0(x0(N),"_stats",null),F0(x0(N),"_mediaLoader",null),F0(x0(N),"_maxChunkWaitTimer",null),F0(x0(N),"_tickTimer",null),F0(x0(N),"_tickInterval",500),F0(x0(N),"_urlSwitching",!1),F0(x0(N),"_seamlessSwitching",!1),F0(x0(N),"_disconnectRetryCount",0),F0(x0(N),"_preLoadEndPoint",0),F0(x0(N),"_keyframes",null),F0(x0(N),"_acceptRanges",!0),F0(x0(N),"_onProgress",function(){var O=G1(S0().mark(function B(w,R,P,x){var k,f,l,s,Y0,t,K0,q0,R0,U0;return S0().wrap(function W0(z0){while(!0)switch(z0.prev=z0.next){case 0:if(k=P.startTime,f=P.endTime,l=P.st,s=P.firstByteTime,N._loading=!R,N._firstProgressEmit){z0.next=13;break}if(N.media){z0.next=6;break}return(Y0=N._mediaLoader)===null||Y0===void 0||Y0.cancel(),z0.abrupt("return");case 6:t=x.headers,K0=l?s-l:f-k,N.emit(w0.TTFB,{url:N._opts.url,responseUrl:x.url,elapsed:K0}),N.emit(w0.LOAD_RESPONSE_HEADERS,{headers:t}),N._transferCost.set(QY.TTFB,K0),N._acceptRanges=!!(t!==null&&t!==void 0&&t.get("Accept-Ranges"))||!!(t!==null&&t!==void 0&&t.get("Content-Range")),N._firstProgressEmit=!0;case 13:if(N._bufferService){z0.next=15;break}return z0.abrupt("return");case 15:return clearTimeout(N._maxChunkWaitTimer),N._bandwidthService.addChunkRecord(w===null||w===void 0?void 0:w.byteLength,f-k),z0.prev=17,z0.next=20,N._bufferService.appendBuffer(w);case 20:(q0=N._bufferService)===null||q0===void 0||q0.evictBuffer(N._opts.bufferBehind),z0.next=33;break;case 23:if(z0.prev=23,z0.t0=z0.catch(17),!(!N.isLive&&N._bufferService.isFull())){z0.next=32;break}return z0.next=28,N._mediaLoader.cancel();case 28:return N._loading=!1,R0=N.bufferInfo().remaining,N._opts.preloadTime=parseInt(R0)/2,z0.abrupt("return");case 32:return z0.abrupt("return",N._emitError(A1.create(z0.t0)));case 33:if(N._urlSwitching)N._urlSwitching=!1,N.emit(w0.SWITCH_URL_SUCCESS,{url:N._opts.url});if(N._seamlessSwitching)N._seamlessSwitching=!1,N._tick();if(!(R&&!N.media.seeking)){z0.next=40;break}if(N.emit(w0.LOAD_COMPLETE),r1.debug("load done"),N.isLive&&N._disconnectRetryCount<=0)N._end();return z0.abrupt("return");case 40:if(N.isLive){z0.next=42;break}return z0.abrupt("return");case 42:if(U0=N._opts.maxReaderInterval,U0&&N._firstProgressEmit)clearTimeout(N._maxChunkWaitTimer),N._maxChunkWaitTimer=setTimeout(function(){if(N._disconnectRetryCount){N._disconnectRetryCount--,N.load();return}r1.debug("onMaxChunkWait",U0),N._end()},U0);case 44:case"end":return z0.stop()}},B,null,[[17,23]])}));return function(B,w,R,P){return O.apply(this,arguments)}}()),F0(x0(N),"_onRetryError",function(O,B){r1.debug("load retry",O,B),N.emit(w0.LOAD_RETRY,{error:A1.network(O),retryTime:B})}),F0(x0(N),"_end",function(){if(N._clear(),N._bufferService)N._bufferService.endOfStream();r1.debug("end stream")}),F0(x0(N),"_resetDisconnectCount",function(){N._disconnectRetryCount=N._opts.disconnectRetryCount}),F0(x0(N),"_tick",function(){clearTimeout(N._tickTimer);var O=x0(N),B=O.media;if(!B)return;N._tickTimer=setTimeout(N._tick,N._tickInterval);var w=J1.end(J1.get(B));if(w<xJ||!B.readyState)return;var R=N._opts;if(wQ(B)&&B.currentTime){if(N._gapService)N._gapService.do(B,R.maxJumpDistance,N.isLive,3)}else{if(!B.currentTime&&N._gapService&&R.enableStartGapJump){var P=N._opts.mseLowLatency||N._opts.mseLowLatency===!1&&N.bufferInfo(JW).nextStart;if(P)N._gapService.do(B,R.maxJumpDistance,N.isLive,3);return}if(R.isLive&&B.readyState===4&&w-B.currentTime>R.disconnectTime)N.disconnect()}}),F0(x0(N),"_onPlay",function(){var O,B,w=N._opts.softDecode||((O=N.media)===null||O===void 0?void 0:(B=O.buffered)===null||B===void 0?void 0:B.length);if(N.isLive){if(!N._loading&&w)N.replay(void 0,!0);return}var R=N.bufferInfo();if((R.start||R.nextStart)>xJ)N._tick()}),F0(x0(N),"_onLoadeddata",function(){if(N.isLive&&!N._opts.mseLowLatency){if(N.media.duration!==1/0)N._bufferService.updateDuration(1/0).catch(function(O){})}}),F0(x0(N),"_onSeeking",G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!N.isLive&&N.seekable)N._preLoadEndPoint=-1,N._checkPreload();case 1:case"end":return w.stop()}},O)}))),F0(x0(N),"_onTimeupdate",function(){if(!N.media)return;var O=N._opts,B=N.media.currentTime;if(O.isLive&&O.maxLatency&&O.targetLatency){var w=J1.end(J1.get(N.media)),R=w-B;if(R>=O.maxLatency)N.media.currentTime=w-O.targetLatency,N.emit(w0.CHASEFRAME,{currentTime:N.media.currentTime,latency:O.targetLatency})}if(N._seiService.throw(B,!0),O.isLive||!N.seekable||N._loading)return;N._checkPreload()}),F0(x0(N),"_onWaiting",function(){if(N.isLive&&!N._loading&&N._disconnectRetryCount)N._disconnectRetryCount--,N.load()}),F0(x0(N),"_onBufferUpdate",function(){if(N._opts.isLive)return;var O=N.bufferInfo(),B=O.end,w=O.nextEnd;if(Math.abs((B||w)-N.media.duration)<1){if(N._end(),N.media.readyState<=2)N._tick()}}),F0(x0(N),"_checkPreload",G1(S0().mark(function O(){var B,w,R,P,x,k,f,l,s,Y0;return S0().wrap(function t(K0){while(!0)switch(K0.prev=K0.next){case 0:if(B=N.bufferInfo(),w=B.remaining,R=w===void 0?0:w,P=N._opts,x=N._keyframes.filepositions,k=N._keyframes.times,f=N.media.currentTime,!(R<P.preloadTime)){K0.next=19;break}if(l=_Q(N._keyframes.times,f+R+xJ),s=_Q(N._keyframes.times,f+R+N._opts.preloadTime),s===l)s=l+1;if(N._preLoadEndPoint!==s){K0.next=11;break}return K0.abrupt("return");case 11:if(Y0=x[l],!(Y0===null||Y0===void 0)){K0.next=14;break}return K0.abrupt("return");case 14:return K0.next=16,N._mediaLoader.cancel();case 16:N._loadData(null,[Y0,x[s]]),N._preLoadEndPoint=s,N._bufferService.unContiguous(k[l]);case 19:case"end":return K0.stop()}},O)}))),F0(x0(N),"_onFlvScriptData",function(O){var B,w,R,P,x=(B=O.data)===null||B===void 0?void 0:(w=B.onMetaData)===null||w===void 0?void 0:w.keyframes,k=(R=O.data)===null||R===void 0?void 0:(P=R.onMetaData)===null||P===void 0?void 0:P.duration;if(x)N._keyframes=x;if(!N._opts.isLive&&k)N._bufferService.updateDuration(k)}),N._opts=l8(U),N.media=N._opts.media||document.createElement("video"),N._opts.media=null,N._firstProgressEmit=!1,N._mediaLoader=new LQ(y1(y1({},N._opts.fetchOptions),{},{retry:N._opts.retryCount,retryDelay:N._opts.retryDelay,timeout:N._opts.loadTimeout,onRetryError:N._onRetryError,onProgress:N._onProgress,responseType:"arraybuffer"})),N._disconnectRetryCount=N._opts.disconnectRetryCount,N._transferCost=new f8,N._bufferService=new c8(x0(N),N._opts.softDecode?N.media:void 0,N._opts),N._seiService=new MQ(x0(N)),N._bandwidthService=new CQ({chunkCountForSpeed:N._opts.chunkCountForSpeed,skipChunkSize:N._opts.skipChunkSize,longtimeNoReceived:N._opts.longtimeNoReceived}),N._stats=new DQ(x0(N)),!N._opts.softDecode)N._gapService=new bQ;return N.media.addEventListener("play",N._onPlay),N.media.addEventListener("loadeddata",N._onLoadeddata),N.media.addEventListener("seeking",N._onSeeking),N.media.addEventListener("timeupdate",N._onTimeupdate),N.media.addEventListener("progress",N._onBufferUpdate),N.media.addEventListener("waiting",N._onWaiting),N.on(w0.FLV_SCRIPT_DATA,N._onFlvScriptData),N}return bY(K,[{key:"version",get:function U(){return"3.0.21"}},{key:"isLive",get:function U(){return this._opts.isLive}},{key:"baseDts",get:function U(){var N;return(N=this._bufferService)===null||N===void 0?void 0:N.baseDts}},{key:"seekable",get:function U(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function U(){return this._mediaLoader}},{key:"blobUrl",get:function U(){var N;return(N=this._bufferService)===null||N===void 0?void 0:N.blobUrl}},{key:"speedInfo",value:function U(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function U(){return this._stats.getStats()}},{key:"bufferInfo",value:function U(){var N,O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xJ;return J1.info(J1.get(this.media),(N=this.media)===null||N===void 0?void 0:N.currentTime,O)}},{key:"playbackQuality",value:function U(){return RQ(this.media)}},{key:"load",value:function(){var U=G1(S0().mark(function O(B){var w,R=arguments;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(w=R.length>1&&R[1]!==void 0?R[1]:!1,this._bufferService){x.next=3;break}return x.abrupt("return");case 3:return x.next=5,this._reset(w);case 5:this._loadData(B,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return x.stop()}},O,this)}));function N(O){return U.apply(this,arguments)}return N}()},{key:"replay",value:function(){var U=G1(S0().mark(function O(){var B=this,w,R,P=arguments;return S0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(w=P.length>0&&P[0]!==void 0?P[0]:this._opts.seamlesslyReload,R=P.length>1?P[1]:void 0,this.media){k.next=4;break}return k.abrupt("return");case 4:if(this._resetDisconnectCount(),!w){k.next=11;break}return k.next=8,this._clear();case 8:setTimeout(function(){B._seamlessSwitching=!0,B._loadData(B._opts.url),B._bufferService.seamlessSwitch()}),k.next=13;break;case 11:return k.next=13,this.load();case 13:return k.abrupt("return",this.media.play(!R).catch(function(){}));case 14:case"end":return k.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"disconnect",value:function U(){var N;return r1.debug("disconnect!"),(N=this._bufferService)===null||N===void 0||N.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var U=G1(S0().mark(function O(B,w){var R=this;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(this._bufferService){x.next=2;break}return x.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&w)){x.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var k=G1(S0().mark(function f(l){return S0().wrap(function s(Y0){while(!0)switch(Y0.prev=Y0.next){case 0:return Y0.next=2,R._clear();case 2:R._bufferService.seamlessLoadingSwitching=!0,R._urlSwitching=!0,R._seamlessSwitching=!0,R._bufferService.seamlessSwitch(),R._loadData(B);case 7:case"end":return Y0.stop()}},f)}));return function(f){return k.apply(this,arguments)}}(),x.abrupt("return");case 6:if(!(!w||!this._opts.isLive)){x.next=11;break}return x.next=9,this.load(B);case 9:return this._urlSwitching=!0,x.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return x.next=13,this._clear();case 13:setTimeout(function(){R._urlSwitching=!0,R._seamlessSwitching=!0,R._loadData(B),R._bufferService.seamlessSwitch()});case 14:case"end":return x.stop()}},O,this)}));function N(O,B){return U.apply(this,arguments)}return N}()},{key:"destroy",value:function(){var U=G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(this.media){w.next=2;break}return w.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),w.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return w.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_emitError",value:function U(N){var O,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(r1.table(N),r1.error(N),r1.error((O=this.media)===null||O===void 0?void 0:O.error),this._urlSwitching)this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(w0.SWITCH_URL_FAILED,N);if(this.emit(w0.ERROR,N),B)this._seiService.reset(),this._end()}},{key:"_reset",value:function(){var U=G1(S0().mark(function O(){var B,w=arguments;return S0().wrap(function R(P){while(!0)switch(P.prev=P.next){case 0:return B=w.length>0&&w[0]!==void 0?w[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),P.next=6,this._clear();case 6:return P.next=8,this._bufferService.reset(B);case 8:case"end":return P.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_loadData",value:function(){var U=G1(S0().mark(function O(B,w){var R;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(B)this._opts.url=B;if(R=B=this._opts.url,B){x.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl)R=this._opts.preProcessUrl(B).url;if(this._mediaLoader.finnalUrl=R,this.emit(w0.LOAD_START,{url:R,seamlessSwitching:this._seamlessSwitching}),r1.debug("load data, loading:",this._loading,R),!this._loading){x.next=11;break}return x.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,x.prev=12,x.next=15,this._mediaLoader.load({url:R,range:w});case 15:x.next=21;break;case 17:return x.prev=17,x.t0=x.catch(12),this._loading=!1,x.abrupt("return",this._emitError(A1.network(x.t0),!1));case 21:case"end":return x.stop()}},O,this,[[12,17]])}));function N(O,B){return U.apply(this,arguments)}return N}()},{key:"_clear",value:function(){var U=G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!this._mediaLoader){w.next=3;break}return w.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return w.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()}],[{key:"isSupported",value:function U(N){if(!N||N==="video"||N==="audio")return NY.isSupported();return typeof WebAssembly!=="undefined"}},{key:"enableLogger",value:function U(){D1.enable(),AY.enable()}},{key:"disableLogger",value:function U(){D1.disable(),AY.disable()}}]),K}(d8.default);try{if(localStorage.getItem("xgd"))aY.enableLogger();else aY.disableLogger()}catch(j){}var i8=IY(o8(),1);var export_Hls=i8.default;export{export_Hls as Hls,aY as Flv};
33
+ iife