lemon-mse 0.3.9 → 0.4.1

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.
@@ -0,0 +1,35 @@
1
+ (function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
2
+ "use strict";var Sh=Object.create;var Ai=Object.defineProperty;var Th=Object.getOwnPropertyDescriptor;var Ah=Object.getOwnPropertyNames;var bh=Object.getPrototypeOf,Lh=Object.prototype.hasOwnProperty;var Ks=(v,m)=>()=>(m||v((m={exports:{}}).exports,m),m.exports),xh=(v,m)=>{for(var o in m)Ai(v,o,{get:m[o],enumerable:!0})},Ws=(v,m,o,h)=>{if(m&&typeof m=="object"||typeof m=="function")for(let f of Ah(m))!Lh.call(v,f)&&f!==o&&Ai(v,f,{get:()=>m[f],enumerable:!(h=Th(m,f))||h.enumerable});return v};var Ar=(v,m,o)=>(o=v!=null?Sh(bh(v)):{},Ws(m||!v||!v.__esModule?Ai(o,"default",{value:v,enumerable:!0}):o,v)),Rh=v=>Ws(Ai({},"__esModule",{value:!0}),v);var xr=Ks((dd,En)=>{"use strict";var Ih=Object.prototype.hasOwnProperty,mt="~";function Hr(){}Object.create&&(Hr.prototype=Object.create(null),new Hr().__proto__||(mt=!1));function wh(v,m,o){this.fn=v,this.context=m,this.once=o||!1}function Qs(v,m,o,h,f){if(typeof o!="function")throw new TypeError("The listener must be a function");var g=new wh(o,h||v,f),E=mt?mt+m:m;return v._events[E]?v._events[E].fn?v._events[E]=[v._events[E],g]:v._events[E].push(g):(v._events[E]=g,v._eventsCount++),v}function Li(v,m){--v._eventsCount===0?v._events=new Hr:delete v._events[m]}function vt(){this._events=new Hr,this._eventsCount=0}vt.prototype.eventNames=function(){var m=[],o,h;if(this._eventsCount===0)return m;for(h in o=this._events)Ih.call(o,h)&&m.push(mt?h.slice(1):h);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(o)):m};vt.prototype.listeners=function(m){var o=mt?mt+m:m,h=this._events[o];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,g=h.length,E=new Array(g);f<g;f++)E[f]=h[f].fn;return E};vt.prototype.listenerCount=function(m){var o=mt?mt+m:m,h=this._events[o];return h?h.fn?1:h.length:0};vt.prototype.emit=function(m,o,h,f,g,E){var _=mt?mt+m:m;if(!this._events[_])return!1;var S=this._events[_],D=arguments.length,P,F;if(S.fn){switch(S.once&&this.removeListener(m,S.fn,void 0,!0),D){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,o),!0;case 3:return S.fn.call(S.context,o,h),!0;case 4:return S.fn.call(S.context,o,h,f),!0;case 5:return S.fn.call(S.context,o,h,f,g),!0;case 6:return S.fn.call(S.context,o,h,f,g,E),!0}for(F=1,P=new Array(D-1);F<D;F++)P[F-1]=arguments[F];S.fn.apply(S.context,P)}else{var H=S.length,W;for(F=0;F<H;F++)switch(S[F].once&&this.removeListener(m,S[F].fn,void 0,!0),D){case 1:S[F].fn.call(S[F].context);break;case 2:S[F].fn.call(S[F].context,o);break;case 3:S[F].fn.call(S[F].context,o,h);break;case 4:S[F].fn.call(S[F].context,o,h,f);break;default:if(!P)for(W=1,P=new Array(D-1);W<D;W++)P[W-1]=arguments[W];S[F].fn.apply(S[F].context,P)}}return!0};vt.prototype.on=function(m,o,h){return Qs(this,m,o,h,!1)};vt.prototype.once=function(m,o,h){return Qs(this,m,o,h,!0)};vt.prototype.removeListener=function(m,o,h,f){var g=mt?mt+m:m;if(!this._events[g])return this;if(!o)return Li(this,g),this;var E=this._events[g];if(E.fn)E.fn===o&&(!f||E.once)&&(!h||E.context===h)&&Li(this,g);else{for(var _=0,S=[],D=E.length;_<D;_++)(E[_].fn!==o||f&&!E[_].once||h&&E[_].context!==h)&&S.push(E[_]);S.length?this._events[g]=S.length===1?S[0]:S:Li(this,g)}return this};vt.prototype.removeAllListeners=function(m){var o;return m?(o=mt?mt+m:m,this._events[o]&&Li(this,o)):(this._events=new Hr,this._eventsCount=0),this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.addListener=vt.prototype.on;vt.prefixed=mt;vt.EventEmitter=vt;typeof En<"u"&&(En.exports=vt)});var Qo=Ks((Xo,Kn)=>{(function v(m){(function(o,h){typeof Xo=="object"&&typeof Kn<"u"?Kn.exports=h():typeof define=="function"&&define.amd?define(h):(o=typeof globalThis<"u"?globalThis:o||self,o.Hls=h())})(this,function(){"use strict";function o(n,s,i){if(P())return Reflect.construct.apply(null,arguments);var t=[null];t.push.apply(t,s);var e=new(n.bind.apply(n,t));return i&&W(e,i.prototype),e}function h(n,s){for(var i=0;i<s.length;i++){var t=s[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ee(t.key),t)}}function f(n,s,i){return s&&h(n.prototype,s),i&&h(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function g(n,s,i){return(s=ee(s))in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function E(){return E=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var t in i)({}).hasOwnProperty.call(i,t)&&(n[t]=i[t])}return n},E.apply(null,arguments)}function _(n){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},_(n)}function S(n,s){n.prototype=Object.create(s.prototype),n.prototype.constructor=n,W(n,s)}function D(n){try{return Function.toString.call(n).indexOf("[native code]")!==-1}catch{return typeof n=="function"}}function P(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(P=function(){return!!n})()}function F(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);s&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),i.push.apply(i,t)}return i}function H(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?F(Object(i),!0).forEach(function(t){g(n,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):F(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}function W(n,s){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,t){return i.__proto__=t,i},W(n,s)}function $(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var t=i.call(n,s);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function ee(n){var s=$(n,"string");return typeof s=="symbol"?s:s+""}function Z(n){var s=typeof Map=="function"?new Map:void 0;return Z=function(i){if(i===null||!D(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(i))return s.get(i);s.set(i,t)}function t(){return o(i,arguments,_(this).constructor)}return t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),W(t,i)},Z(n)}function oe(){try{return crypto.randomUUID()}catch{try{var n=URL.createObjectURL(new Blob),s=n.toString();return URL.revokeObjectURL(n),s.slice(s.lastIndexOf("/")+1)}catch{var i=new Date().getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var u=(i+Math.random()*16)%16|0;return i=Math.floor(i/16),(a=="x"?u:u&3|8).toString(16)});return t}}}function ue(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Se={exports:{}},he;function se(){return he||(he=1,function(n){var s=Object.prototype.hasOwnProperty,i="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(i=!1));function e(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function r(l,d,c,p,y){if(typeof c!="function")throw new TypeError("The listener must be a function");var A=new e(c,p||l,y),T=i?i+d:d;return l._events[T]?l._events[T].fn?l._events[T]=[l._events[T],A]:l._events[T].push(A):(l._events[T]=A,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new t:delete l._events[d]}function u(){this._events=new t,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],c,p;if(this._eventsCount===0)return d;for(p in c=this._events)s.call(c,p)&&d.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},u.prototype.listeners=function(d){var c=i?i+d:d,p=this._events[c];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,A=p.length,T=new Array(A);y<A;y++)T[y]=p[y].fn;return T},u.prototype.listenerCount=function(d){var c=i?i+d:d,p=this._events[c];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,c,p,y,A,T){var b=i?i+d:d;if(!this._events[b])return!1;var L=this._events[b],R=arguments.length,C,I;if(L.fn){switch(L.once&&this.removeListener(d,L.fn,void 0,!0),R){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,c),!0;case 3:return L.fn.call(L.context,c,p),!0;case 4:return L.fn.call(L.context,c,p,y),!0;case 5:return L.fn.call(L.context,c,p,y,A),!0;case 6:return L.fn.call(L.context,c,p,y,A,T),!0}for(I=1,C=new Array(R-1);I<R;I++)C[I-1]=arguments[I];L.fn.apply(L.context,C)}else{var k=L.length,O;for(I=0;I<k;I++)switch(L[I].once&&this.removeListener(d,L[I].fn,void 0,!0),R){case 1:L[I].fn.call(L[I].context);break;case 2:L[I].fn.call(L[I].context,c);break;case 3:L[I].fn.call(L[I].context,c,p);break;case 4:L[I].fn.call(L[I].context,c,p,y);break;default:if(!C)for(O=1,C=new Array(R-1);O<R;O++)C[O-1]=arguments[O];L[I].fn.apply(L[I].context,C)}}return!0},u.prototype.on=function(d,c,p){return r(this,d,c,p,!1)},u.prototype.once=function(d,c,p){return r(this,d,c,p,!0)},u.prototype.removeListener=function(d,c,p,y){var A=i?i+d:d;if(!this._events[A])return this;if(!c)return a(this,A),this;var T=this._events[A];if(T.fn)T.fn===c&&(!y||T.once)&&(!p||T.context===p)&&a(this,A);else{for(var b=0,L=[],R=T.length;b<R;b++)(T[b].fn!==c||y&&!T[b].once||p&&T[b].context!==p)&&L.push(T[b]);L.length?this._events[A]=L.length===1?L[0]:L:a(this,A)}return this},u.prototype.removeAllListeners=function(d){var c;return d?(c=i?i+d:d,this._events[c]&&a(this,c)):(this._events=new t,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,n.exports=u}(Se)),Se.exports}var ce=se(),Me=ue(ce),We={exports:{}},ye;function Ie(){return ye||(ye=1,function(n,s){(function(i){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,e=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var p=u.parseURL(l);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 c.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var A=u.parseURL(l);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var T=e.exec(A.path);A.netLoc=T[1],A.path=T[2]}A.netLoc&&!A.path&&(A.path="/");var b={scheme:A.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(b.netLoc=A.netLoc,y.path[0]!=="/"))if(!y.path)b.path=A.path,y.params||(b.params=A.params,y.query||(b.query=A.query));else{var L=A.path,R=L.substring(0,L.lastIndexOf("/")+1)+y.path;b.path=u.normalizePath(R)}return b.path===null&&(b.path=c.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(b)},parseURL:function(l){var d=t.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=u})()}(We)),We.exports}var Ze=Ie(),w=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},U=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=G},G=Number.MAX_SAFE_INTEGER||9007199254740991,Y=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),M=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",n.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",n.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.ASSET_LIST_LOAD_ERROR="assetListLoadError",n.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",n.ASSET_LIST_PARSING_ERROR="assetListParsingError",n.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.ATTACH_MEDIA_ERROR="attachMediaError",n.UNKNOWN="unknown",n}({}),x=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.MEDIA_ENDED="hlsMediaEnded",n.STALL_RESOLVED="hlsStallResolved",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFERED_TO_END="hlsBufferedToEnd",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n.ASSET_LIST_LOADING="hlsAssetListLoading",n.ASSET_LIST_LOADED="hlsAssetListLoaded",n.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",n.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",n.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",n.INTERSTITIAL_STARTED="hlsInterstitialStarted",n.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",n.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",n.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",n.INTERSTITIAL_ENDED="hlsInterstitialEnded",n.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",n.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",n.EVENT_CUE_ENTER="hlsEventCueEnter",n}({}),ie={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ae={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Re=function(){function n(i,t,e){t===void 0&&(t=0),e===void 0&&(e=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_=t,this.totalWeight_=e}var s=n.prototype;return s.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},n}(),Ue=function(){function n(i,t,e,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_=e,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Re(i),this.fast_=new Re(t),this.defaultTTFB_=r,this.ttfb_=new Re(i)}var s=n.prototype;return s.update=function(t,e){var r=this.slow_,a=this.fast_,u=this.ttfb_;r.halfLife!==t&&(this.slow_=new Re(t,r.getEstimate(),r.getTotalWeight())),a.halfLife!==e&&(this.fast_=new Re(e,a.getEstimate(),a.getTotalWeight())),u.halfLife!==t&&(this.ttfb_=new Re(t,u.getEstimate(),u.getTotalWeight()))},s.sample=function(t,e){t=Math.max(t,this.minDelayMs_);var r=8*e,a=t/1e3,u=r/a;this.fast_.sample(a,u),this.slow_.sample(a,u)},s.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},f(n,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),je=function(s,i){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 t="["+s+"]:";this.trace=xe,this.debug=i.debug.bind(null,t),this.log=i.log.bind(null,t),this.warn=i.warn.bind(null,t),this.info=i.info.bind(null,t),this.error=i.error.bind(null,t)},xe=function(){},Ir={trace:xe,debug:xe,log:xe,warn:xe,info:xe,error:xe};function Dt(){return E({},Ir)}function wr(n,s){var i=self.console[n];return i?i.bind(self.console,(s?"["+s+"] ":"")+"["+n+"] >"):xe}function Pr(n,s,i){return s[n]?s[n].bind(s):wr(n,i)}var Zr=Dt();function Je(n,s,i){var t=Dt();if(typeof console=="object"&&n===!0||typeof n=="object"){var e=["debug","log","info","warn","error"];e.forEach(function(r){t[r]=Pr(r,n,i)});try{t.log('Debug logs enabled for "'+s+'" in hls.js version 1.6.0')}catch{return Dt()}e.forEach(function(r){Zr[r]=Pr(r,n)})}else E(Zr,t);return t}var Oe=Zr,Mi,jn;function Zo(){return jn||(jn=1,Mi=void 0),Mi}var Yn=Zo(),Jo=ue(Yn);function Pt(n,s){if(s===void 0&&(s=!1),typeof TextDecoder<"u"){var i=new TextDecoder("utf-8"),t=i.decode(n);if(s){var e=t.indexOf("\0");return e!==-1?t.substring(0,e):t}return t.replace(/\0/g,"")}for(var r=n.length,a,u,l,d="",c=0;c<r;){if(a=n[c++],a===0&&s)return d;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(a);break;case 12:case 13:u=n[c++],d+=String.fromCharCode((a&31)<<6|u&63);break;case 14:u=n[c++],l=n[c++],d+=String.fromCharCode((a&15)<<12|(u&63)<<6|(l&63)<<0);break}}return d}var zn={hexDump:function(s){for(var i="",t=0;t<s.length;t++){var e=s[t].toString(16);e.length<2&&(e="0"+e),i+=e}return i}},Fi=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}},qe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},qn=function(){function n(i){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof i=="string"&&(i={url:i}),this.base=i,tu(this,"stats")}var s=n.prototype;return s.setByteRange=function(t,e){var r=t.split("@",2),a;r.length===1?a=e?.byteRangeEndOffset||0:a=parseInt(r[1]),this._byteRange=[a,parseInt(r[0])+a]},s.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[qe.AUDIO]=null,t[qe.VIDEO]=null,t[qe.AUDIOVIDEO]=null},f(n,[{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return this._byteRange===null?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){if(this._streams===null){var t;this._streams=(t={},t[qe.AUDIO]=null,t[qe.VIDEO]=null,t[qe.AUDIOVIDEO]=null,t)}return this._streams},set:function(t){this._streams=t}},{key:"hasStats",get:function(){return this._stats!==null}},{key:"hasStreams",get:function(){return this._streams!==null}},{key:"stats",get:function(){return this._stats===null&&(this._stats=new Fi),this._stats},set:function(t){this._stats=t}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ze.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}])}();function jt(n){return n.sn!=="initSegment"}var Ni=function(n){function s(t,e){var r;return r=n.call(this,e)||this,r._decryptdata=null,r._programDateTime=null,r._ref=null,r._bitrate=void 0,r.rawProgramDateTime=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.playlistOffset=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,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=t,r}S(s,n);var i=s.prototype;return i.addStart=function(e){this.setStart(this.start+e)},i.setStart=function(e){this.start=e,this._ref&&(this._ref.start=e)},i.setDuration=function(e){this.duration=e,this._ref&&(this._ref.duration=e)},i.setKeyFormat=function(e){if(this.levelkeys){var r=this.levelkeys[e];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var e,r;(e=this.loader)==null||e.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(e,r,a,u,l,d){d===void 0&&(d=!1);var c=this.elementaryStreams,p=c[e];if(!p){c[e]={startPTS:r,endPTS:a,startDTS:u,endDTS:l,partial:d};return}p.startPTS=Math.min(p.startPTS,r),p.endPTS=Math.max(p.endPTS,a),p.startDTS=Math.min(p.startDTS,u),p.endDTS=Math.max(p.endDTS,l)},f(s,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var r=this.byteRange[0],a=this.byteRange[1];if(w(r)&&w(a))return a-r}return null}},{key:"bitrate",get:function(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e=this.levelkeys;if(!e&&!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 a=Object.keys(this.levelkeys);if(a.length===1)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;var e=w(this.duration)?this.duration:0;return this.programDateTime+e*1e3}},{key:"encrypted",get:function(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),a=r.length;if(a>1||a===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){if(!w(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}},{key:"ref",get:function(){return jt(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(qn),eu=function(n){function s(i,t,e,r,a){var u;u=n.call(this,e)||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.duration=i.decimalFloatingPoint("DURATION"),u.gap=i.bool("GAP"),u.independent=i.bool("INDEPENDENT"),u.relurl=i.enumeratedString("URI"),u.fragment=t,u.index=r;var l=i.enumeratedString("BYTERANGE");return l&&u.setByteRange(l,a),a&&(u.fragOffset=a.fragOffset+a.duration),u}return S(s,n),f(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}])}(qn);function $n(n,s){var i=Object.getPrototypeOf(n);if(i){var t=Object.getOwnPropertyDescriptor(i,s);return t||$n(i,s)}}function tu(n,s){var i=$n(n,s);i&&(i.enumerable=!0,Object.defineProperty(n,s,i))}var Jr=Math.pow(2,32)-1,ru=[].push,Xn={video:1,audio:2,id3:3,text:4};function st(n){return String.fromCharCode.apply(null,n)}function Qn(n,s){var i=n[s]<<8|n[s+1];return i<0?65536+i:i}function Ee(n,s){var i=Jn(n,s);return i<0?4294967296+i:i}function Zn(n,s){var i=Ee(n,s);return i*=Math.pow(2,32),i+=Ee(n,s+4),i}function Jn(n,s){return n[s]<<24|n[s+1]<<16|n[s+2]<<8|n[s+3]}function Ui(n,s,i){n[s]=i>>24,n[s+1]=i>>16&255,n[s+2]=i>>8&255,n[s+3]=i&255}function iu(n){for(var s=n.byteLength,i=0;i<s;){var t=Ee(n,i);if(t>8&&n[i+4]===109&&n[i+5]===111&&n[i+6]===111&&n[i+7]===102)return!0;i=t>1?i+t:s}return!1}function Te(n,s){var i=[];if(!s.length)return i;for(var t=n.byteLength,e=0;e<t;){var r=Ee(n,e),a=st(n.subarray(e+4,e+8)),u=r>1?e+r:t;if(a===s[0])if(s.length===1)i.push(n.subarray(e+8,u));else{var l=Te(n.subarray(e+8,u),s.slice(1));l.length&&ru.apply(i,l)}e=u}return i}function nu(n){var s=[],i=n[0],t=8,e=Ee(n,t);t+=4;var r=0,a=0;i===0?(r=Ee(n,t),a=Ee(n,t+4),t+=8):(r=Zn(n,t),a=Zn(n,t+8),t+=16),t+=2;var u=n.length+a,l=Qn(n,t);t+=2;for(var d=0;d<l;d++){var c=t,p=Ee(n,c);c+=4;var y=p&2147483647,A=(p&2147483648)>>>31;if(A===1)return Oe.warn("SIDX has hierarchical references (not supported)"),null;var T=Ee(n,c);c+=4,s.push({referenceSize:y,subsegmentDuration:T,info:{duration:T/e,start:u,end:u+y-1}}),u+=y,c+=4,t=c}return{earliestPresentationTime:r,timescale:e,version:i,referencesCount:l,references:s}}function ea(n){for(var s=[],i=Te(n,["moov","trak"]),t=0;t<i.length;t++){var e=i[t],r=Te(e,["tkhd"])[0];if(r){var a=r[0],u=Ee(r,a===0?12:20),l=Te(e,["mdia","mdhd"])[0];if(l){a=l[0];var d=Ee(l,a===0?12:20),c=Te(e,["mdia","hdlr"])[0];if(c){var p=st(c.subarray(8,12)),y={soun:qe.AUDIO,vide:qe.VIDEO}[p],A=Te(e,["mdia","minf","stbl","stsd"])[0],T=au(A);y?(s[u]={timescale:d,type:y,stsd:T},s[y]=H({timescale:d,id:u},T)):s[u]={timescale:d,type:p,stsd:T}}}}}var b=Te(n,["moov","mvex","trex"]);return b.forEach(function(L){var R=Ee(L,4),C=s[R];C&&(C.default={duration:Ee(L,12),flags:Ee(L,20)})}),s}function au(n){var s=n.subarray(8),i=s.subarray(86),t=st(s.subarray(4,8)),e=t,r,a=t==="enca"||t==="encv";if(a){var u=Te(s,[t])[0],l=u.subarray(t==="enca"?28:78),d=Te(l,["sinf"]);d.forEach(function(dt){var xt=Te(dt,["schm"])[0];if(xt){var Ye=st(xt.subarray(4,8));if(Ye==="cbcs"||Ye==="cenc"){var ct=Te(dt,["frma"])[0];ct&&(e=st(ct))}}})}var c=e;switch(e){case"avc1":case"avc2":case"avc3":case"avc4":{var p=Te(i,["avcC"])[0];e+="."+ti(p[1])+ti(p[2])+ti(p[3]),r=ei(c==="avc1"?"dva1":"dvav",i);break}case"mp4a":{var y=Te(s,[t])[0],A=Te(y.subarray(28),["esds"])[0];if(A&&A.length>7){var T=4;if(A[T++]!==3)break;T=Bi(A,T),T+=2;var b=A[T++];if(b&128&&(T+=2),b&64&&(T+=A[T++]),A[T++]!==4)break;T=Bi(A,T);var L=A[T++];if(L===64)e+="."+ti(L);else break;if(T+=12,A[T++]!==5)break;T=Bi(A,T);var R=A[T++],C=(R&248)>>3;C===31&&(C+=1+((R&7)<<3)+((A[T]&224)>>5)),e+="."+C}break}case"hvc1":case"hev1":{var I=Te(i,["hvcC"]);if(I){var k=I[0],O=k[1],V=["","A","B","C"][O>>6],N=O&31,B=Ee(k,2),X=(O&32)>>5?"H":"L",z=k[12],K=k.subarray(6,12);e+="."+V+N,e+="."+B.toString(16).toUpperCase(),e+="."+X+z;for(var j="",J=K.length;J--;){var le=K[J];if(le||j){var re=le.toString(16).toUpperCase();j="."+re+j}}e+=j}r=ei(c=="hev1"?"dvhe":"dvh1",i);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{e=ei(e,i)||e;break}case"vp09":{var te=Te(i,["vpcC"])[0],fe=te[4],de=te[5],ve=te[6]>>4&15;e+="."+Yt(fe)+"."+Yt(de)+"."+Yt(ve);break}case"av01":{var ge=Te(i,["av1C"])[0],Ne=ge[1]>>>5,we=ge[1]&31,Be=ge[2]>>>7?"H":"M",Ce=(ge[2]&64)>>6,et=(ge[2]&32)>>5,Ge=Ne===2&&Ce?et?12:10:Ce?10:8,Qe=(ge[2]&16)>>4,_t=(ge[2]&8)>>3,ut=(ge[2]&4)>>2,Ve=ge[2]&3,St=1,it=1,$e=1,Tt=0;e+="."+Ne+"."+Yt(we)+Be+"."+Yt(Ge)+"."+Qe+"."+_t+ut+Ve+"."+Yt(St)+"."+Yt(it)+"."+Yt($e)+"."+Tt,r=ei("dav1",i);break}}return{codec:e,encrypted:a,supplemental:r}}function ei(n,s){var i=Te(s,["dvvC"]),t=i.length?i[0]:Te(s,["dvcC"])[0];if(t){var e=t[2]>>1&127,r=t[2]<<5&32|t[3]>>3&31;return n+"."+Yt(e)+"."+Yt(r)}}function Bi(n,s){for(var i=s+5;n[s++]&128&&s<i;);return s}function ti(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Yt(n){return(n<10?"0":"")+n}function su(n,s){if(!n||!s)return n;var i=s.keyId;if(i&&s.isCommonEncryption){var t=Te(n,["moov","trak"]);t.forEach(function(e){var r=Te(e,["mdia","minf","stbl","stsd"])[0],a=r.subarray(8),u=Te(a,["enca"]),l=u.length>0;l||(u=Te(a,["encv"])),u.forEach(function(d){var c=l?d.subarray(28):d.subarray(78),p=Te(c,["sinf"]);p.forEach(function(y){var A=ou(y);if(A){var T=A.subarray(8,24);T.some(function(b){return b!==0})||(Oe.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+zn.hexDump(T)+" -> "+zn.hexDump(i)),A.set(i,8))}})})})}return n}function ou(n){var s=Te(n,["schm"])[0];if(s){var i=st(s.subarray(4,8));if(i==="cbcs"||i==="cenc")return Te(n,["schi","tenc"])[0]}return null}function uu(n,s){return Te(s,["moof","traf"]).reduce(function(i,t){var e=Te(t,["tfdt"])[0],r=e[0],a=Te(t,["tfhd"]).reduce(function(u,l){var d=Ee(l,4),c=n[d];if(c){var p=Ee(e,4);if(r===1){if(p===Jr)return Oe.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),u;p*=Jr+1,p+=Ee(e,8)}var y=c.timescale||9e4,A=p/y;if(w(A)&&(u===null||A<u))return A}return u},null);return a!==null&&w(a)&&(i===null||a<i)?a:i},null)}function lu(n,s){for(var i=0,t=0,e=0,r=Te(n,["moof","traf"]),a=0;a<r.length;a++){var u=r[a],l=Te(u,["tfhd"])[0],d=Ee(l,4),c=s[d];if(c){var p=c.default,y=Ee(l,0)|p?.flags,A=p?.duration;y&8&&(y&2?A=Ee(l,12):A=Ee(l,8));for(var T=c.timescale||9e4,b=Te(u,["trun"]),L=0;L<b.length;L++){if(i=fu(b[L]),!i&&A){var R=Ee(b[L],4);i=A*R}c.type===qe.VIDEO?t+=i/T:c.type===qe.AUDIO&&(e+=i/T)}}}if(t===0&&e===0){for(var C=1/0,I=0,k=0,O=Te(n,["sidx"]),V=0;V<O.length;V++){var N=nu(O[V]);if(N!=null&&N.references){C=Math.min(C,N.earliestPresentationTime/N.timescale);var B=N.references.reduce(function(X,z){return X+z.info.duration||0},0);I=Math.max(I,B+N.earliestPresentationTime/N.timescale),k=I-C}}if(k&&w(k))return k}return t||e}function fu(n){var s=Ee(n,0),i=8;s&1&&(i+=4),s&4&&(i+=4);for(var t=0,e=Ee(n,4),r=0;r<e;r++){if(s&256){var a=Ee(n,i);t+=a,i+=4}s&512&&(i+=4),s&1024&&(i+=4),s&2048&&(i+=4)}return t}function hu(n,s,i){Te(s,["moof","traf"]).forEach(function(t){Te(t,["tfhd"]).forEach(function(e){var r=Ee(e,4),a=n[r];if(a){var u=a.timescale||9e4;Te(t,["tfdt"]).forEach(function(l){var d=l[0],c=i*u;if(c){var p=Ee(l,4);if(d===0)p-=c,p=Math.max(p,0),Ui(l,4,p);else{p*=Math.pow(2,32),p+=Ee(l,8),p-=c,p=Math.max(p,0);var y=Math.floor(p/(Jr+1)),A=Math.floor(p%(Jr+1));Ui(l,4,y),Ui(l,8,A)}}})}})})}function du(n){var s={valid:null,remainder:null},i=Te(n,["moof"]);if(i.length<2)return s.remainder=n,s;var t=i[i.length-1];return s.valid=n.slice(0,t.byteOffset-8),s.remainder=n.slice(t.byteOffset-8),s}function Ot(n,s){var i=new Uint8Array(n.length+s.length);return i.set(n),i.set(s,n.length),i}function ta(n,s){var i=[],t=s.samples,e=s.timescale,r=s.id,a=!1,u=Te(t,["moof"]);return u.map(function(l){var d=l.byteOffset-8,c=Te(l,["traf"]);c.map(function(p){var y=Te(p,["tfdt"]).map(function(A){var T=A[0],b=Ee(A,4);return T===1&&(b*=Math.pow(2,32),b+=Ee(A,8)),b/e})[0];return y!==void 0&&(n=y),Te(p,["tfhd"]).map(function(A){var T=Ee(A,4),b=Ee(A,0)&16777215,L=(b&1)!==0,R=(b&2)!==0,C=(b&8)!==0,I=0,k=(b&16)!==0,O=0,V=(b&32)!==0,N=8;T===r&&(L&&(N+=8),R&&(N+=4),C&&(I=Ee(A,N),N+=4),k&&(O=Ee(A,N),N+=4),V&&(N+=4),s.type==="video"&&(a=Gi(s.codec)),Te(p,["trun"]).map(function(B){var X=B[0],z=Ee(B,0)&16777215,K=(z&1)!==0,j=0,J=(z&4)!==0,le=(z&256)!==0,re=0,te=(z&512)!==0,fe=0,de=(z&1024)!==0,ve=(z&2048)!==0,ge=0,Ne=Ee(B,4),we=8;K&&(j=Ee(B,we),we+=4),J&&(we+=4);for(var Be=j+d,Ce=0;Ce<Ne;Ce++){if(le?(re=Ee(B,we),we+=4):re=I,te?(fe=Ee(B,we),we+=4):fe=O,de&&(we+=4),ve&&(X===0?ge=Ee(B,we):ge=Jn(B,we),we+=4),s.type===qe.VIDEO)for(var et=0;et<fe;){var Ge=Ee(t,Be);if(Be+=4,cu(a,t[Be])){var Qe=t.subarray(Be,Be+Ge);ra(Qe,a?2:1,n+ge/e,i)}Be+=Ge,et+=Ge+4}n+=re/e}}))})})}),i}function Gi(n){if(!n)return!1;var s=n.substring(0,4);return s==="hvc1"||s==="hev1"||s==="dvh1"||s==="dvhe"}function cu(n,s){if(n){var i=s>>1&63;return i===39||i===40}else{var t=s&31;return t===6}}function ra(n,s,i,t){var e=ia(n),r=0;r+=s;for(var a=0,u=0,l=0;r<e.length;){a=0;do{if(r>=e.length)break;l=e[r++],a+=l}while(l===255);u=0;do{if(r>=e.length)break;l=e[r++],u+=l}while(l===255);var d=e.length-r,c=r;if(u<d)r+=u;else if(u>d){Oe.error("Malformed SEI payload. "+u+" is too small, only "+d+" bytes left to parse.");break}if(a===4){var p=e[c++];if(p===181){var y=Qn(e,c);if(c+=2,y===49){var A=Ee(e,c);if(c+=4,A===1195456820){var T=e[c++];if(T===3){var b=e[c++],L=31&b,R=64&b,C=R?2+L*3:0,I=new Uint8Array(C);if(R){I[0]=b;for(var k=1;k<C;k++)I[k]=e[c++]}t.push({type:T,payloadType:a,pts:i,bytes:I})}}}}}else if(a===5&&u>16){for(var O=[],V=0;V<16;V++){var N=e[c++].toString(16);O.push(N.length==1?"0"+N:N),(V===3||V===5||V===7||V===9)&&O.push("-")}for(var B=u-16,X=new Uint8Array(B),z=0;z<B;z++)X[z]=e[c++];t.push({payloadType:a,pts:i,uuid:O.join(""),userData:Pt(X),userDataBytes:X})}}}function ia(n){for(var s=n.byteLength,i=[],t=1;t<s-2;)n[t]===0&&n[t+1]===0&&n[t+2]===3?(i.push(t+2),t+=2):t++;if(i.length===0)return n;var e=s-i.length,r=new Uint8Array(e),a=0;for(t=0;t<e;a++,t++)a===i[0]&&(a++,i.shift()),r[t]=n[a];return r}function vu(n){var s=n[0],i="",t="",e=0,r=0,a=0,u=0,l=0,d=0;if(s===0){for(;st(n.subarray(d,d+1))!=="\0";)i+=st(n.subarray(d,d+1)),d+=1;for(i+=st(n.subarray(d,d+1)),d+=1;st(n.subarray(d,d+1))!=="\0";)t+=st(n.subarray(d,d+1)),d+=1;t+=st(n.subarray(d,d+1)),d+=1,e=Ee(n,12),r=Ee(n,16),u=Ee(n,20),l=Ee(n,24),d=28}else if(s===1){d+=4,e=Ee(n,d),d+=4;var c=Ee(n,d);d+=4;var p=Ee(n,d);for(d+=4,a=Math.pow(2,32)*c+p,U(a)||(a=Number.MAX_SAFE_INTEGER,Oe.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=Ee(n,d),d+=4,l=Ee(n,d),d+=4;st(n.subarray(d,d+1))!=="\0";)i+=st(n.subarray(d,d+1)),d+=1;for(i+=st(n.subarray(d,d+1)),d+=1;st(n.subarray(d,d+1))!=="\0";)t+=st(n.subarray(d,d+1)),d+=1;t+=st(n.subarray(d,d+1)),d+=1}var y=n.subarray(d,n.byteLength);return{schemeIdUri:i,value:t,timeScale:e,presentationTime:a,presentationTimeDelta:r,eventDuration:u,id:l,payload:y}}function nr(n){if(n===void 0&&(n=!0),!(typeof self>"u")){var s=(n||!self.MediaSource)&&self.ManagedMediaSource;return s||self.MediaSource||self.WebKitMediaSource}}function pu(n){return typeof self<"u"&&n===self.ManagedMediaSource}function gu(n,s){var i=Object.keys(n),t=Object.keys(s),e=i.length,r=t.length;return!e||!r||e===r&&!i.some(function(a){return t.indexOf(a)===-1})}var na=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},gr={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,dav1:.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 aa(n,s){var i=gr[s];return!!i&&!!i[n.slice(0,4)]}function Vi(n,s,i){return i===void 0&&(i=!0),!n.split(",").some(function(t){return!sa(t,s,i)})}function sa(n,s,i){var t;i===void 0&&(i=!0);var e=nr(i);return(t=e?.isTypeSupported(Or(n,s)))!=null?t:!1}function Or(n,s){return s+"/mp4;codecs="+n}function oa(n){if(n){var s=n.substring(0,4);return gr.video[s]}return 2}function ri(n){var s=na();return n.split(",").reduce(function(i,t){var e=s&&Gi(t),r=e?9:gr.video[t];return r?(r*2+i)/(i?3:2):(gr.audio[t]+i)/(i?2:1)},0)}var Hi={};function mu(n,s){if(s===void 0&&(s=!0),Hi[n])return Hi[n];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[n],t=0;t<i.length;t++){var e;if(sa(i[t],"audio",s))return Hi[n]=i[t],i[t];if(i[t]==="mp3"&&(e=nr(s))!=null&&e.isTypeSupported("audio/mpeg"))return""}return n}var yu=/flac|opus|mp4a\.40\.34/i;function ii(n,s){return s===void 0&&(s=!0),n.replace(yu,function(i){return mu(i.toLowerCase(),s)})}function Eu(n,s){var i=[];if(n)for(var t=n.split(","),e=0;e<t.length;e++)aa(t[e],"video")||i.push(t[e]);return s&&i.push(s),i.join(",")}function ni(n,s){if(n&&(n.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(n)!==-1))return n;if(s){var i=s.split(",");if(i.length>1){if(n){for(var t=i.length;t--;)if(i[t].substring(0,4)===n.substring(0,4))return i[t]}return i[0]}}return s||n}function _u(n){for(var s=n.split(","),i=0;i<s.length;i++){var t=s[i].split(".");if(t.length>2){var e=t.shift()+".";e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),s[i]=e}}return s.join(",")}function Su(n){if(n.startsWith("av01.")){for(var s=n.split("."),i=["0","111","01","01","01","0"],t=s.length;t>4&&t<10;t++)s[t]=i[t-4];return s.join(".")}return n}function ua(n){var s=nr(n)||{isTypeSupported:function(){return!1}};return{mpeg:s.isTypeSupported("audio/mpeg"),mp3:s.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function la(n){return n.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var Ki=["NONE","TYPE-0","TYPE-1",null];function Tu(n){return Ki.indexOf(n)>-1}var ai=["SDR","PQ","HLG"];function Au(n){return!!n&&ai.indexOf(n)>-1}var si={No:"",Yes:"YES",v2:"v2"};function fa(n){var s=n.canSkipUntil,i=n.canSkipDateRanges,t=n.age,e=t<s/2;return s&&e?i?si.v2:si.Yes:si.No}var ha=function(){function n(i,t,e){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=t,this.skip=e}var s=n.prototype;return s.addDirectives=function(t){var e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},n}(),da=function(){function n(i){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=[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(r){return!!r}).map(function(r){return r.substring(0,4)}).join(","),"supplemental"in i){var t;this.supplemental=i.supplemental;var e=(t=i.supplemental)==null?void 0:t.videoCodec;e&&e!==i.videoCodec&&(this.codecSet+=","+e.substring(0,4))}this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var s=n.prototype;return s.hasAudioGroup=function(t){return ca(this._audioGroups,t)},s.hasSubtitleGroup=function(t){return ca(this._subtitleGroups,t)},s.addGroupId=function(t,e){if(e){if(t==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(e)===-1&&r.push(e)}else if(t==="text"){var a=this._subtitleGroups;a||(a=this._subtitleGroups=[]),a.indexOf(e)===-1&&a.push(e)}}},s.addFallback=function(){},f(n,[{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(t){}},{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 t;return(t=this.audioGroups)==null?void 0:t[0]}},{key:"textGroupId",get:function(){var t;return(t=this.subtitleGroups)==null?void 0:t[0]}}])}();function ca(n,s){return!s||!n?!1:n.indexOf(s)!==-1}function bu(){if(typeof matchMedia=="function"){var n=matchMedia("(dynamic-range: high)"),s=matchMedia("bad query");if(n.media!==s.media)return n.matches===!0}return!1}function Lu(n,s){var i=!1,t=[];if(n&&(i=n!=="SDR",t=[n]),s){t=s.allowedVideoRanges||ai.slice(0);var e=t.join("")!=="SDR"&&!s.videoCodec;i=s.preferHDR!==void 0?s.preferHDR:e&&bu(),i||(t=["SDR"])}return{preferHDR:i,allowedVideoRanges:t}}var xu=function(s){var i=new WeakSet;return function(t,e){if(s&&(e=s(t,e)),typeof e=="object"&&e!==null){if(i.has(e))return;i.add(e)}return e}},gt=function(s,i){return JSON.stringify(s,xu(i))};function Ru(n,s,i,t,e){for(var r=Object.keys(n),a=t?.channels,u=t?.audioCodec,l=e?.videoCodec,d=a&&parseInt(a)===2,c=!1,p=!1,y=1/0,A=1/0,T=1/0,b=1/0,L=0,R=[],C=Lu(s,e),I=C.preferHDR,k=C.allowedVideoRanges,O=function(){var j=n[r[V]];c||(c=j.channels[2]>0),y=Math.min(y,j.minHeight),A=Math.min(A,j.minFramerate),T=Math.min(T,j.minBitrate);var J=k.filter(function(le){return j.videoRanges[le]>0});J.length>0&&(p=!0)},V=r.length;V--;)O();y=w(y)?y:0,A=w(A)?A:0;var N=Math.max(1080,y),B=Math.max(30,A);T=w(T)?T:i,i=Math.max(T,i),p||(s=void 0);var X=r.length>1,z=r.reduce(function(K,j){var J=n[j];if(j===K)return K;if(R=p?k.filter(function(le){return J.videoRanges[le]>0}):[],X){if(J.minBitrate>i)return zt(j,"min bitrate of "+J.minBitrate+" > current estimate of "+i),K;if(!J.hasDefaultAudio)return zt(j,"no renditions with default or auto-select sound found"),K;if(u&&j.indexOf(u.substring(0,4))%5!==0)return zt(j,'audio codec preference "'+u+'" not found'),K;if(a&&!d){if(!J.channels[a])return zt(j,"no renditions with "+a+" channel sound found (channels options: "+Object.keys(J.channels)+")"),K}else if((!u||d)&&c&&J.channels[2]===0)return zt(j,"no renditions with stereo sound found"),K;if(J.minHeight>N)return zt(j,"min resolution of "+J.minHeight+" > maximum of "+N),K;if(J.minFramerate>B)return zt(j,"min framerate of "+J.minFramerate+" > maximum of "+B),K;if(!R.some(function(le){return J.videoRanges[le]>0}))return zt(j,"no variants with VIDEO-RANGE of "+gt(R)+" found"),K;if(l&&j.indexOf(l.substring(0,4))%5!==0)return zt(j,'video codec preference "'+l+'" not found'),K;if(J.maxScore<L)return zt(j,"max score of "+J.maxScore+" < selected max of "+L),K}return K&&(ri(j)>=ri(K)||J.fragmentError>n[K].fragmentError)?K:(b=J.minIndex,L=J.maxScore,j)},void 0);return{codecSet:z,videoRanges:R,preferHDR:I,minFramerate:A,minBitrate:T,minIndex:b}}function zt(n,s){Oe.log('[abr] start candidates with "'+n+'" ignored because '+s)}function va(n){return n.reduce(function(s,i){var t=s.groups[i.groupId];t||(t=s.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),t.tracks.push(i);var e=i.channels||"2";return t.channels[e]=(t.channels[e]||0)+1,t.hasDefault=t.hasDefault||i.default,t.hasAutoSelect=t.hasAutoSelect||i.autoselect,t.hasDefault&&(s.hasDefaultAudio=!0),t.hasAutoSelect&&(s.hasAutoSelectAudio=!0),s},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Cu(n,s,i,t){return n.slice(i,t+1).reduce(function(e,r,a){if(!r.codecSet)return e;var u=r.audioGroups,l=e[r.codecSet];l||(e[r.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!u,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,r.bitrate);var d=Math.min(r.height,r.width);return l.minHeight=Math.min(l.minHeight,d),l.minFramerate=Math.min(l.minFramerate,r.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,r.score),l.fragmentError+=r.fragmentError,l.videoRanges[r.videoRange]=(l.videoRanges[r.videoRange]||0)+1,e},{})}function pa(n,s){var i;return!!n&&n!==((i=s.loadLevelObj)==null?void 0:i.uri)}var ku=function(n){function s(t){var e;return e=n.call(this,"abr",t.logger)||this,e.hls=void 0,e.lastLevelLoadSec=0,e.lastLoadedFragLevel=-1,e.firstSelection=-1,e._nextAutoLevel=-1,e.nextAutoLevelKey="",e.audioTracksByGroup=null,e.codecTiers=null,e.timer=-1,e.fragCurrent=null,e.partCurrent=null,e.bitrateTestDelay=0,e.rebufferNotice=-1,e.bwEstimator=void 0,e._abandonRulesCheck=function(r){var a,u=e,l=u.fragCurrent,d=u.partCurrent,c=u.hls,p=c.autoLevelEnabled,y=c.media;if(!(!l||!y)){var A=performance.now(),T=d?d.stats:l.stats,b=d?d.duration:l.duration,L=A-T.loading.start,R=c.minAutoLevel,C=l.level,I=e._nextAutoLevel;if(T.aborted||T.loaded&&T.loaded===T.total||C<=R){e.clearTimer(),e._nextAutoLevel=-1;return}if(p){var k=I>-1&&I!==C,O=!!r||k;if(!(!O&&(y.paused||!y.playbackRate||!y.readyState))){var V=c.mainForwardBufferInfo;if(!(!O&&V===null)){var N=e.bwEstimator.getEstimateTTFB(),B=Math.abs(y.playbackRate);if(!(L<=Math.max(N,1e3*(b/(B*2))))){var X=V?V.len/B:0,z=T.loading.first?T.loading.first-T.loading.start:-1,K=T.loaded&&z>-1,j=e.getBwEstimate(),J=c.levels,le=J[C],re=Math.max(T.loaded,Math.round(b*(l.bitrate||le.averageBitrate)/8)),te=K?L-z:L;te<1&&K&&(te=Math.min(L,T.loaded*8/j));var fe=K?T.loaded*1e3/te:0,de=N/1e3,ve=fe?(re-T.loaded)/fe:re*8/j+de;if(!(ve<=X)){var ge=fe?fe*8:j,Ne=((a=r?.details||e.hls.latestLevelDetails)==null?void 0:a.live)===!0,we=e.hls.config.abrBandWidthUpFactor,Be=Number.POSITIVE_INFINITY,Ce;for(Ce=C-1;Ce>R;Ce--){var et=J[Ce].maxBitrate,Ge=!J[Ce].details||Ne;if(Be=e.getTimeToLoadFrag(de,ge,b*et,Ge),Be<Math.min(X,b+de))break}if(!(Be>=ve)&&!(Be>b*10)){K?e.bwEstimator.sample(L-Math.min(N,z),T.loaded):e.bwEstimator.sampleTTFB(L);var Qe=J[Ce].maxBitrate;e.getBwEstimate()*we>Qe&&e.resetEstimator(Qe);var _t=e.findBestLevel(Qe,R,Ce,0,X,1,1);_t>-1&&(Ce=_t),e.warn("Fragment "+l.sn+(d?" part "+d.index:"")+" of level "+C+` is loading too slowly;
3
+ Fragment duration: `+l.duration.toFixed(3)+`
4
+ Time to underbuffer: `+X.toFixed(3)+` s
5
+ Estimated load time for current fragment: `+ve.toFixed(3)+` s
6
+ Estimated load time for down switch fragment: `+Be.toFixed(3)+` s
7
+ TTFB estimate: `+(z|0)+` ms
8
+ Current BW estimate: `+(w(j)?j|0:"Unknown")+` bps
9
+ New BW estimate: `+(e.getBwEstimate()|0)+` bps
10
+ Switching to level `+Ce+" @ "+(Qe|0)+" bps"),c.nextLoadLevel=c.nextAutoLevel=Ce,e.clearTimer();var ut=function(){if(e.clearTimer(),e.fragCurrent===l&&e.hls.loadLevel===Ce&&Ce>0){var St=e.getStarvationDelay();if(e.warn("Aborting inflight request "+(Ce>0?"and switching down":"")+`
11
+ Fragment duration: `+l.duration.toFixed(3)+` s
12
+ Time to underbuffer: `+St.toFixed(3)+" s"),l.abortRequests(),e.fragCurrent=e.partCurrent=null,Ce>R){var it=e.findBestLevel(e.hls.levels[R].bitrate,R,Ce,0,St,1,1);it===-1&&(it=R),e.hls.nextLoadLevel=e.hls.nextAutoLevel=it,e.resetEstimator(e.hls.levels[it].bitrate)}}};k||ve>Be*2?ut():e.timer=self.setInterval(ut,Be*1e3),c.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:d,stats:T})}}}}}}}},e.hls=t,e.bwEstimator=e.initEstimator(),e.registerListeners(),e}S(s,n);var i=s.prototype;return i.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},i.initEstimator=function(){var e=this.hls.config;return new Ue(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},i.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))},i.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},i.onManifestLoading=function(e,r){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},i.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},i.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},i.onFragLoading=function(e,r){var a=r.frag;if(!this.ignoreFragment(a)){if(!a.bitrateTest){var u;this.fragCurrent=a,this.partCurrent=(u=r.part)!=null?u:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},i.onLevelSwitching=function(e,r){this.clearTimer()},i.onError=function(e,r){if(!r.fatal)switch(r.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{var a=r.frag,u=this.fragCurrent,l=this.partCurrent;if(a&&u&&a.sn===u.sn&&a.level===u.level){var d=performance.now(),c=l?l.stats:a.stats,p=d-c.loading.start,y=c.loading.first?c.loading.first-c.loading.start:-1,A=c.loaded&&y>-1;if(A){var T=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(p-Math.min(T,y),c.loaded)}else this.bwEstimator.sampleTTFB(p)}break}}},i.getTimeToLoadFrag=function(e,r,a,u){var l=e+a/r,d=u?e+this.lastLevelLoadSec:0;return l+d},i.onLevelLoaded=function(e,r){var a=this.hls.config,u=r.stats.loading,l=u.end-u.first;w(l)&&(this.lastLevelLoadSec=l/1e3),r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(r.levelInfo)},i.onFragLoaded=function(e,r){var a=r.frag,u=r.part,l=u?u.stats:a.stats;if(a.type===ae.MAIN&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),a.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var d=u?u.duration:a.duration,c=this.hls.levels[a.level],p=(c.loaded?c.loaded.bytes:0)+l.loaded,y=(c.loaded?c.loaded.duration:0)+d;c.loaded={bytes:p,duration:y},c.realBitrate=Math.round(8*p/y)}if(a.bitrateTest){var A={stats:l,frag:a,part:u,id:a.type};this.onFragBuffered(x.FRAG_BUFFERED,A),a.bitrateTest=!1}else this.lastLoadedFragLevel=a.level}},i.onFragBuffered=function(e,r){var a=r.frag,u=r.part,l=u!=null&&u.stats.loaded?u.stats:a.stats;if(!l.aborted&&!this.ignoreFragment(a)){var d=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(d,l.loaded),l.bwEstimate=this.getBwEstimate(),a.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},i.ignoreFragment=function(e){return e.type!==ae.MAIN||e.sn==="initSegment"},i.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},i.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},i.getNextABRAutoLevel=function(){var e=this.fragCurrent,r=this.partCurrent,a=this.hls;if(a.levels.length<=1)return a.loadLevel;var u=a.maxAutoLevel,l=a.config,d=a.minAutoLevel,c=r?r.duration:e?e.duration:0,p=this.getBwEstimate(),y=this.getStarvationDelay(),A=l.abrBandWidthFactor,T=l.abrBandWidthUpFactor;if(y){var b=this.findBestLevel(p,d,u,y,0,A,T);if(b>=0)return this.rebufferNotice=-1,b}var L=c?Math.min(c,l.maxStarvationDelay):l.maxStarvationDelay;if(!y){var R=this.bitrateTestDelay;if(R){var C=c?Math.min(c,l.maxLoadingDelay):l.maxLoadingDelay;L=C-R,this.info("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*L)+" ms"),A=T=1}}var I=this.findBestLevel(p,d,u,y,L,A,T);if(this.rebufferNotice!==I&&(this.rebufferNotice=I,this.info((y?"rebuffering expected":"buffer is empty")+", optimal quality level "+I)),I>-1)return I;var k=a.levels[d],O=a.loadLevelObj;return O&&k?.bitrate<O.bitrate?d:a.loadLevel},i.getStarvationDelay=function(){var e=this.hls,r=e.media;if(!r)return 1/0;var a=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,u=e.mainForwardBufferInfo;return(u?u.len:0)/a},i.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},i.findBestLevel=function(e,r,a,u,l,d,c){var p,y=this,A=u+l,T=this.lastLoadedFragLevel,b=T===-1?this.hls.firstLevel:T,L=this.fragCurrent,R=this.partCurrent,C=this.hls,I=C.levels,k=C.allAudioTracks,O=C.loadLevel,V=C.config;if(I.length===1)return 0;var N=I[b],B=!!((p=this.hls.latestLevelDetails)!=null&&p.live),X=O===-1||T===-1,z,K="SDR",j=N?.frameRate||0,J=V.audioPreference,le=V.videoPreference,re=this.audioTracksByGroup||(this.audioTracksByGroup=va(k)),te=-1;if(X){if(this.firstSelection!==-1)return this.firstSelection;var fe=this.codecTiers||(this.codecTiers=Cu(I,re,r,a)),de=Ru(fe,K,e,J,le),ve=de.codecSet,ge=de.videoRanges,Ne=de.minFramerate,we=de.minBitrate,Be=de.minIndex,Ce=de.preferHDR;te=Be,z=ve,K=Ce?ge[ge.length-1]:ge[0],j=Ne,e=Math.max(e,we),this.log("picked start tier "+gt(de))}else z=N?.codecSet,K=N?.videoRange;for(var et=R?R.duration:L?L.duration:0,Ge=this.bwEstimator.getEstimateTTFB()/1e3,Qe=[],_t=function(){var it,$e=I[Ve],Tt=Ve>b;if(!$e)return 0;if((z&&$e.codecSet!==z||K&&$e.videoRange!==K||Tt&&j>$e.frameRate||!Tt&&j>0&&j<$e.frameRate||$e.supportedResult&&!((it=$e.supportedResult.decodingInfoResults)!=null&&it[0].smooth))&&(!X||Ve!==te))return Qe.push(Ve),0;var dt=$e.details,xt=(R?dt?.partTarget:dt?.averagetargetduration)||et,Ye;Tt?Ye=c*e:Ye=d*e;var ct=et&&u>=et*2&&l===0?$e.averageBitrate:$e.maxBitrate,nt=y.getTimeToLoadFrag(Ge,Ye,ct*xt,dt===void 0),At=Ye>=ct&&(Ve===T||$e.loadError===0&&$e.fragmentError===0)&&(nt<=Ge||!w(nt)||B&&!y.bitrateTestDelay||nt<A);if(At){var Vr=y.forcedAutoLevel;return Ve!==O&&(Vr===-1||Vr!==O)&&(Qe.length&&y.trace("Skipped level(s) "+Qe.join(",")+" of "+a+' max with CODECS and VIDEO-RANGE:"'+I[Qe[0]].codecs+'" '+I[Qe[0]].videoRange+'; not compatible with "'+z+'" '+K),y.info("switch candidate:"+b+"->"+Ve+" adjustedbw("+Math.round(Ye)+")-bitrate="+Math.round(Ye-ct)+" ttfb:"+Ge.toFixed(1)+" avgDuration:"+xt.toFixed(1)+" maxFetchDuration:"+A.toFixed(1)+" fetchDuration:"+nt.toFixed(1)+" firstSelection:"+X+" codecSet:"+$e.codecSet+" videoRange:"+$e.videoRange+" hls.loadLevel:"+O)),X&&(y.firstSelection=Ve),{v:Ve}}},ut,Ve=a;Ve>=r;Ve--)if(ut=_t(),ut!==0&&ut)return ut.v;return-1},i.deriveNextAutoLevel=function(e){var r=this.hls,a=r.maxAutoLevel,u=r.minAutoLevel;return Math.min(Math.max(e,u),a)},f(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,r=e.maxAutoLevel,a=e.minAutoLevel,u=this.getBwEstimate(),l=this.hls.config.maxStarvationDelay,d=this.findBestLevel(u,a,r,0,l,1,1);if(d>-1)return d;var c=this.hls.firstLevel,p=Math.min(Math.max(c,a),r);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+c+" clamped to "+p),p}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,r=this.bwEstimator,a=r.canEstimate(),u=this.lastLoadedFragLevel>-1;if(e!==-1&&(!a||!u||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var l=a&&u?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var d=this.hls.levels;if(d.length>Math.max(e,l)&&d[e].loadError<=d[l].loadError)return e}return this._nextAutoLevel=l,this.nextAutoLevelKey=this.getAutoLevelKey(),l},set:function(e){var r=this.deriveNextAutoLevel(e);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}])}(je),Du=function(){function n(i){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=i}var s=n.prototype;return s.destroy=function(){this.tracks=this.queues=null},s.append=function(t,e,r){if(!(this.queues===null||this.tracks===null)){var a=this.queues[e];a.push(t),a.length===1&&!r&&this.executeNext(e)}},s.appendBlocker=function(t){var e=this;return new Promise(function(r){var a={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.append(a,t)})},s.prependBlocker=function(t){var e=this;return new Promise(function(r){if(e.queues){var a={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.queues[t].unshift(a)}})},s.removeBlockers=function(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(t){var e,r=(e=t[0])==null?void 0:e.label;(r==="async-blocker"||r==="async-blocker-prepend")&&(t[0].execute(),t.splice(0,1))})},s.unblockAudio=function(t){if(this.queues!==null){var e=this.queues.audio;e[0]===t&&this.shiftAndExecuteNext("audio")}},s.executeNext=function(t){if(!(this.queues===null||this.tracks===null)){var e=this.queues[t];if(e.length){var r=e[0];try{r.execute()}catch(l){var a;if(r.onError(l),this.queues===null||this.tracks===null)return;var u=(a=this.tracks[t])==null?void 0:a.buffer;u!=null&&u.updating||this.shiftAndExecuteNext(t)}}}},s.shiftAndExecuteNext=function(t){this.queues!==null&&(this.queues[t].shift(),this.executeNext(t))},s.current=function(t){var e;return((e=this.queues)==null?void 0:e[t][0])||null},s.toString=function(){var t=this.queues,e=this.tracks;return t===null||e===null?"<destroyed>":`
13
+ `+this.list("video")+`
14
+ `+this.list("audio")+`
15
+ `+this.list("audiovideo")+"}"},s.list=function(t){var e,r;return(e=this.queues)!=null&&e[t]||(r=this.tracks)!=null&&r[t]?t+": ("+this.listSbInfo(t)+") "+this.listOps(t):""},s.listSbInfo=function(t){var e,r=(e=this.tracks)==null?void 0:e[t],a=r?.buffer;return a?"SourceBuffer"+(a.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},s.listOps=function(t){var e;return((e=this.queues)==null?void 0:e[t].map(function(r){return r.label}).join(", "))||""},n}(),ga={search:function(s,i){for(var t=0,e=s.length-1,r=null,a=null;t<=e;){r=(t+e)/2|0,a=s[r];var u=i(a);if(u>0)t=r+1;else if(u<0)e=r-1;else return a}return null}};function Iu(n,s,i){if(s===null||!Array.isArray(n)||!n.length||!w(s))return null;var t=n[0].programDateTime;if(s<(t||0))return null;var e=n[n.length-1].endProgramDateTime;if(s>=(e||0))return null;i=i||0;for(var r=0;r<n.length;++r){var a=n[r];if(Pu(s,i,a))return a}return null}function Wi(n,s,i,t,e){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=.005);var r=null;if(n){r=s[1+n.sn-s[0].sn]||null;var a=n.endDTS-i;a>0&&a<15e-7&&(i+=15e-7),r&&n.level!==r.level&&r.end<=n.end&&(r=s[2+n.sn-s[0].sn]||null)}else i===0&&s[0].start===0&&(r=s[0]);if(r&&((!n||n.level===r.level)&&ma(i,t,r)===0||wu(r,n,Math.min(e,t))))return r;var u=ga.search(s,ma.bind(null,i,t));return u&&(u!==n||!r)?u:r}function wu(n,s,i){if(s&&s.start===0&&s.level<n.level&&(s.endPTS||0)>0){var t=s.tagList.reduce(function(e,r){return r[0]==="INF"&&(e+=parseFloat(r[1])),e},i);return n.start<=t}return!1}function ma(n,s,i){if(n===void 0&&(n=0),s===void 0&&(s=0),i.start<=n&&i.start+i.duration>n)return 0;var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-t<=n?1:i.start-t>n&&i.start?-1:0}function Pu(n,s,i){var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,e=i.endProgramDateTime||0;return e-t>n}function Ou(n,s){return ga.search(n,function(i){return i.cc<s?1:i.cc>s?-1:0})}function oi(n){switch(n.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ya(n,s){var i=oi(s);return n.default[(i?"timeout":"error")+"Retry"]}function ji(n,s){var i=n.backoff==="linear"?1:Math.pow(2,s);return Math.min(i*n.retryDelayMs,n.maxRetryDelayMs)}function Ea(n){return H(H({},n),{errorRetry:null,timeoutRetry:null})}function ui(n,s,i,t){if(!n)return!1;var e=t?.code,r=s<n.maxNumRetry&&(Mu(e)||!!i);return n.shouldRetry?n.shouldRetry(n,s,i,t,r):r}function Mu(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}var ht={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Mt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},Fu=function(n){function s(t){var e;return e=n.call(this,"error-controller",t.logger)||this,e.hls=void 0,e.playlistError=0,e.penalizedRenditions={},e.hls=t,e.registerListeners(),e}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},i.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},i.startLoad=function(e){},i.stopLoad=function(){this.playlistError=0},i.getVariantLevelIndex=function(e){return e?.type===ae.MAIN?e.level:this.hls.loadLevel},i.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},i.onLevelUpdated=function(){this.playlistError=0},i.onError=function(e,r){var a;if(!r.fatal){var u=this.hls,l=r.context;switch(r.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:r.errorAction=this.getFragRetryOrSwitchAction(r);return;case M.FRAG_PARSING_ERROR:if((a=r.frag)!=null&&a.gap){r.errorAction=li();return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{r.errorAction=this.getFragRetryOrSwitchAction(r),r.errorAction.action=ht.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var d,c,p=r.parent===ae.MAIN?r.level:u.loadLevel;r.details===M.LEVEL_EMPTY_ERROR&&((d=r.context)!=null&&(c=d.levelDetails)!=null&&c.live)?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,p):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,p))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,l.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var y=u.loadLevelObj;if(y&&(l.type===ie.AUDIO_TRACK&&y.hasAudioGroup(l.groupId)||l.type===ie.SUBTITLE_TRACK&&y.hasSubtitleGroup(l.groupId))){r.errorAction=this.getPlaylistRetryOrSwitchAction(r,u.loadLevel),r.errorAction.action=ht.SendAlternateToPenaltyBox,r.errorAction.flags=Mt.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var A=u.loadLevelObj,T=A?.attrs["HDCP-LEVEL"];T?r.errorAction={action:ht.SendAlternateToPenaltyBox,flags:Mt.MoveAllAlternatesMatchingHDCP,hdcpLevel:T}:this.keySystemError(r)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:if(!r.errorAction){var b;r.errorAction=this.getLevelSwitchAction(r,(b=r.level)!=null?b:u.loadLevel)}return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:r.errorAction=li();return}r.type===Y.KEY_SYSTEM_ERROR&&this.keySystemError(r)}},i.keySystemError=function(e){var r=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,r)},i.getPlaylistRetryOrSwitchAction=function(e,r){var a=this.hls,u=ya(a.config.playlistLoadPolicy,e),l=this.playlistError++,d=ui(u,l,oi(e),e.response);if(d)return{action:ht.RetryRequest,flags:Mt.None,retryConfig:u,retryCount:l};var c=this.getLevelSwitchAction(e,r);return u&&(c.retryConfig=u,c.retryCount=l),c},i.getFragRetryOrSwitchAction=function(e){var r=this.hls,a=this.getVariantLevelIndex(e.frag),u=r.levels[a],l=r.config,d=l.fragLoadPolicy,c=l.keyLoadPolicy,p=ya(e.details.startsWith("key")?c:d,e),y=r.levels.reduce(function(b,L){return b+L.fragmentError},0);if(u){e.details!==M.FRAG_GAP&&u.fragmentError++;var A=ui(p,y,oi(e),e.response);if(A)return{action:ht.RetryRequest,flags:Mt.None,retryConfig:p,retryCount:y}}var T=this.getLevelSwitchAction(e,a);return p&&(T.retryConfig=p,T.retryCount=y),T},i.getLevelSwitchAction=function(e,r){var a=this.hls;r==null&&(r=a.loadLevel);var u=this.hls.levels[r];if(u){var l,d,c=e.details;u.loadError++,c===M.BUFFER_APPEND_ERROR&&u.fragmentError++;var p=-1,y=a.levels,A=a.loadLevel,T=a.minAutoLevel,b=a.maxAutoLevel;a.autoLevelEnabled||(a.loadLevel=-1);for(var L=(l=e.frag)==null?void 0:l.type,R=L===ae.AUDIO&&c===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(c===M.BUFFER_ADD_CODEC_ERROR||c===M.BUFFER_APPEND_ERROR),C=R&&y.some(function(K){var j=K.audioCodec;return u.audioCodec!==j}),I=e.sourceBufferName==="video"&&(c===M.BUFFER_ADD_CODEC_ERROR||c===M.BUFFER_APPEND_ERROR),k=I&&y.some(function(K){var j=K.codecSet,J=K.audioCodec;return u.codecSet!==j&&u.audioCodec===J}),O=(d=e.context)!=null?d:{},V=O.type,N=O.groupId,B=function(){var j=(z+A)%y.length;if(j!==A&&j>=T&&j<=b&&y[j].loadError===0){var J,le,re=y[j];if(c===M.FRAG_GAP&&L===ae.MAIN&&e.frag){var te=y[j].details;if(te){var fe=Wi(e.frag,te.fragments,e.frag.start);if(fe!=null&&fe.gap)return 0}}else{if(V===ie.AUDIO_TRACK&&re.hasAudioGroup(N)||V===ie.SUBTITLE_TRACK&&re.hasSubtitleGroup(N))return 0;if(L===ae.AUDIO&&(J=u.audioGroups)!=null&&J.some(function(de){return re.hasAudioGroup(de)})||L===ae.SUBTITLE&&(le=u.subtitleGroups)!=null&&le.some(function(de){return re.hasSubtitleGroup(de)})||C&&u.audioCodec===re.audioCodec||!C&&u.audioCodec!==re.audioCodec||k&&u.codecSet===re.codecSet)return 0}return p=j,1}},X,z=y.length;z--&&(X=B(),!(X!==0&&X===1)););if(p>-1&&a.loadLevel!==p)return e.levelRetry=!0,this.playlistError=0,{action:ht.SendAlternateToPenaltyBox,flags:Mt.None,nextAutoLevel:p}}return{action:ht.SendAlternateToPenaltyBox,flags:Mt.MoveAllAlternatesMatchingHost}},i.onErrorOut=function(e,r){var a;switch((a=r.errorAction)==null?void 0:a.action){case ht.DoNothing:break;case ht.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(r),!r.errorAction.resolved&&r.details!==M.FRAG_GAP?r.fatal=!0:/MediaSource readyState: ended/.test(r.error.message)&&(this.warn('MediaSource ended after "'+r.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(r.fatal){this.hls.stopLoad();return}},i.sendAlternateToPenaltyBox=function(e){var r=this.hls,a=e.errorAction;if(a){var u=a.flags,l=a.hdcpLevel,d=a.nextAutoLevel;switch(u){case Mt.None:this.switchLevel(e,d);break;case Mt.MoveAllAlternatesMatchingHDCP:l&&(r.maxHdcpLevel=Ki[Ki.indexOf(l)-1],a.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower');break}a.resolved||this.switchLevel(e,d)}},i.switchLevel=function(e,r){if(r!==void 0&&e.errorAction&&(this.warn("switching to level "+r+" after "+e.details),this.hls.nextAutoLevel=r,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===M.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo"))for(var a=la(e.mimeType),u=this.hls.levels,l=u.length;l--;)u[l][e.sourceBufferName+"Codec"]===a&&this.hls.removeLevel(l)},s}(je);function li(n){var s={action:ht.DoNothing,flags:Mt.None};return n&&(s.resolved=!0),s}var _a={length:0,start:function(){return 0},end:function(){return 0}},Fe=function(){function n(){}return n.isBuffered=function(i,t){if(i){for(var e=n.getBuffered(i),r=e.length;r--;)if(t>=e.start(r)&&t<=e.end(r))return!0}return!1},n.bufferedRanges=function(i){if(i){var t=n.getBuffered(i);return n.timeRangesToArray(t)}return[]},n.timeRangesToArray=function(i){for(var t=[],e=0;e<i.length;e++)t.push({start:i.start(e),end:i.end(e)});return t},n.bufferInfo=function(i,t,e){if(i){var r=n.bufferedRanges(i);if(r.length)return n.bufferedInfo(r,t,e)}return{len:0,start:t,end:t,bufferedIndex:-1}},n.bufferedInfo=function(i,t,e){t=Math.max(0,t),i.length>1&&i.sort(function(R,C){return R.start-C.start||C.end-R.end});var r=-1,a=[];if(e)for(var u=0;u<i.length;u++){t>=i[u].start&&t<=i[u].end&&(r=u);var l=a.length;if(l){var d=a[l-1].end;i[u].start-d<e?i[u].end>d&&(a[l-1].end=i[u].end):a.push(i[u])}else a.push(i[u])}else a=i;for(var c=0,p,y=t,A=t,T=0;T<a.length;T++){var b=a[T].start,L=a[T].end;if(r===-1&&t>=b&&t<=L&&(r=T),t+e>=b&&t<L)y=b,A=L,c=A-t;else if(t+e<b){p=b;break}}return{len:c,start:y||0,end:A||0,nextStart:p,buffered:i,bufferedIndex:r}},n.getBuffered=function(i){try{return i.buffered||_a}catch(t){return Oe.log("failed to get media.buffered",t),_a}},n}(),Sa=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ta="HlsJsTrackRemovedError",Nu=function(n){function s(i){var t;return t=n.call(this,i)||this,t.name=Ta,t}return S(s,n),s}(Z(Error)),Uu=function(n){function s(t,e){var r;return r=n.call(this,"buffer-controller",t.logger)||this,r.hls=void 0,r.fragmentTracker=void 0,r.details=null,r._objectUrl=null,r.operationQueue=null,r.bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.lastMpegAudioChunk=null,r.blockedAudioAppend=null,r.lastVideoAppendEnd=0,r.appendSource=void 0,r.transferData=void 0,r.overrides=void 0,r.appendErrors={audio:0,video:0,audiovideo:0},r.tracks={},r.sourceBuffers=[[null,null],[null,null]],r._onEndStreaming=function(a){var u;r.hls&&((u=r.mediaSource)==null?void 0:u.readyState)==="open"&&r.hls.pauseBuffering()},r._onStartStreaming=function(a){r.hls&&r.hls.resumeBuffering()},r._onMediaSourceOpen=function(a){var u=r,l=u.media,d=u.mediaSource;a&&r.log("Media source opened"),!(!l||!d)&&(d.removeEventListener("sourceopen",r._onMediaSourceOpen),l.removeEventListener("emptied",r._onMediaEmptied),r.updateDuration(),r.hls.trigger(x.MEDIA_ATTACHED,{media:l,mediaSource:d}),r.mediaSource!==null&&r.checkPendingTracks())},r._onMediaSourceClose=function(){r.log("Media source closed")},r._onMediaSourceEnded=function(){r.log("Media source ended")},r._onMediaEmptied=function(){var a=r,u=a.mediaSrc,l=a._objectUrl;u!==l&&r.error("Media element src was set while attaching MediaSource ("+l+" > "+u+")")},r.hls=t,r.fragmentTracker=e,r.appendSource=pu(nr(t.config.preferManagedMediaSource)),r.initTracks(),r.registerListeners(),r}S(s,n);var i=s.prototype;return i.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},i.destroy=function(){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},i.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this),e.off(x.ERROR,this.onError,this)},i.transferMedia=function(){var e=this,r=this.media,a=this.mediaSource;if(!r)return null;var u={};if(this.operationQueue){var l=this.isUpdating();l||this.operationQueue.removeBlockers();var d=this.isQueued();(l||d)&&this.warn("Transfering MediaSource with"+(d?" operations in queue":"")+(l?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var c=this.transferData;return!this.sourceBufferCount&&c&&c.mediaSource===a?E(u,c.tracks):this.sourceBuffers.forEach(function(p){var y=p[0];y&&(u[y]=E({},e.tracks[y]),e.removeBuffer(y)),p[0]=p[1]=null}),{media:r,mediaSource:a,tracks:u}},i.initTracks=function(){var e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},i.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},i.onManifestParsed=function(e,r){var a,u=2;r.audio&&!r.video||r.altAudio,u=1,this.bufferCodecEventsTotal=u,this.log(u+" bufferCodec event(s) expected."),(a=this.transferData)!=null&&a.mediaSource&&this.sourceBufferCount&&u&&this.bufferCreated()},i.onMediaAttaching=function(e,r){var a=this.media=r.media,u=nr(this.appendSource);if(this.transferData=this.overrides=void 0,a&&u){var l=!!r.mediaSource;(l||r.overrides)&&(this.transferData=r,this.overrides=r.overrides);var d=this.mediaSource=r.mediaSource||new u;if(this.assignMediaSource(d),l)this._objectUrl=a.src,this.attachTransferred();else{var c=this._objectUrl=self.URL.createObjectURL(d);if(this.appendSource)try{a.removeAttribute("src");var p=self.ManagedMediaSource;a.disableRemotePlayback=a.disableRemotePlayback||p&&d instanceof p,Aa(a),Bu(a,c),a.load()}catch{a.src=c}else a.src=c}a.addEventListener("emptied",this._onMediaEmptied)}},i.assignMediaSource=function(e){var r,a;this.log((((r=this.transferData)==null?void 0:r.mediaSource)===e?"transferred":"created")+" media source: "+((a=e.constructor)==null?void 0:a.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))},i.attachTransferred=function(){var e=this,r=this.media,a=this.transferData;if(!(!a||!r)){var u=this.tracks,l=a.tracks,d=l?Object.keys(l):null,c=d?d.length:0,p=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(l&&d&&c){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
16
+ required tracks: `+gt(u,function(b,L){return b==="initSegment"?void 0:L})+`;
17
+ transfer tracks: `+gt(l,function(b,L){return b==="initSegment"?void 0:L})+"}"),!gu(l,u)){a.mediaSource=null,a.tracks=void 0;var y=r.currentTime,A=this.details,T=Math.max(y,A?.fragments[0].start||0);if(T-y>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+y+" -> "+T);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(l)+'"->"'+Object.keys(u)+'") start time: '+T+" currentTime: "+y),this.onMediaDetaching(x.MEDIA_DETACHING,{}),this.onMediaAttaching(x.MEDIA_ATTACHING,a),r.currentTime=T;return}this.transferData=void 0,d.forEach(function(b){var L=b,R=l[L];if(R){var C=R.buffer;if(C){var I=e.fragmentTracker,k=R.id;if(I.hasFragments(k)||I.hasParts(k)){var O=Fe.getBuffered(C);I.detectEvictedFragments(L,O,k,null,!0)}var V=Yi(L),N=[L,C];e.sourceBuffers[V]=N,C.updating&&e.operationQueue&&e.operationQueue.prependBlocker(L),e.trackSourceBuffer(L,R)}}}),p(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),p()}},i.onMediaDetaching=function(e,r){var a=this,u=!!r.transferMedia;this.transferData=this.overrides=void 0;var l=this.media,d=this.mediaSource,c=this._objectUrl;if(d){if(this.log("media source "+(u?"transferring":"detaching")),u)this.sourceBuffers.forEach(function(T){var b=T[0];b&&a.removeBuffer(b)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var p=d.readyState==="open";try{for(var y=d.sourceBuffers,A=y.length;A--;)p&&y[A].abort(),d.removeSourceBuffer(y[A]);p&&d.endOfStream()}catch(T){this.warn("onMediaDetaching: "+T.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}d.removeEventListener("sourceopen",this._onMediaSourceOpen),d.removeEventListener("sourceended",this._onMediaSourceEnded),d.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(d.removeEventListener("startstreaming",this._onStartStreaming),d.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}l&&(l.removeEventListener("emptied",this._onMediaEmptied),u||(c&&self.URL.revokeObjectURL(c),this.mediaSrc===c?(l.removeAttribute("src"),this.appendSource&&Aa(l),l.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(x.MEDIA_DETACHED,r)},i.onBufferReset=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];a&&e.resetBuffer(a)}),this.initTracks()},i.resetBuffer=function(e){var r,a=(r=this.tracks[e])==null?void 0:r.buffer;if(this.removeBuffer(e),a)try{var u;(u=this.mediaSource)!=null&&u.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(a)}catch(l){this.warn("onBufferReset "+e,l)}delete this.tracks[e]},i.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[Yi(e)]=[null,null];var r=this.tracks[e];r&&(r.buffer=void 0)},i.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Du(this.tracks)},i.onBufferCodecs=function(e,r){var a=this,u=this.tracks,l=Object.keys(r);this.log('BUFFER_CODECS: "'+l+'" (current SB count '+this.sourceBufferCount+")");var d="audiovideo"in r&&(u.audio||u.video)||u.audiovideo&&("audio"in r||"video"in r),c=!d&&this.sourceBufferCount&&this.media&&l.some(function(p){return!u[p]});if(d||c){this.warn('Unsupported transition between "'+Object.keys(u)+'" and "'+l+'" SourceBuffers');return}l.forEach(function(p){var y,A,T,b=r[p],L=b.id,R=b.codec,C=b.levelCodec,I=b.container,k=b.metadata,O=b.supplemental,V=u[p],N=(y=a.transferData)==null||(A=y.tracks)==null?void 0:A[p],B=N!=null&&N.buffer?N:V,X=B?.pendingCodec||B?.codec,z=B?.levelCodec;V||(V=u[p]={buffer:void 0,listeners:[],codec:R,supplemental:O,container:I,levelCodec:C,metadata:k,id:L});var K=ni(X,z),j=K?.replace(Sa,"$1"),J=ni(R,C),le=(T=J)==null?void 0:T.replace(Sa,"$1");J&&K&&j!==le&&(p.slice(0,5)==="audio"&&(J=ii(J,a.appendSource)),a.log("switching codec "+X+" to "+J),J!==(V.pendingCodec||V.codec)&&(V.pendingCodec=J),V.container=I,a.appendChangeType(p,I,J))}),(this.tracksReady||this.sourceBufferCount)&&(r.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks()},i.appendChangeType=function(e,r,a){var u=this,l=r+";codecs="+a,d={label:"change-type="+l,execute:function(){var p=u.tracks[e];if(p){var y=p.buffer;y!=null&&y.changeType&&(u.log("changing "+e+" sourceBuffer type to "+l),y.changeType(l),p.codec=a,p.container=r)}u.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(p){u.warn("Failed to change "+e+" SourceBuffer type",p)}};this.append(d,e,this.isPending(this.tracks[e]))},i.blockAudio=function(e){var r,a=this,u=e.start,l=u+e.duration*.05,d=((r=this.fragmentTracker.getAppendedFrag(u,ae.MAIN))==null?void 0:r.gap)===!0;if(!d){var c={label:"block-audio",execute:function(){var y,A=a.tracks.video;(a.lastVideoAppendEnd>l||A!=null&&A.buffer&&Fe.isBuffered(A.buffer,l)||((y=a.fragmentTracker.getAppendedFrag(l,ae.MAIN))==null?void 0:y.gap)===!0)&&(a.blockedAudioAppend=null,a.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(y){a.warn("Error executing block-audio operation",y)}};this.blockedAudioAppend={op:c,frag:e},this.append(c,"audio",!0)}},i.unblockAudio=function(){var e=this.blockedAudioAppend,r=this.operationQueue;e&&r&&(this.blockedAudioAppend=null,r.unblockAudio(e.op))},i.onBufferAppending=function(e,r){var a=this,u=this.tracks,l=r.data,d=r.type,c=r.parent,p=r.frag,y=r.part,A=r.chunkMeta,T=A.buffering[d],b=p.sn,L=self.performance.now();T.start=L;var R=p.stats.buffering,C=y?y.stats.buffering:null;R.start===0&&(R.start=L),C&&C.start===0&&(C.start=L);var I=u.audio,k=!1;d==="audio"&&I?.container==="audio/mpeg"&&(k=!this.lastMpegAudioChunk||A.id===1||this.lastMpegAudioChunk.sn!==A.sn,this.lastMpegAudioChunk=A);var O=this.tracks.video,V=O?.buffer;if(V&&b!=="initSegment"){var N=y||p,B=this.blockedAudioAppend;if(d==="audio"&&c!=="main"&&!this.blockedAudioAppend){var X=N.start,z=X+N.duration*.05,K=V.buffered,j=this.currentOp("video");!K.length&&!j?this.blockAudio(N):!j&&!Fe.isBuffered(V,z)&&this.lastVideoAppendEnd<z&&this.blockAudio(N)}else if(d==="video"){var J=N.end;if(B){var le=B.frag.start;(J>le||J<this.lastVideoAppendEnd||Fe.isBuffered(V,le))&&this.unblockAudio()}this.lastVideoAppendEnd=J}}var re=(y||p).start,te={label:"append-"+d,execute:function(){if(T.executeStart=self.performance.now(),k){var de=a.tracks[d];if(de){var ve=de.buffer;if(ve){var ge=re-ve.timestampOffset;Math.abs(ge)>=.1&&(a.log("Updating audio SourceBuffer timestampOffset to "+re+" (delta: "+ge+") sn: "+b+")"),ve.timestampOffset=re)}}}a.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var de=self.performance.now();T.executeEnd=T.end=de,R.first===0&&(R.first=de),C&&C.first===0&&(C.first=de);var ve={};a.sourceBuffers.forEach(function(ge){var Ne=ge[0],we=ge[1];Ne&&(ve[Ne]=Fe.getBuffered(we))}),a.appendErrors[d]=0,d==="audio"||d==="video"?a.appendErrors.audiovideo=0:(a.appendErrors.audio=0,a.appendErrors.video=0),a.hls.trigger(x.BUFFER_APPENDED,{type:d,frag:p,part:y,chunkMeta:A,parent:p.type,timeRanges:ve})},onError:function(de){var ve,ge={type:Y.MEDIA_ERROR,parent:p.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:p,part:y,chunkMeta:A,error:de,err:de,fatal:!1};if(de.code===DOMException.QUOTA_EXCEEDED_ERR)ge.details=M.BUFFER_FULL_ERROR;else if(de.code===DOMException.INVALID_STATE_ERR&&a.mediaSourceOpenOrEnded&&!((ve=a.media)!=null&&ve.error))ge.errorAction=li(!0);else if(de.name===Ta)a.sourceBufferCount===0?ge.errorAction=li(!0):++a.appendErrors[d];else{var Ne=++a.appendErrors[d];a.warn("Failed "+Ne+"/"+a.hls.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),Ne>=a.hls.config.appendErrorMaxRetry&&(ge.fatal=!0)}a.hls.trigger(x.ERROR,ge)}};this.append(te,d,this.isPending(this.tracks[d]))},i.getFlushOp=function(e,r,a){var u=this;return this.log('queuing "'+e+'" remove '+r+"-"+a),{label:"remove",execute:function(){u.removeExecutor(e,r,a)},onStart:function(){},onComplete:function(){u.hls.trigger(x.BUFFER_FLUSHED,{type:e})},onError:function(d){u.warn("Failed to remove "+r+"-"+a+' from "'+e+'" SourceBuffer',d)}}},i.onBufferFlushing=function(e,r){var a=this,u=r.type,l=r.startOffset,d=r.endOffset;u?this.append(this.getFlushOp(u,l,d),u):this.sourceBuffers.forEach(function(c){var p=c[0];p&&a.append(a.getFlushOp(p,l,d),p)})},i.onFragParsed=function(e,r){var a=this,u=r.frag,l=r.part,d=[],c=l?l.elementaryStreams:u.elementaryStreams;c[qe.AUDIOVIDEO]?d.push("audiovideo"):(c[qe.AUDIO]&&d.push("audio"),c[qe.VIDEO]&&d.push("video"));var p=function(){var A=self.performance.now();u.stats.buffering.end=A,l&&(l.stats.buffering.end=A);var T=l?l.stats:u.stats;a.hls.trigger(x.FRAG_BUFFERED,{frag:u,part:l,stats:T,id:u.type})};d.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+u.type+" level: "+u.level+" sn: "+u.sn),this.blockBuffers(p,d)},i.onFragChanged=function(e,r){this.trimBuffers()},i.onBufferEos=function(e,r){var a=this,u;this.sourceBuffers.forEach(function(c){var p=c[0];if(p){var y=a.tracks[p];(!r.type||r.type===p)&&(y.ending=!0,y.ended||(y.ended=!0,a.log(p+" buffer reached EOS")))}});var l=((u=this.overrides)==null?void 0:u.endOfStream)!==!1,d=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(c){var p,y=c[0];return y&&!((p=a.tracks[y])!=null&&p.ended)});d&&(l?(this.log("Queueing EOS"),this.blockUntilOpen(function(){a.tracksEnded();var c=a.mediaSource;if(!c||c.readyState!=="open"){c&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+c.readyState);return}a.log("Calling mediaSource.endOfStream()"),c.endOfStream(),a.hls.trigger(x.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(x.BUFFERED_TO_END,void 0)))},i.tracksEnded=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];if(a!==null){var u=e.tracks[a];u&&(u.ending=!1)}})},i.onLevelUpdated=function(e,r){var a=r.details;a.fragments.length&&(this.details=a,this.updateDuration())},i.updateDuration=function(){var e=this,r=this.getDurationAndRange();r&&this.blockUntilOpen(function(){return e.updateMediaSource(r)})},i.onError=function(e,r){if(r.details===M.BUFFER_APPEND_ERROR&&r.frag){var a,u=(a=r.errorAction)==null?void 0:a.nextAutoLevel;w(u)&&u!==r.frag.level&&this.resetAppendErrors()}},i.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},i.trimBuffers=function(){var e=this.hls,r=this.details,a=this.media;if(!(!a||r===null)&&this.sourceBufferCount){var u=e.config,l=a.currentTime,d=r.levelTargetDuration,c=r.live&&u.liveBackBufferLength!==null?u.liveBackBufferLength:u.backBufferLength;if(w(c)&&c>=0){var p=Math.max(c,d),y=Math.floor(l/d)*d-p;this.flushBackBuffer(l,d,y)}if(w(u.frontBufferFlushThreshold)&&u.frontBufferFlushThreshold>0){var A=Math.max(u.maxBufferLength,u.frontBufferFlushThreshold),T=Math.max(A,d),b=Math.floor(l/d)*d+T;this.flushFrontBuffer(l,d,b)}}},i.flushBackBuffer=function(e,r,a){var u=this;this.sourceBuffers.forEach(function(l){var d=l[0],c=l[1];if(c){var p=Fe.getBuffered(c);if(p.length>0&&a>p.start(0)){var y;u.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:a});var A=u.tracks[d];if((y=u.details)!=null&&y.live)u.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a});else if(A!=null&&A.ended){u.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");return}u.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:d})}}})},i.flushFrontBuffer=function(e,r,a){var u=this;this.sourceBuffers.forEach(function(l){var d=l[0],c=l[1];if(c){var p=Fe.getBuffered(c),y=p.length;if(y<2)return;var A=p.start(y-1),T=p.end(y-1);if(a>A||e>=A&&e<=T)return;u.hls.trigger(x.BUFFER_FLUSHING,{startOffset:A,endOffset:1/0,type:d})}})},i.getDurationAndRange=function(){var e,r=this.details,a=this.mediaSource;if(!r||!this.media||a?.readyState!=="open")return null;var u=r.edge;if(r.live&&this.hls.config.liveDurationInfinity){var l=r.fragments.length;if(l&&r.live&&a.setLiveSeekableRange){var d=Math.max(0,r.fragmentStart),c=Math.max(d,u);return{duration:1/0,start:d,end:c}}return{duration:1/0}}var p=(e=this.overrides)==null?void 0:e.duration;if(p)return w(p)?{duration:p}:null;var y=this.media.duration,A=w(a.duration)?a.duration:0;return u>A&&u>y||!w(y)?{duration:u}:null},i.updateMediaSource=function(e){var r=e.duration,a=e.start,u=e.end,l=this.mediaSource;!this.media||!l||l.readyState!=="open"||(l.duration!==r&&(w(r)&&this.log("Updating MediaSource duration to "+r.toFixed(3)),l.duration=r),a!==void 0&&u!==void 0&&(this.log("MediaSource duration is set to "+l.duration+". Setting seekable range to "+a+"-"+u+"."),l.setLiveSeekableRange(a,u)))},i.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,r=this.pendingTrackCount,a=this.tracks;if(this.log("checkPendingTracks (pending: "+r+" codec events expected: "+e+") "+gt(a)),this.tracksReady){var u,l=(u=this.transferData)==null?void 0:u.tracks;l&&Object.keys(l).length?this.attachTransferred():this.createSourceBuffers()}},i.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var r={};this.sourceBuffers.forEach(function(u){var l=u[0],d=u[1];if(l){var c=e.tracks[l];r[l]={buffer:d,container:c.container,codec:c.codec,supplemental:c.supplemental,levelCodec:c.levelCodec,id:c.id,metadata:c.metadata}}}),this.hls.trigger(x.BUFFER_CREATED,{tracks:r}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(u){var l=u[0];e.executeNext(l)})}else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}},i.createSourceBuffers=function(){var e=this.tracks,r=this.sourceBuffers,a=this.mediaSource;if(!a)throw new Error("createSourceBuffers called when mediaSource was null");for(var u in e){var l=u,d=e[l];if(this.isPending(d)){var c=this.getTrackCodec(d,l),p=d.container+";codecs="+c;d.codec=c,this.log("creating sourceBuffer("+p+")"+(this.currentOp(l)?" Queued":"")+" "+gt(d));try{var y=a.addSourceBuffer(p),A=Yi(l),T=[l,y];r[A]=T,d.buffer=y}catch(L){var b;this.error("error while trying to add sourceBuffer: "+L.message),this.shiftAndExecuteNext(l),(b=this.operationQueue)==null||b.removeBlockers(),delete this.tracks[l],this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:L,sourceBufferName:l,mimeType:p,parent:d.id});return}this.trackSourceBuffer(l,d)}}this.bufferCreated()},i.getTrackCodec=function(e,r){var a=e.supplemental,u=e.codec;a&&(r==="video"||r==="audiovideo")&&Vi(a,"video")&&(u=Eu(u,a));var l=ni(u,e.levelCodec);return l?r.slice(0,5)==="audio"?ii(l,this.appendSource):l:""},i.trackSourceBuffer=function(e,r){var a=this,u=r.buffer;if(u){var l=this.getTrackCodec(r,e);this.tracks[e]={buffer:u,codec:l,container:r.container,levelCodec:r.levelCodec,supplemental:r.supplemental,metadata:r.metadata,id:r.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",function(d,c){var p=c.removedRanges;p!=null&&p.length&&a.hls.trigger(x.BUFFER_FLUSHED,{type:d})})}},i.onSBUpdateStart=function(e){var r=this.currentOp(e);r&&r.onStart()},i.onSBUpdateEnd=function(e){var r;if(((r=this.mediaSource)==null?void 0:r.readyState)==="closed"){this.resetBuffer(e);return}var a=this.currentOp(e);a&&(a.onComplete(),this.shiftAndExecuteNext(e))},i.onSBUpdateError=function(e,r){var a,u=new Error(e+" SourceBuffer error. MediaSource readyState: "+((a=this.mediaSource)==null?void 0:a.readyState));this.error(""+u,r),this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:u,fatal:!1});var l=this.currentOp(e);l&&l.onError(u)},i.removeExecutor=function(e,r,a){var u=this.media,l=this.mediaSource,d=this.tracks[e],c=d?.buffer;if(!u||!l||!c){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(e);return}var p=w(u.duration)?u.duration:1/0,y=w(l.duration)?l.duration:1/0,A=Math.max(0,r),T=Math.min(a,p,y);T>A&&(!d.ending||d.ended)?(d.ended=!1,this.log("Removing ["+A+","+T+"] from the "+e+" SourceBuffer"),c.remove(A,T)):this.shiftAndExecuteNext(e)},i.appendExecutor=function(e,r){var a=this.tracks[r],u=a?.buffer;if(!u)throw new Nu("Attempting to append to the "+r+" SourceBuffer, but it does not exist");a.ending=!1,a.ended=!1,u.appendBuffer(e)},i.blockUntilOpen=function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()},i.isUpdating=function(){return this.sourceBuffers.some(function(e){var r=e[0],a=e[1];return r&&a.updating})},i.isQueued=function(){var e=this;return this.sourceBuffers.some(function(r){var a=r[0];return a&&!!e.currentOp(a)})},i.isPending=function(e){return!!e&&!e.buffer},i.blockBuffers=function(e,r){var a=this;if(r===void 0&&(r=this.sourceBufferTypes),!r.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var u=this.operationQueue,l=r.map(function(c){return a.appendBlocker(c)}),d=r.length>1&&!!this.blockedAudioAppend;d&&this.unblockAudio(),Promise.all(l).then(function(c){u===a.operationQueue&&(e(),a.stepOperationQueue(r))})},i.stepOperationQueue=function(e){var r=this;e.forEach(function(a){var u,l=(u=r.tracks[a])==null?void 0:u.buffer;!l||l.updating||r.shiftAndExecuteNext(a)})},i.append=function(e,r,a){this.operationQueue&&this.operationQueue.append(e,r,a)},i.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},i.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},i.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},i.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},i.addBufferListener=function(e,r,a){var u=this.tracks[e];if(u){var l=u.buffer;if(l){var d=a.bind(this,e);u.listeners.push({event:r,listener:d}),l.addEventListener(r,d)}}},i.removeBufferListeners=function(e){var r=this.tracks[e];if(r){var a=r.buffer;a&&(r.listeners.forEach(function(u){a.removeEventListener(u.event,u.listener)}),r.listeners.length=0)}},f(s,[{key:"mediaSourceOpenOrEnded",get:function(){var e,r=(e=this.mediaSource)==null?void 0:e.readyState;return r==="open"||r==="ended"}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){var u=e.tracks[a];return r[a]={id:u.id,container:u.container,codec:u.codec,levelCodec:u.levelCodec},r},{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(r){var a,u,l=r[0];return l&&(!((a=e.tracks[l])!=null&&a.ended)||((u=e.tracks[l])==null?void 0:u.ending))})}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,r,a=((e=this.media)==null||(r=e.querySelector)==null?void 0:r.call(e,"source"))||this.media;return a?.src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){return r+(e.isPending(e.tracks[a])?1:0)},0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce(function(e,r){var a=r[0];return e+(a?1:0)},0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(function(e){var r=e[0];return r}).filter(function(e){return!!e})}}])}(je);function Aa(n){var s=n.querySelectorAll("source");[].slice.call(s).forEach(function(i){n.removeChild(i)})}function Bu(n,s){var i=self.document.createElement("source");i.type="video/mp4",i.src=s,n.appendChild(i)}function Yi(n){return n==="audio"?1:0}var Gu=function(){function n(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 s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,e){var r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},s.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},s.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onLevelsUpdated=function(t,e){this.timer&&w(this.autoLevelCapping)&&this.detectPlayerSize()},s.onBufferCodecs=function(t,e){var r=this.hls;r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping(),this.media=null},s.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var t=this.hls.levels;if(t.length){var e=this.hls,r=this.getMaxLevel(t.length-1);r!==this.autoLevelCapping&&e.logger.log("Setting autoLevelCapping to "+r+": "+t[r].height+"p@"+t[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),e.autoLevelCapping=r,e.autoLevelEnabled&&e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},s.getMaxLevel=function(t){var e=this,r=this.hls.levels;if(!r.length)return-1;var a=r.filter(function(u,l){return e.isLevelAllowed(u)&&l<=t});return this.clientRect=null,n.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,!e.width&&!e.height&&(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},s.isLevelAllowed=function(t){var e=this.restrictedLevels;return!e.some(function(r){return t.bitrate===r.bitrate&&t.width===r.width&&t.height===r.height})},n.getMaxLevelByMediaSize=function(t,e,r){if(!(t!=null&&t.length))return-1;for(var a=function(y,A){return A?y.width!==A.width||y.height!==A.height:!0},u=t.length-1,l=Math.max(e,r),d=0;d<t.length;d+=1){var c=t[d];if((c.width>=l||c.height>=l)&&a(c,t[d+1])){u=d;break}}return u},f(n,[{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 t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return Math.min(t,this.hls.config.maxDevicePixelRatio)}}])}(),Vu=/^(\d+)x(\d+)$/,ba=/(.+?)=(".*?"|.*?)(?:,|$)/g,rt=function(){function n(i,t){typeof i=="string"&&(i=n.parseAttrList(i,t)),E(this,i)}var s=n.prototype;return s.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;for(var r=new Uint8Array(e.length/2),a=0;a<e.length/2;a++)r[a]=parseInt(e.slice(a*2,a*2+2),16);return r}return null},s.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.decimalFloatingPoint=function(t){return parseFloat(this[t])},s.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},s.enumeratedString=function(t){return this[t]},s.enumeratedStringList=function(t,e){var r=this[t];return(r?r.split(/[ ,]+/):[]).reduce(function(a,u){return a[u.toLowerCase()]=!0,a},e)},s.bool=function(t){return this[t]==="YES"},s.decimalResolution=function(t){var e=Vu.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},n.parseAttrList=function(t,e){var r,a={},u='"';for(ba.lastIndex=0;(r=ba.exec(t))!==null;){var l=r[1].trim(),d=r[2],c=d.indexOf(u)===0&&d.lastIndexOf(u)===d.length-1,p=!1;if(c)d=d.slice(1,-1);else switch(l){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":p=!0}if(!(e&&(c||p))){if(!p&&!c)switch(l){case"CLOSED-CAPTIONS":if(d==="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":Oe.warn(t+": attribute "+l+" is missing quotes")}}a[l]=d}return a},f(n,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(t){return t.substring(0,2)==="X-"})}}])}(),Hu="com.apple.hls.interstitial";function Ku(n){return n!=="ID"&&n!=="CLASS"&&n!=="CUE"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Wu(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"||n==="SCTE35-CMD"}var La=function(){function n(s,i,t){var e;if(t===void 0&&(t=0),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=i?.tagAnchor||null,this.tagOrder=(e=i?.tagOrder)!=null?e:t,i){var r=i.attr;for(var a in r)if(Object.prototype.hasOwnProperty.call(s,a)&&s[a]!==r[a]){Oe.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=a;break}s=E(new rt({}),r,s)}if(this.attr=s,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var u=i?.endDate||new Date(this.attr["END-DATE"]);w(u.getTime())&&(this._endDate=u)}}return f(n,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var i=this._cue;return i===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):i}},{key:"startTime",get:function(){var i=this.tagAnchor;return i===null||i.programDateTime===null?(Oe.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+i),NaN):i.start+(this.startDate.getTime()-i.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var i=this._endDate||this._dateAtEnd;if(i)return i;var t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(w(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:"isInterstitial",get:function(){return this.class===Hu}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&w(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)}}])}(),ju=10,Yu=function(){function n(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.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=i}var s=n.prototype;return s.reloaded=function(t){if(!t){this.advanced=!0,this.updated=!0;return}var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1},f(n,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?w(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||ju}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;if(t>0){var e=this.driftEnd-this.driftStart;return e*1e3/t}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var t=this.partList;if(t){var e=this.lastPartIndex;if(e!==-1){for(var r=t.length;r--;)if(t[r].index>e)return t[r].index;return e}}return 0}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}])}(),ar={cbc:0,ctr:1};function Mr(n){return n==="AES-128"||n==="AES-256"||n==="AES-256-CTR"}function xa(n){switch(n){case"AES-128":case"AES-256":return ar.cbc;case"AES-256-CTR":return ar.ctr;default:throw new Error("invalid full segment method "+n)}}var zu=function(){function n(i,t,e,r,a){r===void 0&&(r=[1]),a===void 0&&(a=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=t,this.keyFormat=e,this.keyFormatVersions=r,this.iv=a,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Mr(i)}n.clearKeyUriToKeyIdMap=function(){};var s=n.prototype;return s.isSupported=function(){if(this.method){if(Mr(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},s.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(Mr(this.method)&&this.uri&&!this.iv){typeof t!="number"&&(Oe.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var e=qu(t),r=new n(this.method,this.uri,"identity",this.keyFormatVersions,e);return r}return this},n}();function qu(n){for(var s=new Uint8Array(16),i=12;i<16;i++)s[i]=n>>8*(15-i)&255;return s}var Ra=/#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,Ca=/#EXT-X-MEDIA:(.*)/g,$u=/^#EXT(?:INF|-X-TARGETDURATION):/m,zi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Xu=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("|")),Fr=function(){function n(){}return n.findGroup=function(i,t){for(var e=0;e<i.length;e++){var r=i[e];if(r.id===t)return r}},n.resolve=function(i,t){return Ze.buildAbsoluteURL(t,i,{alwaysNormalize:!0})},n.isMediaPlaylist=function(i){return $u.test(i)},n.parseMasterPlaylist=function(i,t){var e=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:e},a=[];Ra.lastIndex=0;for(var u;(u=Ra.exec(i))!=null;)if(u[1]){var l,d=new rt(u[1],r),c=u[2],p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:n.resolve(c,t)},y=d.decimalResolution("RESOLUTION");y&&(p.width=y.width,p.height=y.height),wa(d.CODECS,p);var A=d["SUPPLEMENTAL-CODECS"];A&&(p.supplemental={},wa(A,p.supplemental)),(l=p.unknownCodecs)!=null&&l.length||a.push(p),r.levels.push(p)}else if(u[3]){var T=u[3],b=u[4];switch(T){case"SESSION-DATA":{var L=new rt(b,r),R=L["DATA-ID"];R&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[R]=L);break}case"SESSION-KEY":{var C=Da(b,t,r);C.encrypted&&C.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(C)):Oe.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+b+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var I=new rt(b,r);r.contentSteering={uri:n.resolve(I["SERVER-URI"],t),pathwayId:I["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Ia(b);break}}}var k=a.length>0&&a.length<r.levels.length;return r.levels=k?a:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},n.parseMasterPlaylistMedia=function(i,t,e){var r,a={},u=e.levels,l={AUDIO:u.map(function(O){return{id:O.attrs.AUDIO,audioCodec:O.audioCodec}}),SUBTITLES:u.map(function(O){return{id:O.attrs.SUBTITLES,textCodec:O.textCodec}}),"CLOSED-CAPTIONS":[]},d=0;for(Ca.lastIndex=0;(r=Ca.exec(i))!==null;){var c=new rt(r[1],e),p=c.TYPE;if(p){var y=l[p],A=a[p]||[];a[p]=A;var T=c.LANGUAGE,b=c["ASSOC-LANGUAGE"],L=c.CHANNELS,R=c.CHARACTERISTICS,C=c["INSTREAM-ID"],I={attrs:c,bitrate:0,id:d++,groupId:c["GROUP-ID"]||"",name:c.NAME||T||"",type:p,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:T,url:c.URI?n.resolve(c.URI,t):""};if(b&&(I.assocLang=b),L&&(I.channels=L),R&&(I.characteristics=R),C&&(I.instreamId=C),y!=null&&y.length){var k=n.findGroup(y,I.groupId)||y[0];Pa(I,k,"audioCodec"),Pa(I,k,"textCodec")}A.push(I)}}return a},n.parseLevelPlaylist=function(i,t,e,r,a,u){var l,d={url:t},c=new Yu(t),p=c.fragments,y=[],A=null,T=0,b=0,L=0,R=0,C=0,I=null,k=new Ni(r,d),O,V,N,B=-1,X=!1,z=null,K;if(zi.lastIndex=0,c.m3u8=i,c.hasVariableRefs=!1,((l=zi.exec(i))==null?void 0:l[0])!=="#EXTM3U")return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;(O=zi.exec(i))!==null;){X&&(X=!1,k=new Ni(r,d),k.playlistOffset=L,k.start=L,k.sn=T,k.cc=R,C&&(k.bitrate=C),k.level=e,A&&(k.initSegment=A,A.rawProgramDateTime&&(k.rawProgramDateTime=A.rawProgramDateTime,A.rawProgramDateTime=null),z&&(k.setByteRange(z),z=null)));var j=O[1];if(j){k.duration=parseFloat(j);var J=(" "+O[2]).slice(1);k.title=J||null,k.tagList.push(J?["INF",j,J]:["INF",j])}else if(O[3]){if(w(k.duration)){k.playlistOffset=L,k.start=L,N&&Ma(k,N,c),k.sn=T,k.level=e,k.cc=R,p.push(k);var le=(" "+O[3]).slice(1);k.relurl=le,qi(k,I,y),I=k,L+=k.duration,T++,b=0,X=!0}}else{if(O=O[0].match(Xu),!O){Oe.warn("No matches on slow regex match for level playlist!");continue}for(V=1;V<O.length&&O[V]===void 0;V++);var re=(" "+O[V]).slice(1),te=(" "+O[V+1]).slice(1),fe=O[V+2]?(" "+O[V+2]).slice(1):null;switch(re){case"BYTERANGE":I?k.setByteRange(te,I):k.setByteRange(te);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=te,k.tagList.push(["PROGRAM-DATE-TIME",te]),B===-1&&(B=p.length);break;case"PLAYLIST-TYPE":c.type&&Qt(c,re,O),c.type=te.toUpperCase();break;case"MEDIA-SEQUENCE":c.startSN!==0?Qt(c,re,O):p.length>0&&Fa(c,re,O),T=c.startSN=parseInt(te);break;case"SKIP":{c.skippedSegments&&Qt(c,re,O);var de=new rt(te,c),ve=de.decimalInteger("SKIPPED-SEGMENTS");if(w(ve)){c.skippedSegments+=ve;for(var ge=ve;ge--;)p.push(null);T+=ve}var Ne=de.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ne&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(Ne.split(" ")));break}case"TARGETDURATION":c.targetduration!==0&&Qt(c,re,O),c.targetduration=Math.max(parseInt(te),1);break;case"VERSION":c.version!==null&&Qt(c,re,O),c.version=parseInt(te);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||Qt(c,re,O),c.live=!1;break;case"#":(te||fe)&&k.tagList.push(fe?[te,fe]:[te]);break;case"DISCONTINUITY":R++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,te]),C=parseInt(te)*1e3,w(C)?k.bitrate=C:C=0;break;case"DATERANGE":{var we=new rt(te,c),Be=new La(we,c.dateRanges[we.ID],c.dateRangeTagCount);c.dateRangeTagCount++,Be.isValid||c.skippedSegments?c.dateRanges[Be.id]=Be:Oe.warn('Ignoring invalid DATERANGE tag: "'+te+'"'),k.tagList.push(["EXT-X-DATERANGE",te]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":c.startCC!==0?Qt(c,re,O):p.length>0&&Fa(c,re,O),c.startCC=R=parseInt(te);break;case"KEY":{var Ce=Da(te,t,c);if(Ce.isSupported()){if(Ce.method==="NONE"){N=void 0;break}N||(N={}),N[Ce.keyFormat]&&(N=E({},N)),N[Ce.keyFormat]=Ce}else Oe.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+te+'"');break}case"START":c.startTimeOffset=Ia(te);break;case"MAP":{var et=new rt(te,c);if(k.duration){var Ge=new Ni(r,d);Oa(Ge,et,e,N),A=Ge,k.initSegment=A,A.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=A.rawProgramDateTime)}else{var Qe=k.byteRangeEndOffset;if(Qe){var _t=k.byteRangeStartOffset;z=Qe-_t+"@"+_t}else z=null;Oa(k,et,e,N),A=k,X=!0}A.cc=R;break}case"SERVER-CONTROL":{K&&Qt(c,re,O),K=new rt(te),c.canBlockReload=K.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=K.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&K.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=K.optionalFloat("PART-HOLD-BACK",0),c.holdBack=K.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{c.partTarget&&Qt(c,re,O);var ut=new rt(te);c.partTarget=ut.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ve=c.partList;Ve||(Ve=c.partList=[]);var St=b>0?Ve[Ve.length-1]:void 0,it=b++,$e=new rt(te,c),Tt=new eu($e,k,d,it,St);Ve.push(Tt),k.duration+=Tt.duration;break}case"PRELOAD-HINT":{var dt=new rt(te,c);c.preloadHint=dt;break}case"RENDITION-REPORT":{var xt=new rt(te,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(xt);break}default:Oe.warn("line parsed but not handled: "+O);break}}}I&&!I.relurl?(p.pop(),L-=I.duration,c.partList&&(c.fragmentHint=I)):c.partList&&(qi(k,I,y),k.cc=R,c.fragmentHint=k,N&&Ma(k,N,c)),c.targetduration||(c.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));var Ye=p.length,ct=p[0],nt=p[Ye-1];if(L+=c.skippedSegments*c.targetduration,L>0&&Ye&&nt){c.averagetargetduration=L/Ye;var At=nt.sn;c.endSN=At!=="initSegment"?At:0,c.live||(nt.endList=!0),ct&&c.startCC===void 0&&(c.startCC=ct.cc),B>0&&(Zu(p,B),ct&&y.unshift(ct))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(L+=c.fragmentHint.duration),c.totalduration=L,y.length&&c.dateRangeTagCount&&ct&&ka(y,c),c.endCC=R,c},n}();function ka(n,s){for(var i=n.length,t=n[i-1],e=s.live?1/0:s.totalduration,r=Object.keys(s.dateRanges),a=r.length;a--;){var u=s.dateRanges[r[a]],l=u.startDate.getTime();u.tagAnchor=t.ref;for(var d=i;d--;){var c=Qu(s,l,n,d,e);if(c!==-1){u.tagAnchor=s.fragments[c].ref;break}}}}function Qu(n,s,i,t,e){var r=i[t];if(r){var a=r.programDateTime;if(s>=a||t===0){var u,l=(((u=i[t+1])==null?void 0:u.start)||e)-r.start;if(s<=a+l*1e3){var d=i[t].sn-n.startSN,c=n.fragments;if(c.length>i.length)for(var p=i[t+1]||c[c.length-1],y=p.sn-n.startSN,A=y;A>d;A--){var T=c[A].programDateTime;if(s>=T&&s<T+c[A].duration*1e3)return A}return d}}}return-1}function Da(n,s,i){var t,e,r=new rt(n,i),a=(t=r.METHOD)!=null?t:"",u=r.URI,l=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,c=(e=r.KEYFORMAT)!=null?e:"identity";u&&r.IV&&!l&&Oe.error("Invalid IV: "+r.IV);var p=u?Fr.resolve(u,s):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new zu(a,p,c,y,l)}function Ia(n){var s=new rt(n),i=s.decimalFloatingPoint("TIME-OFFSET");return w(i)?i:null}function wa(n,s){var i=(n||"").split(/[ ,]+/).filter(function(t){return t});["video","audio","text"].forEach(function(t){var e=i.filter(function(r){return aa(r,t)});e.length&&(s[t+"Codec"]=e.map(function(r){return r.split("/")[0]}).join(","),i=i.filter(function(r){return e.indexOf(r)===-1}))}),s.unknownCodecs=i}function Pa(n,s,i){var t=s[i];t&&(n[i]=t)}function Zu(n,s){for(var i=n[s],t=s;t--;){var e=n[t];if(!e)return;e.programDateTime=i.programDateTime-e.duration*1e3,i=e}}function qi(n,s,i){n.rawProgramDateTime?i.push(n):s!=null&&s.programDateTime&&(n.programDateTime=s.endProgramDateTime)}function Oa(n,s,i,t){n.relurl=s.URI,s.BYTERANGE&&n.setByteRange(s.BYTERANGE),n.level=i,n.sn="initSegment",t&&(n.levelkeys=t),n.initSegment=null}function Ma(n,s,i){n.levelkeys=s;var t=i.encryptedFragments;(!t.length||t[t.length-1].levelkeys!==s)&&Object.keys(s).some(function(e){return s[e].isCommonEncryption})&&t.push(n)}function Qt(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must not appear more than once ("+i[0]+")")}function Fa(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must appear before the first Media Segment ("+i[0]+")")}function $i(n,s){var i=s.startPTS;if(w(i)){var t=0,e;s.sn>n.sn?(t=i-n.start,e=n):(t=n.start-i,e=s),e.duration!==t&&e.setDuration(t)}else if(s.sn>n.sn){var r=n.cc===s.cc;r&&n.minEndPTS?s.setStart(n.start+(n.minEndPTS-n.start)):s.setStart(n.start+n.duration)}else s.setStart(Math.max(n.start-s.duration,0))}function Na(n,s,i,t,e,r){var a=t-i;a<=0&&(Oe.warn("Fragment should have a positive duration",s),t=i+s.duration,r=e+s.duration);var u=i,l=t,d=s.startPTS,c=s.endPTS;if(w(d)){var p=Math.abs(d-i);w(s.deltaPTS)?s.deltaPTS=Math.max(p,s.deltaPTS):s.deltaPTS=p,u=Math.max(i,d),i=Math.min(i,d),e=Math.min(e,s.startDTS),l=Math.min(t,c),t=Math.max(t,c),r=Math.max(r,s.endDTS)}var y=i-s.start;s.start!==0&&s.setStart(i),s.setDuration(t-s.start),s.startPTS=i,s.maxStartPTS=u,s.startDTS=e,s.endPTS=t,s.minEndPTS=l,s.endDTS=r;var A=s.sn;if(!n||A<n.startSN||A>n.endSN)return 0;var T,b=A-n.startSN,L=n.fragments;for(L[b]=s,T=b;T>0;T--)$i(L[T],L[T-1]);for(T=b;T<L.length-1;T++)$i(L[T],L[T+1]);return n.fragmentHint&&$i(L[L.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,y}function Ju(n,s){if(n!==s){for(var i=null,t=n.fragments,e=t.length-1;e>=0;e--){var r=t[e].initSegment;if(r){i=r;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;var a;rl(n,s,function(T,b,L,R){if(s.skippedSegments&&b.cc!==T.cc)for(var C=T.cc-b.cc,I=L;I<R.length;I++)R[I].cc+=C;w(T.startPTS)&&w(T.endPTS)&&(b.setStart(b.startPTS=T.startPTS),b.startDTS=T.startDTS,b.maxStartPTS=T.maxStartPTS,b.endPTS=T.endPTS,b.endDTS=T.endDTS,b.minEndPTS=T.minEndPTS,b.setDuration(T.endPTS-T.startPTS),b.duration&&(a=b),s.PTSKnown=s.alignedSliding=!0),T.hasStreams&&(b.elementaryStreams=T.elementaryStreams),b.loader=T.loader,T.hasStats&&(b.stats=T.stats),T.initSegment&&(b.initSegment=T.initSegment,i=T.initSegment)});var u=s.fragments,l=s.fragmentHint?u.concat(s.fragmentHint):u;if(i&&l.forEach(function(T){var b;T&&(!T.initSegment||T.initSegment.relurl===((b=i)==null?void 0:b.relurl))&&(T.initSegment=i)}),s.skippedSegments)if(s.deltaUpdateFailed=u.some(function(T){return!T}),s.deltaUpdateFailed){Oe.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=s.skippedSegments;d--;)u.shift();s.startSN=u[0].sn}else{s.endCC=u[u.length-1].cc,s.canSkipDateRanges&&(s.dateRanges=el(n.dateRanges,s));var c=n.fragments.filter(function(T){return T.rawProgramDateTime});if(n.hasProgramDateTime&&!s.hasProgramDateTime)for(var p=1;p<l.length;p++)l[p].programDateTime===null&&qi(l[p],l[p-1],c);ka(c,s)}tl(n.partList,s.partList,function(T,b){b.elementaryStreams=T.elementaryStreams,b.stats=T.stats}),a?Na(s,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ba(n,s),u.length&&(s.totalduration=s.edge-u[0].start),s.driftStartTime=n.driftStartTime,s.driftStart=n.driftStart;var y=s.advancedDateTime;if(s.advanced&&y){var A=s.edge;s.driftStart||(s.driftStartTime=y,s.driftStart=A),s.driftEndTime=y,s.driftEnd=A}else s.driftEndTime=n.driftEndTime,s.driftEnd=n.driftEnd,s.advancedDateTime=n.advancedDateTime;s.requestScheduled===-1&&(s.requestScheduled=n.requestScheduled)}}function el(n,s){var i=s.dateRanges,t=s.recentlyRemovedDateranges,e=E({},n);t&&t.forEach(function(u){delete e[u]});var r=Object.keys(e),a=r.length;return a&&Object.keys(i).forEach(function(u){var l=e[u],d=new La(i[u].attr,l);d.isValid?(e[u]=d,l||(d.tagOrder+=a)):Oe.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+gt(i[u].attr)+'"')}),e}function tl(n,s,i){if(n&&s)for(var t=0,e=0,r=n.length;e<=r;e++){var a=n[e],u=s[e+t];a&&u&&a.index===u.index&&a.fragment.sn===u.fragment.sn?i(a,u):t--}}function rl(n,s,i){for(var t=s.skippedSegments,e=Math.max(n.startSN,s.startSN)-s.startSN,r=(n.fragmentHint?1:0)+(t?s.endSN:Math.min(n.endSN,s.endSN))-s.startSN,a=s.startSN-n.startSN,u=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,d=e;d<=r;d++){var c=l[a+d],p=u[d];if(t&&!p&&c&&(p=s.fragments[d]=c),c&&p){if(i(c,p,d,u),c.url&&c.url!==p.url){s.playlistParsingError=Ua("media sequence mismatch "+p.sn+":",n,s,c,p);return}else if(c.cc!==p.cc){s.playlistParsingError=Ua("discontinuity sequence mismatch ("+c.cc+"!="+p.cc+")",n,s,c,p);return}}}}function Ua(n,s,i,t,e){return new Error(n+" "+e.url+`
18
+ Playlist starting @`+s.startSN+`
19
+ `+s.m3u8+`
20
+
21
+ Playlist starting @`+i.startSN+`
22
+ `+i.m3u8)}function Ba(n,s,i){i===void 0&&(i=!0);var t=s.startSN+s.skippedSegments-n.startSN,e=n.fragments,r=t>=0,a=0;if(r&&t<e.length)a=e[t].start;else if(r&&s.startSN===n.endSN+1)a=n.fragmentEnd;else if(r&&i)a=n.fragmentStart+t*s.levelTargetDuration;else if(!s.skippedSegments&&s.fragmentStart===0)a=n.fragmentStart;else return;il(s,a)}function il(n,s){if(s){for(var i=n.fragments,t=n.skippedSegments;t<i.length;t++)i[t].addStart(s);n.fragmentHint&&n.fragmentHint.addStart(s)}}function Ga(n,s){s===void 0&&(s=1/0);var i=1e3*n.targetduration;if(n.updated){var t=n.fragments,e=4;if(t.length&&i*e>s){var r=t[t.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function nl(n,s,i){if(!n)return null;var t=n.fragments[s-n.startSN];return t||(t=n.fragmentHint,t&&t.sn===s)?t:s<n.startSN&&i&&i.sn===s?i:null}function Va(n,s,i){return n?Ha(n.partList,s,i):null}function Ha(n,s,i){if(n)for(var t=n.length;t--;){var e=n[t];if(e.index===i&&e.fragment.sn===s)return e}return null}function Ka(n){n.forEach(function(s,i){var t;(t=s.details)==null||t.fragments.forEach(function(e){e.level=i,e.initSegment&&(e.initSegment.level=i)})})}var al=3e5,sl=function(n){function s(t){var e;return e=n.call(this,"content-steering",t.logger)||this,e.hls=void 0,e.loader=null,e.uri=null,e.pathwayId=".",e._pathwayPriority=null,e.timeToLoad=300,e.reloadTimer=-1,e.updated=0,e.started=!1,e.enabled=!0,e.levels=null,e.audioTracks=null,e.subtitleTracks=null,e.penalizedPathways={},e.hls=t,e.registerListeners(),e}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))},i.pathways=function(){return(this.levels||[]).reduce(function(e,r){return e.indexOf(r.pathwayId)===-1&&e.push(r.pathwayId),e},[])},i.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)}},i.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},i.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},i.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},i.removeLevel=function(e){var r=this.levels;r&&(this.levels=r.filter(function(a){return a!==e}))},i.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},i.onManifestLoaded=function(e,r){var a=r.contentSteering;a!==null&&(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},i.onManifestParsed=function(e,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},i.onError=function(e,r){var a=r.errorAction;if(a?.action===ht.SendAlternateToPenaltyBox&&a.flags===Mt.MoveAllAlternatesMatchingHost){var u=this.levels,l=this._pathwayPriority,d=this.pathwayId;if(r.context){var c=r.context,p=c.groupId,y=c.pathwayId,A=c.type;p&&u?d=this.getPathwayForGroupId(p,A,d):y&&(d=y)}d in this.penalizedPathways||(this.penalizedPathways[d]=performance.now()),!l&&u&&(l=this.pathways()),l&&l.length>1&&(this.updatePathwayPriority(l),a.resolved=this.pathwayId!==d),a.resolved||this.warn("Could not resolve "+r.details+' ("'+r.error.message+'") with content-steering for Pathway: '+d+" levels: "+(u&&u.length)+" priorities: "+gt(l)+" penalized: "+gt(this.penalizedPathways))}},i.filterParsedLevels=function(e){this.levels=e;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var a=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+a+'"'),r=this.getLevelsForPathway(a),this.pathwayId=a}return r.length!==e.length&&this.log("Found "+r.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),r},i.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(r){return e===r.pathwayId})},i.updatePathwayPriority=function(e){this._pathwayPriority=e;var r,a=this.penalizedPathways,u=performance.now();Object.keys(a).forEach(function(A){u-a[A]>al&&delete a[A]});for(var l=0;l<e.length;l++){var d=e[l];if(!(d in a)){if(d===this.pathwayId)return;var c=this.hls.nextLoadLevel,p=this.hls.levels[c];if(r=this.getLevelsForPathway(d),r.length>0){this.log('Setting Pathway to "'+d+'"'),this.pathwayId=d,Ka(r),this.hls.trigger(x.LEVELS_UPDATED,{levels:r});var y=this.hls.levels[c];p&&y&&this.levels&&(y.attrs["STABLE-VARIANT-ID"]!==p.attrs["STABLE-VARIANT-ID"]&&y.bitrate!==p.bitrate&&this.log("Unstable Pathways change from bitrate "+p.bitrate+" to "+y.bitrate),this.hls.nextLoadLevel=c);break}}}},i.getPathwayForGroupId=function(e,r,a){for(var u=this.getLevelsForPathway(a).concat(this.levels||[]),l=0;l<u.length;l++)if(r===ie.AUDIO_TRACK&&u[l].hasAudioGroup(e)||r===ie.SUBTITLE_TRACK&&u[l].hasSubtitleGroup(e))return u[l].pathwayId;return a},i.clonePathways=function(e){var r=this,a=this.levels;if(a){var u={},l={};e.forEach(function(d){var c=d.ID,p=d["BASE-ID"],y=d["URI-REPLACEMENT"];if(!a.some(function(T){return T.pathwayId===c})){var A=r.getLevelsForPathway(p).map(function(T){var b=new rt(T.attrs);b["PATHWAY-ID"]=c;var L=b.AUDIO&&b.AUDIO+"_clone_"+c,R=b.SUBTITLES&&b.SUBTITLES+"_clone_"+c;L&&(u[b.AUDIO]=L,b.AUDIO=L),R&&(l[b.SUBTITLES]=R,b.SUBTITLES=R);var C=ja(T.uri,b["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",y),I=new da({attrs:b,audioCodec:T.audioCodec,bitrate:T.bitrate,height:T.height,name:T.name,url:C,videoCodec:T.videoCodec,width:T.width});if(T.audioGroups)for(var k=1;k<T.audioGroups.length;k++)I.addGroupId("audio",T.audioGroups[k]+"_clone_"+c);if(T.subtitleGroups)for(var O=1;O<T.subtitleGroups.length;O++)I.addGroupId("text",T.subtitleGroups[O]+"_clone_"+c);return I});a.push.apply(a,A),Wa(r.audioTracks,u,y,c),Wa(r.subtitleTracks,l,y,c)}})}},i.loadSteeringManifest=function(e){var r=this,a=this.hls.config,u=a.loader;this.loader&&this.loader.destroy(),this.loader=new u(a);var l;try{l=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(l.protocol!=="data:"){var d=(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate)|0;l.searchParams.set("_HLS_pathway",this.pathwayId),l.searchParams.set("_HLS_throughput",""+d)}var c={responseType:"json",url:l.href},p=a.steeringManifestLoadPolicy.default,y=p.errorRetry||p.timeoutRetry||{},A={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:y.maxNumRetry||0,retryDelay:y.retryDelayMs||0,maxRetryDelay:y.maxRetryDelayMs||0},T={onSuccess:function(L,R,C,I){r.log('Loaded steering manifest: "'+l+'"');var k=L.data;if(k?.VERSION!==1){r.log("Steering VERSION "+k.VERSION+" not supported!");return}r.updated=performance.now(),r.timeToLoad=k.TTL;var O=k["RELOAD-URI"],V=k["PATHWAY-CLONES"],N=k["PATHWAY-PRIORITY"];if(O)try{r.uri=new self.URL(O,l).href}catch{r.enabled=!1,r.log("Failed to parse Steering Manifest RELOAD-URI: "+O);return}r.scheduleRefresh(r.uri||C.url),V&&r.clonePathways(V);var B={steeringManifest:k,url:l.toString()};r.hls.trigger(x.STEERING_MANIFEST_LOADED,B),N&&r.updatePathwayPriority(N)},onError:function(L,R,C,I){if(r.log("Error loading steering manifest: "+L.code+" "+L.text+" ("+R.url+")"),r.stopLoad(),L.code===410){r.enabled=!1,r.log("Steering manifest "+R.url+" no longer available");return}var k=r.timeToLoad*1e3;if(L.code===429){var O=r.loader;if(typeof O?.getResponseHeader=="function"){var V=O.getResponseHeader("Retry-After");V&&(k=parseFloat(V)*1e3)}r.log("Steering manifest "+R.url+" rate limited");return}r.scheduleRefresh(r.uri||R.url,k)},onTimeout:function(L,R,C){r.log("Timeout loading steering manifest ("+R.url+")"),r.scheduleRefresh(r.uri||R.url)}};this.log("Requesting steering manifest: "+l),this.loader.load(c,A,T)},i.scheduleRefresh=function(e,r){var a=this;r===void 0&&(r=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var u,l=(u=a.hls)==null?void 0:u.media;if(l&&!l.ended){a.loadSteeringManifest(e);return}a.scheduleRefresh(e,a.timeToLoad*1e3)},r)},f(s,[{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}}])}(je);function Wa(n,s,i,t){n&&Object.keys(s).forEach(function(e){var r=n.filter(function(a){return a.groupId===e}).map(function(a){var u=E({},a);return u.details=void 0,u.attrs=new rt(u.attrs),u.url=u.attrs.URI=ja(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),u.groupId=u.attrs["GROUP-ID"]=s[e],u.attrs["PATHWAY-ID"]=t,u});n.push.apply(n,r)})}function ja(n,s,i,t){var e=t.HOST,r=t.PARAMS,a=t[i],u;s&&(u=a?.[s],u&&(n=u));var l=new self.URL(n);return e&&!u&&(l.host=e),r&&Object.keys(r).sort().forEach(function(d){d&&l.searchParams.set(d,r[d])}),l.href}var ol=function(){function n(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 s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var a=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=a,a&&typeof a.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},s.onMediaDetaching=function(){this.media=null},s.checkFPS=function(t,e,r){var a=performance.now();if(e){if(this.lastTime){var u=a-this.lastTime,l=r-this.lastDroppedFrames,d=e-this.lastDecodedFrames,c=1e3*l/u,p=this.hls;if(p.trigger(x.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:r}),c>0&&l>p.config.fpsDroppedMonitoringThreshold*d){var y=p.currentLevel;p.logger.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(x.FPS_DROP_LEVEL_CAPPING,{level:y,droppedLevel:p.currentLevel}),p.autoLevelCapping=y,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},s.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},n}(),ul=function(){function n(){this.chunks=[],this.dataLength=0}var s=n.prototype;return s.push=function(t){this.chunks.push(t),this.dataLength+=t.length},s.flush=function(){var t=this.chunks,e=this.dataLength,r;if(t.length)t.length===1?r=t[0]:r=ll(t,e);else return new Uint8Array(0);return this.reset(),r},s.reset=function(){this.chunks.length=0,this.dataLength=0},n}();function ll(n,s){for(var i=new Uint8Array(s),t=0,e=0;e<n.length;e++){var r=n[e];i.set(r,t),t+=r.length}return i}function Ya(n,s){return s+10<=n.length&&n[s]===51&&n[s+1]===68&&n[s+2]===73&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function Xi(n,s){return s+10<=n.length&&n[s]===73&&n[s+1]===68&&n[s+2]===51&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function fi(n,s){var i=0;return i=(n[s]&127)<<21,i|=(n[s+1]&127)<<14,i|=(n[s+2]&127)<<7,i|=n[s+3]&127,i}function hi(n,s){for(var i=s,t=0;Xi(n,s);){t+=10;var e=fi(n,s+6);t+=e,Ya(n,s+10)&&(t+=10),s+=t}if(t>0)return n.subarray(i,i+t)}function fl(n,s,i,t){var e=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=s[i+2],a=r>>2&15;if(a>12){var u=new Error("invalid ADTS sampling index:"+a);n.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:u,reason:u.message});return}var l=(r>>6&3)+1,d=s[i+3]>>6&3|(r&1)<<2,c="mp4a.40."+l,p=e[a],y=a;(l===5||l===29)&&(y-=3);var A=[l<<3|(y&14)>>1,(y&1)<<7|d<<3];return Oe.log("manifest codec:"+t+", parsed codec:"+c+", channels:"+d+", rate:"+p+" (ADTS object type:"+l+" sampling index:"+a+")"),{config:A,samplerate:p,channelCount:d,codec:c,parsedCodec:c,manifestCodec:t}}function za(n,s){return n[s]===255&&(n[s+1]&246)===240}function qa(n,s){return n[s+1]&1?7:9}function Qi(n,s){return(n[s+3]&3)<<11|n[s+4]<<3|(n[s+5]&224)>>>5}function hl(n,s){return s+5<n.length}function di(n,s){return s+1<n.length&&za(n,s)}function dl(n,s){return hl(n,s)&&za(n,s)&&Qi(n,s)<=n.length-s}function cl(n,s){if(di(n,s)){var i=qa(n,s);if(s+i>=n.length)return!1;var t=Qi(n,s);if(t<=i)return!1;var e=s+t;return e===n.length||di(n,e)}return!1}function $a(n,s,i,t,e){if(!n.samplerate){var r=fl(s,i,t,e);if(!r)return;E(n,r)}}function Xa(n){return 1024*9e4/n}function vl(n,s){var i=qa(n,s);if(s+i<=n.length){var t=Qi(n,s)-i;if(t>0)return{headerLength:i,frameLength:t}}}function Qa(n,s,i,t,e){var r=Xa(n.samplerate),a=t+e*r,u=vl(s,i),l;if(u){var d=u.frameLength,c=u.headerLength,p=c+d,y=Math.max(0,i+p-s.length);y?(l=new Uint8Array(p-c),l.set(s.subarray(i+c,s.length),0)):l=s.subarray(i+c,i+p);var A={unit:l,pts:a};return y||n.samples.push(A),{sample:A,length:p,missing:y}}var T=s.length-i;l=new Uint8Array(T),l.set(s.subarray(i,s.length),0);var b={unit:l,pts:a};return{sample:b,length:T,missing:-1}}function pl(n,s){return Xi(n,s)&&fi(n,s+6)+10<=n.length-s}function gl(n){if(!(n.size<2)){var s=Pt(n.data,!0),i=new Uint8Array(n.data.subarray(s.length+1));return{key:n.type,info:s,data:i.buffer}}}function ml(n){if(!(n.size<2)){if(n.type==="TXXX"){var s=1,i=Pt(n.data.subarray(s),!0);s+=i.length+1;var t=Pt(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Pt(n.data.subarray(1));return{key:n.type,info:"",data:e}}}function yl(n){if(n.type==="WXXX"){if(n.size<2)return;var s=1,i=Pt(n.data.subarray(s),!0);s+=i.length+1;var t=Pt(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Pt(n.data);return{key:n.type,info:"",data:e}}function El(n){return n instanceof ArrayBuffer?n:n.byteOffset==0&&n.byteLength==n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer}function Zi(n,s,i){return s===void 0&&(s=0),i===void 0&&(i=1/0),_l(n,s,i,Uint8Array)}function _l(n,s,i,t){var e=Sl(n),r=1;"BYTES_PER_ELEMENT"in t&&(r=t.BYTES_PER_ELEMENT);var a=Tl(n)?n.byteOffset:0,u=(a+n.byteLength)/r,l=(a+s)/r,d=Math.floor(Math.max(0,Math.min(l,u))),c=Math.floor(Math.min(d+Math.max(i,0),u));return new t(e,d,c-d)}function Sl(n){return n instanceof ArrayBuffer?n:n.buffer}function Tl(n){return n&&n.buffer instanceof ArrayBuffer&&n.byteLength!==void 0&&n.byteOffset!==void 0}function Al(n){var s={key:n.type,description:"",data:"",mimeType:null,pictureType:null},i=3;if(!(n.size<2)){if(n.data[0]!==i){console.log("Ignore frame with unrecognized character encoding");return}var t=n.data.subarray(1).indexOf(0);if(t!==-1){var e=Pt(Zi(n.data,1,t)),r=n.data[2+t],a=n.data.subarray(3+t).indexOf(0);if(a!==-1){var u=Pt(Zi(n.data,3+t,a)),l;return e==="-->"?l=Pt(Zi(n.data,4+t+a)):l=El(n.data.subarray(4+t+a)),s.mimeType=e,s.pictureType=r,s.description=u,s.data=l,s}}}}function bl(n){return n.type==="PRIV"?gl(n):n.type[0]==="W"?yl(n):n.type==="APIC"?Al(n):ml(n)}function Ll(n){var s=String.fromCharCode(n[0],n[1],n[2],n[3]),i=fi(n,4),t=10;return{type:s,size:i,data:n.subarray(t,t+i)}}var ci=10,xl=10;function Za(n){for(var s=0,i=[];Xi(n,s);){var t=fi(n,s+6);n[s+5]>>6&1&&(s+=ci),s+=ci;for(var e=s+t;s+xl<e;){var r=Ll(n.subarray(s)),a=bl(r);a&&i.push(a),s+=r.size+ci}Ya(n,s)&&(s+=ci)}return i}function Ja(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"}function Rl(n){if(n.data.byteLength===8){var s=new Uint8Array(n.data),i=s[3]&1,t=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return t/=45,i&&(t+=4772185884e-2),Math.round(t)}}function es(n){for(var s=Za(n),i=0;i<s.length;i++){var t=s[i];if(Ja(t))return Rl(t)}}var Lt=function(n){return n.audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3",n.misbklv="urn:misb:KLV:bin:1910.1",n}({});function qt(n,s){return n===void 0&&(n=""),s===void 0&&(s=9e4),{type:n,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var ts=function(){function n(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(t,e){return!1},s.appendFrame=function(t,e,r){},s.demux=function(t,e){this.cachedData&&(t=Ot(this.cachedData,t),this.cachedData=null);var r=hi(t,0),a=r?r.length:0,u,l=this._audioTrack,d=this._id3Track,c=r?es(r):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&w(c))&&(this.basePTS=Cl(c,e,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:Lt.audioId3,duration:Number.POSITIVE_INFINITY});a<p;){if(this.canParse(t,a)){var y=this.appendFrame(l,t,a);y?(this.frameIndex++,this.lastPTS=y.sample.pts,a+=y.length,u=a):a=p}else pl(t,a)?(r=hi(t,a),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Lt.audioId3,duration:Number.POSITIVE_INFINITY}),a+=r.length,u=a):a++;if(a===p&&u!==p){var A=t.slice(u);this.cachedData?this.cachedData=Ot(this.cachedData,A):this.cachedData=A}}return{audioTrack:l,videoTrack:qt(),id3Track:d,textTrack:qt()}},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:qt(),id3Track:this._id3Track,textTrack:qt()}},s.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},n}(),Cl=function(s,i,t){if(w(s))return s*90;var e=t?t.baseTime*9e4/t.timescale:0;return i*9e4+e},vi=null,kl=[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],Dl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Il=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],wl=[0,1,1,4];function rs(n,s,i,t,e){if(!(i+24>s.length)){var r=is(s,i);if(r&&i+r.frameLength<=s.length){var a=r.samplesPerFrame*9e4/r.sampleRate,u=t+e*a,l={unit:s.subarray(i,i+r.frameLength),pts:u,dts:u};return n.config=[],n.channelCount=r.channelCount,n.samplerate=r.sampleRate,n.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function is(n,s){var i=n[s+1]>>3&3,t=n[s+1]>>1&3,e=n[s+2]>>4&15,r=n[s+2]>>2&3;if(i!==1&&e!==0&&e!==15&&r!==3){var a=n[s+2]>>1&1,u=n[s+3]>>6,l=i===3?3-t:t===3?3:4,d=kl[l*14+e-1]*1e3,c=i===3?0:i===2?1:2,p=Dl[c*3+r],y=u===3?1:2,A=Il[i][t],T=wl[t],b=A*8*T,L=Math.floor(A*d/p+a)*T;if(vi===null){var R=navigator.userAgent||"",C=R.match(/Chrome\/(\d+)/i);vi=C?parseInt(C[1]):0}var I=!!vi&&vi<=87;return I&&t===2&&d>=224e3&&u===0&&(n[s+3]=n[s+3]|128),{sampleRate:p,channelCount:y,frameLength:L,samplesPerFrame:b}}}function Ji(n,s){return n[s]===255&&(n[s+1]&224)===224&&(n[s+1]&6)!==0}function ns(n,s){return s+1<n.length&&Ji(n,s)}function Pl(n,s){var i=4;return Ji(n,s)&&i<=n.length-s}function as(n,s){if(s+1<n.length&&Ji(n,s)){var i=4,t=is(n,s),e=i;t!=null&&t.frameLength&&(e=t.frameLength);var r=s+e;return r===n.length||ns(n,r)}return!1}var Ol=function(n){function s(t,e){var r;return r=n.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=t,r.config=e,r}S(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,u){n.prototype.resetInitSegment.call(this,e,r,a,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}},s.probe=function(e,r){if(!e)return!1;var a=hi(e,0),u=a?.length||0;if(as(e,u))return!1;for(var l=e.length;u<l;u++)if(cl(e,u))return r.log("ADTS sync word found !"),!0;return!1},i.canParse=function(e,r){return dl(e,r)},i.appendFrame=function(e,r,a){$a(e,this.observer,r,a,e.manifestCodec);var u=Qa(e,r,a,this.basePTS,this.frameIndex);if(u&&u.missing===0)return u},s}(ts),Ml=function(s,i){var t=0,e=5;i+=e;for(var r=new Uint32Array(1),a=new Uint32Array(1),u=new Uint8Array(1);e>0;){u[0]=s[i];var l=Math.min(e,8),d=8-l;a[0]=4278190080>>>24+d<<d,r[0]=(u[0]&a[0])>>d,t=t?t<<l|r[0]:r[0],i+=1,e-=l}return t},Fl=function(n){function s(){return n.apply(this,arguments)||this}S(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,u){n.prototype.resetInitSegment.call(this,e,r,a,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}},s.probe=function(e){if(!e)return!1;var r=hi(e,0),a=r?.length||0;if(r&&e[a]===11&&e[a+1]===119&&es(r)!==void 0&&Ml(e,a)<=16)return!1;for(var u=e.length;a<u;a++)if(as(e,a))return Oe.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(e,r){return Pl(e,r)},i.appendFrame=function(e,r,a){if(this.basePTS!==null)return rs(e,r,a,this.basePTS,this.frameIndex)},s}(ts),Nl=function(){function n(i,t,e){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=i,this.aesIV=t,this.aesMode=e}var s=n.prototype;return s.decrypt=function(t,e){switch(this.aesMode){case ar.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t);case ar.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,t);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},n}();function Ul(n){var s=n.byteLength,i=s&&new DataView(n.buffer).getUint8(s-1);return i?n.slice(0,s-i):n}var Bl=function(){function n(){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 s=n.prototype;return s.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),a=0;a<4;a++)r[a]=e.getUint32(a*4);return r},s.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,a=r[0],u=r[1],l=r[2],d=r[3],c=this.invSubMix,p=c[0],y=c[1],A=c[2],T=c[3],b=new Uint32Array(256),L=0,R=0,C=0;for(C=0;C<256;C++)C<128?b[C]=C<<1:b[C]=C<<1^283;for(C=0;C<256;C++){var I=R^R<<1^R<<2^R<<3^R<<4;I=I>>>8^I&255^99,t[L]=I,e[I]=L;var k=b[L],O=b[k],V=b[O],N=b[I]*257^I*16843008;a[L]=N<<24|N>>>8,u[L]=N<<16|N>>>16,l[L]=N<<8|N>>>24,d[L]=N,N=V*16843009^O*65537^k*257^L*16843008,p[I]=N<<24|N>>>8,y[I]=N<<16|N>>>16,A[I]=N<<8|N>>>24,T[I]=N,L?(L=k^b[b[b[V^k]]],R^=b[b[R]]):L=R=1}},s.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,a=0;a<e.length&&r;)r=e[a]===this.key[a],a++;if(!r){this.key=e;var u=this.keySize=e.length;if(u!==4&&u!==6&&u!==8)throw new Error("Invalid aes key size="+u);var l=this.ksRows=(u+6+1)*4,d,c,p=this.keySchedule=new Uint32Array(l),y=this.invKeySchedule=new Uint32Array(l),A=this.sBox,T=this.rcon,b=this.invSubMix,L=b[0],R=b[1],C=b[2],I=b[3],k,O;for(d=0;d<l;d++){if(d<u){k=p[d]=e[d];continue}O=k,d%u===0?(O=O<<8|O>>>24,O=A[O>>>24]<<24|A[O>>>16&255]<<16|A[O>>>8&255]<<8|A[O&255],O^=T[d/u|0]<<24):u>6&&d%u===4&&(O=A[O>>>24]<<24|A[O>>>16&255]<<16|A[O>>>8&255]<<8|A[O&255]),p[d]=k=(p[d-u]^O)>>>0}for(c=0;c<l;c++)d=l-c,c&3?O=p[d]:O=p[d-4],c<4||d<=4?y[c]=O:y[c]=L[A[O>>>24]]^R[A[O>>>16&255]]^C[A[O>>>8&255]]^I[A[O&255]],y[c]=y[c]>>>0}},s.networkToHostOrderSwap=function(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24},s.decrypt=function(t,e,r){for(var a=this.keySize+6,u=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,c=d[0],p=d[1],y=d[2],A=d[3],T=this.uint8ArrayToUint32Array_(r),b=T[0],L=T[1],R=T[2],C=T[3],I=new Int32Array(t),k=new Int32Array(I.length),O,V,N,B,X,z,K,j,J,le,re,te,fe,de,ve=this.networkToHostOrderSwap;e<I.length;){for(J=ve(I[e]),le=ve(I[e+1]),re=ve(I[e+2]),te=ve(I[e+3]),X=J^u[0],z=te^u[1],K=re^u[2],j=le^u[3],fe=4,de=1;de<a;de++)O=c[X>>>24]^p[z>>16&255]^y[K>>8&255]^A[j&255]^u[fe],V=c[z>>>24]^p[K>>16&255]^y[j>>8&255]^A[X&255]^u[fe+1],N=c[K>>>24]^p[j>>16&255]^y[X>>8&255]^A[z&255]^u[fe+2],B=c[j>>>24]^p[X>>16&255]^y[z>>8&255]^A[K&255]^u[fe+3],X=O,z=V,K=N,j=B,fe=fe+4;O=l[X>>>24]<<24^l[z>>16&255]<<16^l[K>>8&255]<<8^l[j&255]^u[fe],V=l[z>>>24]<<24^l[K>>16&255]<<16^l[j>>8&255]<<8^l[X&255]^u[fe+1],N=l[K>>>24]<<24^l[j>>16&255]<<16^l[X>>8&255]<<8^l[z&255]^u[fe+2],B=l[j>>>24]<<24^l[X>>16&255]<<16^l[z>>8&255]<<8^l[K&255]^u[fe+3],k[e]=ve(O^b),k[e+1]=ve(B^L),k[e+2]=ve(N^R),k[e+3]=ve(V^C),b=J,L=le,R=re,C=te,e=e+4}return k.buffer},n}(),Gl=function(){function n(i,t,e){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=i,this.key=t,this.aesMode=e}var s=n.prototype;return s.expandKey=function(){var t=Vl(this.aesMode);return this.subtle.importKey("raw",this.key,{name:t},!1,["encrypt","decrypt"])},n}();function Vl(n){switch(n){case ar.cbc:return"AES-CBC";case ar.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+n)}}var Hl=16,en=function(){function n(i,t){var e=t===void 0?{}:t,r=e.removePKCS7Padding,a=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.enableSoftwareAES=void 0,this.enableSoftwareAES=i.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var s=n.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Ul(r):r},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(t,e,r,a){var u=this;return this.useSoftware?new Promise(function(l,d){var c=ArrayBuffer.isView(t)?t:new Uint8Array(t);u.softwareDecrypt(c,e,r,a);var p=u.flush();p?l(p.buffer):d(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r,a)},s.softwareDecrypt=function(t,e,r,a){var u=this.currentIV,l=this.currentResult,d=this.remainderData;if(a!==ar.cbc||e.byteLength!==16)return Oe.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),d&&(t=Ot(d,t),this.remainderData=null);var c=this.getValidChunk(t);if(!c.length)return null;u&&(r=u);var p=this.softwareDecrypter;p||(p=this.softwareDecrypter=new Bl),p.expandKey(e);var y=l;return this.currentResult=p.decrypt(c.buffer,0,r),this.currentIV=c.slice(-16).buffer,y||null},s.webCryptoDecrypt=function(t,e,r,a){var u=this;if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,r,a));this.key=e,this.fastAesKey=new Gl(this.subtle,e,a)}return this.fastAesKey.expandKey().then(function(l){if(!u.subtle)return Promise.reject(new Error("web crypto not initialized"));u.logOnce("WebCrypto AES decrypt");var d=new Nl(u.subtle,new Uint8Array(r),a);return d.decrypt(t.buffer,l)}).catch(function(l){return Oe.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+l.name+": "+l.message),u.onWebCryptoError(t,e,r,a)})},s.onWebCryptoError=function(t,e,r,a){var u=this.enableSoftwareAES;if(u){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r,a);var l=this.flush();if(l)return l.buffer}throw new Error("WebCrypto"+(u?" and softwareDecrypt":"")+": failed to decrypt data")},s.getValidChunk=function(t){var e=t,r=t.length-t.length%Hl;return r!==t.length&&(e=t.slice(0,r),this.remainderData=t.slice(r)),e},s.logOnce=function(t){this.logEnabled&&(Oe.log("[decrypter]: "+t),this.logEnabled=!1)},n}(),Kl=/\/emsg[-/]ID3/i,Wl=function(){function n(i,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var s=n.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(t,e,r,a){var u=this.videoTrack=qt("video",1),l=this.audioTrack=qt("audio",1),d=this.txtTrack=qt("text",1);if(this.id3Track=qt("id3",1),this.timeOffset=0,!!(t!=null&&t.byteLength)){var c=ea(t);if(c.video){var p=c.video,y=p.id,A=p.timescale,T=p.codec,b=p.supplemental;u.id=y,u.timescale=d.timescale=A,u.codec=T,u.supplemental=b}if(c.audio){var L=c.audio,R=L.id,C=L.timescale,I=L.codec;l.id=R,l.timescale=C,l.codec=I}d.id=Xn.text,u.sampleDuration=0,u.duration=l.duration=a}},s.resetContiguity=function(){this.remainderData=null},n.probe=function(t){return iu(t)},s.demux=function(t,e){this.timeOffset=e;var r=t,a=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ot(this.remainderData,t));var l=du(r);this.remainderData=l.remainder,a.samples=l.valid||new Uint8Array}else a.samples=r;var d=this.extractID3Track(a,e);return u.samples=ta(e,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},s.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var a=this.extractID3Track(e,this.timeOffset);return r.samples=ta(t,e),{videoTrack:e,audioTrack:qt(),id3Track:a,textTrack:qt()}},s.extractID3Track=function(t,e){var r=this,a=this.id3Track;if(t.samples.length){var u=Te(t.samples,["emsg"]);u&&u.forEach(function(l){var d=vu(l);if(Kl.test(d.schemeIdUri)){var c=ss(d,e),p=d.eventDuration===4294967295?Number.POSITIVE_INFINITY:d.eventDuration/d.timeScale;p<=.001&&(p=Number.POSITIVE_INFINITY);var y=d.payload;a.samples.push({data:y,len:y.byteLength,dts:c,pts:c,type:Lt.emsg,duration:p})}else if(r.config.enableEmsgKLVMetadata&&d.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var A=ss(d,e);a.samples.push({data:d.payload,len:d.payload.byteLength,dts:A,pts:A,type:Lt.misbklv,duration:Number.POSITIVE_INFINITY})}})}return a},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},n}();function ss(n,s){return w(n.presentationTime)?n.presentationTime/n.timeScale:s+n.presentationTimeDelta/n.timeScale}var jl=function(){function n(i,t,e){this.keyData=void 0,this.decrypter=void 0,this.keyData=e,this.decrypter=new en(t,{removePKCS7Padding:!1})}var s=n.prototype;return s.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,ar.cbc)},s.decryptAacSample=function(t,e,r){var a=this,u=t[e].unit;if(!(u.length<=16)){var l=u.subarray(16,u.length-u.length%16),d=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(d).then(function(c){var p=new Uint8Array(c);u.set(p,16),a.decrypter.isSync()||a.decryptAacSamples(t,e+1,r)})}},s.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},s.getAvcEncryptedData=function(t){for(var e=Math.floor((t.length-48)/160)*16+16,r=new Int8Array(e),a=0,u=32;u<t.length-16;u+=160,a+=16)r.set(t.subarray(u,u+16),a);return r},s.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),a=0,u=32;u<t.length-16;u+=160,a+=16)t.set(r.subarray(a,a+16),u);return t},s.decryptAvcSample=function(t,e,r,a,u){var l=this,d=ia(u.data),c=this.getAvcEncryptedData(d);this.decryptBuffer(c.buffer).then(function(p){u.data=l.getAvcDecryptedUnit(d,p),l.decrypter.isSync()||l.decryptAvcSamples(t,e,r+1,a)})},s.decryptAvcSamples=function(t,e,r,a){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){a();return}for(var u=t[e].units;!(r>=u.length);r++){var l=u[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,r,a,l),!this.decrypter.isSync()))return}}},n}(),Yl=function(){function n(){this.VideoSample=null}var s=n.prototype;return s.createVideoSample=function(t,e,r){return{key:t,frame:!1,pts:e,dts:r,units:[],length:0}},s.getLastNalUnit=function(t){var e,r=this.VideoSample,a;if((!r||r.units.length===0)&&(r=t[t.length-1]),(e=r)!=null&&e.units){var u=r.units;a=u[u.length-1]}return a},s.pushAccessUnit=function(t,e){if(t.units.length&&t.frame){if(t.pts===void 0){var r=e.samples,a=r.length;if(a){var u=r[a-1];t.pts=u.pts,t.dts=u.dts}else{e.dropped++;return}}e.samples.push(t)}},s.parseNALu=function(t,e,r){var a=e.byteLength,u=t.naluState||0,l=u,d=[],c=0,p,y,A,T=-1,b=0;for(u===-1&&(T=0,b=this.getNALuType(e,0),u=0,c=1);c<a;){if(p=e[c++],!u){u=p?0:1;continue}if(u===1){u=p?0:2;continue}if(!p)u=3;else if(p===1){if(y=c-u-1,T>=0){var L={data:e.subarray(T,y),type:b};d.push(L)}else{var R=this.getLastNalUnit(t.samples);R&&(l&&c<=4-l&&R.state&&(R.data=R.data.subarray(0,R.data.byteLength-l)),y>0&&(R.data=Ot(R.data,e.subarray(0,y)),R.state=0))}c<a?(A=this.getNALuType(e,c),T=c,b=A,u=0):u=-1}else u=0}if(T>=0&&u>=0){var C={data:e.subarray(T,a),type:b,state:u};d.push(C)}if(d.length===0){var I=this.getLastNalUnit(t.samples);I&&(I.data=Ot(I.data,e))}return t.naluState=u,d},n}(),os=function(){function n(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 s=n.prototype;return s.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,a=new Uint8Array(4),u=Math.min(4,e);if(u===0)throw new Error("no bytes available");a.set(t.subarray(r,r+u)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=u*8,this.bytesAvailable-=u},s.skipBits=function(t){var e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},s.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&Oe.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r},s.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!==0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},s.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},n}(),us=function(n){function s(){return n.apply(this,arguments)||this}S(s,n);var i=s.prototype;return i.parsePES=function(e,r,a,u){var l=this,d=this.parseNALu(e,a.data,u),c=this.VideoSample,p,y=!1;a.data=null,c&&d.length&&!e.audFound&&(this.pushAccessUnit(c,e),c=this.VideoSample=this.createVideoSample(!1,a.pts,a.dts)),d.forEach(function(A){var T,b;switch(A.type){case 1:{var L=!1;p=!0;var R=A.data;if(y&&R.length>4){var C=l.readSliceType(R);(C===2||C===4||C===7||C===9)&&(L=!0)}if(L){var I;(I=c)!=null&&I.frame&&!c.key&&(l.pushAccessUnit(c,e),c=l.VideoSample=null)}c||(c=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),c.frame=!0,c.key=L;break}case 5:p=!0,(T=c)!=null&&T.frame&&!c.key&&(l.pushAccessUnit(c,e),c=l.VideoSample=null),c||(c=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),c.key=!0,c.frame=!0;break;case 6:{p=!0,ra(A.data,1,a.pts,r.samples);break}case 7:{var k,O;p=!0,y=!0;var V=A.data,N=l.readSPS(V);if(!e.sps||e.width!==N.width||e.height!==N.height||((k=e.pixelRatio)==null?void 0:k[0])!==N.pixelRatio[0]||((O=e.pixelRatio)==null?void 0:O[1])!==N.pixelRatio[1]){e.width=N.width,e.height=N.height,e.pixelRatio=N.pixelRatio,e.sps=[V];for(var B=V.subarray(1,4),X="avc1.",z=0;z<3;z++){var K=B[z].toString(16);K.length<2&&(K="0"+K),X+=K}e.codec=X}break}case 8:p=!0,e.pps=[A.data];break;case 9:p=!0,e.audFound=!0,(b=c)!=null&&b.frame&&(l.pushAccessUnit(c,e),c=null),c||(c=l.VideoSample=l.createVideoSample(!1,a.pts,a.dts));break;case 12:p=!0;break;default:p=!1;break}if(c&&p){var j=c.units;j.push(A)}}),u&&c&&(this.pushAccessUnit(c,e),this.VideoSample=null)},i.getNALuType=function(e,r){return e[r]&31},i.readSliceType=function(e){var r=new os(e);return r.readUByte(),r.readUEG(),r.readUEG()},i.skipScalingList=function(e,r){for(var a=8,u=8,l,d=0;d<e;d++)u!==0&&(l=r.readEG(),u=(a+l+256)%256),a=u===0?a:u},i.readSPS=function(e){var r=new os(e),a=0,u=0,l=0,d=0,c,p,y,A=r.readUByte.bind(r),T=r.readBits.bind(r),b=r.readUEG.bind(r),L=r.readBoolean.bind(r),R=r.skipBits.bind(r),C=r.skipEG.bind(r),I=r.skipUEG.bind(r),k=this.skipScalingList.bind(this);A();var O=A();if(T(5),R(3),A(),I(),O===100||O===110||O===122||O===244||O===44||O===83||O===86||O===118||O===128){var V=b();if(V===3&&R(1),I(),I(),R(1),L())for(p=V!==3?8:12,y=0;y<p;y++)L()&&(y<6?k(16,r):k(64,r))}I();var N=b();if(N===0)b();else if(N===1)for(R(1),C(),C(),c=b(),y=0;y<c;y++)C();I(),R(1);var B=b(),X=b(),z=T(1);z===0&&R(1),R(1),L()&&(a=b(),u=b(),l=b(),d=b());var K=[1,1];if(L()&&L()){var j=A();switch(j){case 1:K=[1,1];break;case 2:K=[12,11];break;case 3:K=[10,11];break;case 4:K=[16,11];break;case 5:K=[40,33];break;case 6:K=[24,11];break;case 7:K=[20,11];break;case 8:K=[32,11];break;case 9:K=[80,33];break;case 10:K=[18,11];break;case 11:K=[15,11];break;case 12:K=[64,33];break;case 13:K=[160,99];break;case 14:K=[4,3];break;case 15:K=[3,2];break;case 16:K=[2,1];break;case 255:{K=[A()<<8|A(),A()<<8|A()];break}}}return{width:Math.ceil((B+1)*16-a*2-u*2),height:(2-z)*(X+1)*16-(z?2:4)*(l+d),pixelRatio:K}},s}(Yl),ot=188,zl=function(){function n(i,t,e,r){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=i,this.config=t,this.typeSupported=e,this.logger=r,this.videoParser=null}n.probe=function(t,e){var r=n.syncOffset(t);return r>0&&e.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},n.syncOffset=function(t){for(var e=t.length,r=Math.min(ot*5,e-ot)+1,a=0;a<r;){for(var u=!1,l=-1,d=0,c=a;c<e;c+=ot)if(t[c]===71&&(e-c===ot||t[c+ot]===71)){if(d++,l===-1&&(l=c,l!==0&&(r=Math.min(l+ot*99,t.length-ot)+1)),u||(u=tn(t,c)===0),u&&d>1&&(l===0&&d>2||c+ot>r))return l}else{if(d)return-1;break}a++}return-1},n.createTrack=function(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Xn[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}};var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=n.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=n.createTrack("audio",a),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r},s.resetTimeStamp=function(){},s.resetContiguity=function(){var t=this._audioTrack,e=this._videoTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},s.demux=function(t,e,r,a){r===void 0&&(r=!1),a===void 0&&(a=!1),r||(this.sampleAes=null);var u,l=this._videoTrack,d=this._audioTrack,c=this._id3Track,p=this._txtTrack,y=l.pid,A=l.pesData,T=d.pid,b=c.pid,L=d.pesData,R=c.pesData,C=null,I=this.pmtParsed,k=this._pmtId,O=t.length;if(this.remainderData&&(t=Ot(this.remainderData,t),O=t.length,this.remainderData=null),O<ot&&!a)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:c,textTrack:p};var V=Math.max(0,n.syncOffset(t));O-=(O-V)%ot,O<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,O,t.buffer.byteLength-O));for(var N=0,B=V;B<O;B+=ot)if(t[B]===71){var X=!!(t[B+1]&64),z=tn(t,B),K=(t[B+3]&48)>>4,j=void 0;if(K>1){if(j=B+5+t[B+4],j===B+ot)continue}else j=B+4;switch(z){case y:if(X){if(A&&(u=mr(A,this.logger))){if(this.videoParser===null)switch(l.segmentCodec){case"avc":this.videoParser=new us;break}this.videoParser!==null&&this.videoParser.parsePES(l,p,u,!1)}A={data:[],size:0}}A&&(A.data.push(t.subarray(j,B+ot)),A.size+=B+ot-j);break;case T:if(X){if(L&&(u=mr(L,this.logger)))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(t.subarray(j,B+ot)),L.size+=B+ot-j);break;case b:X&&(R&&(u=mr(R,this.logger))&&this.parseID3PES(c,u),R={data:[],size:0}),R&&(R.data.push(t.subarray(j,B+ot)),R.size+=B+ot-j);break;case 0:X&&(j+=t[j]+1),k=this._pmtId=ql(t,j);break;case k:{X&&(j+=t[j]+1);var J=$l(t,j,this.typeSupported,r,this.observer,this.logger);y=J.videoPid,y>0&&(l.pid=y,l.segmentCodec=J.segmentVideoCodec),T=J.audioPid,T>0&&(d.pid=T,d.segmentCodec=J.segmentAudioCodec),b=J.id3Pid,b>0&&(c.pid=b),C!==null&&!I&&(this.logger.warn("MPEG-TS PMT found at "+B+" after unknown PID '"+C+"'. Backtracking to sync byte @"+V+" to parse all TS packets."),C=null,B=V-188),I=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=z;break}}else N++;N>0&&pi(this.observer,new Error("Found "+N+" TS packet/s that do not start with 0x47"),void 0,this.logger),l.pesData=A,d.pesData=L,c.pesData=R;var le={audioTrack:d,videoTrack:l,id3Track:c,textTrack:p};return a&&this.extractRemainingSamples(le),le},s.flush=function(){var t=this.remainderData;this.remainderData=null;var e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},s.extractRemainingSamples=function(t){var e=t.audioTrack,r=t.videoTrack,a=t.id3Track,u=t.textTrack,l=r.pesData,d=e.pesData,c=a.pesData,p;if(l&&(p=mr(l,this.logger))){if(this.videoParser===null)switch(r.segmentCodec){case"avc":this.videoParser=new us;break}this.videoParser!==null&&(this.videoParser.parsePES(r,u,p,!0),r.pesData=null)}else r.pesData=l;if(d&&(p=mr(d,this.logger))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;c&&(p=mr(c,this.logger))?(this.parseID3PES(a,p),a.pesData=null):a.pesData=c},s.demuxSampleAes=function(t,e,r){var a=this.demux(t,r,!0,!this.config.progressive),u=this.sampleAes=new jl(this.observer,this.config,e);return this.decrypt(a,u)},s.decrypt=function(t,e){return new Promise(function(r){var a=t.audioTrack,u=t.videoTrack;a.samples&&a.segmentCodec==="aac"?e.decryptAacSamples(a.samples,0,function(){u.samples?e.decryptAvcSamples(u.samples,0,0,function(){r(t)}):r(t)}):u.samples&&e.decryptAvcSamples(u.samples,0,0,function(){r(t)})})},s.destroy=function(){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},s.parseAACPES=function(t,e){var r=0,a=this.aacOverFlow,u=e.data;if(a){this.aacOverFlow=null;var l=a.missing,d=a.sample.unit.byteLength;if(l===-1)u=Ot(a.sample.unit,u);else{var c=d-l;a.sample.unit.set(u.subarray(0,l),c),t.samples.push(a.sample),r=a.missing}}var p,y;for(p=r,y=u.length;p<y-1&&!di(u,p);p++);if(p!==r){var A,T=p<y-1;if(T?A="AAC PES did not start with ADTS header,offset:"+p:A="No ADTS header found in AAC PES",pi(this.observer,new Error(A),T,this.logger),!T)return}$a(t,this.observer,u,p,this.audioCodec);var b;if(e.pts!==void 0)b=e.pts;else if(a){var L=Xa(t.samplerate);b=a.sample.pts+L}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var R=0,C;p<y;)if(C=Qa(t,u,p,b,R),p+=C.length,C.missing){this.aacOverFlow=C;break}else for(R++;p<y-1&&!di(u,p);p++);},s.parseMPEGPES=function(t,e){var r=e.data,a=r.length,u=0,l=0,d=e.pts;if(d===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<a;)if(ns(r,l)){var c=rs(t,r,l,d,u);if(c)l+=c.length,u++;else break}else l++},s.parseAC3PES=function(t,e){},s.parseID3PES=function(t,e){if(e.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=E({},e,{type:this._videoTrack?Lt.emsg:Lt.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)},n}();function tn(n,s){return((n[s+1]&31)<<8)+n[s+2]}function ql(n,s){return(n[s+10]&31)<<8|n[s+11]}function $l(n,s,i,t,e,r){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=(n[s+1]&15)<<8|n[s+2],l=s+3+u-4,d=(n[s+10]&15)<<8|n[s+11];for(s+=12+d;s<l;){var c=tn(n,s),p=(n[s+3]&15)<<8|n[s+4];switch(n[s]){case 207:if(!t){rn("ADTS AAC",r);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!t){rn("H.264",r);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!i.mpeg&&!i.mp3?r.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!t){rn("AC-3",r);break}case 129:r.warn("AC-3 in M2TS support not included in build");break;case 6:if(a.audioPid===-1&&p>0)for(var y=s+5,A=p;A>2;){var T=n[y];switch(T){case 106:r.warn("AC-3 in M2TS support not included in build");break}var b=n[y+1]+2;y+=b,A-=b}break;case 194:case 135:return pi(e,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:return pi(e,new Error("Unsupported HEVC in M2TS found"),void 0,r),a}s+=p+5}return a}function pi(n,s,i,t){t.warn("parsing error: "+s.message),n.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:s,reason:s.message})}function rn(n,s){s.log(n+" with AES-128-CBC encryption found in unencrypted stream")}function mr(n,s){var i=0,t,e,r,a,u,l=n.data;if(!n||n.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Ot(l[0],l[1]),l.splice(1,1);t=l[0];var d=(t[0]<<16)+(t[1]<<8)+t[2];if(d===1){if(e=(t[4]<<8)+t[5],e&&e>n.size-6)return null;var c=t[7];c&192&&(a=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(u=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,a-u>60*9e4&&(s.warn(Math.round((a-u)/9e4)+"s delta between PTS and DTS, align them"),a=u)):u=a),r=t[8];var p=r+9;if(n.size<=p)return null;n.size-=p;for(var y=new Uint8Array(n.size),A=0,T=l.length;A<T;A++){t=l[A];var b=t.byteLength;if(p)if(p>b){p-=b;continue}else t=t.subarray(p),b-=p,p=0;y.set(t,i),i+=b}return e&&(e-=r+3),{data:y,pts:a,dts:u,len:e}}return null}var Xl=function(){function n(){}return n.getSilentFrame=function(i,t){switch(i){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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}},n}(),sr=Math.pow(2,32)-1,lt=function(){function n(){}return n.init=function(){n.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 i;for(i in n.types)n.types.hasOwnProperty(i)&&(n.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e=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]);n.HDLR_TYPES={video:t,audio:e};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);n.STTS=n.STSC=n.STCO=a,n.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),n.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),n.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),n.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);n.FTYP=n.box(n.types.ftyp,u,d,u,l),n.DINF=n.box(n.types.dinf,n.box(n.types.dref,r))},n.box=function(i){for(var t=8,e=arguments.length,r=new Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];for(var u=r.length,l=u;u--;)t+=r[u].byteLength;var d=new Uint8Array(t);for(d[0]=t>>24&255,d[1]=t>>16&255,d[2]=t>>8&255,d[3]=t&255,d.set(i,4),u=0,t=8;u<l;u++)d.set(r[u],t),t+=r[u].byteLength;return d},n.hdlr=function(i){return n.box(n.types.hdlr,n.HDLR_TYPES[i])},n.mdat=function(i){return n.box(n.types.mdat,i)},n.mdhd=function(i,t){t*=i;var e=Math.floor(t/(sr+1)),r=Math.floor(t%(sr+1));return n.box(n.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,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},n.mdia=function(i){return n.box(n.types.mdia,n.mdhd(i.timescale||0,i.duration||0),n.hdlr(i.type),n.minf(i))},n.mfhd=function(i){return n.box(n.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},n.minf=function(i){return i.type==="audio"?n.box(n.types.minf,n.box(n.types.smhd,n.SMHD),n.DINF,n.stbl(i)):n.box(n.types.minf,n.box(n.types.vmhd,n.VMHD),n.DINF,n.stbl(i))},n.moof=function(i,t,e){return n.box(n.types.moof,n.mfhd(i),n.traf(e,t))},n.moov=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trak(i[t]);return n.box.apply(null,[n.types.moov,n.mvhd(i[0].timescale||0,i[0].duration||0)].concat(e).concat(n.mvex(i)))},n.mvex=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trex(i[t]);return n.box.apply(null,[n.types.mvex].concat(e))},n.mvhd=function(i,t){t*=i;var e=Math.floor(t/(sr+1)),r=Math.floor(t%(sr+1)),a=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,e>>24,e>>16&255,e>>8&255,e&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 n.box(n.types.mvhd,a)},n.sdtp=function(i){var t=i.samples||[],e=new Uint8Array(4+t.length),r,a;for(r=0;r<t.length;r++)a=t[r].flags,e[r+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return n.box(n.types.sdtp,e)},n.stbl=function(i){return n.box(n.types.stbl,n.stsd(i),n.box(n.types.stts,n.STTS),n.box(n.types.stsc,n.STSC),n.box(n.types.stsz,n.STSZ),n.box(n.types.stco,n.STCO))},n.avc1=function(i){var t=[],e=[],r,a,u;for(r=0;r<i.sps.length;r++)a=i.sps[r],u=a.byteLength,t.push(u>>>8&255),t.push(u&255),t=t.concat(Array.prototype.slice.call(a));for(r=0;r<i.pps.length;r++)a=i.pps[r],u=a.byteLength,e.push(u>>>8&255),e.push(u&255),e=e.concat(Array.prototype.slice.call(a));var l=n.box(n.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|i.sps.length].concat(t).concat([i.pps.length]).concat(e))),d=i.width,c=i.height,p=i.pixelRatio[0],y=i.pixelRatio[1];return n.box(n.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,c>>8&255,c&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]),l,n.box(n.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n.box(n.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&255])))},n.esds=function(i){var t=i.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(t,[6,1,2]))},n.audioStsd=function(i){var t=i.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])},n.mp4a=function(i){return n.box(n.types.mp4a,n.audioStsd(i),n.box(n.types.esds,n.esds(i)))},n.mp3=function(i){return n.box(n.types[".mp3"],n.audioStsd(i))},n.ac3=function(i){return n.box(n.types["ac-3"],n.audioStsd(i),n.box(n.types.dac3,i.config))},n.stsd=function(i){var t=i.segmentCodec;if(i.type==="audio"){if(t==="aac")return n.box(n.types.stsd,n.STSD,n.mp4a(i));if(t==="mp3"&&i.codec==="mp3")return n.box(n.types.stsd,n.STSD,n.mp3(i))}else if(i.pps&&i.sps){if(t==="avc")return n.box(n.types.stsd,n.STSD,n.avc1(i))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+i.type+" segment codec ("+t+"/"+i.codec+")")},n.tkhd=function(i){var t=i.id,e=(i.duration||0)*(i.timescale||0),r=i.width||0,a=i.height||0,u=Math.floor(e/(sr+1)),l=Math.floor(e%(sr+1));return n.box(n.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&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,a>>8&255,a&255,0,0]))},n.traf=function(i,t){var e=n.sdtp(i),r=i.id,a=Math.floor(t/(sr+1)),u=Math.floor(t%(sr+1));return n.box(n.types.traf,n.box(n.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),n.box(n.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,u>>24,u>>16&255,u>>8&255,u&255])),n.trun(i,e.length+16+20+8+16+8+8),e)},n.trak=function(i){return i.duration=i.duration||4294967295,n.box(n.types.trak,n.tkhd(i),n.mdia(i))},n.trex=function(i){var t=i.id;return n.box(n.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},n.trun=function(i,t){var e=i.samples||[],r=e.length,a=12+16*r,u=new Uint8Array(a),l,d,c,p,y,A;for(t+=8+a,u.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),l=0;l<r;l++)d=e[l],c=d.duration,p=d.size,y=d.flags,A=d.cts,u.set([c>>>24&255,c>>>16&255,c>>>8&255,c&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,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*l);return n.box(n.types.trun,u)},n.initSegment=function(i){n.types||n.init();var t=n.moov(i),e=Ot(n.FTYP,t);return e},n.hvc1=function(i){return new Uint8Array},n}();lt.types=void 0,lt.HDLR_TYPES=void 0,lt.STTS=void 0,lt.STSC=void 0,lt.STCO=void 0,lt.STSZ=void 0,lt.VMHD=void 0,lt.SMHD=void 0,lt.STSD=void 0,lt.FTYP=void 0,lt.DINF=void 0;var Ql=9e4;function Zl(n,s,i,t){var e=n*s*i;return Math.round(e)}function Nr(n,s){return Zl(n,1e3,1/Ql)}var Jl=10*1e3,ef=1024,tf=1152,rf=1536,yr=null,nn=null;function ls(n,s,i,t){return{duration:s,size:i,cts:t,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}}}var an=function(){function n(i,t,e,r){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=i,this.config=t,this.typeSupported=e,this.logger=r,this.ISGenerated=!1,yr===null){var a=navigator.userAgent||"",u=a.match(/Chrome\/(\d+)/i);yr=u?parseInt(u[1]):0}if(nn===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);nn=l?parseInt(l[1]):0}}var s=n.prototype;return s.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},s.resetTimeStamp=function(t){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},s.resetNextTimestamp=function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},s.getVideoStartPts=function(t){var e=!1,r=t[0].pts,a=t.reduce(function(u,l){var d=l.pts,c=d-u;return c<-4294967296&&(e=!0,d=Ft(d,r),c=d-u),c>0?u:d},r);return e&&this.logger.debug("PTS rollover detected"),a},s.remux=function(t,e,r,a,u,l,d,c){var p,y,A,T,b,L,R=u,C=u,I=t.pid>-1,k=e.pid>-1,O=e.samples.length,V=t.samples.length>0,N=d&&O>0||O>1,B=(!I||V)&&(!k||N)||this.ISGenerated||d;if(B){if(this.ISGenerated){var X,z,K,j,J=this.videoTrackConfig;(J&&(e.width!==J.width||e.height!==J.height||((X=e.pixelRatio)==null?void 0:X[0])!==((z=J.pixelRatio)==null?void 0:z[0])||((K=e.pixelRatio)==null?void 0:K[1])!==((j=J.pixelRatio)==null?void 0:j[1]))||!J&&N||this.nextAudioPts===null&&V)&&this.resetInitSegment()}this.ISGenerated||(A=this.generateIS(t,e,u,l));var le=this.isVideoContiguous,re=-1,te;if(N&&(re=nf(e.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,re>0){this.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+O+" video samples due to a missing keyframe");var fe=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(re),e.dropped+=re,C+=(e.samples[0].pts-fe)/e.inputTimeScale,te=C}else re===-1&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of "+O+" video samples"),L=!1);if(this.ISGenerated){if(V&&N){var de=this.getVideoStartPts(e.samples),ve=Ft(t.samples[0].pts,de)-de,ge=ve/e.inputTimeScale;R+=Math.max(0,ge),C+=Math.max(0,-ge)}if(V){if(t.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),A=this.generateIS(t,e,u,l)),y=this.remuxAudio(t,R,this.isAudioContiguous,l,k||N||c===ae.AUDIO?C:void 0),N){var Ne=y?y.endPTS-y.startPTS:0;e.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),A=this.generateIS(t,e,u,l)),p=this.remuxVideo(e,C,le,Ne)}}else N&&(p=this.remuxVideo(e,C,le,0));p&&(p.firstKeyFrame=re,p.independent=re!==-1,p.firstKeyFramePTS=te)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(b=fs(r,u,this._initPTS,this._initDTS)),a.samples.length&&(T=hs(a,u,this._initPTS))),{audio:y,video:p,initSegment:A,independent:L,text:T,id3:b}},s.generateIS=function(t,e,r,a){var u=t.samples,l=e.samples,d=this.typeSupported,c={},p=this._initPTS,y=!p||a,A="audio/mp4",T,b,L;if(y&&(T=b=1/0),t.config&&u.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(A="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3";break}c.audio={id:"audio",container:A,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):lt.initSegment([t]),metadata:{channelCount:t.channelCount}},y&&(L=t.inputTimeScale,!p||L!==p.timescale?T=b=u[0].pts-Math.round(L*r):y=!1)}if(e.sps&&e.pps&&l.length){if(e.timescale=e.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:lt.initSegment([e]),metadata:{width:e.width,height:e.height}},y)if(L=e.inputTimeScale,!p||L!==p.timescale){var R=this.getVideoStartPts(l),C=Math.round(L*r);b=Math.min(b,Ft(l[0].dts,R)-C),T=Math.min(T,R-C)}else y=!1;this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:T,timescale:L},this._initDTS={baseTime:b,timescale:L}):T=L=void 0,{tracks:c,initPTS:T,timescale:L}},s.remuxVideo=function(t,e,r,a){var u=t.inputTimeScale,l=t.samples,d=[],c=l.length,p=this._initPTS,y=this.nextAvcDts,A=8,T=this.videoSampleDuration,b,L,R=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,I=!1;if(!r||y===null){var k=e*u,O=l[0].pts-Ft(l[0].dts,l[0].pts);yr&&y!==null&&Math.abs(k-O-y)<15e3?r=!0:y=k-O}for(var V=p.baseTime*u/p.timescale,N=0;N<c;N++){var B=l[N];B.pts=Ft(B.pts-V,y),B.dts=Ft(B.dts-V,y),B.dts<l[N>0?N-1:N].dts&&(I=!0)}I&&l.sort(function(Ti,Hs){var Eh=Ti.dts-Hs.dts,_h=Ti.pts-Hs.pts;return Eh||_h}),b=l[0].dts,L=l[l.length-1].dts;var X=L-b,z=X?Math.round(X/(c-1)):T||t.inputTimeScale/30;if(r){var K=b-y,j=K>z,J=K<-1;if((j||J)&&(j?this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+Nr(K)+" ms ("+K+"dts) hole between fragments detected at "+e.toFixed(3)):this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+Nr(-K)+" ms ("+K+"dts) overlapping between fragments detected at "+e.toFixed(3)),!J||y>=l[0].pts||yr)){b=y;var le=l[0].pts-K;if(j)l[0].dts=b,l[0].pts=le;else for(var re=!0,te=0;te<l.length&&!(l[te].dts>le&&re);te++){var fe=l[te].pts;if(l[te].dts-=K,l[te].pts-=K,te<l.length-1){var de=l[te+1].pts,ve=l[te].pts,ge=de<=ve,Ne=de<=fe;re=ge==Ne}}this.logger.log("Video: Initial PTS/DTS adjusted: "+Nr(le)+"/"+Nr(b)+", delta: "+Nr(K)+" ms")}}b=Math.max(0,b);for(var we=0,Be=0,Ce=b,et=0;et<c;et++){for(var Ge=l[et],Qe=Ge.units,_t=Qe.length,ut=0,Ve=0;Ve<_t;Ve++)ut+=Qe[Ve].data.length;Be+=ut,we+=_t,Ge.length=ut,Ge.dts<Ce?(Ge.dts=Ce,Ce+=z/4|0||1):Ce=Ge.dts,R=Math.min(Ge.pts,R),C=Math.max(Ge.pts,C)}L=l[c-1].dts;var St=Be+4*we+8,it;try{it=new Uint8Array(St)}catch(Ti){this.observer.emit(x.ERROR,x.ERROR,{type:Y.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Ti,bytes:St,reason:"fail allocating video mdat "+St});return}var $e=new DataView(it.buffer);$e.setUint32(0,St),it.set(lt.types.mdat,4);for(var Tt=!1,dt=Number.POSITIVE_INFINITY,xt=Number.POSITIVE_INFINITY,Ye=Number.NEGATIVE_INFINITY,ct=Number.NEGATIVE_INFINITY,nt=0;nt<c;nt++){for(var At=l[nt],Vr=At.units,Fs=0,vn=0,fh=Vr.length;vn<fh;vn++){var Ns=Vr[vn],hh=Ns.data,pn=Ns.data.byteLength;$e.setUint32(A,pn),A+=4,it.set(hh,A),A+=pn,Fs+=4+pn}var _i=void 0;if(nt<c-1)T=l[nt+1].dts-At.dts,_i=l[nt+1].pts-At.pts;else{var Us=this.config,Si=nt>0?At.dts-l[nt-1].dts:z;if(_i=nt>0?At.pts-l[nt-1].pts:z,Us.stretchShortVideoTrack&&this.nextAudioPts!==null){var dh=Math.floor(Us.maxBufferHole*u),gn=(a?R+a*u:this.nextAudioPts)-At.pts;gn>dh?(T=gn-Si,T<0?T=Si:Tt=!0,this.logger.log("[mp4-remuxer]: It is approximately "+gn/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=Si}else T=Si}var ch=Math.round(At.pts-At.dts);dt=Math.min(dt,T),Ye=Math.max(Ye,T),xt=Math.min(xt,_i),ct=Math.max(ct,_i),d.push(ls(At.key,T,Fs,ch))}if(d.length){if(yr){if(yr<70){var Bs=d[0].flags;Bs.dependsOn=2,Bs.isNonSync=0}}else if(nn&&ct-xt<Ye-dt&&z/Ye<.025&&d[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var mn=b,Nt=0,Gs=d.length;Nt<Gs;Nt++){var Vs=mn+d[Nt].duration,vh=mn+d[Nt].cts;if(Nt<Gs-1){var ph=Vs+d[Nt+1].cts;d[Nt].duration=ph-vh}else d[Nt].duration=Nt?d[Nt-1].duration:z;d[Nt].cts=0,mn=Vs}}}T=Tt||!T?z:T,this.nextAvcDts=y=L+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var gh=lt.moof(t.sequenceNumber++,b,E(t,{samples:d})),mh="video",yh={data1:gh,data2:it,startPTS:R/u,endPTS:(C+T)/u,startDTS:b/u,endDTS:y/u,type:mh,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,yh},s.getSamplesPerFrame=function(t){switch(t.segmentCodec){case"mp3":return tf;case"ac3":return rf;default:return ef}},s.remuxAudio=function(t,e,r,a,u){var l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,c=l/d,p=this.getSamplesPerFrame(t),y=p*c,A=this._initPTS,T=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],L=u!==void 0,R=t.samples,C=T?0:8,I=this.nextAudioPts||-1,k=e*l,O=A.baseTime*l/A.timescale;if(this.isAudioContiguous=r=r||R.length&&I>0&&(a&&Math.abs(k-I)<9e3||Math.abs(Ft(R[0].pts-O,k)-I)<20*y),R.forEach(function(Ye){Ye.pts=Ft(Ye.pts-O,k)}),!r||I<0){if(R=R.filter(function(Ye){return Ye.pts>=0}),!R.length)return;u===0?I=0:a&&!L?I=Math.max(0,k):I=R[0].pts}if(t.segmentCodec==="aac")for(var V=this.config.maxAudioFramesDrift,N=0,B=I;N<R.length;N++){var X=R[N],z=X.pts,K=z-B,j=Math.abs(1e3*K/l);if(K<=-V*y&&L)N===0&&(this.logger.warn("Audio frame @ "+(z/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*K/l)+" ms."),this.nextAudioPts=I=B=z);else if(K>=V*y&&j<Jl&&L){var J=Math.round(K/y);B=z-J*y,B<0&&(J--,B+=y),N===0&&(this.nextAudioPts=I=B),this.logger.warn("[mp4-remuxer]: Injecting "+J+" audio frame @ "+(B/l).toFixed(3)+"s due to "+Math.round(1e3*K/l)+" ms gap.");for(var le=0;le<J;le++){var re=Math.max(B,0),te=Xl.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);te||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),te=X.unit.subarray()),R.splice(N,0,{unit:te,pts:re}),B+=y,N++}}X.pts=B,B+=y}for(var fe=null,de=null,ve,ge=0,Ne=R.length;Ne--;)ge+=R[Ne].unit.byteLength;for(var we=0,Be=R.length;we<Be;we++){var Ce=R[we],et=Ce.unit,Ge=Ce.pts;if(de!==null){var Qe=b[we-1];Qe.duration=Math.round((Ge-de)/c)}else if(r&&t.segmentCodec==="aac"&&(Ge=I),fe=Ge,ge>0){ge+=C;try{ve=new Uint8Array(ge)}catch(Ye){this.observer.emit(x.ERROR,x.ERROR,{type:Y.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Ye,bytes:ge,reason:"fail allocating audio mdat "+ge});return}if(!T){var _t=new DataView(ve.buffer);_t.setUint32(0,ge),ve.set(lt.types.mdat,4)}}else return;ve.set(et,C);var ut=et.byteLength;C+=ut,b.push(ls(!0,p,ut,0)),de=Ge}var Ve=b.length;if(Ve){var St=b[b.length-1];this.nextAudioPts=I=de+c*St.duration;var it=T?new Uint8Array(0):lt.moof(t.sequenceNumber++,fe/c,E({},t,{samples:b}));t.samples=[];var $e=fe/l,Tt=I/l,dt="audio",xt={data1:it,data2:ve,startPTS:$e,endPTS:Tt,startDTS:$e,endDTS:Tt,type:dt,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,xt}},n}();function Ft(n,s){var i;if(s===null)return n;for(s<n?i=-8589934592:i=8589934592;Math.abs(n-s)>4294967296;)n+=i;return n}function nf(n){for(var s=0;s<n.length;s++)if(n[s].key)return s;return-1}function fs(n,s,i,t){var e=n.samples.length;if(e){for(var r=n.inputTimeScale,a=0;a<e;a++){var u=n.samples[a];u.pts=Ft(u.pts-i.baseTime*r/i.timescale,s*r)/r,u.dts=Ft(u.dts-t.baseTime*r/t.timescale,s*r)/r}var l=n.samples;return n.samples=[],{samples:l}}}function hs(n,s,i){var t=n.samples.length;if(t){for(var e=n.inputTimeScale,r=0;r<t;r++){var a=n.samples[r];a.pts=Ft(a.pts-i.baseTime*e/i.timescale,s*e)/e}n.samples.sort(function(l,d){return l.pts-d.pts});var u=n.samples;return n.samples=[],{samples:u}}}var af=function(){function n(i,t,e,r){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=r}var s=n.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(t,e,r,a){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(su(t,a)),this.emitInitSegment=!0},s.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=ea(t);a.audio&&(e=ds(a.audio,qe.AUDIO)),a.video&&(r=ds(a.video,qe.VIDEO));var u={};a.audio&&a.video?u.audiovideo={container:"video/mp4",codec:e+","+r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:a.audio?u.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:a.video?u.video={container:"video/mp4",codec:r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=u},s.remux=function(t,e,r,a,u,l){var d,c,p=this.initPTS,y=this.lastEndTime,A={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};w(y)||(y=this.lastEndTime=u||0);var T=e.samples;if(!(T!=null&&T.length))return A;var b={initPTS:void 0,timescale:1},L=this.initData;if((d=L)!=null&&d.length||(this.generateInitSegment(T),L=this.initData),!((c=L)!=null&&c.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),A;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);var R=lu(T,L),C=uu(L,T),I=C===null?u:C;(l||!p)&&(sf(p,I,u,R)||b.timescale!==p.timescale)&&(b.initPTS=I-u,p&&p.timescale===1&&this.logger.warn("Adjusting initPTS @"+u+" from "+p.baseTime/p.timescale+" to "+b.initPTS),this.initPTS=p={baseTime:b.initPTS,timescale:1});var k=t?I-p.baseTime/p.timescale:y,O=k+R;hu(L,T,p.baseTime/p.timescale),R>0?this.lastEndTime=O:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var V=!!L.audio,N=!!L.video,B="";V&&(B+="audio"),N&&(B+="video");var X={data1:T,startPTS:k,startDTS:k,endPTS:O,endDTS:O,type:B,hasAudio:V,hasVideo:N,nb:1,dropped:0};return A.audio=X.type==="audio"?X:void 0,A.video=X.type!=="audio"?X:void 0,A.initSegment=b,A.id3=fs(r,u,p,p),a.samples.length&&(A.text=hs(a,u,p)),A},n}();function sf(n,s,i,t){if(n===null)return!0;var e=Math.max(t,1),r=s-n.baseTime/n.timescale;return Math.abs(r-i)>e}function ds(n,s){var i=n?.codec;if(i&&i.length>4)return i;if(s===qe.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var t=!1;return ii(i,t)}return Oe.warn('Unhandled audio codec "'+i+'" in mp4 MAP'),i||"mp4a"}return Oe.warn('Unhandled video codec "'+i+'" in mp4 MAP'),i||"avc1"}var Zt;try{Zt=self.performance.now.bind(self.performance)}catch{Zt=Date.now}var sn=[{demux:Wl,remux:af},{demux:zl,remux:an},{demux:Ol,remux:an},{demux:Fl,remux:an}],on=function(){function n(i,t,e,r,a,u){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=i,this.typeSupported=t,this.config=e,this.id=a,this.logger=u}var s=n.prototype;return s.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},s.push=function(t,e,r,a){var u=this,l=r.transmuxing;l.executeStart=Zt();var d=new Uint8Array(t),c=this.currentTransmuxState,p=this.transmuxConfig;a&&(this.currentTransmuxState=a);var y=a||c,A=y.contiguous,T=y.discontinuity,b=y.trackSwitch,L=y.accurateTimeOffset,R=y.timeOffset,C=y.initSegmentChange,I=p.audioCodec,k=p.videoCodec,O=p.defaultInitPts,V=p.duration,N=p.initSegmentData,B=of(d,e);if(B&&Mr(B.method)){var X=this.getDecrypter(),z=xa(B.method);if(X.isSync()){var K=X.softwareDecrypt(d,B.key.buffer,B.iv.buffer,z),j=r.part>-1;if(j){var J=X.flush();K=J&&J.buffer}if(!K)return l.executeEnd=Zt(),un(r);d=new Uint8Array(K)}else return this.asyncResult=!0,this.decryptionPromise=X.webCryptoDecrypt(d,B.key.buffer,B.iv.buffer,z).then(function(de){var ve=u.push(de,null,r);return u.decryptionPromise=null,ve}),this.decryptionPromise}var le=this.needsProbing(T,b);if(le){var re=this.configureTransmuxer(d);if(re)return this.logger.warn("[transmuxer] "+re.message),this.observer.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:re,reason:re.message}),l.executeEnd=Zt(),un(r)}(T||b||C||le)&&this.resetInitSegment(N,I,k,V,e),(T||C||le)&&this.resetInitialTimestamp(O),A||this.resetContiguity();var te=this.transmux(d,B,R,L,r);this.asyncResult=dr(te);var fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,l.executeEnd=Zt(),te},s.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=Zt();var a=this.decrypter,u=this.currentTransmuxState,l=this.decryptionPromise;if(l)return this.asyncResult=!0,l.then(function(){return e.flush(t)});var d=[],c=u.timeOffset;if(a){var p=a.flush();p&&d.push(this.push(p.buffer,null,t))}var y=this.demuxer,A=this.remuxer;if(!y||!A){r.executeEnd=Zt();var T=[un(t)];return this.asyncResult?Promise.resolve(T):T}var b=y.flush(c);return dr(b)?(this.asyncResult=!0,b.then(function(L){return e.flushRemux(d,L,t),d})):(this.flushRemux(d,b,t),this.asyncResult?Promise.resolve(d):d)},s.flushRemux=function(t,e,r){var a=e.audioTrack,u=e.videoTrack,l=e.id3Track,d=e.textTrack,c=this.currentTransmuxState,p=c.accurateTimeOffset,y=c.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+(this.id===ae.MAIN?"level":"track")+" "+r.level);var A=this.remuxer.remux(a,u,l,d,y,p,!0,this.id);t.push({remuxResult:A,chunkMeta:r}),r.transmuxing.executeEnd=Zt()},s.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;!e||!r||(e.resetTimeStamp(t),r.resetTimeStamp(t))},s.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())},s.resetInitSegment=function(t,e,r,a,u){var l=this.demuxer,d=this.remuxer;!l||!d||(l.resetInitSegment(t,e,r,a),d.resetInitSegment(t,e,r,u))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(t,e,r,a,u){var l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,r,a,u):l=this.transmuxUnencrypted(t,r,a,u),l},s.transmuxUnencrypted=function(t,e,r,a){var u=this.demuxer.demux(t,e,!1,!this.config.progressive),l=u.audioTrack,d=u.videoTrack,c=u.id3Track,p=u.textTrack,y=this.remuxer.remux(l,d,c,p,e,r,!1,this.id);return{remuxResult:y,chunkMeta:a}},s.transmuxSampleAes=function(t,e,r,a,u){var l=this;return this.demuxer.demuxSampleAes(t,e,r).then(function(d){var c=l.remuxer.remux(d.audioTrack,d.videoTrack,d.id3Track,d.textTrack,r,a,!1,l.id);return{remuxResult:c,chunkMeta:u}})},s.configureTransmuxer=function(t){for(var e=this.config,r=this.observer,a=this.typeSupported,u,l=0,d=sn.length;l<d;l++){var c;if((c=sn[l].demux)!=null&&c.probe(t,this.logger)){u=sn[l];break}}if(!u)return new Error("Failed to find demuxer by probing fragment data");var p=this.demuxer,y=this.remuxer,A=u.remux,T=u.demux;(!y||!(y instanceof A))&&(this.remuxer=new A(r,e,a,this.logger)),(!p||!(p instanceof T))&&(this.demuxer=new T(r,e,a,this.logger),this.probe=T.probe)},s.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},s.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new en(this.config)),t},n}();function of(n,s){var i=null;return n.byteLength>0&&s?.key!=null&&s.iv!==null&&s.method!=null&&(i=s),i}var un=function(s){return{remuxResult:{},chunkMeta:s}};function dr(n){return"then"in n&&n.then instanceof Function}var uf=function(s,i,t,e,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=i,this.initSegmentData=t,this.duration=e,this.defaultInitPts=r||null},lf=function(s,i,t,e,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=s,this.contiguous=i,this.accurateTimeOffset=t,this.trackSwitch=e,this.timeOffset=r,this.initSegmentChange=a};function ff(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var hf=/(\d+)-(\d+)\/(\d+)/,cs=function(){function n(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||pf,this.controller=new self.AbortController,this.stats=new Fi}var s=n.prototype;return s.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},s.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(t,e,r){var a=this,u=this.stats;if(u.loading.start)throw new Error("Loader can only be used once.");u.loading.start=self.performance.now();var l=df(t,this.controller.signal),d=t.responseType==="arraybuffer",c=d?"byteLength":"length",p=e.loadPolicy,y=p.maxTimeToFirstByteMs,A=p.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,l),self.clearTimeout(this.requestTimeout),e.timeout=y&&w(y)?y:A,this.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(u,t,a.response))},e.timeout);var T=dr(this.request)?this.request.then(self.fetch):self.fetch(this.request);T.then(function(b){var L;a.response=a.loader=b;var R=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(a.requestTimeout),e.timeout=A,a.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(u,t,a.response))},A-(R-u.loading.start)),!b.ok){var C=b.status,I=b.statusText;throw new gf(I||"fetch, bad network response",C,b)}u.loading.first=R,u.total=vf(b.headers)||u.total;var k=(L=a.callbacks)==null?void 0:L.onProgress;return k&&w(e.highWaterMark)?a.loadProgressively(b,u,t,e.highWaterMark,k):d?b.arrayBuffer():t.responseType==="json"?b.json():b.text()}).then(function(b){var L,R,C=a.response;if(!C)throw new Error("loader destroyed");self.clearTimeout(a.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var I=b[c];I&&(u.loaded=u.total=I);var k={url:C.url,data:b,code:C.status},O=(L=a.callbacks)==null?void 0:L.onProgress;O&&!w(e.highWaterMark)&&O(u,t,b,C),(R=a.callbacks)==null||R.onSuccess(k,u,t,C)}).catch(function(b){var L;if(self.clearTimeout(a.requestTimeout),!u.aborted){var R=b&&b.code||0,C=b?b.message:null;(L=a.callbacks)==null||L.onError({code:R,text:C},t,b?b.details:null,u)}})},s.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},s.loadProgressively=function(t,e,r,a,u){a===void 0&&(a=0);var l=new ul,d=t.body.getReader(),c=function(){return d.read().then(function(y){if(y.done)return l.dataLength&&u(e,r,l.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));var A=y.value,T=A.length;return e.loaded+=T,T<a||l.dataLength?(l.push(A),l.dataLength>=a&&u(e,r,l.flush().buffer,t)):u(e,r,A.buffer,t),c()}).catch(function(){return Promise.reject()})};return c()},n}();function df(n,s){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:s,headers:new self.Headers(E({},n.headers))};return n.rangeEnd&&i.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),i}function cf(n){var s=hf.exec(n);if(s)return parseInt(s[2])-parseInt(s[1])+1}function vf(n){var s=n.get("Content-Range");if(s){var i=cf(s);if(w(i))return i}var t=n.get("Content-Length");if(t)return parseInt(t)}function pf(n,s){return new self.Request(n.url,s)}var gf=function(n){function s(i,t,e){var r;return r=n.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=t,r.details=e,r}return S(s,n),s}(Z(Error)),mf=/^age:\s*[\d.]+\s*$/im,vs=function(){function n(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 Fi,this.retryDelay=0}var s=n.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},s.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},s.loadInternal=function(){var t=this,e=this.config,r=this.context;if(!(!e||!r)){var a=this.loader=new self.XMLHttpRequest,u=this.stats;u.loading.first=0,u.loaded=0,u.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!(t.loader!==a||t.stats.aborted))return l(a,r.url)}).catch(function(d){if(!(t.loader!==a||t.stats.aborted))return a.open("GET",r.url,!0),l(a,r.url)}).then(function(){t.loader!==a||t.stats.aborted||t.openAndSendXhr(a,r,e)}).catch(function(d){var c;(c=t.callbacks)==null||c.onError({code:a.status,text:d.message},r,a,u)}):this.openAndSendXhr(a,r,e)}},s.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var a=e.headers,u=r.loadPolicy,l=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;if(a)for(var c in a)t.setRequestHeader(c,a[c]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&w(l)?l:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},s.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(!(!t||!e)){var a=e.readyState,u=this.config;if(!r.aborted&&a>=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)))),a===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var l=e.status,d=e.responseType==="text"?e.responseText:null;if(l>=200&&l<300){var c=d??e.response;if(c!=null){var p,y;r.loading.end=Math.max(self.performance.now(),r.loading.first);var A=e.responseType==="arraybuffer"?c.byteLength:c.length;r.loaded=r.total=A,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first);var T=(p=this.callbacks)==null?void 0:p.onProgress;T&&T(r,t,c,e);var b={url:e.responseURL,data:c,code:l};(y=this.callbacks)==null||y.onSuccess(b,r,t,e);return}}var L=u.loadPolicy.errorRetry,R=r.retry,C={url:t.url,data:void 0,code:l};if(ui(L,R,!1,C))this.retry(L);else{var I;Oe.error(l+" while loading "+t.url),(I=this.callbacks)==null||I.onError({code:l,text:e.statusText},t,e,r)}}}},s.loadtimeout=function(){if(this.config){var t=this.config.loadPolicy.timeoutRetry,e=this.stats.retry;if(ui(t,e,!0))this.retry(t);else{var r;Oe.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))}}},s.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=ji(t,r.retry),r.retry++,Oe.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e?.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},s.getCacheAge=function(){var t=null;if(this.loader&&mf.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},n}(),ps={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},yf=H(H({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:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.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:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:vs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ku,bufferController:Uu,capLevelController:Gu,errorController:Fu,fpsController:ol,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,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,certLoadPolicy:{default:ps},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}}},interstitialAssetListLoadPolicy:{default:ps},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Ef()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:sl,interstitialsController:void 0});function Ef(){return{cueHandler:Jo,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 _f(n,s,i){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var t=ln(n),e=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(a){var u=(a==="level"?"playlist":a)+"LoadPolicy",l=s[u]===void 0,d=[];r.forEach(function(c){var p=a+"Loading"+c,y=s[p];if(y!==void 0&&l){d.push(p);var A=t[u].default;switch(s[u]={default:A},c){case"TimeOut":A.maxLoadTimeMs=y,A.maxTimeToFirstByteMs=y;break;case"MaxRetry":A.errorRetry.maxNumRetry=y,A.timeoutRetry.maxNumRetry=y;break;case"RetryDelay":A.errorRetry.retryDelayMs=y,A.timeoutRetry.retryDelayMs=y;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=y,A.timeoutRetry.maxRetryDelayMs=y;break}}}),d.length&&i.warn('hls.js config: "'+d.join('", "')+'" setting(s) are deprecated, use "'+u+'": '+gt(s[u]))}),H(H({},t),s)}function ln(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(ln):Object.keys(n).reduce(function(s,i){return s[i]=ln(n[i]),s},{}):n}function Sf(n,s){var i=n.loader;if(i!==cs&&i!==vs)s.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1;else{var t=ff();t&&(n.loader=cs,n.progressive=!0,n.enableSoftwareAES=!0,s.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Et={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Tf=function(){function n(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 s=n.prototype;return s._registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.BUFFER_APPENDED,this.onBufferAppended,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.BUFFER_APPENDED,this.onBufferAppended,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var a=r.length;a--;){var u=r[a];if(!u)break;var l=u.end;if(u.start<=t&&l!==null&&t<=l)return u}return this.getBufferedFrag(t,e)},s.getBufferedFrag=function(t,e){return this.getFragAtPos(t,e,!0)},s.getFragAtPos=function(t,e,r){for(var a=this.fragments,u=Object.keys(a),l=u.length;l--;){var d=a[u[l]];if(d?.body.type===e&&(!r||d.buffered)){var c=d.body;if(c.start<=t&&t<=c.end)return c}}return null},s.detectEvictedFragments=function(t,e,r,a,u){var l=this;this.timeRanges&&(this.timeRanges[t]=e);var d=a?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(c){var p=l.fragments[c];if(p&&!(d>=p.body.sn)){if(!p.buffered&&(!p.loaded||u)){p.body.type===r&&l.removeFragment(p.body);return}var y=p.range[t];if(y){if(y.time.length===0){l.removeFragment(p.body);return}y.time.some(function(A){var T=!l.isTimeBuffered(A.startPTS,A.endPTS,e);return T&&l.removeFragment(p.body),T})}}})},s.detectPartialFragments=function(t){var e=this,r=this.timeRanges;if(!(!r||t.frag.sn==="initSegment")){var a=t.frag,u=Er(a),l=this.fragments[u];if(!(!l||l.buffered&&a.gap)){var d=!a.relurl;if(Object.keys(r).forEach(function(p){var y=a.elementaryStreams[p];if(y){var A=r[p],T=d||y.partial===!0;l.range[p]=e.getBufferedTimes(a,t.part,T,A)}}),l.loaded=null,Object.keys(l.range).length){l.buffered=!0;var c=l.body.endList=a.endList||l.body.endList;c&&(this.endListFragments[l.body.type]=l),gi(l)||this.removeParts(a.sn-1,a.type)}else this.removeFragment(l.body)}}},s.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(function(a){return a.fragment.sn>=t}))},s.fragBuffered=function(t,e){var r=Er(t),a=this.fragments[r];!a&&e&&(a=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),a&&(a.loaded=null,a.buffered=!0)},s.getBufferedTimes=function(t,e,r,a){for(var u={time:[],partial:r},l=t.start,d=t.end,c=t.minEndPTS||d,p=t.maxStartPTS||l,y=0;y<a.length;y++){var A=a.start(y)-this.bufferPadding,T=a.end(y)+this.bufferPadding;if(p>=A&&c<=T){u.time.push({startPTS:Math.max(l,a.start(y)),endPTS:Math.min(d,a.end(y))});break}else if(l<T&&d>A){var b=Math.max(l,a.start(y)),L=Math.min(d,a.end(y));L>b&&(u.partial=!0,u.time.push({startPTS:b,endPTS:L}))}else if(d<=A)break}return u},s.getPartialFragment=function(t){var e=null,r,a,u,l=0,d=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(p){var y=c[p];y&&gi(y)&&(a=y.body.start-d,u=y.body.end+d,t>=a&&t<=u&&(r=Math.min(t-a,u-t),l<=r&&(e=y.body,l=r)))}),e},s.isEndListAppended=function(t){var e=this.endListFragments[t];return e!==void 0&&(e.buffered||gi(e))},s.getState=function(t){var e=Er(t),r=this.fragments[e];return r?r.buffered?gi(r)?Et.PARTIAL:Et.OK:Et.APPENDING:Et.NOT_LOADED},s.isTimeBuffered=function(t,e,r){for(var a,u,l=0;l<r.length;l++){if(a=r.start(l)-this.bufferPadding,u=r.end(l)+this.bufferPadding,t>=a&&e<=u)return!0;if(e<=a)return!1}return!1},s.onManifestLoading=function(){this.removeAllFragments()},s.onFragLoaded=function(t,e){if(!(e.frag.sn==="initSegment"||e.frag.bitrateTest)){var r=e.frag,a=e.part?null:e,u=Er(r);this.fragments[u]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(t,e){var r=e.frag,a=e.part,u=e.timeRanges,l=e.type;if(r.sn!=="initSegment"){var d=r.type;if(a){var c=this.activePartLists[d];c||(this.activePartLists[d]=c=[]),c.push(a)}this.timeRanges=u;var p=u[l];this.detectEvictedFragments(l,p,d,a)}},s.onFragBuffered=function(t,e){this.detectPartialFragments(e)},s.hasFragment=function(t){var e=Er(t);return!!this.fragments[e]},s.hasFragments=function(t){var e=this.fragments,r=Object.keys(e);if(!t)return r.length>0;for(var a=r.length;a--;){var u=e[r[a]];if(u?.body.type===t)return!0}return!1},s.hasParts=function(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)},s.removeFragmentsInRange=function(t,e,r,a,u){var l=this;a&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var c=l.fragments[d];if(c){var p=c.body;p.type!==r||a&&!p.gap||p.start<e&&p.end>t&&(c.buffered||u)&&l.removeFragment(p)}})},s.removeFragment=function(t){var e=Er(t);t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var a=t.sn;this.activePartLists[t.type]=r.filter(function(u){return u.fragment.sn!==a})}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},s.removeAllFragments=function(){var t,e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var r=(t=this.hls)==null||(e=t.latestLevelDetails)==null?void 0:e.partList;r&&r.forEach(function(a){return a.clearElementaryStreamInfo()})},n}();function gi(n){var s,i,t;return n.buffered&&(n.body.gap||((s=n.range.video)==null?void 0:s.partial)||((i=n.range.audio)==null?void 0:i.partial)||((t=n.range.audiovideo)==null?void 0:t.partial))}function Er(n){return n.type+"_"+n.level+"_"+n.sn}var gs=Math.pow(2,17),Af=function(){function n(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var s=n.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(t,e){var r=this,a=t.url;if(!a)return Promise.reject(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var u=this.config,l=u.fLoader,d=u.loader;return new Promise(function(c,p){if(r.loader&&r.loader.destroy(),t.gap)if(t.tagList.some(function(R){return R[0]==="GAP"})){p(ys(t));return}else t.gap=!1;var y=r.loader=l?new l(u):new d(u),A=ms(t);t.loader=y;var T=Ea(u.fragLoadPolicy.default),b={loadPolicy:T,timeout:T.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:gs};t.stats=y.stats;var L={onSuccess:function(C,I,k,O){r.resetLoader(t,y);var V=C.data;k.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(V.slice(0,16)),V=V.slice(16)),c({frag:t,part:null,payload:V,networkDetails:O})},onError:function(C,I,k,O){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:H({url:a,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:k,stats:O}))},onAbort:function(C,I,k){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:k,stats:C}))},onTimeout:function(C,I,k){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:k,stats:C}))}};e&&(L.onProgress=function(R,C,I,k){return e({frag:t,part:null,payload:I,networkDetails:k})}),y.load(A,b,L)})},s.loadPart=function(t,e,r){var a=this;this.abort();var u=this.config,l=u.fLoader,d=u.loader;return new Promise(function(c,p){if(a.loader&&a.loader.destroy(),t.gap||e.gap){p(ys(t,e));return}var y=a.loader=l?new l(u):new d(u),A=ms(t,e);t.loader=y;var T=Ea(u.fragLoadPolicy.default),b={loadPolicy:T,timeout:T.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:gs};e.stats=y.stats,y.load(A,b,{onSuccess:function(R,C,I,k){a.resetLoader(t,y),a.updateStatsFromPart(t,e);var O={frag:t,part:e,payload:R.data,networkDetails:k};r(O),c(O)},onError:function(R,C,I,k){a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:H({url:A.url,data:void 0},R),error:new Error("HTTP Error "+R.code+" "+R.text),networkDetails:I,stats:k}))},onAbort:function(R,C,I){t.stats.aborted=e.stats.aborted,a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:I,stats:R}))},onTimeout:function(R,C,I){a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:I,stats:R}))}})})},s.updateStatsFromPart=function(t,e){var r=t.stats,a=e.stats,u=a.total;if(r.loaded+=a.loaded,u){var l=Math.round(t.duration/e.duration),d=Math.min(Math.round(r.loaded/u),l),c=l-d,p=c*Math.round(r.loaded/d);r.total=r.loaded+p}else r.total=Math.max(r.loaded,r.total);var y=r.loading,A=a.loading;y.start?y.first+=A.first-A.start:(y.start=A.start,y.first=A.first),y.end=A.end},s.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},n}();function ms(n,s){s===void 0&&(s=null);var i=s||n,t={frag:n,part:s,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},e=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(w(e)&&w(r)){var a,u=e,l=r;if(n.sn==="initSegment"&&bf((a=n.decryptdata)==null?void 0:a.method)){var d=r-e;d%16&&(l=r+(16-d%16)),e!==0&&(t.resetIV=!0,u=e-16)}t.rangeStart=u,t.rangeEnd=l}return t}function ys(n,s){var i=new Error("GAP "+(n.gap?"tag":"attribute")+" found"),t={type:Y.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:n,error:i,networkDetails:null};return s&&(t.part=s),(s||n).stats.aborted=!0,new Jt(t)}function bf(n){return n==="AES-128"||n==="AES-256"}var Jt=function(n){function s(i){var t;return t=n.call(this,i.error.message)||this,t.data=void 0,t.data=i,t}return S(s,n),s}(Z(Error)),Es=function(n){function s(t,e){var r;return r=n.call(this,t,e)||this,r._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(r),r}S(s,n);var i=s.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},i.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},i.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},s}(je),_s=function(s,i,t,e,r,a){e===void 0&&(e=0),r===void 0&&(r=-1),a===void 0&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=mi(),this.buffering={audio:mi(),video:mi(),audiovideo:mi()},this.level=s,this.sn=i,this.id=t,this.size=e,this.part=r,this.partial=a};function mi(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Ur(n,s){for(var i=0,t=n.length;i<t;i++){var e;if(((e=n[i])==null?void 0:e.cc)===s)return n[i]}return null}function Lf(n,s){return!!(n&&s.startCC<n.endCC&&s.endCC>n.startCC)}function Ss(n,s){if(n){var i=n.start+s;n.start=n.startPTS=i,n.endPTS=i+n.duration}}function Ts(n,s){for(var i=s.fragments,t=0,e=i.length;t<e;t++)Ss(i[t],n);s.fragmentHint&&Ss(s.fragmentHint,n),s.alignedSliding=!0}function xf(n,s){n&&(Rf(s,n),!s.alignedSliding&&n&&Cf(s,n),!s.alignedSliding&&n&&!s.skippedSegments&&Ba(n,s,!1))}function Rf(n,s){if(Lf(s,n)){var i=Math.min(s.endCC,n.endCC),t=Ur(s.fragments,i),e=Ur(n.fragments,i);if(!(!t||!e)){Oe.log("Aligning playlist at start of dicontinuity sequence "+i);var r=t.start-e.start;Ts(r,n)}}}function Cf(n,s){if(!(!n.hasProgramDateTime||!s.hasProgramDateTime)){var i=n.fragments,t=s.fragments;if(!(!i.length||!t.length)){var e,r,a=Math.min(s.endCC,n.endCC);s.startCC<a&&n.startCC<a&&(e=Ur(t,a),r=Ur(i,a)),(!e||!r)&&(e=t[Math.floor(t.length/2)],r=Ur(i,e.cc)||i[Math.floor(i.length/2)]);var u=e.programDateTime,l=r.programDateTime;if(!(!u||!l)){var d=(l-u)/1e3-(r.start-e.start);Ts(d,n)}}}}var kf={toString:function(s){for(var i="",t=s.length,e=0;e<t;e++)i+="["+s.start(e).toFixed(3)+"-"+s.end(e).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",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},Df=function(n){function s(t,e,r,a,u){var l;return l=n.call(this,a,t.logger)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=ne.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var d=l,c=d.config,p=d.fragCurrent,y=d.media,A=d.mediaBuffer,T=d.state,b=y?y.currentTime:0,L=Fe.bufferInfo(A||y,b,c.maxBufferHole);if(l.log("media seeking to "+(w(b)?b.toFixed(3):b)+", state: "+T),l.state===ne.ENDED)l.resetLoadingState();else if(p){var R=c.maxFragLookUpTolerance,C=p.start-R,I=p.start+p.duration+R;if(!L.len||I<L.start||C>L.end){var k=b>I;(b<C||k)&&(k&&p.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),p.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(y){l.fragmentTracker.removeFragmentsInRange(b,1/0,l.playlistType,!0);var O=l.lastCurrentTime;if(b>O&&(l.lastCurrentTime=b),!l.loadingParts){var V=Math.max(L.end,b),N=l.shouldLoadParts(l.getLevelDetails(),V);N&&(l.log("LL-Part loading ON after seeking to "+b.toFixed(2)+" with buffer @"+V.toFixed(2)),l.loadingParts=N)}}!l.hls.hasEnoughToStart&&!L.len&&(l.log("setting startPosition to "+b+" because of seek before start"),l.nextLoadPosition=l.startPosition=b),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0},l.playlistType=u,l.hls=t,l.fragmentLoader=new Af(t.config),l.keyLoader=r,l.fragmentTracker=e,l.config=t.config,l.decrypter=new en(t.config),l}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.ERROR,this.onError,this)},i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(e){},i.stopLoad=function(){if(this.state!==ne.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ne.STOPPED}},i.pauseBuffering=function(){this.buffering=!1},i.resumeBuffering=function(){this.buffering=!0},i._streamEnded=function(e,r){if(r.live||!this.media)return!1;var a=e.end||0,u=this.config.timelineOffset||0;if(a<=u)return!1;var l=e.nextStart,d=l&&l>u&&l<r.edge;if(d||this.media.currentTime<e.start)return!1;var c=r.partList;if(c!=null&&c.length){var p=c[c.length-1],y=Fe.isBuffered(this.media,p.start+p.duration/2);return y}var A=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(A)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}},i.onMediaAttached=function(e,r){var a=this.media=this.mediaBuffer=r.media;a.removeEventListener("seeking",this.onMediaSeeking),a.removeEventListener("ended",this.onMediaEnded),a.addEventListener("seeking",this.onMediaSeeking),a.addEventListener("ended",this.onMediaEnded);var u=this.config;this.levels&&u.autoStartLoad&&this.state===ne.STOPPED&&this.startLoad(u.startPosition)},i.onMediaDetaching=function(e,r){var a=!!r.transferMedia,u=this.media;if(u!==null){if(u.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),u.removeEventListener("seeking",this.onMediaSeeking),u.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!a&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,a){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}},i.onManifestLoading=function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},i.onError=function(e,r){},i.onManifestLoaded=function(e,r){this.startTimeOffset=r.startTimeOffset},i.onHandlerDestroying=function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),n.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=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,n.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(e,r,a){this.startFragRequested=!0,this._loadFragForPlayback(e,r,a)},i._loadFragForPlayback=function(e,r,a){var u=this,l=function(c){var p=c.frag;if(u.fragContextChanged(p)){u.warn(p.type+" sn: "+p.sn+(c.part?" part: "+c.part.index:"")+" of "+u.fragInfo(p,!1,c.part)+") was dropped during download."),u.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,u._handleFragmentLoadProgress(c)};this._doFragLoad(e,r,a,l).then(function(d){if(d){var c=u.state,p=d.frag;if(u.fragContextChanged(p)){(c===ne.FRAG_LOADING||!u.fragCurrent&&c===ne.PARSING)&&(u.fragmentTracker.removeFragment(p),u.state=ne.IDLE);return}"payload"in d&&(u.log("Loaded "+p.type+" sn: "+p.sn+" of "+u.playlistLabel()+" "+p.level),u.hls.trigger(x.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(e))})},i.clearTrackerIfNeeded=function(e){var r,a=this.fragmentTracker,u=a.getState(e);if(u===Et.APPENDING){var l=e.type,d=this.getFwdBufferInfo(this.mediaBuffer,l),c=Math.max(e.duration,d?d.len:this.config.maxBufferLength),p=this.backtrackFragment,y=p?e.sn-p.sn:0;(y===1||this.reduceMaxBufferLength(c,e.duration))&&a.removeFragment(e)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?a.removeAllFragments():a.hasParts(e.type)&&(a.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),a.getState(e)===Et.PARTIAL&&a.removeFragment(e))},i.checkLiveUpdate=function(e){if(e.updated&&!e.live){var r=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},i.waitForLive=function(e){var r=e.details;return r?.live&&r.type!=="EVENT"&&(this.levelLastLoaded!==e||r.expired)},i.flushMainBuffer=function(e,r,a){if(a===void 0&&(a=null),!!(e-r)){var u={startOffset:e,endOffset:r,type:a};this.hls.trigger(x.BUFFER_FLUSHING,u)}},i._loadInitSegment=function(e,r){var a=this;this._doFragLoad(e,r).then(function(u){var l=u?.frag;if(!l||a.fragContextChanged(l)||!a.levels)throw new Error("init load aborted");return u}).then(function(u){var l=a.hls,d=u.frag,c=u.payload,p=d.decryptdata;if(c&&c.byteLength>0&&p!=null&&p.key&&p.iv&&Mr(p.method)){var y=self.performance.now();return a.decrypter.decrypt(new Uint8Array(c),p.key.buffer,p.iv.buffer,xa(p.method)).catch(function(A){throw l.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:A,reason:A.message,frag:d}),A}).then(function(A){var T=self.performance.now();return l.trigger(x.FRAG_DECRYPTED,{frag:d,payload:A,stats:{tstart:y,tdecrypt:T}}),u.payload=A,a.completeInitSegmentLoad(u)})}return a.completeInitSegmentLoad(u)}).catch(function(u){a.state===ne.STOPPED||a.state===ne.ERROR||(a.warn(u),a.resetFragmentLoading(e))})},i.completeInitSegmentLoad=function(e){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var a=e.frag.stats;this.state!==ne.STOPPED&&(this.state=ne.IDLE),e.frag.data=new Uint8Array(e.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(e){var r=this.fragCurrent;return!e||!r||e.sn!==r.sn||e.level!==r.level},i.fragBufferedComplete=function(e,r){var a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+" > buffer:"+(a?kf.toString(Fe.getBuffered(a)):"(detached)")+")"),jt(e)){var u;if(e.type!==ae.SUBTITLE){var l=e.elementaryStreams;if(!Object.keys(l).some(function(c){return!!l[c]})){this.state=ne.IDLE;return}}var d=(u=this.levels)==null?void 0:u[e.level];d!=null&&d.fragmentError&&(this.log("Resetting level fragment error count of "+d.fragmentError+" on frag buffered"),d.fragmentError=0)}this.state=ne.IDLE},i._handleFragmentLoadComplete=function(e){var r=this.transmuxer;if(r){var a=e.frag,u=e.part,l=e.partsLoaded,d=!l||l.length===0||l.some(function(p){return!p}),c=new _s(a.level,a.sn,a.stats.chunkCount+1,0,u?u.index:-1,!d);r.flush(c)}},i._handleFragmentLoadProgress=function(e){},i._doFragLoad=function(e,r,a,u){var l,d=this;a===void 0&&(a=null),this.fragCurrent=e;var c=r?.details;if(!this.levels||!c)throw new Error("frag load aborted, missing level"+(c?"":" detail")+"s");var p=null;e.encrypted&&!((l=e.decryptdata)!=null&&l.key)?(this.log("Loading key for "+e.sn+" of ["+c.startSN+"-"+c.endSN+"], "+this.playlistLabel()+" "+e.level),this.state=ne.KEY_LOADING,this.fragCurrent=e,p=this.keyLoader.load(e).then(function(k){if(!d.fragContextChanged(k.frag))return d.hls.trigger(x.KEY_LOADED,k),d.state===ne.KEY_LOADING&&(d.state=ne.IDLE),k}),this.hls.trigger(x.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(e,c.encryptedFragments);var y=this.fragPrevious;if(jt(e)&&(!y||e.sn!==y.sn)){var A=this.shouldLoadParts(r.details,e.end);A!==this.loadingParts&&(this.log("LL-Part loading "+(A?"ON":"OFF")+" loading sn "+y?.sn+"->"+e.sn),this.loadingParts=A)}if(a=Math.max(e.start,a||0),this.loadingParts&&jt(e)){var T=c.partList;if(T&&u){a>e.end&&c.fragmentHint&&(e=c.fragmentHint);var b=this.getNextPart(T,e,a);if(b>-1){var L=T[b];e=this.fragCurrent=L.fragment,this.log("Loading "+e.type+" sn: "+e.sn+" part: "+L.index+" ("+b+"/"+(T.length-1)+") of "+this.fragInfo(e,!1,L)+") cc: "+e.cc+" ["+c.startSN+"-"+c.endSN+"], target: "+parseFloat(a.toFixed(3))),this.nextLoadPosition=L.start+L.duration,this.state=ne.FRAG_LOADING;var R;return p?R=p.then(function(k){return!k||d.fragContextChanged(k.frag)?null:d.doFragPartsLoad(e,L,r,u)}).catch(function(k){return d.handleFragLoadError(k)}):R=this.doFragPartsLoad(e,L,r,u).catch(function(k){return d.handleFragLoadError(k)}),this.hls.trigger(x.FRAG_LOADING,{frag:e,part:L,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):R}else if(!e.url||this.loadedEndOfParts(T,a))return Promise.resolve(null)}}if(jt(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+a.toFixed(2)),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+") cc: "+e.cc+" "+(c?"["+c.startSN+"-"+c.endSN+"]":"")+", target: "+parseFloat(a.toFixed(3))),w(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ne.FRAG_LOADING;var C=this.config.progressive,I;return C&&p?I=p.then(function(k){return!k||d.fragContextChanged(k?.frag)?null:d.fragmentLoader.load(e,u)}).catch(function(k){return d.handleFragLoadError(k)}):I=Promise.all([this.fragmentLoader.load(e,C?u:void 0),p]).then(function(k){var O=k[0];return!C&&O&&u&&u(O),O}).catch(function(k){return d.handleFragLoadError(k)}),this.hls.trigger(x.FRAG_LOADING,{frag:e,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):I},i.doFragPartsLoad=function(e,r,a,u){var l=this;return new Promise(function(d,c){var p,y=[],A=(p=a.details)==null?void 0:p.partList,T=function(L){l.fragmentLoader.loadPart(e,L,u).then(function(R){y[L.index]=R;var C=R.part;l.hls.trigger(x.FRAG_LOADED,R);var I=Va(a.details,e.sn,L.index+1)||Ha(A,e.sn,L.index+1);if(I)T(I);else return d({frag:e,part:C,partsLoaded:y})}).catch(c)};T(r)})},i.handleFragLoadError=function(e){if("data"in e){var r=e.data;e.data&&r.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(x.ERROR,r)}else this.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},i._handleTransmuxerFlush=function(e){var r=this.getCurrentContext(e);if(!r||this.state!==ne.PARSING){!this.fragCurrent&&this.state!==ne.STOPPED&&this.state!==ne.ERROR&&(this.state=ne.IDLE);return}var a=r.frag,u=r.part,l=r.level,d=self.performance.now();a.stats.parsing.end=d,u&&(u.stats.parsing.end=d);var c=this.getLevelDetails(),p=c&&a.sn>c.endSN,y=p||this.shouldLoadParts(c,a.end);y!==this.loadingParts&&(this.log("LL-Part loading "+(y?"ON":"OFF")+" after parsing segment ending @"+a.end.toFixed(2)),this.loadingParts=y),this.updateLevelTiming(a,u,l,e.partial)},i.shouldLoadParts=function(e,r){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e!=null&&e.partList){var a,u=e.partList[0],l=u.end+(((a=e.fragmentHint)==null?void 0:a.duration)||0);if(r>=l){var d,c=this.hls.hasEnoughToStart?((d=this.media)==null?void 0:d.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(c>u.start-u.fragment.duration)return!0}}}return!1},i.getCurrentContext=function(e){var r=this.levels,a=this.fragCurrent,u=e.level,l=e.sn,d=e.part;if(!(r!=null&&r[u]))return this.warn("Levels object was unset while buffering fragment "+l+" of "+this.playlistLabel()+" "+u+". The current chunk will not be buffered."),null;var c=r[u],p=c.details,y=d>-1?Va(p,l,d):null,A=y?y.fragment:nl(p,l,a);return A?(a&&a!==A&&(A.stats=a.stats),{frag:A,part:y,level:c}):null},i.bufferFragmentData=function(e,r,a,u,l){var d;if(!(!e||this.state!==ne.PARSING)){var c=e.data1,p=e.data2,y=c;if(c&&p&&(y=Ot(c,p)),!!((d=y)!=null&&d.length)){var A={type:e.type,frag:r,part:a,chunkMeta:u,parent:r.type,data:y};if(this.hls.trigger(x.BUFFER_APPENDING,A),e.dropped&&e.independent&&!a){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(e){var r=this.media;if(r){if(!Fe.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,e.start);return}var a=r.currentTime,u=Fe.bufferInfo(r,a,0),l=e.duration,d=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),c=Math.max(Math.min(e.start-d,u.end-d),a+d);e.start-c>d&&this.flushMainBuffer(c,e.start)}},i.getFwdBufferInfo=function(e,r){var a,u=this.getLoadPosition();if(!w(u))return null;var l=this.lastCurrentTime>u,d=l||(a=this.media)!=null&&a.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,u,r,d)},i.getFwdBufferInfoAtPos=function(e,r,a,u){var l=Fe.bufferInfo(e,r,u);if(l.len===0&&l.nextStart!==void 0){var d=this.fragmentTracker.getBufferedFrag(r,a);if(d&&(l.nextStart<=d.end||d.gap)){var c=Math.max(Math.min(l.nextStart,d.end)-r,u);return Fe.bufferInfo(e,r,c)}}return l},i.getMaxBufferLength=function(e){var r=this.config,a;return e?a=Math.max(8*r.maxBufferSize/e,r.maxBufferLength):a=r.maxBufferLength,Math.min(a,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(e,r){var a=this.config,u=Math.max(Math.min(e-r,a.maxBufferLength),r),l=Math.max(e-r*3,a.maxMaxBufferLength/2,u);return l>=u?(a.maxMaxBufferLength=l,this.warn("Reduce max buffer length to "+l+"s"),!0):!1},i.getAppendedFrag=function(e,r){var a;r===void 0&&(r=ae.MAIN);var u=(a=this.fragmentTracker)==null?void 0:a.getAppendedFrag(e,r);return u&&"fragment"in u?u.fragment:u},i.getNextFragment=function(e,r){var a=r.fragments,u=a.length;if(!u)return null;var l=this.config,d=a[0].start,c=l.lowLatencyMode&&!!r.partList,p=null;if(r.live){var y=l.initialLiveManifestSize;if(u<y)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+y+")"),null;if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<d){var A;c&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),p=this.getInitialLiveFragment(r,a);var T=this.hls.startPosition,b=this.hls.liveSyncPosition,L=p?(T!==-1&&T>=d?T:b)||p.start:e;this.log("Setting startPosition to "+L+" to match start frag at live edge. mainStart: "+T+" liveSyncPosition: "+b+" frag.start: "+((A=p)==null?void 0:A.start)),this.startPosition=this.nextLoadPosition=L}}else e<=d&&(p=a[0]);if(!p){var R=this.loadingParts?r.partEnd:r.fragmentEnd;p=this.getFragmentAtPosition(e,R,r)}var C=this.filterReplacedPrimary(p,r);if(!C&&p){var I=p.sn-r.startSN;C=this.filterReplacedPrimary(a[I+1]||null,r)}return this.mapToInitFragWhenRequired(C)},i.isLoopLoading=function(e,r){var a=this.fragmentTracker.getState(e);return(a===Et.OK||a===Et.PARTIAL&&!!e.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(e,r,a,u,l){var d=null;if(e.gap&&(d=this.getNextFragment(this.nextLoadPosition,r),d&&!d.gap&&a.nextStart)){var c=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,a.nextStart,u,0);if(c!==null&&a.len+c.len>=l){var p=d.sn;return this.loopSn!==p&&(this.log('buffer full after gaps in "'+u+'" playlist starting at sn: '+p),this.loopSn=p),null}}return this.loopSn=void 0,d},i.filterReplacedPrimary=function(e,r){return e&&(As(this.hls.config),e)},i.mapToInitFragWhenRequired=function(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e},i.getNextPart=function(e,r,a){for(var u=-1,l=!1,d=!0,c=0,p=e.length;c<p;c++){var y=e[c];if(d=d&&!y.independent,u>-1&&a<y.start)break;var A=y.loaded;A?u=-1:(l||y.independent||d)&&y.fragment===r&&(u=c),l=A}return u},i.loadedEndOfParts=function(e,r){var a=e[e.length-1];return a&&r>a.start&&a.loaded},i.getInitialLiveFragment=function(e,r){var a=this.fragPrevious,u=null;if(a){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),u=Iu(r,a.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var l=a.sn+1;if(l>=e.startSN&&l<=e.endSN){var d=r[l-e.startSN];a.cc===d.cc&&(u=d,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=Ou(r,a.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var c=this.hls.liveSyncPosition;c!==null&&(u=this.getFragmentAtPosition(c,this.bitrateTest?e.fragmentEnd:e.edge,e))}return u},i.getFragmentAtPosition=function(e,r,a){var u=this.config,l=this.fragPrevious,d=a.fragments,c=a.endSN,p=a.fragmentHint,y=u.maxFragLookUpTolerance,A=a.partList,T=!!(this.loadingParts&&A!=null&&A.length&&p);T&&p&&!this.bitrateTest&&A[A.length-1].fragment.sn===p.sn&&(d=d.concat(p),c=p.sn);var b;if(e<r){var L,R=e<this.lastCurrentTime,C=R||e>r-y||(L=this.media)!=null&&L.paused||!this.startFragRequested?0:y;b=Wi(l,d,e,C)}else b=d[d.length-1];if(b){var I=b.sn-a.startSN,k=this.fragmentTracker.getState(b);if((k===Et.OK||k===Et.PARTIAL&&b.gap)&&(l=b),l&&b.sn===l.sn&&(!T||A[0].fragment.sn>b.sn||!a.live&&!T)){var O=l&&b.level===l.level;if(O){var V=d[I+1];b.sn<c&&this.fragmentTracker.getState(V)!==Et.OK?b=V:b=null}}}return b},i.alignPlaylists=function(e,r,a){var u=e.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var l=e.fragmentStart,d=!r,c=e.alignedSliding&&w(l);if(d||!c&&!l){xf(a,e);var p=e.fragmentStart;return this.log("Live playlist sliding: "+p.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+e.startSN+" fragments: "+u),p}return l},i.waitForCdnTuneIn=function(e){var r=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*r)},i.setStartPosition=function(e,r){var a=this.startPosition;a<r&&(a=-1);var u=this.timelineOffset;if(a===-1){var l=this.startTimeOffset!==null,d=l?this.startTimeOffset:e.startTimeOffset;d!==null&&w(d)?(a=r+d,d<0&&(a+=e.edge),a=Math.min(Math.max(r,a),r+e.totalduration),this.log("Setting startPosition to "+a+" for start time offset "+d+" found in "+(l?"multivariant":"media")+" playlist"),this.startPosition=a):e.live?(a=this.hls.liveSyncPosition||r,this.log("Setting startPosition to -1 to start at live edge "+a),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=a=0),this.lastCurrentTime=a+u}this.nextLoadPosition=a+u},i.getLoadPosition=function(){var e,r=this.media,a=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&r?a=r.currentTime:this.nextLoadPosition>=0&&(a=this.nextLoadPosition),a},i.handleFragLoadAborted=function(e,r){this.transmuxer&&e.type===this.playlistType&&jt(e)&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(r?" part "+r.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},i.resetFragmentLoading=function(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==ne.FRAG_LOADING_WAITING_RETRY)&&(this.state=ne.IDLE)},i.onFragmentOrKeyLoadError=function(e,r){if(r.chunkMeta&&!r.frag){var a=this.getCurrentContext(r.chunkMeta);a&&(r.frag=a.frag)}var u=r.frag;if(!(!u||u.type!==e||!this.levels)){if(this.fragContextChanged(u)){var l;this.warn("Frag load error must match current frag to retry "+u.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var d=r.details===M.FRAG_GAP;d&&this.fragmentTracker.fragBuffered(u,!0);var c=r.errorAction,p=c||{},y=p.action,A=p.flags,T=p.retryCount,b=T===void 0?0:T,L=p.retryConfig,R=!!c&&!!L,C=R&&y===ht.RetryRequest,I=R&&!c.resolved&&A===Mt.MoveAllAlternatesMatchingHost;if(!C&&I&&jt(u)&&!u.endList)this.resetFragmentErrors(e),this.treatAsGap(u),c.resolved=!0;else if((C||I)&&b<L.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var k=ji(L,b);this.warn("Fragment "+u.sn+" of "+e+" "+u.level+" errored with "+r.details+", retrying loading "+(b+1)+"/"+L.maxNumRetry+" in "+k+"ms"),c.resolved=!0,this.retryDate=self.performance.now()+k,this.state=ne.FRAG_LOADING_WAITING_RETRY}else if(L&&c)if(this.resetFragmentErrors(e),b<L.maxNumRetry)!d&&y!==ht.RemoveAlternatePermanently&&(c.resolved=!0);else{this.warn(r.details+" reached or exceeded max retry ("+b+")");return}else y===ht.SendAlternateToPenaltyBox?this.state=ne.WAITING_LEVEL:this.state=ne.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(e){if(this.state===ne.PARSING||this.state===ne.PARSED){var r=e.frag,a=e.parent,u=this.getFwdBufferInfo(this.mediaBuffer,a),l=u&&u.len>.5;l&&this.reduceMaxBufferLength(u.len,r?.duration||10);var d=!l;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+a+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),d}return!1},i.resetFragmentErrors=function(e){e===ae.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.afterBufferFlushed=function(e,r,a){if(e){var u=Fe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(r,u,a),this.state===ne.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.resetStartWhenNotLoaded=function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var r=e?e.details:null;r!=null&&r.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(r,r.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(e){e===void 0&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(e,r,a,u){var l=this,d=a.details;if(!d){this.warn("level.details undefined");return}var c=Object.keys(e.elementaryStreams).reduce(function(A,T){var b=e.elementaryStreams[T];if(b){var L=b.endPTS-b.startPTS;if(L<=0)return l.warn("Could not parse fragment "+e.sn+" "+T+" duration reliably ("+L+")"),A||!1;var R=u?0:Na(d,e,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return l.hls.trigger(x.LEVEL_PTS_UPDATED,{details:d,level:a,drift:R,type:T,frag:e,start:b.startPTS,end:b.endPTS}),!0}return A},!1);if(!c){var p;if(a.fragmentError===0&&this.treatAsGap(e,a),((p=this.transmuxer)==null?void 0:p.error)===null){var y=new Error("Found no media in fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(y.message),this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+a.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=ne.PARSED,this.log("Parsed "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+")"),this.hls.trigger(x.FRAG_PARSED,{frag:e,part:r})},i.playlistLabel=function(){return this.playlistType===ae.MAIN?"level":"track"},i.fragInfo=function(e,r,a){var u,l;return r===void 0&&(r=!0),this.playlistLabel()+" "+e.level+" ("+(a?"part":"frag")+":["+((u=r&&!a?e.startPTS:(a||e).start)!=null?u:NaN).toFixed(3)+"-"+((l=r&&!a?e.endPTS:(a||e).end)!=null?l:NaN).toFixed(3)+"]"+(a&&e.type==="main"?"INDEPENDENT="+(a.independent?"YES":"NO"):"")},i.treatAsGap=function(e,r){r&&r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)},i.resetTransmuxer=function(){var e;(e=this.transmuxer)==null||e.reset()},i.recoverWorkerError=function(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},f(s,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,r=this.startPosition;return r===-1&&e?e:r}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e=this.config.timelineOffset;if(e){var r;return((r=this.getLevelDetails())==null?void 0:r.appliedTimelineOffset)||e}return 0}},{key:"primaryPrefetch",get:function(){return As(this.hls.config),!1}},{key:"state",get:function(){return this._state},set:function(e){var r=this._state;r!==e&&(this._state=e,this.log(r+"->"+e))}}])}(Es);function As(n){return!1}function Br(n,s,i){_r(n,s,i),n.addEventListener(s,i)}function _r(n,s,i){n.removeEventListener(s,i)}var yi=2,If=.1,wf=.05,Pf=100,Of=function(n){function s(t,e){var r;return r=n.call(this,"gap-controller",t.logger)||this,r.hls=null,r.fragmentTracker=null,r.media=null,r.mediaSource=void 0,r.nudgeRetry=0,r.stallReported=!1,r.stalled=null,r.moved=!1,r.seeking=!1,r.buffered={},r.lastCurrentTime=0,r.ended=0,r.waiting=0,r.onMediaPlaying=function(){r.ended=0,r.waiting=0},r.onMediaWaiting=function(){var a;(a=r.media)!=null&&a.seeking||(r.waiting=self.performance.now(),r.tick())},r.onMediaEnded=function(){if(r.hls){var a;r.ended=((a=r.media)==null?void 0:a.currentTime)||1,r.hls.trigger(x.MEDIA_ENDED,{stalled:!1})}},r.hls=t,r.fragmentTracker=e,r.registerListeners(),r}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e&&(e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.BUFFER_APPENDED,this.onBufferAppended,this))},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.BUFFER_APPENDED,this.onBufferAppended,this))},i.destroy=function(){n.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},i.onMediaAttached=function(e,r){this.setInterval(Pf),this.mediaSource=r.mediaSource;var a=this.media=r.media;Br(a,"playing",this.onMediaPlaying),Br(a,"waiting",this.onMediaWaiting),Br(a,"ended",this.onMediaEnded)},i.onMediaDetaching=function(e,r){this.clearInterval();var a=this.media;a&&(_r(a,"playing",this.onMediaPlaying),_r(a,"waiting",this.onMediaWaiting),_r(a,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},i.onBufferAppended=function(e,r){this.buffered=r.timeRanges},i.tick=function(){var e;if(!(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)){var r=this.media.currentTime;this.poll(r,this.lastCurrentTime),this.lastCurrentTime=r}},i.poll=function(e,r){var a,u,l=(a=this.hls)==null?void 0:a.config;if(l){var d=this.media,c=this.stalled;if(d){var p=d.seeking,y=this.seeking&&!p,A=!this.seeking&&p,T=d.paused&&!p||d.ended||d.playbackRate===0;if(this.seeking=p,e!==r){r&&(this.ended=0),this.moved=!0,p||(this.nudgeRetry=0,l.nudgeOnVideoHole&&!T&&e>r&&this.nudgeOnVideoHole(e,r)),this.waiting===0&&this.stallResolved(e);return}if(A||y){y&&this.stallResolved(e);return}if(T){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&d.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(x.MEDIA_ENDED,{stalled:!1}));return}if(!Fe.getBuffered(d).length){this.nudgeRetry=0;return}var b=Fe.bufferInfo(d,e,0),L=b.nextStart||0,R=this.fragmentTracker;if(p&&R&&this.hls){var C=bs(this.hls.inFlightFragments,e),I=b.len>yi,k=!L||C||L-e>yi&&!R.getPartialFragment(e);if(I||k)return;this.moved=!1}var O=(u=this.hls)==null?void 0:u.latestLevelDetails;if(!this.moved&&this.stalled!==null&&R){var V=b.len>0;if(!V&&!L)return;var N=Math.max(L,b.start||0)-e,B=!!(O!=null&&O.live),X=B?O.targetduration*2:yi,z=R.getPartialFragment(e);if(N>0&&(N<=X||z)){d.paused||this._trySkipBufferHole(z);return}}var K=l.detectStallWithCurrentTimeMs,j=self.performance.now(),J=this.waiting;if(c===null){J>0&&j-J<K?this.stalled=J:this.stalled=j;return}var le=j-c;if(!p&&(le>=K||J)&&this.hls){var re;if(((re=this.mediaSource)==null?void 0:re.readyState)==="ended"&&!(O!=null&&O.live)&&Math.abs(e-(O?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(x.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(b),!this.media||!this.hls)return}var te=Fe.bufferInfo(d,e,l.maxBufferHole);this._tryFixBufferStall(te,le)}}},i.stallResolved=function(e){var r=this.stalled;if(r&&this.hls&&(this.stalled=null,this.stallReported)){var a=self.performance.now()-r;this.log("playback not stuck anymore @"+e+", after "+Math.round(a)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(x.STALL_RESOLVED,{})}},i.nudgeOnVideoHole=function(e,r){var a,u=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(a=this.buffered.audio)!=null&&a.length&&u&&u.length>1&&e>u.end(0)){var l=Fe.bufferedInfo(Fe.timeRangesToArray(this.buffered.audio),e,0);if(l.len>1&&r>=l.start){var d=Fe.timeRangesToArray(u),c=Fe.bufferedInfo(d,r,0).bufferedIndex;if(c>-1&&c<d.length-1){var p=Fe.bufferedInfo(d,e,0).bufferedIndex,y=d[c].end,A=d[c+1].start;if((p===-1||p>c)&&A-y<1&&e-y<2){var T=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+y+" -> "+A+" buffered index: "+p);this.warn(T.message),this.media.currentTime+=1e-6;var b=this.fragmentTracker.getPartialFragment(e)||void 0,L=Fe.bufferInfo(this.media,e,0);this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:T,reason:T.message,frag:b,buffer:L.len,bufferInfo:L})}}}}},i._tryFixBufferStall=function(e,r){var a,u,l=this.fragmentTracker,d=this.media,c=(a=this.hls)==null?void 0:a.config;if(!(!d||!l||!c)){var p=d.currentTime,y=(u=this.hls)==null?void 0:u.latestLevelDetails,A=l.getPartialFragment(p);if(A||y!=null&&y.live&&p<y.fragmentStart){var T=this._trySkipBufferHole(A);if(T||!this.media)return}var b=e.buffered;(b&&b.length>1&&e.len>c.maxBufferHole||e.nextStart&&e.nextStart-p<c.maxBufferHole)&&(r>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},i._reportStall=function(e){var r=this.hls,a=this.media,u=this.stallReported,l=this.stalled;if(!u&&l!==null&&a&&r){this.stallReported=!0;var d=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+gt(e)+")");this.warn(d.message),r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:d,buffer:e.len,bufferInfo:e,stalled:{start:l}})}},i._trySkipBufferHole=function(e){var r,a=this.fragmentTracker,u=this.media,l=(r=this.hls)==null?void 0:r.config;if(!u||!a||!l)return 0;var d=u.currentTime,c=Fe.bufferInfo(u,d,0),p=d<c.start?c.start:c.nextStart;if(p&&this.hls){var y=c.len<=l.maxBufferHole,A=c.len>0&&c.len<1&&u.readyState<3,T=p-d;if(T>0&&(y||A)){if(T>l.maxBufferHole){var b=!1;if(d===0){var L=a.getAppendedFrag(0,ae.MAIN);L&&p<L.end&&(b=!0)}if(!b){var R=e||a.getAppendedFrag(d,ae.MAIN);if(R){var C;if(!((C=this.hls.loadLevelObj)!=null&&C.details))return 0;var I=bs(this.hls.inFlightFragments,p);if(I)return 0;for(var k=!1,O=R.end;O<p;){var V=a.getPartialFragment(O);if(V)O+=V.duration;else{k=!0;break}}if(k)return 0}}}var N=Math.max(p+wf,d+If);if(this.warn("skipping hole, adjusting currentTime from "+d+" to "+N),this.moved=!0,u.currentTime=N,!(e!=null&&e.gap)){var B=new Error("fragment loaded with buffer holes, seeking from "+d+" to "+N);this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:B,reason:B.message,frag:e||void 0,buffer:c.len,bufferInfo:c})}return N}}return 0},i._tryNudgeBuffer=function(e){var r=this.hls,a=this.media,u=this.nudgeRetry,l=r?.config;if(!a||!l)return 0;var d=a.currentTime;if(this.nudgeRetry++,u<l.nudgeMaxRetry){var c=d+(u+1)*l.nudgeOffset,p=new Error("Nudging 'currentTime' from "+d+" to "+c);this.warn(p.message),a.currentTime=c,r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:p,fatal:!1,buffer:e.len,bufferInfo:e})}else{var y=new Error("Playhead still not moving while enough data buffered @"+d+" after "+l.nudgeMaxRetry+" nudges");this.error(y.message),r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:y,fatal:!0,buffer:e.len,bufferInfo:e})}},f(s,[{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}}])}(Es);function bs(n,s){var i=Ls(n.main);if(i&&i.start<=s)return i;var t=Ls(n.audio);return t&&t.start<=s?t:null}function Ls(n){if(!n)return null;switch(n.state){case ne.IDLE:case ne.STOPPED:case ne.ENDED:case ne.ERROR:return null}return n.frag}function Mf(n,s){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=n,s.dispatchEvent(i)}function Ff(n,s){var i=n.mode;if(i==="disabled"&&(n.mode="hidden"),n.cues)for(var t=n.cues.length;t--;)s&&n.cues[t].removeEventListener("enter",s),n.removeCue(n.cues[t]);i==="disabled"&&(n.mode=i)}function Nf(n,s,i,t){var e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0)for(var r=Bf(n.cues,s,i),a=0;a<r.length;a++)(!t||t(r[a]))&&n.removeCue(r[a]);e==="disabled"&&(n.mode=e)}function Uf(n,s){if(s<=n[0].startTime)return 0;var i=n.length-1;if(s>n[i].endTime)return-1;for(var t=0,e=i,r;t<=e;)if(r=Math.floor((e+t)/2),s<n[r].startTime)e=r-1;else if(s>n[r].startTime&&t<i)t=r+1;else return r;return n[t].startTime-s<s-n[e].startTime?t:e}function Bf(n,s,i){var t=[],e=Uf(n,s);if(e>-1)for(var r=e,a=n.length;r<a;r++){var u=n[r];if(u.startTime>=s&&u.endTime<=i)t.push(u);else if(u.startTime>i)return t}return t}var Gf=.25;function fn(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function xs(n,s,i,t,e){var r=new n(s,i,"");try{r.value=t,e&&(r.type=e)}catch{r=new n(s,i,gt(e?H({type:e},t):t))}return r}var Ei=function(){var n=fn();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Vf(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Hf=function(){function n(i){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(x.EVENT_CUE_ENTER,{})},this.hls=i,this._registerListeners()}var s=n.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},s._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s.onMediaAttaching=function(t,e){var r;this.media=e.media,((r=e.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)},s.onMediaAttached=function(){var t=this.hls.latestLevelDetails;t&&this.updateDateRangeCues(t)},s.onMediaDetaching=function(t,e){this.media=null;var r=!!e.transferMedia;r||(this.id3Track&&(this.removeCues&&Ff(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},s.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if(r.kind==="metadata"&&r.label==="id3")return Mf(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,a=r.enableEmsgMetadataCues,u=r.enableID3MetadataCues;if(!(!a&&!u)){var l=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var d=fn();if(d)for(var c=0;c<l.length;c++){var p=l[c].type;if(!(p===Lt.emsg&&!a||!u)){var y=Za(l[c].data);if(y){var A=l[c].pts,T=A+l[c].duration;T>Ei&&(T=Ei);var b=T-A;b<=0&&(T=A+Gf);for(var L=0;L<y.length;L++){var R=y[L];if(!Ja(R)){this.updateId3CueEnds(A,p);var C=xs(d,A,T,R,p);C&&this.id3Track.addCue(C)}}}}}}}},s.updateId3CueEnds=function(t,e){var r,a=(r=this.id3Track)==null?void 0:r.cues;if(a)for(var u=a.length;u--;){var l=a[u];l.type===e&&l.startTime<t&&l.endTime===Ei&&(l.endTime=t)}},s.onBufferFlushing=function(t,e){var r=e.startOffset,a=e.endOffset,u=e.type,l=this.id3Track,d=this.hls;if(d){var c=d.config,p=c.enableEmsgMetadataCues,y=c.enableID3MetadataCues;if(l&&(p||y)){var A;u==="audio"?A=function(b){return b.type===Lt.audioId3&&y}:u==="video"?A=function(b){return b.type===Lt.emsg&&p}:A=function(b){return b.type===Lt.audioId3&&y||b.type===Lt.emsg&&p},Nf(l,r,a,A)}}},s.onLevelUpdated=function(t,e){var r=e.details;this.updateDateRangeCues(r,!0)},s.onLevelPtsUpdated=function(t,e){Math.abs(e.drift)>.01&&this.updateDateRangeCues(e.details)},s.updateDateRangeCues=function(t,e){var r=this;if(!(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var a=this.id3Track,u=t.dateRanges,l=Object.keys(u),d=this.dateRangeCuesAppended;if(a&&e){var c;if((c=a.cues)!=null&&c.length)for(var p=Object.keys(d).filter(function(C){return!l.includes(C)}),y=function(){var I=p[A],k=d[I].cues;delete d[I],Object.keys(k).forEach(function(O){try{var V=k[O];V.removeEventListener("enter",r.onEventCueEnter),a.removeCue(V)}catch{}})},A=p.length;A--;)y();else d=this.dateRangeCuesAppended={}}var T=t.fragments[t.fragments.length-1];if(!(l.length===0||!w(T?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var b=fn(),L=function(){var I=l[R],k=u[I],O=k.startTime,V=d[I],N=V?.cues||{},B=V?.durationKnown||!1,X=Ei,z=k.duration,K=k.endDate;if(K&&z!==null)X=O+z,B=!0;else if(k.endOnNext&&!B){var j=l.reduce(function(ge,Ne){if(Ne!==k.id){var we=u[Ne];if(we.class===k.class&&we.startDate>k.startDate&&(!ge||k.startDate<ge.startDate))return we}return ge},null);j&&(X=j.startTime,B=!0)}for(var J=Object.keys(k.attr),le=0;le<J.length;le++){var re=J[le];if(Ku(re)){var te=N[re];if(te)B&&!V.durationKnown?te.endTime=X:Math.abs(te.startTime-O)>.01&&(te.startTime=O,te.endTime=X);else if(b){var fe=k.attr[re];Wu(re)&&(fe=Vf(fe));var de={key:re,data:fe},ve=xs(b,O,X,de,Lt.dateRange);ve&&(ve.id=I,r.id3Track.addCue(ve),N[re]=ve)}}}d[I]={cues:N,dateRange:k,durationKnown:B}},R=0;R<l.length;R++)L()}}},n}(),Kf=function(){function n(i){var t=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 e=t.media,r=t.levelDetails;if(!(!e||!r)){t.currentTime=e.currentTime;var a=t.computeLatency();if(a!==null){t._latency=a;var u=t.config,l=u.lowLatencyMode,d=u.maxLiveSyncPlaybackRate;if(!(!l||d===1||!r.live)){var c=t.targetLatency;if(c!==null){var p=a-c,y=Math.min(t.maxLatency,c+r.targetduration),A=p<y;if(A&&p>.05&&t.forwardBufferLength>1){var T=Math.min(2,Math.max(1,d)),b=Math.round(2/(1+Math.exp(-.75*p-t.edgeStalled))*20)/20,L=Math.min(T,Math.max(1,b));t.changeMediaPlaybackRate(e,L)}else e.playbackRate!==1&&e.playbackRate!==0&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=i,this.config=i.config,this.registerListeners()}var s=n.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},s.registerListeners=function(){var t=this.hls;t&&(t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.ERROR,this.onError,this))},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.ERROR,this.onError,this))},s.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},s.onManifestLoading=function(){this._latency=null,this.stallCount=0},s.onLevelUpdated=function(t,e){var r=e.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},s.onError=function(t,e){var r;e.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},s.changeMediaPlaybackRate=function(t,e){var r,a;t.playbackRate!==e&&((r=this.hls)==null||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((a=this.targetLatency)==null?void 0:a.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+t.playbackRate+" to "+e),t.playbackRate=e)},s.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},s.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},f(n,[{key:"levelDetails",get:function(){var t;return((t=this.hls)==null?void 0:t.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config;if(t.liveMaxLatencyDuration!==void 0)return t.liveMaxLatencyDuration;var e=this.levelDetails;return e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null||this.hls===null)return null;var e=t.holdBack,r=t.partHoldBack,a=t.targetduration,u=this.config,l=u.liveSyncDuration,d=u.liveSyncDurationCount,c=u.lowLatencyMode,p=this.hls.userConfig,y=c&&r||e;(this._targetLatencyUpdated||p.liveSyncDuration||p.liveSyncDurationCount||y===0)&&(y=l!==void 0?l:d*a);var A=a;return y+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,A)},set:function(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency;if(t===null||e===null)return null;var r=this.levelDetails;if(r===null)return null;var a=r.edge,u=t-e-this.edgeStalled,l=a-r.totalduration,d=a-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,u),d)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}])}(),Wf=function(n){function s(t,e){var r;return r=n.call(this,e,t.logger)||this,r.hls=void 0,r.canLoad=!1,r.timer=-1,r.hls=t,r}S(s,n);var i=s.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},i.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(e,r,a){var u=r?.renditionReports;if(u){for(var l=-1,d=0;d<u.length;d++){var c=u[d],p=void 0;try{p=new self.URL(c.URI,r.url).href}catch(R){this.warn("Could not construct new URL for Rendition Report: "+R),p=c.URI||""}if(p===e){l=d;break}else p===e.substring(0,p.length)&&(l=d)}if(l!==-1){var y=u[l],A=parseInt(y["LAST-MSN"])||r?.lastPartSn,T=parseInt(y["LAST-PART"])||r?.lastPartIndex;if(this.hls.config.lowLatencyMode){var b=Math.min(r.age-r.partTarget,r.targetduration);T>=0&&b>r.partTarget&&(T+=1)}var L=a&&fa(a);return new ha(A,T>=0?T:void 0,L)}}},i.loadPlaylist=function(e){this.clearTimer()},i.loadingPlaylist=function(e,r){this.clearTimer()},i.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},i.getUrlWithDirectives=function(e,r){if(r)try{return r.addDirectives(e)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}return e},i.playlistLoaded=function(e,r,a){var u=r.details,l=r.stats,d=self.performance.now(),c=l.loading.first?Math.max(0,d-l.loading.first):0;u.advancedDateTime=Date.now()-c;var p=this.hls.config.timelineOffset;if(p!==u.appliedTimelineOffset){var y=Math.max(p||0,0);u.appliedTimelineOffset=y,u.fragments.forEach(function(ge){ge.start=ge.playlistOffset+y})}if(u.live||a!=null&&a.live){var A="levelInfo"in r?r.levelInfo:r.track;if(u.reloaded(a),a&&u.fragments.length>0){Ju(a,u);var T=u.playlistParsingError;if(T){this.warn(T);var b=this.hls;if(!b.config.ignorePlaylistParsingErrors){var L,R=r.networkDetails;b.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:u.url,error:T,reason:T.message,level:r.level||void 0,parent:(L=u.fragments[0])==null?void 0:L.type,networkDetails:R,stats:l});return}u.playlistParsingError=null}}u.requestScheduled===-1&&(u.requestScheduled=l.loading.start);var C=this.hls.mainForwardBufferInfo,I=C?C.end-C.len:0,k=(u.edge-I)*1e3,O=Ga(u,k);if(u.requestScheduled+O<d?u.requestScheduled=d:u.requestScheduled+=O,this.log("live playlist "+e+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:u.updated?"UPDATED":"MISSED")),!this.canLoad||!u.live)return;var V,N=void 0,B=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var X=this.hls.config.lowLatencyMode,z=u.lastPartSn,K=u.endSN,j=u.lastPartIndex,J=j!==-1,le=z===K;J?le?(N=K+1,B=X?0:j):(N=z,B=X?j+1:u.maxPartIndex):N=K+1;var re=u.age,te=re+u.ageHeader,fe=Math.min(te-u.partTarget,u.targetduration*1.5);if(fe>0){if(te>u.targetduration*3)this.log("Playlist last advanced "+re.toFixed(2)+"s ago. Omitting segment and part directives."),N=void 0,B=void 0;else if(a!=null&&a.tuneInGoal&&te-u.partTarget>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+fe+" with playlist age: "+u.age),fe=0;else{var de=Math.floor(fe/u.targetduration);if(N+=de,B!==void 0){var ve=Math.round(fe%u.targetduration/u.partTarget);B+=ve}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+re.toFixed(2)+"s goal: "+fe+" skip sn "+de+" to part "+B)}u.tuneInGoal=fe}if(V=this.getDeliveryDirectives(u,r.deliveryDirectives,N,B),X||!le){u.requestScheduled=d,this.loadingPlaylist(A,V);return}}else(u.canBlockReload||u.canSkipUntil)&&(V=this.getDeliveryDirectives(u,r.deliveryDirectives,N,B));V&&N!==void 0&&u.canBlockReload&&(u.requestScheduled=l.loading.first+Math.max(O-c*2,O/2)),this.scheduleLoading(A,V,u)}else this.clearTimer()},i.scheduleLoading=function(e,r,a){var u=this,l=a||e.details;if(!l){this.loadingPlaylist(e,r);return}var d=self.performance.now(),c=l.requestScheduled;if(d>=c){this.loadingPlaylist(e,r);return}var p=c-d;this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(p)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return u.loadingPlaylist(e,r)},p)},i.getDeliveryDirectives=function(e,r,a,u){var l=fa(e);return r!=null&&r.skip&&e.deltaUpdateFailed&&(a=r.msn,u=r.part,l=si.No),new ha(a,u,l)},i.checkRetry=function(e){var r=this,a=e.details,u=oi(e),l=e.errorAction,d=l||{},c=d.action,p=d.retryCount,y=p===void 0?0:p,A=d.retryConfig,T=!!l&&!!A&&(c===ht.RetryRequest||!l.resolved&&c===ht.SendAlternateToPenaltyBox);if(T){var b;if(y>=A.maxNumRetry)return!1;if(u&&(b=e.context)!=null&&b.deliveryDirectives)this.warn("Retrying playlist loading "+(y+1)+"/"+A.maxNumRetry+' after "'+a+'" without delivery-directives'),this.loadPlaylist();else{var L=ji(A,y);this.clearTimer(),this.timer=self.setTimeout(function(){return r.loadPlaylist()},L),this.warn("Retrying playlist loading "+(y+1)+"/"+A.maxNumRetry+' after "'+a+'" in '+L+"ms")}e.levelRetry=!0,l.resolved=!0}return T},s}(je),jf=function(n){function s(t,e){var r;return r=n.call(this,t,"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=e,r._registerListeners(),r}S(s,n);var i=s.prototype;return i._registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.ERROR,this.onError,this)},i._unregisterListeners=function(){var e=this.hls;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),n.prototype.destroy.call(this)},i.stopLoad=function(){var e=this._levels;e.forEach(function(r){r.loadError=0,r.fragmentError=0}),n.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(e,r){this.resetLevels()},i.onManifestLoaded=function(e,r){var a=this,u=this.hls.config.preferManagedMediaSource,l=[],d={},c={},p=!1,y=!1,A=!1;r.levels.forEach(function(T){var b,L=T.attrs,R=T.audioCodec,C=T.videoCodec;R&&(T.audioCodec=R=ii(R,u)||void 0),((b=C)==null?void 0:b.indexOf("avc1"))===0&&(C=T.videoCodec=_u(C));var I=T.width,k=T.height,O=T.unknownCodecs,V=O?O.length:0;if(O)for(var N=V;N--;){var B=O[N];a.isAudioSupported(B)?(T.audioCodec=R=R?R+","+B:B,V--,gr.audio[R.substring(0,4)]=2):a.isVideoSupported(B)&&(T.videoCodec=C=C?C+","+B:B,V--,gr.video[C.substring(0,4)]=2)}if(p||(p=!!(I&&k)),y||(y=!!C),A||(A=!!R),V||R&&!a.isAudioSupported(R)||C&&!a.isVideoSupported(C)){a.log('Some or all CODECS not supported "'+L.CODECS+'"');return}var X=L.CODECS,z=L["FRAME-RATE"],K=L["HDCP-LEVEL"],j=L["PATHWAY-ID"],J=L.RESOLUTION,le=L["VIDEO-RANGE"],re=(j||".")+"-",te=""+re+T.bitrate+"-"+J+"-"+z+"-"+X+"-"+le+"-"+K;if(d[te])if(d[te].uri!==T.url&&!T.attrs["PATHWAY-ID"]){var de=c[te]+=1;T.attrs["PATHWAY-ID"]=new Array(de+1).join(".");var ve=a.createLevel(T);d[te]=ve,l.push(ve)}else d[te].addGroupId("audio",L.AUDIO),d[te].addGroupId("text",L.SUBTITLES);else{var fe=a.createLevel(T);d[te]=fe,c[te]=1,l.push(fe)}}),this.filterAndSortMediaOptions(l,r,p,y,A)},i.createLevel=function(e){var r=new da(e),a=e.supplemental;if(a!=null&&a.videoCodec&&!this.isVideoSupported(a.videoCodec)){var u=new Error('SUPPLEMENTAL-CODECS not supported "'+a.videoCodec+'"');this.log(u.message),r.supportedResult=Yn.getUnsupportedResult(u,[])}return r},i.isAudioSupported=function(e){return Vi(e,"audio",this.hls.config.preferManagedMediaSource)},i.isVideoSupported=function(e){return Vi(e,"video",this.hls.config.preferManagedMediaSource)},i.filterAndSortMediaOptions=function(e,r,a,u,l){var d=this,c=[],p=[],y=e;if((a||u)&&l&&(y=y.filter(function(N){var B=N.videoCodec,X=N.videoRange,z=N.width,K=N.height;return(!!B||!!(z&&K))&&Au(X)})),y.length===0){Promise.resolve().then(function(){if(d.hls){var N="no level with compatible codecs found in manifest",B=N;r.levels.length&&(B="one or more CODECS in variant not supported: "+gt(r.levels.map(function(z){return z.attrs.CODECS}).filter(function(z,K,j){return j.indexOf(z)===K})),d.warn(B),N+=" ("+B+")");var X=new Error(N);d.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:X,reason:B})}});return}r.audioTracks&&(c=r.audioTracks.filter(function(N){return!N.audioCodec||d.isAudioSupported(N.audioCodec)}),Rs(c)),r.subtitles&&(p=r.subtitles,Rs(p));var A=y.slice(0);y.sort(function(N,B){if(N.attrs["HDCP-LEVEL"]!==B.attrs["HDCP-LEVEL"])return(N.attrs["HDCP-LEVEL"]||"")>(B.attrs["HDCP-LEVEL"]||"")?1:-1;if(a&&N.height!==B.height)return N.height-B.height;if(N.frameRate!==B.frameRate)return N.frameRate-B.frameRate;if(N.videoRange!==B.videoRange)return ai.indexOf(N.videoRange)-ai.indexOf(B.videoRange);if(N.videoCodec!==B.videoCodec){var X=oa(N.videoCodec),z=oa(B.videoCodec);if(X!==z)return z-X}if(N.uri===B.uri&&N.codecSet!==B.codecSet){var K=ri(N.codecSet),j=ri(B.codecSet);if(K!==j)return j-K}return N.averageBitrate!==B.averageBitrate?N.averageBitrate-B.averageBitrate:0});var T=A[0];if(this.steering&&(y=this.steering.filterParsedLevels(y),y.length!==A.length)){for(var b=0;b<A.length;b++)if(A[b].pathwayId===y[0].pathwayId){T=A[b];break}}this._levels=y;for(var L=0;L<y.length;L++)if(y[L]===T){var R;this._firstLevel=L;var C=T.bitrate,I=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+C),((R=this.hls.userConfig)==null?void 0:R.abrEwmaDefaultEstimate)===void 0){var k=Math.min(C,this.hls.config.abrEwmaDefaultEstimateMax);k>I&&I===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=k)}break}var O=l&&!u,V={levels:y,audioTracks:c,subtitleTracks:p,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:u,altAudio:!O&&c.some(function(N){return!!N.url})};this.hls.trigger(x.MANIFEST_PARSED,V)},i.onError=function(e,r){r.fatal||!r.context||r.context.type===ie.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(e,r){var a=r.frag;if(a!==void 0&&a.type===ae.MAIN){var u=a.elementaryStreams;if(!Object.keys(u).some(function(d){return!!u[d]}))return;var l=this._levels[a.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(e,r){var a,u=r.level,l=r.details,d=r.levelInfo;if(!d){var c;this.warn("Invalid level index "+u),(c=r.deliveryDirectives)!=null&&c.skip&&(l.deltaUpdateFailed=!0);return}if(d===this.currentLevel||r.withoutMultiVariant){d.fragmentError===0&&(d.loadError=0);var p=d.details;p===r.details&&p.advanced&&(p=void 0),this.playlistLoaded(u,r,p)}else(a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(e){n.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)},i.loadingPlaylist=function(e,r){n.prototype.loadingPlaylist.call(this,e,r);var a=this.getUrlWithDirectives(e.uri,r),u=this.currentLevelIndex,l=e.attrs["PATHWAY-ID"],d=e.details,c=d?.age;this.log("Loading level index "+u+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+(l?" Pathway "+l:"")+(c&&d.live?" age "+c.toFixed(1)+(d.type&&" "+d.type||""):"")+" "+a),this.hls.trigger(x.LEVEL_LOADING,{url:a,level:u,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},i.removeLevel=function(e){var r=this,a;if(this._levels.length!==1){var u=this._levels.filter(function(d,c){return c!==e?!0:(r.steering&&r.steering.removeLevel(d),d===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,d.details&&d.details.fragments.forEach(function(p){return p.level=-1})),!1)});Ka(u),this._levels=u,this.currentLevelIndex>-1&&(a=this.currentLevel)!=null&&a.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var l=u.length-1;this._firstLevel=Math.min(this._firstLevel,l),this._startLevel&&(this._startLevel=Math.min(this._startLevel,l)),this.hls.trigger(x.LEVELS_UPDATED,{levels:u})}},i.onLevelsUpdated=function(e,r){var a=r.levels;this._levels=a},i.checkMaxAutoUpdated=function(){var e=this.hls,r=e.autoLevelCapping,a=e.maxAutoLevel,u=e.maxHdcpLevel;this._maxAutoLevel!==a&&(this._maxAutoLevel=a,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:a,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:u}))},f(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var r=this._levels;if(r.length!==0){if(e<0||e>=r.length){var a=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:a,reason:a.message}),u)return;e=Math.min(e,r.length-1)}var l=this.currentLevelIndex,d=this.currentLevel,c=d?d.attrs["PATHWAY-ID"]:void 0,p=r[e],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=p,!(l===e&&d&&c===y)){this.log("Switching to level "+e+" ("+(p.height?p.height+"p ":"")+(p.videoRange?p.videoRange+" ":"")+(p.codecSet?p.codecSet+" ":"")+"@"+p.bitrate+")"+(y?" with Pathway "+y:"")+" from level "+l+(c?" with Pathway "+c:""));var A={level:e,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(x.LEVEL_SWITCHING,A);var T=p.details;if(!T||T.live){var b=this.switchParams(p.uri,d?.details,T);this.loadPlaylist(b)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var r=this.steering.pathways(),a=e.filter(function(u){return r.indexOf(u)!==-1});if(e.length<1){this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+r);return}this.steering.pathwayPriority=a}}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}}])}(Wf);function Rs(n){var s={};n.forEach(function(i){var t=i.groupId||"";i.id=s[t]=s[t]||0,s[t]++})}var hn=[];typeof m<"u"&&m&&Yf();function Yf(){self.addEventListener("message",function(n){var s=n.data,i=s.instanceNo;if(i!==void 0){var t=hn[i];if(s.cmd==="reset"&&(delete hn[s.resetNo],t&&t.destroy(),s.cmd="init"),s.cmd==="init"){var e=JSON.parse(s.config),r=new Me;r.on(x.FRAG_DECRYPTED,Sr),r.on(x.ERROR,Sr);var a=Je(e.debug,s.id);zf(a,i),hn[i]=new on(r,s.typeSupported,e,"",s.id,a),Sr("init",null,i);return}if(t)switch(s.cmd){case"configure":{t.configure(s.config);break}case"demux":{var u=t.push(s.data,s.decryptdata,s.chunkMeta,s.state);dr(u)?u.then(function(c){dn(self,c,i)}).catch(function(c){Sr(x.ERROR,{instanceNo:i,type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"},i)}):dn(self,u,i);break}case"flush":{var l=s.chunkMeta,d=t.flush(l);dr(d)?d.then(function(c){ks(self,c,l,i)}).catch(function(c){Sr(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"},i)}):ks(self,d,l,i);break}}}})}function dn(n,s,i){if(qf(s.remuxResult))return!1;var t=[],e=s.remuxResult,r=e.audio,a=e.video;return r&&Cs(t,r),a&&Cs(t,a),n.postMessage({event:"transmuxComplete",data:s,instanceNo:i},t),!0}function Cs(n,s){s.data1&&n.push(s.data1.buffer),s.data2&&n.push(s.data2.buffer)}function ks(n,s,i,t){var e=s.reduce(function(r,a){return dn(n,a,t)||r},!1);e||n.postMessage({event:"transmuxComplete",data:s[0],instanceNo:t}),n.postMessage({event:"flush",data:i,instanceNo:t})}function Sr(n,s,i){self.postMessage({event:n,data:s,instanceNo:i})}function zf(n,s){var i=function(r){var a=function(l){Sr("workerLog",{logType:r,message:l},s)};n[r]=a};for(var t in n)i(t)}function qf(n){return!n.audio&&!n.video&&!n.text&&!n.id3&&!n.initSegment}var Gr="1.6.0",Tr={};function $f(){return typeof v=="function"}function Xf(){var n=Tr[Gr];if(n)return n.clientCount++,n;var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+v.toString()+")(true);"],{type:"text/javascript"}),i=self.URL.createObjectURL(s),t=new self.Worker(i),e={worker:t,objectURL:i,clientCount:1};return Tr[Gr]=e,e}function Qf(n){var s=Tr[n];if(s)return s.clientCount++,s;var i=new self.URL(n,self.location.href).href,t=new self.Worker(i),e={worker:t,scriptURL:i,clientCount:1};return Tr[n]=e,e}function Zf(n){var s=Tr[n||Gr];if(s){var i=s.clientCount--;if(i===1){var t=s.worker,e=s.objectURL;delete Tr[n||Gr],e&&self.URL.revokeObjectURL(e),t.terminate()}}}var Ds=0,Jf=function(){function n(i,t,e,r){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Ds++,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(A){var T=A.data,b=a.hls;if(!(!b||!(T!=null&&T.event)||T.instanceNo!==a.instanceNo))switch(T.event){case"init":{var L,R=(L=a.workerContext)==null?void 0:L.objectURL;R&&self.URL.revokeObjectURL(R);break}case"transmuxComplete":{a.handleTransmuxComplete(T.data);break}case"flush":{a.onFlush(T.data);break}case"workerLog":{b.logger[T.data.logType]&&b.logger[T.data.logType](T.data.message);break}default:{T.data=T.data||{},T.data.frag=a.frag,T.data.part=a.part,T.data.id=a.id,b.trigger(T.event,T.data);break}}},this.onWorkerError=function(A){if(a.hls){var T=new Error(A.message+" ("+A.filename+":"+A.lineno+")");a.hls.config.enableWorker=!1,a.hls.logger.warn('Error in "'+a.id+'" Web Worker, fallback to inline'),a.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:T})}};var u=i.config;this.hls=i,this.id=t,this.useWorker=!!u.enableWorker,this.onTransmuxComplete=e,this.onFlush=r;var l=function(T,b){b=b||{},b.frag=a.frag||void 0,T===x.ERROR&&(b=b,b.parent=a.id,b.part=a.part,a.error=b.error),a.hls.trigger(T,b)};this.observer=new Me,this.observer.on(x.FRAG_DECRYPTED,l),this.observer.on(x.ERROR,l);var d=ua(u.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){var c=this.hls.logger,p=u.workerPath||$f();if(p){try{u.workerPath?(c.log("loading Web Worker "+u.workerPath+' for "'+t+'"'),this.workerContext=Qf(u.workerPath)):(c.log('injecting Web Worker for "'+t+'"'),this.workerContext=Xf());var y=this.workerContext.worker;y.addEventListener("message",this.onWorkerMessage),y.addEventListener("error",this.onWorkerError),y.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:d,id:t,config:gt(u)})}catch(A){c.warn('Error setting up "'+t+'" Web Worker, fallback to inline',A),this.terminateWorker(),this.error=null,this.transmuxer=new on(this.observer,d,u,"",t,i.logger)}return}}this.transmuxer=new on(this.observer,d,u,"",t,i.logger)}var s=n.prototype;return s.reset=function(){if(this.frag=null,this.part=null,this.workerContext){var t=this.instanceNo;this.instanceNo=Ds++;var e=this.hls.config,r=ua(e.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:r,id:this.id,config:gt(e)})}},s.terminateWorker=function(){if(this.workerContext){var t=this.workerContext.worker;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),Zf(this.hls.config.workerPath)}},s.destroy=function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null},s.push=function(t,e,r,a,u,l,d,c,p,y){var A,T,b=this;p.transmuxing.start=self.performance.now();var L=this.instanceNo,R=this.transmuxer,C=l?l.start:u.start,I=u.decryptdata,k=this.frag,O=!(k&&u.cc===k.cc),V=!(k&&p.level===k.level),N=k?p.sn-k.sn:-1,B=this.part?p.part-this.part.index:-1,X=N===0&&p.id>1&&p.id===k?.stats.chunkCount,z=!V&&(N===1||N===0&&(B===1||X&&B<=0)),K=self.performance.now();(V||N||u.stats.parsing.start===0)&&(u.stats.parsing.start=K),l&&(B||!z)&&(l.stats.parsing.start=K);var j=!(k&&((A=u.initSegment)==null?void 0:A.url)===((T=k.initSegment)==null?void 0:T.url)),J=new lf(O,z,c,V,C,j);if(!z||O||j){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+u.type+" sn: "+p.sn+(p.part>-1?" part: "+p.part:"")+" "+(this.id===ae.MAIN?"level":"track")+": "+p.level+" id: "+p.id+`
23
+ discontinuity: `+O+`
24
+ trackSwitch: `+V+`
25
+ contiguous: `+z+`
26
+ accurateTimeOffset: `+c+`
27
+ timeOffset: `+C+`
28
+ initSegmentChange: `+j);var le=new uf(r,a,e,d,y);this.configureTransmuxer(le)}if(this.frag=u,this.part=l,this.workerContext)this.workerContext.worker.postMessage({instanceNo:L,cmd:"demux",data:t,decryptdata:I,chunkMeta:p,state:J},t instanceof ArrayBuffer?[t]:[]);else if(R){var re=R.push(t,I,p,J);dr(re)?re.then(function(te){b.handleTransmuxComplete(te)}).catch(function(te){b.transmuxerError(te,p,"transmuxer-interface push error")}):this.handleTransmuxComplete(re)}},s.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.instanceNo,a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:t});else if(a){var u=a.flush(t);dr(u)?u.then(function(l){e.handleFlushResult(l,t)}).catch(function(l){e.transmuxerError(l,t,"transmuxer-interface flush error")}):this.handleFlushResult(u,t)}},s.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:r}))},s.handleFlushResult=function(t,e){var r=this;t.forEach(function(a){r.handleTransmuxComplete(a)}),this.onFlush(e)},s.configureTransmuxer=function(t){var e=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:e,cmd:"configure",config:t}):r&&r.configure(t)},s.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},n}();function Is(){return self.SourceBuffer||self.WebKitSourceBuffer}function ws(){var n=nr();if(!n)return!1;var s=Is();return!s||s.prototype&&typeof s.prototype.appendBuffer=="function"&&typeof s.prototype.remove=="function"}function eh(){if(!ws())return!1;var n=nr();return typeof n?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(s){return n.isTypeSupported(Or(s,"video"))})||["mp4a.40.2","fLaC"].some(function(s){return n.isTypeSupported(Or(s,"audio"))}))}function th(){var n,s=Is();return typeof(s==null||(n=s.prototype)==null?void 0:n.changeType)=="function"}var rh=100,ih=function(n){function s(t,e,r){var a;return a=n.call(this,t,e,r,"stream-controller",ae.MAIN)||this,a.audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var u=a.media,l=u?u.currentTime:null;if(!(l===null||!w(l))&&(a.log("Media seeked to "+l.toFixed(3)),!!a.getBufferedFrag(l))){var d=a.getFwdBufferInfoAtPos(u,l,ae.MAIN,0);if(d===null||d.len===0){a.warn("Main forward buffer length at "+l+' on "seeked" event '+(d?d.len:"empty")+")");return}a.tick()}},a.registerListeners(),a}S(s,n);var i=s.prototype;return i.registerListeners=function(){n.prototype.registerListeners.call(this);var e=this.hls;e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(x.BUFFER_CREATED,this.onBufferCreated,this),e.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){n.prototype.unregisterListeners.call(this);var e=this.hls;e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(x.BUFFER_CREATED,this.onBufferCreated,this),e.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),n.prototype.onHandlerDestroying.call(this)},i.startLoad=function(e,r){if(this.levels){var a=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(rh),this.level=-1,!this.startFragRequested){var l=u.startLevel;l===-1&&(u.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=u.firstAutoLevel),u.nextLoadLevel=l,this.level=u.loadLevel,this._hasEnoughToStart=!!r}a>0&&e===-1&&!r&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),e=a),this.state=ne.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=r?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=ne.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ne.WAITING_LEVEL:{var e=this.levels,r=this.level,a=e?.[r],u=a?.details;if(u&&(!u.live||this.levelLastLoaded===a&&!this.waitForLive(a))){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 l,d=self.performance.now(),c=this.retryDate;if(!c||d>=c||(l=this.media)!=null&&l.seeking){var p=this.levels,y=this.level,A=p?.[y];this.resetStartWhenNotLoaded(A||null),this.state=ne.IDLE}}break}this.state===ne.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){var e;n.prototype.onTickEnd.call(this),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},i.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,a=this.levels,u=this.media;if(!(r===null||!u&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=this.buffering?e.nextLoadLevel:e.loadLevel;if(a!=null&&a[l]){var d=a[l],c=this.getMainFwdBufferInfo();if(c!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(c,p)){var y={};this.altAudio===2&&(y.type="video"),this.hls.trigger(x.BUFFER_EOS,y),this.state=ne.ENDED;return}if(this.buffering){e.loadLevel!==l&&e.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=e.nextLoadLevel=l;var A=d.details;if(!A||this.state===ne.WAITING_LEVEL||this.waitForLive(d)){this.level=l,this.state=ne.WAITING_LEVEL,this.startFragRequested=!1;return}var T=c.len,b=this.getMaxBufferLength(d.maxBitrate);if(!(T>=b)){this.backtrackFragment&&this.backtrackFragment.start>c.end&&(this.backtrackFragment=null);var L=this.backtrackFragment?this.backtrackFragment.start:c.end,R=this.getNextFragment(L,A);if(this.couldBacktrack&&!this.fragPrevious&&R&&jt(R)&&this.fragmentTracker.getState(R)!==Et.OK){var C,I=((C=this.backtrackFragment)!=null?C:R).sn,k=I-A.startSN,O=A.fragments[k-1];O&&R.cc===O.cc&&(R=O,this.fragmentTracker.removeFragment(O))}else this.backtrackFragment&&c.len&&(this.backtrackFragment=null);if(R&&this.isLoopLoading(R,L)){var V=R.gap;if(!V){var N=this.audioOnly&&!this.altAudio?qe.AUDIO:qe.VIDEO,B=(N===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;B&&this.afterBufferFlushed(B,N,ae.MAIN)}R=this.getNextFragmentLoopLoading(R,A,c,ae.MAIN,b)}R&&(R.initSegment&&!R.initSegment.data&&!this.bitrateTest&&(R=R.initSegment),this.loadFragment(R,d,L))}}}}}},i.loadFragment=function(e,r,a){var u=this.fragmentTracker.getState(e);u===Et.NOT_LOADED||u===Et.PARTIAL?jt(e)?this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):n.prototype.loadFragment.call(this,e,r,a):this._loadInitSegment(e,r):this.clearTrackerIfNeeded(e)},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,ae.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var a,u=this.getAppendedFrag(r.currentTime);u&&u.start>1&&this.flushMainBuffer(0,u.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var d=this.getMainFwdBufferInfo();if(!d||d.len<l.targetduration*2)return}if(!r.paused&&e){var c=this.hls.nextLoadLevel,p=e[c],y=this.fragLastKbps;y&&this.fragCurrent?a=this.fragCurrent.duration*p.maxBitrate/(1e3*y)+1:a=0}else a=0;var A=this.getBufferedFrag(r.currentTime+a);if(A){var T=this.followingBufferedFrag(A);if(T){this.abortCurrentFrag();var b=T.maxStartPTS?T.maxStartPTS:T.start,L=T.duration,R=Math.max(A.end,b+Math.min(Math.max(L-this.config.maxFragLookUpTolerance,L*(this.couldBacktrack?.5:.125)),L*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(R,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),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(e,r){n.prototype.flushMainBuffer.call(this,e,r,this.altAudio===2?"video":null)},i.onMediaAttached=function(e,r){n.prototype.onMediaAttached.call(this,e,r);var a=r.media;Br(a,"playing",this.onMediaPlaying),Br(a,"seeked",this.onMediaSeeked)},i.onMediaDetaching=function(e,r){var a=this.media;a&&(_r(a,"playing",this.onMediaPlaying),_r(a,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,n.prototype.onMediaDetaching.call(this,e,r);var u=!!r.transferMedia;u||(this._hasEnoughToStart=!1)},i.onManifestLoading=function(){n.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},i.onManifestParsed=function(e,r){var a=!1,u=!1;r.levels.forEach(function(l){var d=l.audioCodec;d&&(a=a||d.indexOf("mp4a.40.2")!==-1,u=u||d.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=a&&u&&!th(),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(e,r){var a=this.levels;if(!(!a||this.state!==ne.IDLE)){var u=r.levelInfo;(!u.details||u.details.live&&(this.levelLastLoaded!==u||u.details.expired)||this.waitForCdnTuneIn(u.details))&&(this.state=ne.WAITING_LEVEL)}},i.onLevelLoaded=function(e,r){var a,u=this.levels,l=this.startFragRequested,d=r.level,c=r.details,p=c.totalduration;if(!u){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+c.startSN+","+c.endSN+"]"+(c.lastPartSn?"[part-"+c.lastPartSn+"-"+c.lastPartIndex+"]":"")+", cc ["+c.startCC+", "+c.endCC+"] duration:"+p);var y=r.levelInfo,A=this.fragCurrent;A&&(this.state===ne.FRAG_LOADING||this.state===ne.FRAG_LOADING_WAITING_RETRY)&&A.level!==r.level&&A.loader&&this.abortCurrentFrag();var T=0;if(c.live||(a=y.details)!=null&&a.live){var b;if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;T=this.alignPlaylists(c,y.details,(b=this.levelLastLoaded)==null?void 0:b.details)}if(y.details=c,this.levelLastLoaded=y,l||this.setStartPosition(c,T),this.hls.trigger(x.LEVEL_UPDATED,{details:c,level:d}),this.state===ne.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=ne.IDLE}l&&c.live&&this.synchronizeToLiveEdge(c),this.tick()},i.synchronizeToLiveEdge=function(e){var r=this.config,a=this.media;if(a){var u=this.hls.liveSyncPosition,l=this.getLoadPosition(),d=e.fragmentStart,c=e.edge,p=l>=d-r.maxFragLookUpTolerance&&l<=c;if(u!==null&&a.duration>u&&(l<u||!p)){var y=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*e.targetduration;(!p&&a.readyState<4||l<c-y)&&(this._hasEnoughToStart||(this.nextLoadPosition=u),a.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+c+", reset currentTime to : "+u.toFixed(3)),a.currentTime=u))}}},i._handleFragmentLoadProgress=function(e){var r,a=e.frag,u=e.part,l=e.payload,d=this.levels;if(!d){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var c=d[a.level];if(!c){this.warn("Level "+a.level+" not found on progress");return}var p=c.details;if(!p){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset"),this.fragmentTracker.removeFragment(a);return}var y=c.videoCodec,A=p.PTSKnown||!p.live,T=(r=a.initSegment)==null?void 0:r.data,b=this._getAudioCodec(c),L=this.transmuxer=this.transmuxer||new Jf(this.hls,ae.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),R=u?u.index:-1,C=R!==-1,I=new _s(a.level,a.sn,a.stats.chunkCount,l.byteLength,R,C),k=this.initPTS[a.cc];L.push(l,T,b,y,a,u,p.totalduration,A,I,k)},i.onAudioTrackSwitching=function(e,r){var a=this,u=this.hls,l=this.altAudio===2,d=pa(r.url,u);if(d)this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var c=this.fragCurrent;c&&(this.log("Switching to main audio track, cancel main fragment load"),c.abortRequests(),this.fragmentTracker.removeFragment(c)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(l){this.fragmentTracker.removeAllFragments(),u.once(x.BUFFER_FLUSHED,function(){var p;(p=a.hls)==null||p.trigger(x.AUDIO_TRACK_SWITCHED,r)}),u.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}u.trigger(x.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(e,r){var a=pa(r.url,this.hls);if(a){var u=this.videoBuffer;u&&this.mediaBuffer!==u&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=u)}this.altAudio=a?2:0,this.tick()},i.onBufferCreated=function(e,r){var a=r.tracks,u,l,d=!1;for(var c in a){var p=a[c];if(p.id==="main"){if(l=c,u=p,c==="video"){var y=a[c];y&&(this.videoBuffer=y.buffer)}}else d=!0}d&&u?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(e,r){var a=r.frag,u=r.part,l=a.type===ae.MAIN;if(l){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(u?" p: "+u.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===ne.PARSED&&(this.state=ne.IDLE);return}var d=u?u.stats:a.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),jt(a)&&(this.fragPrevious=a),this.fragBufferedComplete(a,u)}var c=this.media;c&&(!this._hasEnoughToStart&&Fe.getBuffered(c).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),l&&this.tick())},i.onError=function(e,r){var a;if(r.fatal){this.state=ne.ERROR;return}switch(r.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ae.MAIN,r);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===ne.WAITING_LEVEL&&((a=r.context)==null?void 0:a.type)===ie.LEVEL&&(this.state=ne.IDLE);break;case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:if(r.parent!=="main")return;this.resetLoadingState();break;case M.BUFFER_FULL_ERROR:if(r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.onFragLoadEmergencyAborted=function(){this.state=ne.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},i.onBufferFlushed=function(e,r){var a=r.type;if(a!==qe.AUDIO||!this.altAudio){var u=(a===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;u&&(this.afterBufferFlushed(u,a,ae.MAIN),this.tick())}},i.onLevelsUpdated=function(e,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var e=this.media;if(e){var r=e.currentTime,a=this.startPosition;if(a>=0&&r<a){if(e.seeking){this.log("could not seek to "+a+", already seeking at "+r);return}var u=this.timelineOffset;u&&a&&(a+=u);var l=this.getLevelDetails(),d=Fe.getBuffered(e),c=d.length?d.start(0):0,p=c-a,y=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);p>0&&(p<y||this.loadingParts&&p<2*(l?.partTarget||0))&&(this.log("adjusting start position by "+p+" to match buffer start"),a+=p,this.startPosition=a),r<a&&(this.log("seek to target start position "+a+" from current time "+r+" buffer start "+c),e.currentTime=a)}}},i._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.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(e,r){var a=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(u){var l=a.hls,d=u?.frag;if(!(!d||a.fragContextChanged(d))){r.fragmentError=0,a.state=ne.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var c=d.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),l.trigger(x.FRAG_LOADED,u),d.bitrateTest=!1}})},i._handleTransmuxComplete=function(e){var r,a=this.playlistType,u=this.hls,l=e.remuxResult,d=e.chunkMeta,c=this.getCurrentContext(d);if(!c){this.resetWhenMissingContext(d);return}var p=c.frag,y=c.part,A=c.level,T=l.video,b=l.text,L=l.id3,R=l.initSegment,C=A.details,I=this.altAudio?void 0:l.audio;if(this.fragContextChanged(p)){this.fragmentTracker.removeFragment(p);return}if(this.state=ne.PARSING,R){if(R!=null&&R.tracks){var k=p.initSegment||p;this._bufferInitSegment(A,R.tracks,k,d),u.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:k,id:a,tracks:R.tracks})}var O=R.initPTS,V=R.timescale;w(O)&&(this.initPTS[p.cc]={baseTime:O,timescale:V},u.trigger(x.INIT_PTS_FOUND,{frag:p,id:a,initPTS:O,timescale:V}))}if(T&&C){var N=C.fragments[p.sn-1-C.startSN],B=p.sn===C.startSN,X=!N||p.cc>N.cc;if(l.independent!==!1){var z=T.startPTS,K=T.endPTS,j=T.startDTS,J=T.endDTS;if(y)y.elementaryStreams[T.type]={startPTS:z,endPTS:K,startDTS:j,endDTS:J};else if(T.firstKeyFrame&&T.independent&&d.id===1&&!X&&(this.couldBacktrack=!0),T.dropped&&T.independent){var le=this.getMainFwdBufferInfo(),re=(le?le.end:this.getLoadPosition())+this.config.maxBufferHole,te=T.firstKeyFramePTS?T.firstKeyFramePTS:z;if(!B&&re<te-this.config.maxBufferHole&&!X){this.backtrack(p);return}else X&&(p.gap=!0);p.setElementaryStreamInfo(T.type,p.start,K,p.start,J,!0)}else B&&z-(C.appliedTimelineOffset||0)>yi&&(p.gap=!0);p.setElementaryStreamInfo(T.type,z,K,j,J),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(T,p,y,d,B||X)}else if(B||X)p.gap=!0;else{this.backtrack(p);return}}if(I){var fe=I.startPTS,de=I.endPTS,ve=I.startDTS,ge=I.endDTS;y&&(y.elementaryStreams[qe.AUDIO]={startPTS:fe,endPTS:de,startDTS:ve,endDTS:ge}),p.setElementaryStreamInfo(qe.AUDIO,fe,de,ve,ge),this.bufferFragmentData(I,p,y,d)}if(C&&L!=null&&(r=L.samples)!=null&&r.length){var Ne={id:a,frag:p,details:C,samples:L.samples};u.trigger(x.FRAG_PARSING_METADATA,Ne)}if(C&&b){var we={id:a,frag:p,details:C,samples:b.samples};u.trigger(x.FRAG_PARSING_USERDATA,we)}},i._bufferInitSegment=function(e,r,a,u){var l=this;if(this.state===ne.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,c=r.video,p=r.audiovideo;if(d){var y=ni(d.codec,e.audioCodec);y==="mp4a"&&(y="mp4a.40.5");var A=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){y&&(y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5");var T=d.metadata;T&&"channelCount"in T&&(T.channelCount||1)!==1&&A.indexOf("firefox")===-1&&(y="mp4a.40.5")}y&&y.indexOf("mp4a.40.5")!==-1&&A.indexOf("android")!==-1&&d.container!=="audio/mpeg"&&(y="mp4a.40.2",this.log("Android: force audio codec to "+y)),e.audioCodec&&e.audioCodec!==y&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+y+'"'),d.levelCodec=y,d.id=ae.MAIN,this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(y||"")+"/"+(e.audioCodec||"")+"/"+d.codec+"]"),delete r.audiovideo}if(c){c.levelCodec=e.videoCodec,c.id=ae.MAIN;var b=c.codec;if(b?.length===4)switch(b){case"hvc1":case"hev1":c.codec="hvc1.1.6.L120.90";break;case"av01":c.codec="av01.0.04M.08";break;case"avc1":c.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+c.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+b+"]"+(c.codec!==b?" parsed-corrected="+c.codec:"")+(c.supplemental?" supplemental="+c.supplemental:"")),delete r.audiovideo}p&&(this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+e.codecs+"/"+p.codec+"]"),delete r.video,delete r.audio);var L=Object.keys(r);if(L.length){if(this.hls.trigger(x.BUFFER_CODECS,r),!this.hls)return;L.forEach(function(R){var C=r[R],I=C.initSegment;I!=null&&I.byteLength&&l.hls.trigger(x.BUFFER_APPENDING,{type:R,data:I,frag:a,part:null,chunkMeta:u,parent:a.type})})}this.tickImmediate()}},i.getMainFwdBufferInfo=function(){var e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,ae.MAIN)},i.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ne.IDLE},i.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var a=e.currentTime;if(Fe.isBuffered(e,a)?r=this.getAppendedFrag(a):Fe.isBuffered(e,a+.1)&&(r=this.getAppendedFrag(a+.1)),r){this.backtrackFragment=null;var u=this.fragPlaying,l=r.level;(!u||r.sn!==u.sn||u.level!==l)&&(this.fragPlaying=r,this.hls.trigger(x.FRAG_CHANGED,{frag:r}),(!u||u.level!==l)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:l}))}}},f(s,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,r=this.level,a=e?.[r];return a?this.getMaxBufferLength(a.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return w(r)?this.getAppendedFrag(r):null}},{key:"currentProgramDateTime",get:function(){var e,r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(w(r)){var a=this.getLevelDetails(),u=this.currentFrag||(a?Wi(null,a.fragments,r):null);if(u){var l=u.programDateTime;if(l!==null){var d=l+(r-u.start)*1e3;return new Date(d)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(Df),nh=function(){function n(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var s=n.prototype;return s.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){var a;if(t&&t!==((a=r.context)==null?void 0:a.frag.type))return;r.abort()}}},s.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},s.destroy=function(){this.detach();for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(t,e,r,a,u){return e===void 0&&(e=M.KEY_LOAD_ERROR),new Jt({type:Y.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:u,error:r,networkDetails:a})},s.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var a=t.sn,u=t.cc,l=function(){var p=e[d];if(u<=p.cc&&(a==="initSegment"||p.sn==="initSegment"||a<p.sn))return r.emeController.selectKeySystemFormat(p).then(function(y){p.setKeyFormat(y)}),1},d=0;d<e.length&&!l();d++);},s.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(function(r){return e.loadInternal(t,r)}):this.loadInternal(t)},s.loadInternal=function(t,e){var r,a;e&&t.setKeyFormat(e);var u=t.decryptdata;if(!u){var l=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,l))}var d=u.uri;if(!d)return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+d+'"')));var c=this.keyUriToKeyInfo[d];if((r=c)!=null&&r.decryptdata.key)return u.key=c.decryptdata.key,Promise.resolve({frag:t,keyInfo:c});if((a=c)!=null&&a.keyLoadPromise){var p;switch((p=c.mediaKeySessionContext)==null?void 0:p.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return c.keyLoadPromise.then(function(y){return u.key=y.keyInfo.decryptdata.key,{frag:t,keyInfo:c}})}}switch(c=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(c,t):this.loadKeyEME(c,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,t);default:return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+u.method+'"')))}},s.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var a=this.emeController.loadKey(r);if(a)return(t.keyLoadPromise=a.then(function(u){return t.mediaKeySessionContext=u,r})).catch(function(u){throw t.keyLoadPromise=null,u})}return Promise.resolve(r)},s.loadKeyHTTP=function(t,e){var r=this,a=this.config,u=a.loader,l=new u(a);return e.keyLoader=t.loader=l,t.keyLoadPromise=new Promise(function(d,c){var p={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},y=a.keyLoadPolicy.default,A={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},T={onSuccess:function(L,R,C,I){var k=C.frag,O=C.keyInfo,V=C.url;if(!k.decryptdata||O!==r.keyUriToKeyInfo[V])return c(r.createKeyLoadError(k,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),I));O.decryptdata.key=k.decryptdata.key=new Uint8Array(L.data),k.keyLoader=null,O.loader=null,d({frag:k,keyInfo:O})},onError:function(L,R,C,I){r.resetLoader(R),c(r.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error("HTTP Error "+L.code+" loading key "+L.text),C,H({url:p.url,data:void 0},L)))},onTimeout:function(L,R,C){r.resetLoader(R),c(r.createKeyLoadError(e,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),C))},onAbort:function(L,R,C){r.resetLoader(R),c(r.createKeyLoadError(e,M.INTERNAL_ABORTED,new Error("key loading aborted"),C))}};l.load(p,A,T)})},s.resetLoader=function(t){var e=t.frag,r=t.keyInfo,a=t.url,u=r.loader;e.keyLoader===u&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[a],u&&u.destroy()},n}();function Ps(n){var s=n.type;switch(s){case ie.AUDIO_TRACK:return ae.AUDIO;case ie.SUBTITLE_TRACK:return ae.SUBTITLE;default:return ae.MAIN}}function cn(n,s){var i=n.url;return(i===void 0||i.indexOf("data:")===0)&&(i=s.url),i}var ah=function(){function n(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=i,this.registerListeners()}var s=n.prototype;return s.startLoad=function(t){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_LOADING,this.onLevelLoading,this),t.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,a=e.loader,u=r||a,l=new u(e);return this.loaders[t.type]=l,l},s.getInternalLoader=function(t){return this.loaders[t.type]},s.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},s.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})},s.onLevelLoading=function(t,e){var r=e.id,a=e.level,u=e.pathwayId,l=e.url,d=e.deliveryDirectives,c=e.levelInfo;this.load({id:r,level:a,pathwayId:u,responseType:"text",type:ie.LEVEL,url:l,deliveryDirectives:d,levelOrTrack:c})},s.onAudioTrackLoading=function(t,e){var r=e.id,a=e.groupId,u=e.url,l=e.deliveryDirectives,d=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:ie.AUDIO_TRACK,url:u,deliveryDirectives:l,levelOrTrack:d})},s.onSubtitleTrackLoading=function(t,e){var r=e.id,a=e.groupId,u=e.url,l=e.deliveryDirectives,d=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:ie.SUBTITLE_TRACK,url:u,deliveryDirectives:l,levelOrTrack:d})},s.onLevelsUpdated=function(t,e){var r=this.loaders[ie.LEVEL];if(r){var a=r.context;a&&!e.levels.some(function(u){return u===a.levelOrTrack})&&(r.abort(),delete this.loaders[ie.LEVEL])}},s.load=function(t){var e,r=this,a=this.hls.config,u=this.getInternalLoader(t);if(u){var l=this.hls.logger,d=u.context;if(d&&d.levelOrTrack===t.levelOrTrack&&(d.url===t.url||d.deliveryDirectives&&!t.deliveryDirectives)){d.url===t.url?l.log("[playlist-loader]: ignore "+t.url+" ongoing request"):l.log("[playlist-loader]: ignore "+t.url+" in favor of "+d.url);return}l.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}var c;if(t.type===ie.MANIFEST?c=a.manifestLoadPolicy.default:c=E({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(t),w((e=t.deliveryDirectives)==null?void 0:e.part)){var p;if(t.type===ie.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===ie.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===ie.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){var y=p.partTarget,A=p.targetduration;if(y&&A){var T=Math.max(y*3,A*.8)*1e3;c=E({},c,{maxTimeToFirstByteMs:Math.min(T,c.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(T,c.maxTimeToFirstByteMs)})}}}var b=c.errorRetry||c.timeoutRetry||{},L={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:b.maxNumRetry||0,retryDelay:b.retryDelayMs||0,maxRetryDelay:b.maxRetryDelayMs||0},R={onSuccess:function(I,k,O,V){var N=r.getInternalLoader(O);r.resetInternalLoader(O.type);var B=I.data;if(B.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(I,O,new Error("no EXTM3U delimiter"),V||null,k);return}k.parsing.start=performance.now(),Fr.isMediaPlaylist(B)||O.type!==ie.MANIFEST?r.handleTrackOrLevelPlaylist(I,k,O,V||null,N):r.handleMasterPlaylist(I,k,O,V)},onError:function(I,k,O,V){r.handleNetworkError(k,O,!1,I,V)},onTimeout:function(I,k,O){r.handleNetworkError(k,O,!0,void 0,I)}};u.load(t,L,R)},s.checkAutostartLoad=function(){if(this.hls){var t=this.hls,e=t.config,r=e.autoStartLoad,a=e.startPosition,u=t.forceStartLoad;(r||u)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+a),this.hls.startLoad(a))}},s.handleMasterPlaylist=function(t,e,r,a){var u=this.hls,l=t.data,d=cn(t,r),c=Fr.parseMasterPlaylist(l,d);if(c.playlistParsingError){this.handleManifestParsingError(t,r,c.playlistParsingError,a,e);return}var p=c.contentSteering,y=c.levels,A=c.sessionData,T=c.sessionKeys,b=c.startTimeOffset,L=c.variableList;this.variableList=L;var R=Fr.parseMasterPlaylistMedia(l,d,c),C=R.AUDIO,I=C===void 0?[]:C,k=R.SUBTITLES,O=R["CLOSED-CAPTIONS"];if(I.length){var V=I.some(function(N){return!N.url});!V&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),I.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new rt({}),bitrate:0,url:""}))}u.trigger(x.MANIFEST_LOADED,{levels:y,audioTracks:I,subtitles:k,captions:O,contentSteering:p,url:d,stats:e,networkDetails:a,sessionData:A,sessionKeys:T,startTimeOffset:b,variableList:L})},s.handleTrackOrLevelPlaylist=function(t,e,r,a,u){var l=this.hls,d=r.id,c=r.level,p=r.type,y=cn(t,r),A=w(c)?c:w(d)?d:0,T=Ps(r),b=Fr.parseLevelPlaylist(t.data,y,A,T,0,this.variableList);if(p===ie.MANIFEST){var L={attrs:new rt({}),bitrate:0,details:b,name:"",url:y};b.requestScheduled=e.loading.start+Ga(b,0),l.trigger(x.MANIFEST_LOADED,{levels:[L],audioTracks:[],url:y,stats:e,networkDetails:a,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=b,this.handlePlaylistLoaded(b,t,e,r,a,u)},s.handleManifestParsingError=function(t,e,r,a,u){this.hls.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:e.type===ie.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:a,stats:u})},s.handleNetworkError=function(t,e,r,a,u){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+t.type;t.type===ie.LEVEL?l+=": "+t.level+" id: "+t.id:(t.type===ie.AUDIO_TRACK||t.type===ie.SUBTITLE_TRACK)&&(l+=" id: "+t.id+' group-id: "'+t.groupId+'"');var d=new Error(l);this.hls.logger.warn("[playlist-loader]: "+l);var c=M.UNKNOWN,p=!1,y=this.getInternalLoader(t);switch(t.type){case ie.MANIFEST:c=r?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,p=!0;break;case ie.LEVEL:c=r?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,p=!1;break;case ie.AUDIO_TRACK:c=r?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case ie.SUBTITLE_TRACK:c=r?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,p=!1;break}y&&this.resetInternalLoader(t.type);var A={type:Y.NETWORK_ERROR,details:c,fatal:p,url:t.url,loader:y,context:t,error:d,networkDetails:e,stats:u};if(a){var T=e?.url||t.url;A.response=H({url:T,data:void 0},a)}this.hls.trigger(x.ERROR,A)},s.handlePlaylistLoaded=function(t,e,r,a,u,l){var d=this.hls,c=a.type,p=a.level,y=a.id,A=a.groupId,T=a.deliveryDirectives,b=cn(e,a),L=Ps(a),R=typeof a.level=="number"&&L===ae.MAIN?p:void 0;if(!t.fragments.length){var C=t.playlistParsingError=new Error("No Segments found in Playlist");d.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:C,reason:C.message,response:e,context:a,level:R,parent:L,networkDetails:u,stats:r});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var I=t.playlistParsingError;if(I){if(this.hls.logger.warn(I),!d.config.ignorePlaylistParsingErrors){d.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:I,reason:I.message,response:e,context:a,level:R,parent:L,networkDetails:u,stats:r});return}t.playlistParsingError=null}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),c){case ie.MANIFEST:case ie.LEVEL:d.trigger(x.LEVEL_LOADED,{details:t,levelInfo:a.levelOrTrack||d.levels[0],level:R||0,id:y||0,stats:r,networkDetails:u,deliveryDirectives:T,withoutMultiVariant:c===ie.MANIFEST});break;case ie.AUDIO_TRACK:d.trigger(x.AUDIO_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:y||0,groupId:A||"",stats:r,networkDetails:u,deliveryDirectives:T});break;case ie.SUBTITLE_TRACK:d.trigger(x.SUBTITLE_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:y||0,groupId:A||"",stats:r,networkDetails:u,deliveryDirectives:T});break}},n}(),sh={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function oh(n,s){return{supported:!1,configurations:s,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:n}}var Os={};function uh(n,s,i){var t=n.videoCodec,e=n.audioCodec;if(!t&&!e||!i)return Promise.resolve(sh);var r=[];if(t){var a={width:n.width,height:n.height,bitrate:Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)),framerate:n.frameRate||30},u=n.videoRange;u!=="SDR"&&(a.transferFunction=u.toLowerCase());var l=t.split(","),d=navigator.userAgent;if(l.some(function(c){return Gi(c)})&&na())return Promise.resolve(oh(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+d+")"),r));r.push.apply(r,l.map(function(c){return{type:"media-source",video:H(H({},a),{},{contentType:Or(Su(c),"video")})}}))}return e&&n.audioGroups&&n.audioGroups.forEach(function(c){var p;c&&((p=s.groups[c])==null||p.tracks.forEach(function(y){if(y.groupId===c){var A=y.channels||"",T=parseFloat(A);w(T)&&T>2&&r.push.apply(r,e.split(",").map(function(b){return{type:"media-source",audio:{contentType:Or(b,"audio"),channels:""+T}}}))}}))}),Promise.all(r.map(function(c){var p=lh(c);return Os[p]||(Os[p]=i.decodingInfo(c))})).then(function(c){return{supported:!c.some(function(p){return!p.supported}),configurations:r,decodingInfoResults:c}}).catch(function(c){return{supported:!1,configurations:r,decodingInfoResults:[],error:c}})}function lh(n){var s=n.audio,i=n.video,t=i||s;if(t){var e=la(t.contentType);if(i)return"r"+i.height+"x"+i.width+"f"+Math.ceil(i.framerate)+(i.transferFunction||"sd")+"_"+e+"_"+Math.ceil(i.bitrate/1e5);if(s)return"c"+s.channels+(s.spatialRendering?"s":"n")+"_"+e}return""}var Ms=function(){function n(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Me,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 t=this.logger=Je(i.debug||!1,"Hls instance",i.assetPlayerId),e=this.config=_f(n.DefaultConfig,i,t);this.userConfig=i,e.progressive&&Sf(e,t);var r=e.abrController,a=e.bufferController,u=e.capLevelController,l=e.errorController,d=e.fpsController,c=new l(this),p=this.abrController=new r(this),y=new Tf(this),A=e.interstitialsController,T=A?this.interstitialsController=new A(this,n):null,b=this.bufferController=new a(this,y),L=this.capLevelController=new u(this),R=new d(this),C=new ah(this),I=e.contentSteeringController,k=I?new I(this):null,O=this.levelController=new jf(this,k),V=new Hf(this),N=new nh(this.config),B=this.streamController=new ih(this,y,N),X=this.gapController=new Of(this,y);L.setStreamController(B),R.setStreamController(B);var z=[C,O,B];T&&z.splice(1,0,T),k&&z.splice(1,0,k),this.networkControllers=z;var K=[p,b,X,L,R,V,y];this.audioTrackController=this.createController(e.audioTrackController,z);var j=e.audioStreamController;j&&z.push(this.audioStreamController=new j(this,y,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,z);var J=e.subtitleStreamController;J&&z.push(this.subtititleStreamController=new J(this,y,N)),this.createController(e.timelineController,K),N.emeController=this.emeController=this.createController(e.emeController,K),this.cmcdController=this.createController(e.cmcdController,K),this.latencyController=this.createController(Kf,K),this.coreComponents=K,z.push(c);var le=c.onErrorOut;typeof le=="function"&&this.on(x.ERROR,le,c),this.on(x.MANIFEST_LOADED,C.onManifestLoaded,C)}n.isMSESupported=function(){return ws()},n.isSupported=function(){return eh()},n.getMediaSource=function(){return nr()};var s=n.prototype;return s.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},s.on=function(t,e,r){r===void 0&&(r=this),this._emitter.on(t,e,r)},s.once=function(t,e,r){r===void 0&&(r=this),this._emitter.once(t,e,r)},s.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},s.off=function(t,e,r,a){r===void 0&&(r=this),this._emitter.off(t,e,r,a)},s.listeners=function(t){return this._emitter.listeners(t)},s.emit=function(t,e,r){return this._emitter.emit(t,e,r)},s.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(a){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+a.message+'". Here is a stacktrace:',a),!this.triggeringException){this.triggeringException=!0;var r=t===x.ERROR;this.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:r,event:t,error:a}),this.triggeringException=!1}}return!1},s.listenerCount=function(t){return this._emitter.listenerCount(t)},s.destroy=function(){this.logger.log("destroy"),this.trigger(x.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(e){return e.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(e){return e.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(t){if(!t||"media"in t&&!t.media){var e=new Error("attachMedia failed: invalid argument ("+t+")");this.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.ATTACH_MEDIA_ERROR,fatal:!0,error:e});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in t,a=r?t.media:t,u=r?t:{media:a};this._media=a,this.trigger(x.MEDIA_ATTACHING,u)},s.detachMedia=function(){this.logger.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,{}),this._media=null},s.transferMedia=function(){this._media=null;var t=this.bufferController.transferMedia();return this.trigger(x.MEDIA_DETACHING,{transferMedia:t}),t},s.loadSource=function(t){this.stopLoad();var e=this.media,r=this._url,a=this._url=Ze.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+a),e&&r&&(r!==a||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(x.MANIFEST_LOADING,{url:t})},s.startLoad=function(t,e){t===void 0&&(t=-1),this.logger.log("startLoad("+(t+(e?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(t,e),!(!this.started||!this.networkControllers));r++);},s.stopLoad=function(){this.logger.log("stopLoad"),this.started=!1;for(var t=0;t<this.networkControllers.length&&(this.networkControllers[t].stopLoad(),!(this.started||!this.networkControllers));t++);},s.resumeBuffering=function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(function(t){t.resumeBuffering&&t.resumeBuffering()}))},s.pauseBuffering=function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(function(t){t.pauseBuffering&&t.pauseBuffering()}))},s.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){this.logger.log("recoverMediaError");var t=this._media,e=t?.currentTime;this.detachMedia(),t&&(this.attachMedia(t),e&&this.startLoad(e))},s.removeLevel=function(t){this.levelController.removeLevel(t)},s.setAudioOption=function(t){var e;return((e=this.audioTrackController)==null?void 0:e.setAudioOption(t))||null},s.setSubtitleOption=function(t){var e;return((e=this.subtitleTrackController)==null?void 0:e.setSubtitleOption(t))||null},s.getMediaDecodingInfo=function(t,e){e===void 0&&(e=this.allAudioTracks);var r=va(e);return uh(t,r,navigator.mediaCapabilities)},f(n,[{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function(){var t,e=(t={},t[ae.MAIN]=this.streamController.inFlightFrag,t);return this.audioStreamController&&(e[ae.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[ae.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}},{key:"sessionId",get:function(){var t=this._sessionId;return t||(t=this._sessionId=oe()),t}},{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){this.logger.log("set currentLevel:"+t),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){this.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){this.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){this.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){var t=this.levelController.startLevel;return t===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t},set:function(t){this.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(this.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},set:function(t){this.abrController.resetEstimator(t)}},{key:"abrEwmaDefaultEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){Tu(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,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 t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,a=0;a<r;a++)if(t[a].maxBitrate>=e)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping,r=this.maxHdcpLevel,a;if(e===-1&&t!=null&&t.length?a=t.length-1:a=e,r)for(var u=a;u--;){var l=t[u].attrs["HDCP-LEVEL"];if(l&&l<=r)return u}return a}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(t){this.abrController.nextAutoLevel=t}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var t=this.audioTrackController;return t?t.allAudioTracks:[]}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"allSubtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{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},set:function(t){this.latencyController.targetLatency=t}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(t){this.levelController.pathwayPriority=t}},{key:"bufferedToEnd",get:function(){var t;return!!((t=this.bufferController)!=null&&t.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var t;return((t=this.interstitialsController)==null?void 0:t.interstitialsManager)||null}}],[{key:"version",get:function(){return Gr}},{key:"Events",get:function(){return x}},{key:"MetadataSchema",get:function(){return Lt}},{key:"ErrorTypes",get:function(){return Y}},{key:"ErrorDetails",get:function(){return M}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:yf},set:function(t){n.defaultConfig=t}}])}();return Ms.defaultConfig=void 0,Ms})})(!1)});var ld={};xh(ld,{Flv:()=>Dr,Hls:()=>Wn.default});module.exports=Rh(ld);function js(v,m){var o=Object.keys(v);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(v);m&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(v,f).enumerable})),o.push.apply(o,h)}return o}function It(v){for(var m=1;m<arguments.length;m++){var o=arguments[m]!=null?arguments[m]:{};m%2?js(Object(o),!0).forEach(function(h){me(v,h,o[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(o)):js(Object(o)).forEach(function(h){Object.defineProperty(v,h,Object.getOwnPropertyDescriptor(o,h))})}return v}function ke(){ke=function(){return v};var v={},m=Object.prototype,o=m.hasOwnProperty,h=Object.defineProperty||function(w,U,G){w[U]=G.value},f=typeof Symbol=="function"?Symbol:{},g=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(w,U,G){return Object.defineProperty(w,U,{value:G,enumerable:!0,configurable:!0,writable:!0}),w[U]}try{S({},"")}catch{S=function(U,G,Y){return U[G]=Y}}function D(w,U,G,Y){var M=U&&U.prototype instanceof H?U:H,x=Object.create(M.prototype),ie=new ye(Y||[]);return h(x,"_invoke",{value:se(w,G,ie)}),x}function P(w,U,G){try{return{type:"normal",arg:w.call(U,G)}}catch(Y){return{type:"throw",arg:Y}}}v.wrap=D;var F={};function H(){}function W(){}function $(){}var ee={};S(ee,g,function(){return this});var Z=Object.getPrototypeOf,oe=Z&&Z(Z(Ie([])));oe&&oe!==m&&o.call(oe,g)&&(ee=oe);var ue=$.prototype=H.prototype=Object.create(ee);function Se(w){["next","throw","return"].forEach(function(U){S(w,U,function(G){return this._invoke(U,G)})})}function he(w,U){function G(M,x,ie,ae){var Re=P(w[M],w,x);if(Re.type!=="throw"){var Ue=Re.arg,je=Ue.value;return je&&typeof je=="object"&&o.call(je,"__await")?U.resolve(je.__await).then(function(xe){G("next",xe,ie,ae)},function(xe){G("throw",xe,ie,ae)}):U.resolve(je).then(function(xe){Ue.value=xe,ie(Ue)},function(xe){return G("throw",xe,ie,ae)})}ae(Re.arg)}var Y;h(this,"_invoke",{value:function(M,x){function ie(){return new U(function(ae,Re){G(M,x,ae,Re)})}return Y=Y?Y.then(ie,ie):ie()}})}function se(w,U,G){var Y="suspendedStart";return function(M,x){if(Y==="executing")throw new Error("Generator is already running");if(Y==="completed"){if(M==="throw")throw x;return Ze()}for(G.method=M,G.arg=x;;){var ie=G.delegate;if(ie){var ae=ce(ie,G);if(ae){if(ae===F)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(Y==="suspendedStart")throw Y="completed",G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);Y="executing";var Re=P(w,U,G);if(Re.type==="normal"){if(Y=G.done?"completed":"suspendedYield",Re.arg===F)continue;return{value:Re.arg,done:G.done}}Re.type==="throw"&&(Y="completed",G.method="throw",G.arg=Re.arg)}}}function ce(w,U){var G=U.method,Y=w.iterator[G];if(Y===void 0)return U.delegate=null,G==="throw"&&w.iterator.return&&(U.method="return",U.arg=void 0,ce(w,U),U.method==="throw")||G!=="return"&&(U.method="throw",U.arg=new TypeError("The iterator does not provide a '"+G+"' method")),F;var M=P(Y,w.iterator,U.arg);if(M.type==="throw")return U.method="throw",U.arg=M.arg,U.delegate=null,F;var x=M.arg;return x?x.done?(U[w.resultName]=x.value,U.next=w.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,F):x:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,F)}function Me(w){var U={tryLoc:w[0]};1 in w&&(U.catchLoc=w[1]),2 in w&&(U.finallyLoc=w[2],U.afterLoc=w[3]),this.tryEntries.push(U)}function We(w){var U=w.completion||{};U.type="normal",delete U.arg,w.completion=U}function ye(w){this.tryEntries=[{tryLoc:"root"}],w.forEach(Me,this),this.reset(!0)}function Ie(w){if(w){var U=w[g];if(U)return U.call(w);if(typeof w.next=="function")return w;if(!isNaN(w.length)){var G=-1,Y=function M(){for(;++G<w.length;)if(o.call(w,G))return M.value=w[G],M.done=!1,M;return M.value=void 0,M.done=!0,M};return Y.next=Y}}return{next:Ze}}function Ze(){return{value:void 0,done:!0}}return W.prototype=$,h(ue,"constructor",{value:$,configurable:!0}),h($,"constructor",{value:W,configurable:!0}),W.displayName=S($,_,"GeneratorFunction"),v.isGeneratorFunction=function(w){var U=typeof w=="function"&&w.constructor;return!!U&&(U===W||(U.displayName||U.name)==="GeneratorFunction")},v.mark=function(w){return Object.setPrototypeOf?Object.setPrototypeOf(w,$):(w.__proto__=$,S(w,_,"GeneratorFunction")),w.prototype=Object.create(ue),w},v.awrap=function(w){return{__await:w}},Se(he.prototype),S(he.prototype,E,function(){return this}),v.AsyncIterator=he,v.async=function(w,U,G,Y,M){M===void 0&&(M=Promise);var x=new he(D(w,U,G,Y),M);return v.isGeneratorFunction(U)?x:x.next().then(function(ie){return ie.done?ie.value:x.next()})},Se(ue),S(ue,_,"Generator"),S(ue,g,function(){return this}),S(ue,"toString",function(){return"[object Generator]"}),v.keys=function(w){var U=Object(w),G=[];for(var Y in U)G.push(Y);return G.reverse(),function M(){for(;G.length;){var x=G.pop();if(x in U)return M.value=x,M.done=!1,M}return M.done=!0,M}},v.values=Ie,ye.prototype={constructor:ye,reset:function(w){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(We),!w)for(var U in this)U.charAt(0)==="t"&&o.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var U=this;function G(Re,Ue){return x.type="throw",x.arg=w,U.next=Re,Ue&&(U.method="next",U.arg=void 0),!!Ue}for(var Y=this.tryEntries.length-1;Y>=0;--Y){var M=this.tryEntries[Y],x=M.completion;if(M.tryLoc==="root")return G("end");if(M.tryLoc<=this.prev){var ie=o.call(M,"catchLoc"),ae=o.call(M,"finallyLoc");if(ie&&ae){if(this.prev<M.catchLoc)return G(M.catchLoc,!0);if(this.prev<M.finallyLoc)return G(M.finallyLoc)}else if(ie){if(this.prev<M.catchLoc)return G(M.catchLoc,!0)}else{if(!ae)throw new Error("try statement without catch or finally");if(this.prev<M.finallyLoc)return G(M.finallyLoc)}}}},abrupt:function(w,U){for(var G=this.tryEntries.length-1;G>=0;--G){var Y=this.tryEntries[G];if(Y.tryLoc<=this.prev&&o.call(Y,"finallyLoc")&&this.prev<Y.finallyLoc){var M=Y;break}}M&&(w==="break"||w==="continue")&&M.tryLoc<=U&&U<=M.finallyLoc&&(M=null);var x=M?M.completion:{};return x.type=w,x.arg=U,M?(this.method="next",this.next=M.finallyLoc,F):this.complete(x)},complete:function(w,U){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&U&&(this.next=U),F},finish:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.finallyLoc===w)return this.complete(G.completion,G.afterLoc),We(G),F}},catch:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.tryLoc===w){var Y=G.completion;if(Y.type==="throw"){var M=Y.arg;We(G)}return M}}throw new Error("illegal catch attempt")},delegateYield:function(w,U,G){return this.delegate={iterator:Ie(w),resultName:U,nextLoc:G},this.method==="next"&&(this.arg=void 0),F}},v}function Ys(v,m,o,h,f,g,E){try{var _=v[g](E),S=_.value}catch(D){o(D);return}_.done?m(S):Promise.resolve(S).then(h,f)}function at(v){return function(){var m=this,o=arguments;return new Promise(function(h,f){var g=v.apply(m,o);function E(S){Ys(g,h,f,E,_,"next",S)}function _(S){Ys(g,h,f,E,_,"throw",S)}E(void 0)})}}function br(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function zs(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,Xs(h.key),h)}}function Lr(v,m,o){return m&&zs(v.prototype,m),o&&zs(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function me(v,m,o){return m=Xs(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function qs(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&yn(v,m)}function bi(v){return bi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},bi(v)}function yn(v,m){return yn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},yn(v,m)}function Ch(){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 Pe(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function kh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pe(v)}function $s(v){var m=Ch();return function(){var h=bi(v),f;if(m){var g=bi(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return kh(this,f)}}function Dh(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function Xs(v){var m=Dh(v,"string");return typeof m=="symbol"?m:String(m)}function Zs(v,m){var o=Object.keys(v);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(v);m&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(v,f).enumerable})),o.push.apply(o,h)}return o}function ur(v){for(var m=1;m<arguments.length;m++){var o=arguments[m]!=null?arguments[m]:{};m%2?Zs(Object(o),!0).forEach(function(h){q(v,h,o[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(o)):Zs(Object(o)).forEach(function(h){Object.defineProperty(v,h,Object.getOwnPropertyDescriptor(o,h))})}return v}function Xe(){Xe=function(){return v};var v={},m=Object.prototype,o=m.hasOwnProperty,h=Object.defineProperty||function(w,U,G){w[U]=G.value},f=typeof Symbol=="function"?Symbol:{},g=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(w,U,G){return Object.defineProperty(w,U,{value:G,enumerable:!0,configurable:!0,writable:!0}),w[U]}try{S({},"")}catch{S=function(U,G,Y){return U[G]=Y}}function D(w,U,G,Y){var M=U&&U.prototype instanceof H?U:H,x=Object.create(M.prototype),ie=new ye(Y||[]);return h(x,"_invoke",{value:se(w,G,ie)}),x}function P(w,U,G){try{return{type:"normal",arg:w.call(U,G)}}catch(Y){return{type:"throw",arg:Y}}}v.wrap=D;var F={};function H(){}function W(){}function $(){}var ee={};S(ee,g,function(){return this});var Z=Object.getPrototypeOf,oe=Z&&Z(Z(Ie([])));oe&&oe!==m&&o.call(oe,g)&&(ee=oe);var ue=$.prototype=H.prototype=Object.create(ee);function Se(w){["next","throw","return"].forEach(function(U){S(w,U,function(G){return this._invoke(U,G)})})}function he(w,U){function G(M,x,ie,ae){var Re=P(w[M],w,x);if(Re.type!=="throw"){var Ue=Re.arg,je=Ue.value;return je&&typeof je=="object"&&o.call(je,"__await")?U.resolve(je.__await).then(function(xe){G("next",xe,ie,ae)},function(xe){G("throw",xe,ie,ae)}):U.resolve(je).then(function(xe){Ue.value=xe,ie(Ue)},function(xe){return G("throw",xe,ie,ae)})}ae(Re.arg)}var Y;h(this,"_invoke",{value:function(M,x){function ie(){return new U(function(ae,Re){G(M,x,ae,Re)})}return Y=Y?Y.then(ie,ie):ie()}})}function se(w,U,G){var Y="suspendedStart";return function(M,x){if(Y==="executing")throw new Error("Generator is already running");if(Y==="completed"){if(M==="throw")throw x;return Ze()}for(G.method=M,G.arg=x;;){var ie=G.delegate;if(ie){var ae=ce(ie,G);if(ae){if(ae===F)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(Y==="suspendedStart")throw Y="completed",G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);Y="executing";var Re=P(w,U,G);if(Re.type==="normal"){if(Y=G.done?"completed":"suspendedYield",Re.arg===F)continue;return{value:Re.arg,done:G.done}}Re.type==="throw"&&(Y="completed",G.method="throw",G.arg=Re.arg)}}}function ce(w,U){var G=U.method,Y=w.iterator[G];if(Y===void 0)return U.delegate=null,G==="throw"&&w.iterator.return&&(U.method="return",U.arg=void 0,ce(w,U),U.method==="throw")||G!=="return"&&(U.method="throw",U.arg=new TypeError("The iterator does not provide a '"+G+"' method")),F;var M=P(Y,w.iterator,U.arg);if(M.type==="throw")return U.method="throw",U.arg=M.arg,U.delegate=null,F;var x=M.arg;return x?x.done?(U[w.resultName]=x.value,U.next=w.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,F):x:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,F)}function Me(w){var U={tryLoc:w[0]};1 in w&&(U.catchLoc=w[1]),2 in w&&(U.finallyLoc=w[2],U.afterLoc=w[3]),this.tryEntries.push(U)}function We(w){var U=w.completion||{};U.type="normal",delete U.arg,w.completion=U}function ye(w){this.tryEntries=[{tryLoc:"root"}],w.forEach(Me,this),this.reset(!0)}function Ie(w){if(w){var U=w[g];if(U)return U.call(w);if(typeof w.next=="function")return w;if(!isNaN(w.length)){var G=-1,Y=function M(){for(;++G<w.length;)if(o.call(w,G))return M.value=w[G],M.done=!1,M;return M.value=void 0,M.done=!0,M};return Y.next=Y}}return{next:Ze}}function Ze(){return{value:void 0,done:!0}}return W.prototype=$,h(ue,"constructor",{value:$,configurable:!0}),h($,"constructor",{value:W,configurable:!0}),W.displayName=S($,_,"GeneratorFunction"),v.isGeneratorFunction=function(w){var U=typeof w=="function"&&w.constructor;return!!U&&(U===W||(U.displayName||U.name)==="GeneratorFunction")},v.mark=function(w){return Object.setPrototypeOf?Object.setPrototypeOf(w,$):(w.__proto__=$,S(w,_,"GeneratorFunction")),w.prototype=Object.create(ue),w},v.awrap=function(w){return{__await:w}},Se(he.prototype),S(he.prototype,E,function(){return this}),v.AsyncIterator=he,v.async=function(w,U,G,Y,M){M===void 0&&(M=Promise);var x=new he(D(w,U,G,Y),M);return v.isGeneratorFunction(U)?x:x.next().then(function(ie){return ie.done?ie.value:x.next()})},Se(ue),S(ue,_,"Generator"),S(ue,g,function(){return this}),S(ue,"toString",function(){return"[object Generator]"}),v.keys=function(w){var U=Object(w),G=[];for(var Y in U)G.push(Y);return G.reverse(),function M(){for(;G.length;){var x=G.pop();if(x in U)return M.value=x,M.done=!1,M}return M.done=!0,M}},v.values=Ie,ye.prototype={constructor:ye,reset:function(w){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(We),!w)for(var U in this)U.charAt(0)==="t"&&o.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var U=this;function G(Re,Ue){return x.type="throw",x.arg=w,U.next=Re,Ue&&(U.method="next",U.arg=void 0),!!Ue}for(var Y=this.tryEntries.length-1;Y>=0;--Y){var M=this.tryEntries[Y],x=M.completion;if(M.tryLoc==="root")return G("end");if(M.tryLoc<=this.prev){var ie=o.call(M,"catchLoc"),ae=o.call(M,"finallyLoc");if(ie&&ae){if(this.prev<M.catchLoc)return G(M.catchLoc,!0);if(this.prev<M.finallyLoc)return G(M.finallyLoc)}else if(ie){if(this.prev<M.catchLoc)return G(M.catchLoc,!0)}else{if(!ae)throw new Error("try statement without catch or finally");if(this.prev<M.finallyLoc)return G(M.finallyLoc)}}}},abrupt:function(w,U){for(var G=this.tryEntries.length-1;G>=0;--G){var Y=this.tryEntries[G];if(Y.tryLoc<=this.prev&&o.call(Y,"finallyLoc")&&this.prev<Y.finallyLoc){var M=Y;break}}M&&(w==="break"||w==="continue")&&M.tryLoc<=U&&U<=M.finallyLoc&&(M=null);var x=M?M.completion:{};return x.type=w,x.arg=U,M?(this.method="next",this.next=M.finallyLoc,F):this.complete(x)},complete:function(w,U){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&U&&(this.next=U),F},finish:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.finallyLoc===w)return this.complete(G.completion,G.afterLoc),We(G),F}},catch:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.tryLoc===w){var Y=G.completion;if(Y.type==="throw"){var M=Y.arg;We(G)}return M}}throw new Error("illegal catch attempt")},delegateYield:function(w,U,G){return this.delegate={iterator:Ie(w),resultName:U,nextLoc:G},this.method==="next"&&(this.arg=void 0),F}},v}function $t(v){"@babel/helpers - typeof";return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},$t(v)}function Js(v,m,o,h,f,g,E){try{var _=v[g](E),S=_.value}catch(D){o(D);return}_.done?m(S):Promise.resolve(S).then(h,f)}function Rt(v){return function(){var m=this,o=arguments;return new Promise(function(h,f){var g=v.apply(m,o);function E(S){Js(g,h,f,E,_,"next",S)}function _(S){Js(g,h,f,E,_,"throw",S)}E(void 0)})}}function He(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function eo(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,ao(h.key),h)}}function Ke(v,m,o){return m&&eo(v.prototype,m),o&&eo(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function q(v,m,o){return m=ao(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function Ut(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&Wr(v,m)}function or(v){return or=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},or(v)}function Wr(v,m){return Wr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},Wr(v,m)}function ro(){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 xi(v,m,o){return ro()?xi=Reflect.construct.bind():xi=function(f,g,E){var _=[null];_.push.apply(_,g);var S=Function.bind.apply(f,_),D=new S;return E&&Wr(D,E.prototype),D},xi.apply(null,arguments)}function Ph(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function cr(v){var m=typeof Map=="function"?new Map:void 0;return cr=function(h){if(h===null||!Ph(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof m<"u"){if(m.has(h))return m.get(h);m.set(h,f)}function f(){return xi(h,arguments,or(this).constructor)}return f.prototype=Object.create(h.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Wr(f,h)},cr(v)}function Oh(v,m){if(v==null)return{};var o={},h=Object.keys(v),f,g;for(g=0;g<h.length;g++)f=h[g],!(m.indexOf(f)>=0)&&(o[f]=v[f]);return o}function io(v,m){if(v==null)return{};var o=Oh(v,m),h,f;if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(v);for(f=0;f<g.length;f++)h=g[f],!(m.indexOf(h)>=0)&&Object.prototype.propertyIsEnumerable.call(v,h)&&(o[h]=v[h])}return o}function pe(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Mh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pe(v)}function Bt(v){var m=ro();return function(){var h=or(v),f;if(m){var g=or(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return Mh(this,f)}}function Fh(v,m){for(;!Object.prototype.hasOwnProperty.call(v,m)&&(v=or(v),v!==null););return v}function Kr(){return typeof Reflect<"u"&&Reflect.get?Kr=Reflect.get.bind():Kr=function(m,o,h){var f=Fh(m,o);if(f){var g=Object.getOwnPropertyDescriptor(f,o);return g.get?g.get.call(arguments.length<3?m:h):g.value}},Kr.apply(this,arguments)}function Nh(v,m){if(v){if(typeof v=="string")return to(v,m);var o=Object.prototype.toString.call(v).slice(8,-1);if(o==="Object"&&v.constructor&&(o=v.constructor.name),o==="Map"||o==="Set")return Array.from(v);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return to(v,m)}}function to(v,m){(m==null||m>v.length)&&(m=v.length);for(var o=0,h=new Array(m);o<m;o++)h[o]=v[o];return h}function no(v,m){var o=typeof Symbol<"u"&&v[Symbol.iterator]||v["@@iterator"];if(!o){if(Array.isArray(v)||(o=Nh(v))||m&&v&&typeof v.length=="number"){o&&(v=o);var h=0,f=function(){};return{s:f,n:function(){return h>=v.length?{done:!0}:{done:!1,value:v[h++]}},e:function(S){throw S},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
29
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var g=!0,E=!1,_;return{s:function(){o=o.call(v)},n:function(){var S=o.next();return g=S.done,S},e:function(S){E=!0,_=S},f:function(){try{!g&&o.return!=null&&o.return()}finally{if(E)throw _}}}}function Uh(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function ao(v){var m=Uh(v,"string");return typeof m=="symbol"?m:String(m)}var tt=function(){function v(){He(this,v)}return Ke(v,null,[{key:"start",value:function(o){return!o||!o.length||o.length===1&&o.end(0)-o.start(0)<1e-6||o.length===1&&o.start(0)<0?0:o.start(0)}},{key:"end",value:function(o){return!o||!o.length||o.length===1&&o.end(0)-o.start(0)<1e-6?0:o.end(o.length-1)}},{key:"get",value:function(o){if(o)try{return o.buffered}catch{}}},{key:"buffers",value:function(o,h){if(!o||!o.length)return[];for(var f=[],g=0,E=o.length;g<E;g++){var _=f.length;if(!_||!h)f.push([o.start(g),o.end(g)]);else{var S=f[_-1],D=S[1],P=o.start(g);if(P-D<=h){var F=o.end(g);F>D&&(S[1]=F)}else f.push([o.start(g),o.end(g)])}}return f}},{key:"totalLength",value:function(o){return!o||!o.length?0:o.reduce(function(h,f){return h+=f[1]-f[0]},0)}},{key:"info",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!o||!o.length)return{start:0,end:0,buffers:[]};for(var g=0,E=0,_=0,S=0,D=0,P=0,F=0,H=v.buffers(o,f),W=0,$=H.length;W<$;W++){var ee=H[W];if(h+f>=ee[0]&&h<=ee[1])g=ee[0],E=ee[1],_=W;else if(h+f<ee[0]){S=ee[0],D=ee[1];break}else h+f>ee[1]&&(P=ee[0],F=ee[1])}return{start:g,end:E,index:_,buffers:H,nextStart:S,nextEnd:D,prevStart:P,prevEnd:F,currentTime:h,behind:h-g,remaining:E?E-h:0,length:v.totalLength&&v.totalLength(H)}}},{key:"isBuffered",value:function(o,h){if(o){var f=v.get(o);if(f!=null&&f.length){for(var g=0;g<f.length;g++)if(h>=f.start(g)&&h<=f.end(g))return!0}}return!1}}]),v}();var so=typeof window<"u";var bt,De={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"}},Ri=(bt={},q(bt,De.MANIFEST,{HLS:1100,DASH:1200}),q(bt,De.NETWORK,2100),q(bt,De.NETWORK_TIMEOUT,2101),q(bt,De.NETWORK_FORBIDDEN,2103),q(bt,De.NETWORK_NOTFOUND,2104),q(bt,De.NETWROK_RANGE_NOT_SATISFIABLE,2116),q(bt,De.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),q(bt,De.REMUX,{FMP4:4100,MP4:4200}),q(bt,De.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(bt,De.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),q(bt,De.OTHER,8e3),q(bt,De.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),bt),pt=function(v){Ut(o,v);var m=Bt(o);function o(h,f,g,E,_){var S;return He(this,o),S=m.call(this,_||g?.message),S.errorType=h===De.NETWORK_TIMEOUT?De.NETWORK:h,S.originError=g,S.ext=E,S.errorCode=Ri[h][f]||Ri[h],S.errorMessage=S.message,S.errorCode||(S.errorType=De.OTHER,S.errorCode=Ri[S.errorType]),S}return Ke(o,null,[{key:"create",value:function(f,g,E,_,S){return f instanceof o?f:(f instanceof Error&&(E=f,f=""),f||(f=De.OTHER),new o(f,g,E,_,S))}},{key:"network",value:function(f){var g;return new o(f!=null&&f.isTimeout?De.NETWORK_TIMEOUT:De.NETWORK,null,f instanceof Error?f:null,{url:f?.url,response:f?.response,httpCode:f==null||(g=f.response)===null||g===void 0?void 0:g.status})}}]),o}(cr(Error));var Yr={DEBUG:1,LOG:2,WARN:3,ERROR:4},Bh=200*1024,Gh=["Boolean","Number","String","Undefined","Null","Date","Object"],Ct=function(){function v(m,o){He(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=o?.logCacheLevel||3,this.logMaxSize=o?.logMaxSize||Bh,this.logSize=0,this.logTextArray=[]}return Ke(v,[{key:"debug",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.DEBUG].concat(f)),!v.disabled&&(o=console).debug.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"log",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.LOG].concat(f)),!v.disabled&&(o=console).log.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"warn",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.WARN].concat(f)),!v.disabled&&(o=console).warn.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"error",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.ERROR].concat(f)),!v.disabled&&(o=console).error.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"logCache",value:function(o){if(!(o<this.logCacheLevel)){var h="";try{for(var f=arguments.length,g=new Array(f>1?f-1:0),E=1;E<f;E++)g[E-1]=arguments[E];var _=g.map(function(D){return oo(D)});h="[".concat(jr(),"]")+this._prefix+JSON.stringify(_)}catch{return}if(o>=this.logCacheLevel&&(this.logSize+=h.length,this.logTextArray.push(h)),this.logSize>this.logMaxSize){var S=this.logTextArray.shift();this.logSize-=S.length}}}},{key:"getLogCache",value:function(){var o=this.logTextArray.join(`
30
+ `);return this.reset(),o}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var o;v.disabled||(console.group(this._prefix),(o=console).table.apply(o,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(o){this.logCacheLevel=o}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();q(Ct,"disabled",!0);function jr(){return new Date().toLocaleString()}function Vh(v){if($t(v)!=="object")return v;var m=Object.prototype.toString.call(v).slice(8,-1);switch(m){case"Array":case"Uint8Array":case"ArrayBuffer":return m+"["+v.length+"]";case"Object":return"{}";default:return m}}function oo(v,m,o){o||(o=1),m||(m=2);var h={};if(!v||$t(v)!=="object")return v;var f=Object.prototype.toString.call(v).slice(8,-1);if(!Gh.includes(f))return f;if(!(o>m)){for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(o===m?h[g]=Vh(v[g]):$t(v[g])==="object"?h[g]=oo(v[g],m,o+1):h[g]=v[g]);return h}}function lr(){var v,m,o=new Promise(function(h,f){v=h,m=f});return o.used=!1,o.resolve=function(){return o.used=!0,v.apply(void 0,arguments)},o.reject=function(){return o.used=!0,m.apply(void 0,arguments)},o}function vr(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var uo={stringify:function(m){try{return JSON.stringify(m)}catch{return""}},parse:function(m){try{return JSON.parse(m)}catch{return}}};function lo(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return so?v&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function _n(v){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(v))}function Hh(v){var m=[];if(v instanceof TimeRanges)for(var o=0;o<v.length;o++)m.push({start:v.start(o),end:v.end(o)});return m}var Ci={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var fr=function(){function v(m,o){var h=this;He(this,v),q(this,"media",null),q(this,"mediaSource",null),q(this,"_openPromise",lr()),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(){h._logger.debug("startstreaming")}),q(this,"_onEndStreaming",function(){h._logger.debug("endstreaming")}),q(this,"_onSBUpdateEnd",function(f){var g=h._queue[f];if(g){var E=g[0];if(E?.opName!==Ci.UPDATE_DURATION&&g.shift(),E){var _,S,D=vr()-h._opst;h._logger.debug("UpdateEnd(".concat(f,"/").concat(E.opName,")"),uo.stringify(Hh((_=h._sourceBuffer[f])===null||_===void 0?void 0:_.buffered)),D,E.context),E.promise.resolve({name:E.opName,context:E.context,costtime:D});var P=(S=E.context)===null||S===void 0?void 0:S.callback;P&&typeof P=="function"&&P(E.context),h._startQueue(f)}}}),q(this,"_onSBUpdateError",function(f,g){var E=h._queue[f];if(E){var _=E[0];_&&(h._logger.error("UpdateError",f,_.opName,_.context),_.promise.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_APPEND_BUFFER,g)))}}),this._config=Object.assign(v.getDefaultConfig(),o),m&&this.bindMedia(m),this._logger=new Ct("MSE"),this._config.openLog&&Ct.enable()}return Ke(v,[{key:"isOpened",get:function(){var o;return((o=this.mediaSource)===null||o===void 0?void 0:o.readyState)==="open"}},{key:"hasOpTasks",get:function(){var o=this,h=!1;return Object.keys(this._queue).forEach(function(f){var g=o._queue[f];Array.isArray(g)&&(h||(h=g.length>0))}),h}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var o;return((o=this.mediaSource)===null||o===void 0?void 0:o.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return _n(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(o){return o?this._mseFullFlag[o]:this._mseFullFlag[v.VIDEO]}},{key:"updateDuration",value:function(o){var h=this,f=this.mediaSource&&this.mediaSource.duration>o;if(this.mediaSource&&this.mediaSource.duration>o){var g=0;if(Object.keys(this._sourceBuffer).forEach(function(E){try{g=Math.max(h.bufferEnd(E)||0,g)}catch{}}),o<g)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(h.isEnded){h._logger.debug("setDuration but ended");return}h.mediaSource&&(h.mediaSource.duration=o,h._logger.debug("setDuration",o))},Ci.UPDATE_DURATION,{isReduceDuration:f})}},{key:"open",value:function(){var o=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var h=this.mediaSource,f=function g(){var E=vr()-o._st;o._logger.debug("sourceopen",E),h.removeEventListener("sourceopen",g),o._openPromise.resolve({costtime:E})};h.addEventListener("sourceopen",f),this._openPromise=lr()}return this._openPromise}},{key:"bindMedia",value:function(){var m=Rt(Xe().mark(function h(f){var g=this,E,_,S,D;return Xe().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(!(this.mediaSource||this.media)){F.next=3;break}return F.next=3,this.unbindMedia();case 3:if(E=lo(this._config.preferMMS),!(!f||!E)){F.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=f,_=this.mediaSource=new E,S=_n(_),this._st=vr(),D=function H(){var W=vr()-g._st;g._logger.debug("sourceopen"),_.removeEventListener("sourceopen",H),URL.revokeObjectURL(f.src),g._openPromise.resolve({costtime:W})},_.addEventListener("sourceopen",D),S&&(_.addEventListener("startstreaming",this._onStartStreaming),_.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(_),f.src=this._url,f.disableRemotePlayback=S,F.abrupt("return",this._openPromise);case 17:case"end":return F.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"unbindMedia",value:function(){var m=Rt(Xe().mark(function h(){var f=this,g,E,_;return Xe().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),g=this.mediaSource,g){if(Object.keys(this._queue).forEach(function(P){var F=f._queue[P];F&&F.forEach(function(H){var W,$;return(W=H.promise)===null||W===void 0||($=W.resolve)===null||$===void 0?void 0:$.call(W)})}),E=!!this.media&&this.media.readyState>=1,_=g.readyState==="open",E&&_)try{g.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(P){try{g.removeSourceBuffer(f._sourceBuffer[P])}catch{}}),_n(g)&&(g.removeEventListener("startstreaming",this._onStartStreaming),g.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=lr(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return D.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"createSource",value:function(o,h){if(!(this._sourceBuffer[o]||!this.mediaSource)){var f;try{f=this._sourceBuffer[o]=this.mediaSource.addSourceBuffer(h)}catch(g){throw new pt(De.MEDIA,De.SUB_TYPES.MSE_ADD_SB,g)}f.mimeType=h,f.addEventListener("updateend",this._onSBUpdateEnd.bind(this,o)),f.addEventListener("error",this._onSBUpdateError.bind(this,o))}}},{key:"changeType",value:function(o,h){var f=this,g=this._sourceBuffer[o];return!this.mediaSource||!g||g.mimeType===h?Promise.resolve():typeof g.changeType!="function"?Promise.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(o,function(){try{g.changeType(h)}catch(E){throw new pt(De.MEDIA,De.SUB_TYPES.MSE_CHANGE_TYPE,E)}g.mimeType=h,f._onSBUpdateEnd(o)},"changeType",{mimeType:h})}},{key:"createOrChangeSource",value:function(o,h){return this.createSource(o,h),this.changeType(o,h)}},{key:"append",value:function(o,h,f){var g=this;return!h||!h.byteLength||!this._sourceBuffer[o]?Promise.resolve():this._enqueueOp(o,function(){var E;!g.mediaSource||g.media.error||(g._logger.debug("MSE APPEND START",f),g._opst=vr(),(E=g._sourceBuffer[o])===null||E===void 0||E.appendBuffer(h))},Ci.APPEND,f)}},{key:"remove",value:function(o,h,f,g){var E=this,_=!1;return this._mseFullFlag[o]&&(_=!0),this._enqueueOp(o,function(){if(!(!E.mediaSource||E.media.error)){var S=E._sourceBuffer[o];if(h>=f||!S){E._onSBUpdateEnd(o);return}E._opst=vr(),E._logger.debug("MSE REMOVE START",o,h,f,g),S.remove(h,f)}},Ci.REMOVE,g,_)}},{key:"clearBuffer",value:function(o,h){var f=this,g;return Object.keys(this._sourceBuffer).forEach(function(E){g=f.remove(E,o,h)}),g||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var o=this,h;return Object.keys(this._sourceBuffer).forEach(function(f){var g=o._sourceBuffer[f];h=o.remove(f,0,tt.end(tt.get(g)))}),h}},{key:"clearOpQueues",value:function(o,h){var f;this._logger.debug("MSE clearOpQueue START");var g=this._queue[o];if(h&&g){this._queue[o]=[];return}if(!(!g||!g[o]||g.length<5)){var E=[];g.forEach(function(_){_.context&&_.context.isinit&&E.push(_)}),this._queue[o]=g.slice(0,2),E.length>0&&(f=this._queue[o]).push.apply(f,E)}}},{key:"endOfStream",value:function(o){var h=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var f=h.mediaSource;!f||f.readyState!=="open"||(h._logger.debug("MSE endOfStream START"),o?f.endOfStream(o):f.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(o,h){var f=this.mediaSource;o<0||h<o||!(f!=null&&f.setLiveSeekableRange)||f.readyState!=="open"||f.setLiveSeekableRange(o,h)}},{key:"getSourceBuffer",value:function(o){return this._sourceBuffer[o]}},{key:"buffered",value:function(o){return tt.get(this._sourceBuffer[o])}},{key:"bufferStart",value:function(o){return tt.start(this.buffered(o))}},{key:"bufferEnd",value:function(o){return tt.end(this.buffered(o))}},{key:"_enqueueOp",value:function(o,h,f,g,E){var _=this;if(!this.mediaSource)return Promise.resolve();var S=this._queue[o]=this._queue[o]||[],D={exec:h,promise:lr(),opName:f,context:g};return E?(S.splice(0,0,D),this._mseFullFlag[o]=!1,this._startQueue(o)):S.push(D),this.isOpened||this.isEnded?S.length===1&&this._startQueue(o):this._openPromise.then(function(){S.length===1&&_._startQueue(o)}),D.promise}},{key:"_enqueueBlockingOp",value:function(){var m=Rt(Xe().mark(function h(f,g,E){var _=this,S,D;return Xe().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(this.mediaSource){F.next=2;break}return F.abrupt("return",Promise.resolve());case 2:if(S=Object.keys(this._sourceBuffer),S.length){F.next=5;break}return F.abrupt("return",f());case 5:return D=[],S.forEach(function(H){var W=_._queue[H],$=lr();D.push($),W.push({exec:function(){$.resolve()},promise:$,opName:g,context:E}),W.length===1&&_._startQueue(H)}),F.abrupt("return",Promise.all(D).then(function(){try{return f()}finally{S.forEach(function(H){var W=_._queue[H],$=_._sourceBuffer[H];W?.shift(),(!$||!$.updating)&&_._startQueue(H)})}}));case 8:case"end":return F.stop()}},h,this)}));function o(h,f,g){return m.apply(this,arguments)}return o}()},{key:"_startQueue",value:function(o){var h=this._queue[o];if(h){var f=h[0];if(f&&!this._mseFullFlag[o])try{f.exec()}catch(_){if(_&&_.message&&_.message.indexOf("SourceBuffer is full")>=0){var g;this._mseFullFlag[o]=!0,f.context&&$t(f.context)==="object"&&(f.context.isFull=!0),this._logger.error("[MSE error], context,",f.context," ,name,",f.opName,",err,SourceBuffer is full"),f==null||(g=f.promise)===null||g===void 0||g.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_FULL,_))}else{var E;this._logger.error(_),f==null||(E=f.promise)===null||E===void 0||E.reject(_.constructor===pt?_:new pt(De.MEDIA,De.SUB_TYPES.MSE_OTHER,_)),h.shift(),this._startQueue(o)}}}}},{key:"setTimeoffset",value:function(o,h,f){var g=this;return this._enqueueOp(o,function(){h<0&&(h+=.001),g._sourceBuffer[o].timestampOffset=h,g._onSBUpdateEnd(o)},"setTimeoffset",f)}},{key:"abort",value:function(o,h){var f=this;return this.isOpened?this._enqueueOp(o,function(){f._sourceBuffer[o].abort(),f._onSBUpdateEnd(o)},"abort",h):Promise.resolve()}}],[{key:"isSupported",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',h=lo();if(!h)return!1;try{return h.isTypeSupported(o)}catch(f){return this._logger.error(o,f),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),v}();q(fr,"VIDEO","video");q(fr,"AUDIO","audio");var Gt={FETCH:"fetch",XHR:"xhr"},hr={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var wt=function(v){Ut(o,v);var m=Bt(o);function o(h,f,g,E){var _;return He(this,o),_=m.call(this,E),q(pe(_),"retryCount",0),q(pe(_),"isTimeout",!1),q(pe(_),"loaderType",Gt.FETCH),q(pe(_),"startTime",0),q(pe(_),"endTime",0),q(pe(_),"options",{}),_.url=h,_.request=f,_.response=g,_}return Ke(o)}(cr(Error));var fo=Object.prototype.toString;function ho(v){return v!==null&&$t(v)==="object"}function Sn(v){if(fo.call(v)!=="[object Object]")return!1;var m=Object.getPrototypeOf(v);return m===null||m===Object.prototype}function co(v){return fo.call(v)==="[object Date]"}function ki(v){if(!(!v||v[0]===null||v[0]===void 0||v[0]===0&&(v[1]===null||v[1]===void 0))){var m="bytes="+v[0]+"-";return v[1]&&(m+=v[1]),m}}function vo(v){return encodeURIComponent(v).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Di(v,m){if(v){if(!m)return v;var o,h=Object.keys(m).map(function(g){if(o=m[g],o!=null)return Array.isArray(o)?g=g+"[]":o=[o],o.map(function(E){return co(E)?E=E.toISOString():ho(E)&&(E=JSON.stringify(E)),"".concat(vo(g),"=").concat(vo(E))}).join("&")}).filter(Boolean).join("&");if(h){var f=v.indexOf("#");f!==-1&&(v=v.slice(0,f)),v+=(v.indexOf("?")===-1?"?":"&")+h}return v}}function zr(v,m,o,h,f,g,E,_,S,D,P){f=f!=null?parseFloat(f):null,h=parseInt(h||"0",10),Number.isNaN(h)&&(h=0);var F={range:S,vid:D,index:_,contentLength:h,age:f,startTime:g,firstByteTime:E,endTime:Date.now(),priOptions:P};return{data:v,done:m,options:F,response:o}}function qr(v,m){return Math.round(v*8*1e3/m/1024)}var _e={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 go=Ar(xr()),po=2*1024*1024,$r=function(v){Ut(o,v);var m=Bt(o);function o(){var h;return He(this,o),h=m.call(this),q(pe(h),"_abortController",null),q(pe(h),"_timeoutTimer",null),q(pe(h),"_reader",null),q(pe(h),"_response",null),q(pe(h),"_aborted",!1),q(pe(h),"_index",-1),q(pe(h),"_range",null),q(pe(h),"_receivedLength",0),q(pe(h),"_running",!1),q(pe(h),"_logger",null),q(pe(h),"_vid",""),q(pe(h),"_onProcessMinLen",0),q(pe(h),"_onCancel",null),q(pe(h),"_priOptions",null),h}return Ke(o,[{key:"load",value:function(f){var g,E=this,_=f.url,S=f.vid,D=f.timeout,P=f.responseType,F=f.onProgress,H=f.index,W=f.onTimeout,$=f.onCancel,ee=f.range,Z=f.transformResponse,oe=f.request,ue=f.params,Se=f.logger,he=f.method,se=f.headers,ce=f.body,Me=f.mode,We=f.credentials,ye=f.cache,Ie=f.redirect,Ze=f.referrer,w=f.referrerPolicy,U=f.onProcessMinLen,G=f.priOptions;this._logger=Se,this._aborted=!1,this._onProcessMinLen=U,this._onCancel=$,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=H,this._range=ee||[0,0],this._vid=S||_,this._priOptions=G||{};var Y={method:he,headers:se,body:ce,mode:Me,credentials:We,cache:ye,redirect:Ie,referrer:Ze,referrerPolicy:w,signal:(g=this._abortController)===null||g===void 0?void 0:g.signal},M=!1;clearTimeout(this._timeoutTimer),_=Di(_,ue);var x=ki(ee);x&&(oe?se=oe.headers:se=Y.headers=Y.headers||(Headers?new Headers:{}),Headers&&se instanceof Headers?se.append("Range",x):se.Range=x),D&&(this._timeoutTimer=setTimeout(function(){if(M=!0,E.cancel(),W){var ae=new wt(_,Y,null,"timeout");ae.isTimeout=!0,W(ae,{index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions})}},D));var ie=Date.now();return this._logger.debug("[fetch load start], index,",H,",range,",ee),new Promise(function(ae,Re){fetch(oe||_,oe?void 0:Y).then(function(){var Ue=Rt(Xe().mark(function je(xe){var Ir,Dt,wr,Pr;return Xe().wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(clearTimeout(E._timeoutTimer),E._response=xe,!(E._aborted||!E._running)){Je.next=4;break}return Je.abrupt("return");case 4:if(Z&&(xe=Z(xe,_)||xe),xe.ok){Je.next=7;break}throw new wt(_,Y,xe,"bad network response");case 7:if(Ir=Date.now(),P!==hr.TEXT){Je.next=15;break}return Je.next=11,xe.text();case 11:Dt=Je.sent,E._running=!1,Je.next=37;break;case 15:if(P!==hr.JSON){Je.next=22;break}return Je.next=18,xe.json();case 18:Dt=Je.sent,E._running=!1,Je.next=37;break;case 22:if(!F){Je.next=29;break}return E.resolve=ae,E.reject=Re,E._loadChunk(xe,F,ie,Ir),Je.abrupt("return");case 29:return Je.next=31,xe.arrayBuffer();case 31:Dt=Je.sent,Dt=new Uint8Array(Dt),E._running=!1,wr=Date.now()-ie,Pr=qr(Dt.byteLength,wr),E.emit(_e.REAL_TIME_SPEED,{speed:Pr,len:Dt.byteLength,time:wr,vid:E._vid,index:E._index,range:E._range,priOptions:E._priOptions});case 37:E._logger.debug("[fetch load end], index,",H,",range,",ee),ae(zr(Dt,!0,xe,xe.headers.get("Content-Length"),xe.headers.get("age"),ie,Ir,H,ee,E._vid,E._priOptions));case 39:case"end":return Je.stop()}},je)}));return function(je){return Ue.apply(this,arguments)}}()).catch(function(Ue){var je;clearTimeout(E._timeoutTimer),E._running=!1,!(E._aborted&&!M)&&(Ue=Ue instanceof wt?Ue:new wt(_,Y,null,(je=Ue)===null||je===void 0?void 0:je.message),Ue.startTime=ie,Ue.endTime=Date.now(),Ue.isTimeout=M,Ue.options={index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions},Re(Ue))})})}},{key:"cancel",value:function(){var h=Rt(Xe().mark(function g(){return Xe().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()}},g,this,[[5,11]])}));function f(){return h.apply(this,arguments)}return f}()},{key:"_loadChunk",value:function(f,g,E,_){var S=this;if(!f.body||!f.body.getReader){this._running=!1;var D=new wt(f.url,"",f,"onProgress of bad response.body.getReader");D.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(D);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(po),this._writeIdx=0);var P=this._reader=f.body.getReader(),F,H,W,$=function(){var ee=Rt(Xe().mark(function Z(){var oe,ue,Se,he,se,ce,Me,We;return Xe().wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return H=Date.now(),Ie.prev=1,Ie.next=4,P.read();case 4:F=Ie.sent,W=Date.now(),Ie.next=13;break;case 8:return Ie.prev=8,Ie.t0=Ie.catch(1),W=Date.now(),S._aborted||(S._running=!1,Ie.t0.options={index:S._index,range:S._range,vid:S._vid,priOptions:S._priOptions},S.reject(Ie.t0)),Ie.abrupt("return");case 13:if(ue=((oe=S._range)===null||oe===void 0?void 0:oe.length)>0?S._range[0]:0,Se=ue+S._receivedLength,!S._aborted){Ie.next=19;break}return S._running=!1,g(void 0,!1,{range:[Se,Se],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),Ie.abrupt("return");case 19:he=F.value?F.value.byteLength:0,S._receivedLength+=he,S._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",S._range,", start,",Se,", end,",ue+S._receivedLength,", done,",F.done),S._onProcessMinLen>0?S._writeIdx+he>=S._onProcessMinLen||F.done?(se=new Uint8Array(S._writeIdx+he),se.set(S._cache.slice(0,S._writeIdx),0),he>0&&se.set(F.value,S._writeIdx),S._writeIdx=0,S._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",F.done,",len,",se.byteLength,", writeIdx,",S._writeIdx)):he>0&&S._writeIdx+he<po?(S._cache.set(F.value,S._writeIdx),S._writeIdx+=he,S._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",he,", writeIdx,",S._writeIdx)):he>0&&(ce=new Uint8Array(S._writeIdx+he+2048),S._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",S._writeIdx+he+2048,", datalen,",he,", writeIdx,",S._writeIdx),ce.set(S._cache.slice(0,S._writeIdx),0),he>0&&ce.set(F.value,S._writeIdx),S._writeIdx+=he,delete S._cache,S._cache=ce,S._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",he,", writeIdx,",S._writeIdx)):se=F.value,(se&&se.byteLength>0||F.done)&&g(se,F.done,{range:[S._range[0]+S._receivedLength-(se?se.byteLength:0),S._range[0]+S._receivedLength],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),F.done?(Me=Date.now()-E,We=qr(S._receivedLength,Me),S.emit(_e.REAL_TIME_SPEED,{speed:We,len:S._receivedLength,time:Me,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,",F.done),S.resolve(zr(F,!0,f,f.headers.get("Content-Length"),f.headers.get("age"),E,_,S._index,S._range,S._vid,S._priOptions))):$();case 25:case"end":return Ie.stop()}},Z,null,[[1,8]])}));return function(){return ee.apply(this,arguments)}}();$()}},{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"}}]),o}(go.default);function mo(v){return ur({loaderType:Gt.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:hr.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},v)}var yo=Ar(xr()),Eo=function(v){Ut(o,v);var m=Bt(o);function o(){var h;return He(this,o),h=m.call(this),q(pe(h),"_xhr",null),q(pe(h),"_aborted",!1),q(pe(h),"_timeoutTimer",null),q(pe(h),"_range",null),q(pe(h),"_receivedLength",0),q(pe(h),"_url",null),q(pe(h),"_onProgress",null),q(pe(h),"_index",-1),q(pe(h),"_headers",null),q(pe(h),"_currentChunkSizeKB",384),q(pe(h),"_timeout",null),q(pe(h),"_xhr",null),q(pe(h),"_withCredentials",null),q(pe(h),"_startTime",-1),q(pe(h),"_loadCompleteResolve",null),q(pe(h),"_loadCompleteReject",null),q(pe(h),"_runing",!1),q(pe(h),"_logger",!1),q(pe(h),"_vid",""),q(pe(h),"_responseType",void 0),q(pe(h),"_credentials",void 0),q(pe(h),"_method",void 0),q(pe(h),"_transformResponse",void 0),q(pe(h),"_firstRtt",void 0),q(pe(h),"_onCancel",null),q(pe(h),"_priOptions",null),h}return Ke(o,[{key:"load",value:function(f){var g=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){g._loadCompleteResolve=_,g._loadCompleteReject=S,g._startLoad()}).catch(function(_){if(clearTimeout(g._timeoutTimer),g._runing=!1,!g._aborted)throw _=_ instanceof wt?_:new wt(g._url,g._request),_.startTime=E,_.endTime=Date.now(),_.options={index:g._index,vid:g._vid,priOptions:g._priOptions},_})}},{key:"_startLoad",value:function(){var f=null;if(this._responseType===hr.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var g=this._currentChunkSizeKB*1024,E=this._range[0]+this._receivedLength,_=this._range[1];g<this._range[1]-E&&(_=E+g),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 g=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(D){var P,F,H;g._running=!1;var W=new wt(g._url,g._request,D==null||(P=D.currentTarget)===null||P===void 0?void 0:P.response,"xhr.onerror.status:"+(D==null||(F=D.currentTarget)===null||F===void 0?void 0:F.status)+",statusText,"+(D==null||(H=D.currentTarget)===null||H===void 0?void 0:H.statusText));W.options={index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions},g._loadCompleteReject(W)},E.ontimeout=function(D){g.cancel();var P=new wt(g._url,g._request,{status:408},"timeout");g._onTimeout&&(P.isTimeout=!0,g._onTimeout(P,{index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions})),P.options={index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions},g._loadCompleteReject(P)};var _=this._headers||{},S=ki(f);S&&(_.Range=S),_&&Object.keys(_).forEach(function(D){E.setRequestHeader(D,_[D])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",f),E.send(this._body)}catch(D){D.options={index:this._index,range:f,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(D)}}},{key:"_onReadyStatechange",value:function(f){var g=f.target;g.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(f){var g,E=f.target.status;if(E<200||E>299){var _=new wt(this._url,null,ur(ur({},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,D=!1,P,F=((g=this._range)===null||g===void 0?void 0:g.length)>0?this._range[0]:0;if(this._responseType===hr.ARRAY_BUFFER){var H,W=new Uint8Array(f.target.response);if(P=F+this._receivedLength,W&&W.byteLength>0){this._receivedLength+=W.byteLength;var $=Date.now()-this._startTime,ee=qr(this._receivedLength,$);this.emit(_e.REAL_TIME_SPEED,{speed:ee,len:this._receivedLength,time:$,vid:this._vid,index:this._index,range:[P,F+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]?D=!1:D=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",P,"end ",F+this._receivedLength,",dataLen,",W?W.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",D)}else D=!0,S=f.target.response;var Z={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&&(Z=this._transformResponse(Z,this._url)||Z),this._onProgress&&this._onProgress(S,D,{index:this._index,vid:this._vid,range:[P,F+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},Z),D?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(zr(this._onProgress?null:S,D,Z,Z.headers["content-length"],Z.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,Kr(or(o.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 g=f.getAllResponseHeaders().trim().split(`\r
31
+ `),E={},_=no(g),S;try{for(_.s();!(S=_.n()).done;){var D=S.value,P=D.split(": ");E[P[0].toLowerCase()]=P.slice(1).join(": ")}}catch(F){_.e(F)}finally{_.f()}return E}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),o}(yo.default);var Kh=["retry","retryDelay","onRetryError","transformError"],_o=function(){function v(m,o){He(this,v),this.promise=lr(),this.alive=!!o.onProgress,!o.logger&&(o.logger=new Ct("Loader")),this._loaderType=m,this._loader=m===Gt.FETCH&&typeof fetch<"u"?new $r:new Eo,this._config=o,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=o.retryCheckFunc,this._logger=o.logger}return Ke(v,[{key:"exec",value:function(){var o=this,h=this._config,f=h.retry,g=h.retryDelay,E=h.onRetryError,_=h.transformError,S=io(h,Kh),D=function(){var P=Rt(Xe().mark(function F(){var H,W,$;return Xe().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:return Z.prev=0,Z.next=3,o._loader.load(S);case 3:H=Z.sent,o.promise.resolve(H),Z.next=27;break;case 7:if(Z.prev=7,Z.t0=Z.catch(0),o._loader.running=!1,o._logger.debug("[task request catch err]",Z.t0),!o._canceled){Z.next=13;break}return Z.abrupt("return");case 13:if(Z.t0.loaderType=o._loaderType,Z.t0.retryCount=o._retryCount,W=Z.t0,_&&(W=_(W)||W),E&&o._retryCount>0&&E(W,o._retryCount,{index:S.index,vid:S.vid,range:S.range,priOptions:S.priOptions}),o._retryCount++,$=!0,o._retryCheckFunc&&($=o._retryCheckFunc(Z.t0)),!($&&o._retryCount<=f)){Z.next=26;break}return clearTimeout(o._retryTimer),o._logger.debug("[task request setTimeout],retry",o._retryCount,",retry range,",S.range),o._retryTimer=setTimeout(D,g),Z.abrupt("return");case 26:o.promise.reject(W);case 27:case"end":return Z.stop()}},F,null,[[0,7]])}));return function(){return P.apply(this,arguments)}}();return D(),this.promise}},{key:"cancel",value:function(){var m=Rt(Xe().mark(function h(){return Xe().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,g.abrupt("return",this._loader.cancel());case 4:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),v}();function Tn(v){return v&&!v.paused&&!v.ended&&v.playbackRate!==0&&v.readyState!==0}function An(v){if(!v)return{};if(typeof v.getVideoPlaybackQuality=="function"){var m=v.getVideoPlaybackQuality();return{droppedVideoFrames:m.droppedVideoFrames||m.corruptedVideoFrames,totalVideoFrames:m.totalVideoFrames,creationTime:m.creationTime}}return{droppedVideoFrames:v.webkitDroppedFrameCount,totalVideoFrames:v.webkitDecodedFrameCount,creationTime:performance.now()}}function bn(){for(var v=arguments.length,m=new Array(v),o=0;o<v;o++)m[o]=arguments[o];if(m=m.filter(Boolean),m.length<2)return m[0];var h=new Uint8Array(m.reduce(function(g,E){return g+E.byteLength},0)),f=0;return m.forEach(function(g){h.set(g,f),f+=g.byteLength}),h}function Ln(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(m){return setTimeout(m,v)})}var So=Ar(xr()),xn=function(v){Ut(o,v);var m=Bt(o);function o(h){var f;return He(this,o),f=m.call(this,h),q(pe(f),"type",Gt.FETCH),q(pe(f),"_queue",[]),q(pe(f),"_alive",[]),q(pe(f),"_currentTask",null),q(pe(f),"_finnalUrl",""),q(pe(f),"_config",void 0),f._config=mo(h),(f._config.loaderType===Gt.XHR||!$r.isSupported())&&(f.type=Gt.XHR),f.log=h.logger,f}return Ke(o,[{key:"isFetch",value:function(){return this.type===Gt.FETCH}},{key:"load",value:function(f){var g=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&&Sn(E.headers)&&(E.headers=Object.assign({},E.headers)),E.body&&Sn(E.body)&&(E.body=Object.assign({},E.body)),E.transformRequest&&(E=E.transformRequest(E)||E),E.logger=this.log;var _=new _o(this.type,E);return _.loader.on(_e.REAL_TIME_SPEED,function(S){g.emit(_e.REAL_TIME_SPEED,S)}),this._queue.push(_),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),_.promise}},{key:"cancel",value:function(){var h=Rt(Xe().mark(function g(){var E;return Xe().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return E=this._queue.map(function(D){return D.cancel()}).concat(this._alive.map(function(D){return D.cancel()})),this._currentTask&&E.push(this._currentTask.cancel()),this._queue=[],this._alive=[],S.next=6,Promise.all(E);case 6:return S.next=8,Ln();case 8:case"end":return S.stop()}},g,this)}));function f(){return h.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 g=this._currentTask.exec().catch(function(E){});g&&typeof g.finally=="function"&&g.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 $r.isSupported()}}]),o}(So.default);var Rn=function(){function v(){He(this,v),q(this,"_prevCurrentTime",0)}return Ke(v,[{key:"do",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,f=arguments.length>2?arguments[2]:void 0,g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(o){var E=o.currentTime,_=0;if(this._prevCurrentTime===E){var S=tt.info(tt.get(o),E);if(!S.buffers.length)return;f&&S.nextStart||S.nextStart&&S.nextStart-E<h?_=S.nextStart+.1:S.end&&S.end-E>g&&!o.seeking&&(_=E+.1)}this._prevCurrentTime=E,_&&E!==_&&(o.currentTime=_)}}}]),v}();var Cn=function(){function v(m){var o=this;He(this,v),q(this,"_seiSet",new Set),this.emitter=m,m.on(_e.SEI,function(h){h&&o._seiSet.add(h)})}return Ke(v,[{key:"throw",value:function(o,h){var f=this;if(!(o==null||!this._seiSet.size)){var g=o-.2,E=o+.2,_=[];this._seiSet.forEach(function(S){S.time>=g&&S.time<=E&&_.push(S)}),_.forEach(function(S){f._seiSet.delete(S),f.emitter.emit(_e.SEI_IN_TIME,S)}),h&&this._seiSet.forEach(function(S){S.time<o-5&&f._seiSet.delete(S)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),v}();var Wh=1e3,jh=50,Yh=3,zh=3e3,kn=function(){function v(m){He(this,v),q(this,"_chunkSpeed",0),q(this,"_chunkCache",[]),q(this,"_speeds",[]),q(this,"_totalSize",0),q(this,"_totalCost",0),this._opts=m||{}}return Ke(v,[{key:"addRecord",value:function(o,h){!o||!h||(this._speeds.push(8e3*o/h),this._speeds=this._speeds.slice(-Yh))}},{key:"addChunkRecord",value:function(o,h){var f,g;if(!(!o||!h||o<(((f=this._opts)===null||f===void 0?void 0:f.skipChunkSize)||Wh))){this._totalSize+=o,this._totalCost+=h,this._chunkSpeed=8e3*o/h,this._chunkCache.push({size:o,duration:h,timestamp:performance.now()});var E=((g=this._opts)===null||g===void 0?void 0:g.chunkCountForSpeed)||jh;this._chunkCache.length>E&&(this._chunkCache=this._chunkCache.slice(-E))}}},{key:"getAvgSpeed",value:function(){var o;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 h=this._chunkCache[this._chunkCache.length-1],f=performance.now()-h.timestamp;f>(((o=this._opts)===null||o===void 0?void 0:o.longtimeNoReceived)||zh)&&this._chunkCache.push({size:0,duration:f,timestamp:performance.now()});var g=this._chunkCache.reduce(function(_,S){return _+=S.size},0),E=this._chunkCache.reduce(function(_,S){return _+=S.duration},0);return 8e3*g/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}}]),v}();var xc=Ar(xr());var To=function(){function v(m){He(this,v),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=m}return Ke(v,[{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(o){this.encodeType=o}},{key:"setFpsFromScriptData",value:function(o){var h,f=o.data,g=f==null||(h=f.onMetaData)===null||h===void 0?void 0:h.framerate;g&&g>0&&g<100&&(this.fps=g)}},{key:"setVideoMeta",value:function(o){if(this.width=o.width,this.height=o.height,this.videoCodec=o.codec,this.encodeType=o.codecType,o.fpsNum&&o.fpsDen){var h=o.fpsNum/o.fpsDen;h>0&&h<100&&(this.fps=h)}}},{key:"setAudioMeta",value:function(o){this.audioCodec=o.codec,this.samplerate=o.sampleRate,this.channelCount=o.channelCount}},{key:"setDomain",value:function(o){this.domain=o.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(o){var h=this;if((!this.fps||this.fps>=100)&&o.length){var f=o.reduce(function(g,E){return g+=E.duration},0)/o.length;this.fps=Math.round(this._timescale/f)}o.forEach(function(g){h._startGopId===-1&&(h._startGopId=g.gopId),g.gopId===h._startGopId&&h.gop++,h._bitsAccumulateDuration+=g.duration/(h._timescale/1e3),h._bitsAccumulateSize+=g.units.reduce(function(E,_){return E+=_.length},0),h._bitsAccumulateDuration>=1e3&&(h.bitrate=h._bitsAccumulateSize*8,h._bitsAccumulateDuration=0,h._bitsAccumulateSize=0)})}}]),v}(),Dn=function(){function v(m){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;He(this,v),q(this,"_core",null),q(this,"_samples",[]),this._core=m,this._timescale=o,this._stats=new To(o),this._bindEvents()}return Ke(v,[{key:"getStats",value:function(){var o,h,f,g,E,_,S,D,P,F,H,W=((o=this._core)===null||o===void 0?void 0:o.media)||{},$=W.currentTime,ee=$===void 0?0:$,Z=W.decodeFps,oe=Z===void 0?0:Z;return ur(ur({},this._stats.getStats()),{},{downloadSpeed:((h=this._core)===null||h===void 0||(f=h.speedInfo)===null||f===void 0?void 0:f.call(h).speed)||0,avgSpeed:((g=this._core)===null||g===void 0||(E=g.speedInfo)===null||E===void 0?void 0:E.call(g).avgSpeed)||0,totalReceivedByte:((_=this._core)===null||_===void 0||(S=_.speedInfo)===null||S===void 0?void 0:S.call(_).totalSize)||0,totalReceivedCost:((D=this._core)===null||D===void 0||(P=D.speedInfo)===null||P===void 0?void 0:P.call(D).totalCost)||0,currentTime:ee,bufferEnd:((F=this._core)===null||F===void 0||(H=F.bufferInfo())===null||H===void 0?void 0:H.remaining)||0,decodeFps:oe})}},{key:"_bindEvents",value:function(){var o=this;this._core.on(_e.DEMUXED_TRACK,function(h){var f=h.videoTrack;return o._stats.updateBitrate(f.samples)}),this._core.on(_e.FLV_SCRIPT_DATA,function(h){o._stats.setFpsFromScriptData(h)}),this._core.on(_e.METADATA_PARSED,function(h){h.type==="video"?o._stats.setVideoMeta(h.track):o._stats.setAudioMeta(h.track)}),this._core.on(_e.TTFB,function(h){o._stats.setDomain(h.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new To(this._timescale)}}]),v}();var $o=Ar(xr());function qh(v,m){var o=v==null?null:typeof Symbol<"u"&&v[Symbol.iterator]||v["@@iterator"];if(o!=null){var h,f,g,E,_=[],S=!0,D=!1;try{if(g=(o=o.call(v)).next,m===0){if(Object(o)!==o)return;S=!1}else for(;!(S=(h=g.call(o)).done)&&(_.push(h.value),_.length!==m);S=!0);}catch(P){D=!0,f=P}finally{try{if(!S&&o.return!=null&&(E=o.return(),Object(E)!==E))return}finally{if(D)throw f}}return _}}function Ae(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function Ao(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,xo(h.key),h)}}function be(v,m,o){return m&&Ao(v.prototype,m),o&&Ao(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function Q(v,m,o){return m=xo(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function Pn(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&In(v,m)}function Ii(v){return Ii=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Ii(v)}function In(v,m){return In=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},In(v,m)}function $h(){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 Xh(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Qh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xh(v)}function On(v){var m=$h();return function(){var h=Ii(v),f;if(m){var g=Ii(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return Qh(this,f)}}function bo(v,m){return Jh(v)||qh(v,m)||Lo(v,m)||rd()}function Vt(v){return Zh(v)||ed(v)||Lo(v)||td()}function Zh(v){if(Array.isArray(v))return wn(v)}function Jh(v){if(Array.isArray(v))return v}function ed(v){if(typeof Symbol<"u"&&v[Symbol.iterator]!=null||v["@@iterator"]!=null)return Array.from(v)}function Lo(v,m){if(v){if(typeof v=="string")return wn(v,m);var o=Object.prototype.toString.call(v).slice(8,-1);if(o==="Object"&&v.constructor&&(o=v.constructor.name),o==="Map"||o==="Set")return Array.from(v);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return wn(v,m)}}function wn(v,m){(m==null||m>v.length)&&(m=v.length);for(var o=0,h=new Array(m);o<m;o++)h[o]=v[o];return h}function td(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
32
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
33
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function id(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function xo(v){var m=id(v,"string");return typeof m=="symbol"?m:String(m)}var Ht={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},er={AV1:"av1",AVC:"avc",HEVC:"hevc"},ze={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus",MP3:"mp3"},yt={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 Ro=function(){function v(){Ae(this,v),Q(this,"id",1),Q(this,"type",Ht.VIDEO),Q(this,"codecType",er.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 be(v,[{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 o=this.samples[0],h=this.samples[this.samples.length-1];return h.dts-o.dts+h.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}}]),v}();var Co=function(){function v(){Ae(this,v),Q(this,"id",2),Q(this,"type",Ht.AUDIO),Q(this,"codecType",ze.AAC),Q(this,"pid",-1),Q(this,"codec",""),Q(this,"container",""),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 be(v,[{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.container)&&(this.codecType===ze.AAC||this.codecType===ze.G711PCMA||this.codecType===ze.G711PCMU||this.codecType===ze.OPUS||this.codecType===ze.MP3))}},{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 o=this.samples[0],h=this.samples[this.samples.length-1];return h.dts-o.dts+h.duration}return 0}}]),v}();var ko=function(){function v(m,o,h){Ae(this,v),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=m,this.originDts=this.dts=o,h&&(this.units=h)}return be(v,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),v}();var Rr=be(function v(m,o,h,f){Ae(this,v),Q(this,"duration",1024),Q(this,"flag",{dependsOn:2,isNonSyncSample:0}),Q(this,"keyframe",!0),this.originPts=this.pts=this.dts=m,this.data=o,this.size=o.byteLength,this.sampleOffset=f,h&&(this.duration=h)});var Do=be(function v(m,o){Ae(this,v),Q(this,"time",0),this.data=m,this.originPts=this.pts=o}),Io=function(v){Pn(o,v);var m=On(o);function o(){return Ae(this,o),m.apply(this,arguments)}return be(o)}(Do),wo=function(v){Pn(o,v);var m=On(o);function o(){return Ae(this,o),m.apply(this,arguments)}return be(o)}(Do),Po=function(){function v(){Ae(this,v),Q(this,"id",3),Q(this,"type",Ht.METADATA),Q(this,"timescale",0),Q(this,"flvScriptSamples",[]),Q(this,"seiSamples",[])}return be(v,[{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)}}]),v}();var pr=function(){function v(m){Ae(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]")}return be(v,[{key:"warn",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).warn.apply(o,[this._prefix].concat(f))}}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();Q(pr,"disabled",!0);var wi=typeof window<"u",Mn=wi&&navigator.userAgent.toLocaleLowerCase(),Oo=wi&&/^((?!chrome|android).)*safari/.test(Mn),Mo=wi&&Mn.includes("firefox"),Fo=wi&&Mn.includes("android");var Cr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"getRateIndexByRate",value:function(o){return v.FREQ.indexOf(o)}},{key:"parseADTS",value:function(o,h){for(var f=o.length,g=0;g+2<f&&!(o[g]===255&&(o[g+1]&246)===240);)g++;if(!(g>=f)){var E=g,_=[],S=(o[g+2]&60)>>>2,D=v.FREQ[S];if(!D)throw new Error("Invalid sampling index: ".concat(S));for(var P=((o[g+2]&192)>>>6)+1,F=(o[g+2]&1)<<2|(o[g+3]&192)>>>6,H=v._getConfig(S,F,P),W=H.config,$=H.codec,ee,Z,oe=0,ue=v.getFrameDuration(D);g+7<f;){if(o[g]!==255||(o[g+1]&246)!==240){g++;continue}if(Z=(o[g+3]&3)<<11|o[g+4]<<3|(o[g+5]&224)>>5,!Z||f-g<Z)break;ee=(~o[g+1]&1)*2,_.push({pts:h+oe*ue,data:o.subarray(g+7+ee,g+Z)}),oe++,g+=Z}return{skip:E,remaining:g>=f?void 0:o.subarray(g),frames:_,samplingFrequencyIndex:S,sampleRate:D,objectType:P,channelCount:F,codec:$,config:W,originCodec:"mp4a.40.".concat(P)}}}},{key:"parseAudioSpecificConfig",value:function(o){if(o.length){var h=o[0]>>>3,f=(o[0]&7)<<1|o[1]>>>7,g=(o[1]&120)>>>3,E=v.FREQ[f];if(E){var _=v._getConfig(f,g,h),S=_.config,D=_.codec;return{samplingFrequencyIndex:f,sampleRate:E,objectType:h,channelCount:g,config:S,codec:D,originCodec:"mp4a.40.".concat(h)}}}}},{key:"getFrameDuration",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*h/o}},{key:"_getConfig",value:function(o,h,f){var g=[],E,_;return Mo?o>=6?(E=5,_=o-3):(E=2,_=o):Fo?(E=2,_=o):(E=5,_=o,o>=6?_=o-3:h===1&&(E=2,_=o)),g[0]=E<<3,g[0]|=(o&14)>>1,g[1]=(o&1)<<7,g[1]|=h<<3,E===5&&(g[1]|=(_&14)>>1,g[2]=(_&1)<<7,g[2]|=8,g[3]=0),{config:g,codec:"mp4a.40.".concat(E)}}},{key:"getSilentFrame",value:function(o,h){switch(o){case"mp4a.40.2":if(h===1)return new Uint8Array([0,200,0,128,35,128]);if(h===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(h===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(h===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(h===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(h===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(h===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(h===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(h===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}}}]),v}();Q(Cr,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Xr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"getFrameDuration",value:function(o){return 20}},{key:"parseHeaderPackets",value:function(o){if(o.length){for(var h=new DataView(o.buffer,o.byteOffset,o.byteLength),f="",g=0;g<8;g++)f+=String.fromCodePoint(o[g]);if(f!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var E=o[9];console.log("Pre-skip",o[10],o[11]);var _=h.getUint32(12,!0),S=h.getInt16(16,!0);if(_){var D="opus",P="opus",F=new Uint8Array(o.buffer,o.byteOffset+8,o.byteLength-8);return{outputGain:S,sampleRate:_,channelCount:E,config:F,codec:D,originCodec:P}}}}}]),v}();var nd=500,No=3,Fn=1e3,Nn=5e3,ad=1e3,sd=200,Uo=5e3,Bo=5,Go=function(){function v(m,o,h){Ae(this,v),this.videoTrack=m,this.audioTrack=o,this.metadataTrack=h,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 be(v,[{key:"fix",value:function(){var o=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;h=Math.round(h*1e3);var E=this.videoTrack,_=this.audioTrack;(f||!g)&&(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&&!g&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(_,E),!g&&h&&(this._audioNextPts=this._videoNextDts=h);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 D=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(P){P.pts=P.originPts-o._baseDts,P.time=Math.max(0,P.pts)/D}),this.metadataTrack.flvScriptSamples.forEach(function(P){P.pts=P.originPts-o._baseDts,P.time=Math.max(0,P.pts)/D})}E.samples.length&&(E.baseMediaDecodeTime=E.samples[0].dts),_.samples.length&&(_.baseMediaDecodeTime=_.samples[0].pts*_.timescale/1e3)}},{key:"_fixVideo",value:function(o){var h=this,f=o.samples;if(f.length){f.forEach(function(ue){ue.dts-=h._baseDts,ue.pts-=h._baseDts,ue.keyframe&&(h._keyFrameInNextChunk=!0)});var g;if(o.fpsNum&&o.fpsDen)g=o.timescale*(o.fpsDen/o.fpsNum);else if(o.length>1){var E=o.samples[0],_=o.samples[f.length-1];g=Math.floor((_.dts-E.dts)/(f.length-1))}else g=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 D=f[0];this._videoNextDts=D.dts}var P=f.length,F=0,H=f[0],W=this._videoNextDts-H.dts;if(Math.abs(W)>sd){if(Math.abs(H.dts-this._lastVideoExceptionChunkFirstDtsDot)>Uo){var $;this._lastVideoExceptionChunkFirstDtsDot=H.dts,o.warnings.push({type:yt.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:H.dts,nextSampleDts:($=f[1])===null||$===void 0?void 0:$.dts,sampleDuration:W})}this._videoTimestampBreak>=Bo?(this._videoNextDts=H.dts,this._videoTimestampBreak=0):(H.dts+=W,H.pts+=W,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var ee=0;ee<P;ee++){var Z=f[ee].dts,oe=f[ee+1];ee<P-1?F=oe.dts-Z:S?F=S.dts-Z:F=g,(F>ad||F<0)&&(this._videoTimestampBreak++,Math.abs(Z-this._lastVideoExceptionLargeGapDot)>Uo&&(this._lastVideoExceptionLargeGapDot=Z,o.warnings.push({type:yt.LARGE_VIDEO_GAP,time:Z/o.timescale,dts:Z,originDts:f[ee].originDts,nextDts:this._videoNextDts,sampleDuration:F,refSampleDuration:g})),F=g),f[ee].duration=F,this._videoNextDts+=F,this._lastVideoDuration=F}}}}},{key:"_fixAudio",value:function(o){var h=this,f=o.samples;f.length&&(f.forEach(function(g){g.dts=g.pts-=h._baseDts}),this._doFixAudioInternal(o,f,1e3))}},{key:"_calculateBaseDts",value:function(o,h){var f=o.samples,g=h.samples;if(!f.length&&!g.length)return!1;var E=1/0,_=1/0;f.length&&(o.baseDts=E=f[0].pts),g.length&&(h.baseDts=_=g[0].dts),this._baseDts=Math.min(E,_);var S=_-E;return Number.isFinite(S)&&Math.abs(S)>nd&&h.warnings.push({type:yt.LARGE_AV_SHIFT,videoBaseDts:_,audioBasePts:E,baseDts:this._baseDts,delta:S}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var o=this._calculateBaseDts(this.audioTrack,this.videoTrack);o&&(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(o,h,f){if(!o.sampleDuration)switch(o.codecType){case ze.AAC:{o.sampleDuration=Cr.getFrameDuration(o.timescale,f);break}case ze.OPUS:{o.sampleDuration=Xr.getFrameDuration(o.samples,f);break}case ze.G711PCMA:case ze.G711PCMU:{o.sampleDuration=this._getG711Duration(o);break}default:console.error("can't fix audio codecType:",o.codecType);break}var g=o.sampleDuration,E=o.codecType===ze.OPUS?20:o.codecType===ze.AAC?1024:g*o.timescale/1e3;if(this._audioNextPts===void 0){var _=h[0];this._audioNextPts=_.pts}for(var S=0;S<h.length;S++){var D=this._audioNextPts,P=h[S],F=P.pts-D;if(S===0&&this._audioTimestampBreak>=Bo&&this._keyFrameInNextChunk&&(D=this._audioNextPts=P.dts,F=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&F>=No*g&&F<=Fn&&!Oo){var H=this._getSilentFrame(o)||h[0].data.subarray(),W=Math.floor(F/g);Math.abs(P.pts-this._lastAudioExceptionGapDot)>Nn&&(this._lastAudioExceptionGapDot=P.pts,o.warnings.push({type:yt.AUDIO_FILLED,pts:P.pts,originPts:P.originPts,count:W,nextPts:D,refSampleDuration:g}));for(var $=0;$<W;$++){var ee=new Rr(Math.floor(this._audioNextPts+g)-Math.floor(this._audioNextPts),H,E);ee.originPts=Math.floor(this._baseDts+D),h.splice(S,0,ee),this._audioNextPts+=g,S++}S--}else if(F<=-No*g&&F>=-1*Fn)Math.abs(P.pts-this._lastAudioExceptionOverlapDot)>Nn&&(this._lastAudioExceptionOverlapDot=P.pts,o.warnings.push({type:yt.AUDIO_DROPPED,pts:P.pts,originPts:P.originPts,nextPts:D,refSampleDuration:g})),h.splice(S,1),S--;else{if(Math.abs(F)>Fn&&(this._audioTimestampBreak++,Math.abs(P.pts-this._lastAudioExceptionLargeGapDot)>Nn&&(this._lastAudioExceptionLargeGapDot=P.pts,o.warnings.push({type:yt.LARGE_AUDIO_GAP,time:P.pts/1e3,pts:P.pts,originPts:P.originPts,nextPts:D,sampleDuration:F,refSampleDuration:g}))),o.codecType===ze.OPUS){var Z=h[h.length-1];Z&&(Z.duration=P.pts-Z.pts)}else P.dts=P.pts=D,P.duration=E;this._audioNextPts+=g}}}},{key:"_getG711Duration",value:function(o){var h=o.sampleSize,f=o.channelCount,g=o.sampleRate,E=o.samples[0];if(E)return E.data.byteLength*2/f/(h/8)/g*1e3}},{key:"_getSilentFrame",value:function(o){return o.codecType===ze.AAC?Cr.getSilentFrame(o.codec,o.channelCount):new Uint8Array(8*o.sampleDuration*o.channelCount)}}]),v}();function kt(){for(var v=arguments.length,m=new Array(v),o=0;o<v;o++)m[o]=arguments[o];m=m.filter(Boolean);var h=new Uint8Array(m.reduce(function(g,E){return g+E.byteLength},0)),f=0;return m.forEach(function(g){h.set(g,f),f+=g.byteLength}),h}var yv=Math.pow(2,32);function kr(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(v[m]<<24>>>0)+(v[m+1]<<16)+(v[m+2]<<8)+(v[m+3]||0)}function Vo(v){for(var m="avc1.",o,h=0;h<3;h++)o=v[h].toString(16),o.length<2&&(o="0".concat(o)),m+=o;return m}function Un(v){if(!Array.isArray(v)){for(var m=[],o="",h=0;h<v.length;h++)h%2&&(o=v[h-1]+v[h],m.push(parseInt(o,16)),o="");return m}return v.map(function(f){return parseInt(f,16)})}var tr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseAnnexB",value:function(o){var h=o.byteLength-1,f=0;do{if(o[h]===0)f++;else break;h--}while(h>0);f>=3&&(o=o.subarray(0,h+1));for(var g=o.length,E=2,_=0;o[E]!==null&&o[E]!==void 0&&o[E]!==1;)E++;if(E++,_=E+2,_>=g)return[];for(var S=[];_<g;)switch(o[_]){case 0:if(o[_-1]!==0){_+=2;break}else if(o[_-2]!==0){_++;break}else if(_<g-1&&o[_+1]!==1){_++;break}E!==_-2&&S.push(o.subarray(E,_-2));do _++;while(o[_]!==1&&_<g);E=_+1,_=E+2;break;case 1:if(o[_-1]!==0||o[_-2]!==0){_+=3;break}E!==_-2&&S.push(o.subarray(E,_-2)),E=_+1,_=E+2;break;default:_+=3;break}return E<g&&S.push(o.subarray(E)),S}},{key:"parseAvcC",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(o.length<4)){for(var f=o.length,g=[],E=0,_;E+h<f;)if(_=kr(o,E),h===3&&(_>>>=8),E+=h,!!_){if(E+_>f)break;g.push(o.subarray(E,E+_)),E+=_}return g}}},{key:"parseSEI",value:function(o,h){for(var f=o.length,g=h?2:1,E=0,_=0,S="";o[g]===255;)E+=255,g++;for(E+=o[g++];o[g]===255;)_+=255,g++;if(_+=o[g++],E===5&&f>g+16)for(var D=0;D<16;D++)S+=o[g].toString(16),g++;return{payload:o.subarray(g,g+_),type:E,size:_,uuid:S}}},{key:"removeEPB",value:function(o){for(var h=o.byteLength,f=[],g=1;g<h-2;)o[g]===0&&o[g+1]===0&&o[g+2]===3?(f.push(g+2),g+=2):g++;if(!f.length)return o;var E=h-f.length,_=new Uint8Array(E),S=0;for(g=0;g<E;S++,g++)S===f[0]&&(S++,f.shift()),_[g]=o[S];return _}}]),v}();var Qr=function(){function v(m){if(Ae(this,v),Q(this,"_bytesAvailable",void 0),Q(this,"_bitsAvailable",0),Q(this,"_word",0),!m)throw new Error("ExpGolomb data params is required");this._data=m,this._bytesAvailable=m.byteLength,this._bytesAvailable&&this._loadWord()}return be(v,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var o=this._data.byteLength-this._bytesAvailable,h=Math.min(4,this._bytesAvailable);if(h===0)throw new Error("No bytes available");var f=new Uint8Array(4);f.set(this._data.subarray(o,o+h)),this._word=new DataView(f.buffer).getUint32(0),this._bitsAvailable=h*8,this._bytesAvailable-=h}},{key:"skipBits",value:function(o){if(this._bitsAvailable>o)this._word<<=o,this._bitsAvailable-=o;else{o-=this._bitsAvailable;var h=Math.floor(o/8);o-=h*8,this._bytesAvailable-=h,this._loadWord(),this._word<<=o,this._bitsAvailable-=o}}},{key:"readBits",value:function(o){if(o>32)throw new Error("Cannot read more than 32 bits");var h=Math.min(this._bitsAvailable,o),f=this._word>>>32-h;return this._bitsAvailable-=h,this._bitsAvailable>0?this._word<<=h:this._bytesAvailable>0&&this._loadWord(),h=o-h,h>0&&this._bitsAvailable?f<<h|this.readBits(h):f}},{key:"skipLZ",value:function(){var o;for(o=0;o<this._bitsAvailable;++o)if((this._word&2147483648>>>o)!==0)return this._word<<=o,this._bitsAvailable-=o,o;return this._loadWord(),o+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var o=this.skipLZ();return this.readBits(o+1)-1}},{key:"readEG",value:function(){var o=this.readUEG();return 1&o?1+o>>>1:-1*(o>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(o){for(var h=8,f=8,g,E=0;E<o;E++)f!==0&&(g=this.readEG(),f=(h+g+256)%256),h=f===0?h:f}}]),v}();var Ho=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(o){if(!(o.length<7)){for(var h=(o[4]&3)+1,f,g=[],E=[],_=6,S=o[5]&31,D,P=0;P<S;P++)if(D=o[_]<<8|o[_+1],_+=2,!!D){var F=o.subarray(_,_+D);_+=D,g.push(F),f||(f=v.parseSPS(tr.removeEPB(F)))}var H=o[_];_++;for(var W,$=0;$<H;$++)W=o[_]<<8|o[_+1],_+=2,W&&(E.push(o.subarray(_,_+W)),_+=W);return{sps:f,spsArr:g,ppsArr:E,nalUnitSize:h}}}},{key:"parseSPS",value:function(o){var h=new Qr(o);h.readUByte();var f=h.readUByte(),g=h.readUByte(),E=h.readUByte();h.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=h.readUEG();if(S<=3&&(_=[0,420,422,444][S]),S===3&&h.skipBits(1),h.skipUEG(),h.skipUEG(),h.skipBits(1),h.readBool())for(var D=S!==3?8:12,P=0;P<D;P++)h.readBool()&&(P<6?h.skipScalingList(16):h.skipScalingList(64))}h.skipUEG();var F=h.readUEG();if(F===0)h.readUEG();else if(F===1){h.skipBits(1),h.skipUEG(),h.skipUEG();for(var H=h.readUEG(),W=0;W<H;W++)h.skipUEG()}h.skipUEG(),h.skipBits(1);var $=h.readUEG(),ee=h.readUEG(),Z=h.readBits(1);Z===0&&h.skipBits(1),h.skipBits(1);var oe=0,ue=0,Se=0,he=0;h.readBool()&&(oe=h.readUEG(),ue=h.readUEG(),Se=h.readUEG(),he=h.readUEG());var se,ce,Me,We,ye;if(h.readBool()){if(h.readBool()){var Ie=h.readUByte();switch(Ie){case 1:se=[1,1];break;case 2:se=[12,11];break;case 3:se=[10,11];break;case 4:se=[16,11];break;case 5:se=[40,33];break;case 6:se=[24,11];break;case 7:se=[20,11];break;case 8:se=[32,11];break;case 9:se=[80,33];break;case 10:se=[18,11];break;case 11:se=[15,11];break;case 12:se=[64,33];break;case 13:se=[160,99];break;case 14:se=[4,3];break;case 15:se=[3,2];break;case 16:se=[2,1];break;case 255:{se=[h.readUByte()<<8|h.readUByte(),h.readUByte()<<8|h.readUByte()];break}}}if(h.readBool()&&h.readBool(),h.readBool()&&(h.readBits(4),h.readBool()&&h.readBits(24)),h.readBool()&&(h.readUEG(),h.readUEG()),h.readBool()){var Ze=h.readBits(32),w=h.readBits(32);ce=h.readBool(),Me=w,We=Ze*2,ye=Me/We}}return{codec:Vo(o.subarray(1,4)),profileIdc:f,profileCompatibility:g,levelIdc:E,chromaFormat:_,width:Math.ceil(($+1)*16-2*(oe+ue)),height:(2-Z)*(ee+1)*16-(Z?2:4)*(Se+he),sarRatio:se,fpsNum:Me,fpsDen:We,fps:ye,fixedFrame:ce}}}]),v}();var Ko=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(o.length<23)){h=h||{};for(var f=(o[21]&3)+1,g,E,_=[],S=[],D=[],P=23,F=o[22],H,W,$,ee=0;ee<F;ee++){H=o[P]&63,W=o[P+1]<<8|o[P+2],P+=3;for(var Z=0;Z<W;Z++)if($=o[P]<<8|o[P+1],P+=2,!!$){switch(H){case 32:{var oe=o.subarray(P,P+$);g||(g=v.parseVPS(tr.removeEPB(oe),h)),D.push(oe)}break;case 33:{var ue=o.subarray(P,P+$);E||(E=v.parseSPS(tr.removeEPB(ue),h)),_.push(ue)}break;case 34:S.push(o.subarray(P,P+$));break}P+=$}}return{hvcC:h,sps:E,spsArr:_,ppsArr:S,vpsArr:D,nalUnitSize:f}}}},{key:"parseVPS",value:function(o,h){h=h||{};var f=new Qr(o);f.readUByte(),f.readUByte(),f.readBits(12);var g=f.readBits(3);return h.numTemporalLayers=Math.max(h.numTemporalLayers||0,g+1),f.readBits(17),v._parseProfileTierLevel(f,g,h),h}},{key:"parseSPS",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};h=h||{};var f=new Qr(o);f.readUByte(),f.readUByte(),f.readBits(4);var g=f.readBits(3);h.numTemporalLayers=Math.max(g+1,h.numTemporalLayers||0),h.temporalIdNested=f.readBits(1),v._parseProfileTierLevel(f,g,h),f.readUEG();var E=h.chromaFormatIdc=f.readUEG(),_=420;E<=3&&(_=[0,420,422,444][E]);var S=0;E===3&&(S=f.readBits(1));var D=f.readUEG(),P=f.readUEG(),F=f.readBits(1),H,W,$,ee;if(F===1&&(H=f.readUEG(),W=f.readUEG(),$=f.readUEG(),ee=f.readUEG()),h.bitDepthLumaMinus8=f.readUEG(),h.bitDepthChromaMinus8=f.readUEG(),F===1){var Z=(E===1||E===2)&&S===0?2:1,oe=E===1&&S===0?2:1;D-=Z*(W+H),P-=oe*(ee+$)}return{codec:"hev1.1.6.L93.B0",width:D,height:P,chromaFormat:_,hvcC:h}}},{key:"_parseProfileTierLevel",value:function(o,h,f){var g=f.generalTierFlag||0;f.generalProfileSpace=o.readBits(2),f.generalTierFlag=Math.max(o.readBits(1),g),f.generalProfileIdc=Math.max(o.readBits(5),f.generalProfileIdc||0),f.generalProfileCompatibilityFlags=o.readBits(32),f.generalConstraintIndicatorFlags=[o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8)];var E=o.readBits(8);g<f.generalTierFlag?f.generalLevelIdc=E:f.generalLevelIdc=Math.max(E,f.generalLevelIdc||0);var _=[],S=[];if(h>o.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(h));for(var D=0;D<h;D++)_[D]=o.readBits(1),S[D]=o.readBits(1);h>0&&o.readBits((8-h)*2);for(var P=0;P<h;P++)_[P]!==0&&(o.readBits(2),o.readBits(1),o.readBits(5),o.readBits(16),o.readBits(16),o.readBits(4),o.readBits(16),o.readBits(16),o.readBits(12)),S[P]!==0&&o.readBits(8)}}]),v}();var Bn=function(){function v(){Ae(this,v)}return be(v,null,[{key:"decode",value:function(o){for(var h=[],f=o,g=0,E=o.length;g<E;){if(f[g]<128){h.push(String.fromCharCode(f[g])),++g;continue}else if(!(f[g]<192)){if(f[g]<224){if(v._checkContinuation(f,g,1)){var _=(f[g]&31)<<6|f[g+1]&63;if(_>=128){h.push(String.fromCharCode(_&65535)),g+=2;continue}}}else if(f[g]<240){if(v._checkContinuation(f,g,2)){var S=(f[g]&15)<<12|(f[g+1]&63)<<6|f[g+2]&63;if(S>=2048&&(S&63488)!==55296){h.push(String.fromCharCode(S&65535)),g+=3;continue}}}else if(f[g]<248&&v._checkContinuation(f,g,3)){var D=(f[g]&7)<<18|(f[g+1]&63)<<12|(f[g+2]&63)<<6|f[g+3]&63;if(D>65536&&D<1114112){D-=65536,h.push(String.fromCharCode(D>>>10|55296)),h.push(String.fromCharCode(D&1023|56320)),g+=4;continue}}}h.push("\uFFFD"),++g}return h.join("")}},{key:"_checkContinuation",value:function(o,h,f){var g=o;if(h+f<g.length){for(;f--;)if((g[++h]&192)!==128)return!1;return!0}else return!1}}]),v}();var Wo=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parse",value:function(o){if(!(o.length<3)){var h={},f=v._parseValue(new DataView(o.buffer,o.byteOffset,o.byteLength)),g=v._parseValue(new DataView(o.buffer,o.byteOffset+f.size,o.byteLength-f.size));return h[f.data]=g.data,h}}},{key:"_parseValue",value:function(o){var h=o.byteLength,f=o.getUint8(0),g=1,E=!1,_;switch(f){case 0:_=o.getFloat64(1),g+=8;break;case 1:{_=!!o.getUint8(1),g+=1;break}case 2:{var S=v._parseString(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g)),D=S.data,P=S.size;_=D,g+=P}break;case 3:{_={};var F=0;for((o.getUint32(h-4)&16777215)===9&&(F=3);g<h-4;){var H=v._parseObject(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g-F)),W=H.size,$=H.data,ee=H.isEnd;if(ee)break;_[$.name]=$.value,g+=W}if(g<=h-3){var Z=o.getUint32(g-1)&16777215;Z===9&&(g+=3)}}break;case 8:{_={},g+=4;var oe=0;for((o.getUint32(h-4)&16777215)===9&&(oe=3);g<h-8;){var ue=v._parseObject(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g-oe)),Se=ue.size,he=ue.data,se=ue.isEnd;if(se)break;_[he.name]=he.value,g+=Se}if(g<=h-3){var ce=o.getUint32(g-1)&16777215;ce===9&&(g+=3)}}break;case 9:_=void 0,g=1,E=!0;break;case 10:{_=[];var Me=o.getUint32(1);g+=4;for(var We=0;We<Me;We++){var ye=v._parseValue(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g)),Ie=ye.data,Ze=ye.size;_.push(Ie),g+=Ze}}break;case 11:{var w=o.getFloat64(g)+o.getInt16(g+8)*6e4;_=new Date(w),g+=10}break;case 12:{var U=o.getUint32(1);g+=4,_="",U>0&&(_=Bn.decode(new Uint8Array(o.buffer,o.byteOffset+g,U))),g+=U}break;default:g=h;break}return{data:_,size:g,isEnd:E}}},{key:"_parseString",value:function(o){var h=o.getUint16(0),f="";return h>0&&(f=Bn.decode(new Uint8Array(o.buffer,o.byteOffset+2,h))),{data:f,size:2+h}}},{key:"_parseObject",value:function(o){if(!(o.byteLength<3)){var h=v._parseString(o),f=v._parseValue(new DataView(o.buffer,o.byteOffset+h.size,o.byteLength-h.size));return{data:{name:h.data,value:f.data},size:h.size+f.size,isEnd:f.isEnd}}}}]),v}();var Kt={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Wt=new pr("FlvDemuxer"),Pi=function(){function v(m,o,h){Ae(this,v),Q(this,"_headerParsed",!1),Q(this,"_remainingData",null),Q(this,"_gopId",0),Q(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=m||new Ro,this.audioTrack=o||new Co,this.metadataTrack=h||new Po,this._fixer=new Go(this.videoTrack,this.audioTrack,this.metadataTrack)}return be(v,[{key:"demux",value:function(o){var h,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,E=arguments.length>3?arguments[3]:void 0,_=this.audioTrack,S=this.videoTrack,D=this.metadataTrack;if((f||!g)&&(this._remainingData=null),f&&(this._headerParsed=!1),f?(S.reset(),_.reset(),D.reset()):(S.samples=[],_.samples=[],D.seiSamples=[],D.flvScriptSamples=[],S.warnings=[],_.warnings=[],this._remainingData&&(o=kt(this._remainingData,o),this._remainingData=null)),!o.length)return{videoTrack:S,audioTrack:_,metadataTrack:D};var P=0;if(!this._headerParsed){if(!v.probe(o))throw new Error("Invalid flv file");_.present=(o[4]&4)>>>2!==0,S.present=(o[4]&1)!==0,this._headerParsed=!0,P=kr(o,5)+4}for(var F=o.length,H,W,$,ee,Z;P+15<F&&(H=o[P],W=o[P+1]<<16|o[P+2]<<8|o[P+3],!(P+15+W>F));)$=(o[P+7]<<24>>>0)+(o[P+4]<<16)+(o[P+5]<<8)+o[P+6],P+=11,ee=o.subarray(P,P+W),H===8?this._parseAudio(ee,$):H===9?(E&&(this.seamlessLoadingSwitching=!0),this._parseVideo(ee,$)):H===18?this._parseScript(ee,$):Wt.warn("Invalid tag type: ".concat(H)),P+=W,Z=kr(o,P),Z!==11+W&&Wt.warn("Invalid PrevTagSize ".concat(Z," (").concat(11+W,")")),P+=4;P<F&&(this._remainingData=o.subarray(P)),_.formatTimescale=S.formatTimescale=S.timescale=D.timescale=1e3,_.timescale=_.codecType===ze.OPUS?1e3:_.sampleRate||0,!_.exist()&&_.hasSample()&&_.reset(),!S.exist()&&S.hasSample()&&S.reset();var oe=D.flvScriptSamples[D.flvScriptSamples.length-1],ue=oe==null||(h=oe.data)===null||h===void 0?void 0:h.onMetaData;return ue&&(S!=null&&S.exist()&&(ue.hasOwnProperty("duration")&&(S.duration=ue.duration*1e3),ue.hasOwnProperty("width")&&ue.hasOwnProperty("height")&&(S.width=ue.width,S.height=ue.height)),_!=null&&_.exist()&&ue.hasOwnProperty("duration")&&(_.duration=ue.duration*1e3)),{videoTrack:S,audioTrack:_,metadataTrack:D}}},{key:"fix",value:function(o,h,f){return this._fixer.fix(o,h,f),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(o,h,f,g,E){return this.demux(o,h,f,E),this.fix(g,h,f)}},{key:"_parseAudio",value:function(o,h){if(o.length){var f=(o[0]&240)>>>4,g=this.audioTrack;if(f!==Kt.AAC&&f!==Kt.G711A&&f!==Kt.G711M&&f!==Kt.OPUS){Wt.warn("Unsupported sound format: ".concat(f)),g.reset();return}if(f!==Kt.AAC&&f!==Kt.OPUS){var E=(o[0]&12)>>2,_=(o[0]&2)>>1,S=o[0]&1;g.sampleRate=v.AUDIO_RATE[E],g.sampleSize=_?16:8,g.channelCount=S+1}switch(f){case Kt.G711A:case Kt.G711M:this._parseG711(o,h,f);break;case Kt.AAC:this._parseAac(o,h);break;case Kt.OPUS:this._parseOpus(o,h);break}}}},{key:"_parseOpus",value:function(o,h){var f=this.audioTrack,g=o[1];switch(f.codecType=ze.OPUS,g){case 0:{var E=Xr.parseHeaderPackets(o.subarray(2));E?(f.codec=E.codec,f.channelCount=E.channelCount,f.sampleRate=E.sampleRate,f.config=E.config,f.sampleDuration=Xr.getFrameDuration([],f.timescale)):(f.reset(),Wt.warn("Cannot parse AudioSpecificConfig",o));break}case 1:{if(h==null)return;var _=new Rr(h,o.subarray(2),f.sampleDuration);f.samples.push(_);break}default:Wt.warn("Unknown OpusPacketType: ".concat(g))}}},{key:"_parseG711",value:function(o,h,f){var g=this.audioTrack,E=o.subarray(1);if(!(E.byteLength<1)){var _=new Rr(h,E);g.codecType=f===7?ze.G711PCMA:ze.G711PCMU,g.sampleRate=8e3,g.codec=g.codecType,g.samples.push(_)}}},{key:"_parseAac",value:function(o,h){var f=this.audioTrack;if(f.codecType=ze.AAC,o[1]===0){var g=Cr.parseAudioSpecificConfig(o.subarray(2));g?(f.codec=g.codec,f.channelCount=g.channelCount,f.sampleRate=g.sampleRate,f.config=g.config,f.objectType=g.objectType,f.sampleRateIndex=g.samplingFrequencyIndex):(f.reset(),Wt.warn("Cannot parse AudioSpecificConfig",o))}else if(o[1]===1){if(h==null)return;f.samples.push(new Rr(h,o.subarray(2)))}else Wt.warn("Unknown AACPacketType: ".concat(o[1]))}},{key:"_parseVideo",value:function(o,h){var f=this;if(!(o.length<6)){var g=(o[0]&240)>>>4,E=o[0]&15,_=this.videoTrack;if(E!==7&&E!==12){_.reset(),Wt.warn("Unsupported codecId: ".concat(E));return}var S=E===12;_.codecType=S?er.HEVC:er.AVC;var D=o[1],P=(o[2]<<16|o[3]<<8|o[4])<<8>>8;if(D===0){var F=o.subarray(5),H=S?Ko.parseHEVCDecoderConfigurationRecord(F):Ho.parseAVCDecoderConfigurationRecord(F);if(H){var W=H.hvcC,$=H.sps,ee=H.ppsArr,Z=H.spsArr,oe=H.vpsArr,ue=H.nalUnitSize;W&&(_.hvcC=_.hvcC||W),$&&(_.codec=$.codec,_.width=$.width,_.height=$.height,_.sarRatio=$.sarRatio,_.fpsNum=$.fpsNum,_.fpsDen=$.fpsDen),Z.length&&(_.sps=Z),ee.length&&(_.pps=ee),oe&&oe.length&&(_.vps=oe),ue&&(_.nalUnitSize=ue)}else Wt.warn("Cannot parse ".concat(S?"HEVC":"AVC","DecoderConfigurationRecord"),o)}else if(D===1){var Se=tr.parseAvcC(o.subarray(5),_.nalUnitSize);if(Se=this._checkAddMetaNalToUnits(S,Se,_),Se&&Se.length){var he=new ko(h+P,h,Se);if(this.seamlessLoadingSwitching&&h<_.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,g===1&&(he.setToKeyframe(),_.lastKeyFrameDts=h),_.samples.push(he),Se.forEach(function(se){var ce=S?se[0]>>>1&63:se[0]&31;switch(ce){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!S&&ce!==5||S&&ce===5)break;he.setToKeyframe();break;case 6:case 39:case 40:if(!S&&ce!==6||S&&ce===6)break;f.metadataTrack.seiSamples.push(new wo(tr.parseSEI(tr.removeEPB(se),S),h+P));break}}),he.keyframe&&this._gopId++,he.gopId=this._gopId}else Wt.warn("Cannot parse NALUs",o)}else D===2||Wt.warn("Unknown AVCPacketType: ".concat(D))}}},{key:"_checkAddMetaNalToUnits",value:function(o,h,f){if(!o||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,h;var g=h.map(function(E){return E[0]>>>1&63});return g.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,h):(h.unshift(f.pps[0]),h.unshift(f.sps[0]),h.unshift(f.vps[0]),h.filter(Boolean))}},{key:"_parseScript",value:function(o,h){this.metadataTrack.flvScriptSamples.push(new Io(Wo.parse(o),h))}}],[{key:"probe",value:function(o){return o[0]!==70||o[1]!==76||o[2]!==86||o[3]!==1?!1:kr(o,5)>=9}}]),v}();Q(Pi,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function od(v){for(var m=0,o=arguments.length,h=new Array(o>1?o-1:0),f=1;f<o;f++)h[f-1]=arguments[f];h.forEach(function(_){m+=_.length});var g=new v(m),E=0;return h.forEach(function(_){g.set(_,E),E+=_.length}),g}var ft=function(){function v(){Ae(this,v),this.buffer=new Uint8Array(0)}return be(v,[{key:"write",value:function(){for(var o=this,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];f.forEach(function(E){E?o.buffer=od(Uint8Array,o.buffer,E):window.console.warn(E)})}}],[{key:"writeUint16",value:function(o){return new Uint8Array([o>>8&255,o&255])}},{key:"writeUint32",value:function(o){return new Uint8Array([o>>24,o>>16&255,o>>8&255,o&255])}}]),v}();var jo=Math.pow(2,32)-1,Le=function(){function v(){Ae(this,v)}return be(v,null,[{key:"box",value:function(o){for(var h=arguments.length,f=new Array(h>1?h-1:0),g=1;g<h;g++)f[g-1]=arguments[g];f=f.filter(Boolean);var E=8+f.reduce(function(D,P){return D+P.byteLength},0),_=new Uint8Array(E);_[0]=E>>24&255,_[1]=E>>16&255,_[2]=E>>8&255,_[3]=E&255,_.set(o,4);var S=8;return f.forEach(function(D){_.set(D,S),S+=D.byteLength}),_}},{key:"ftyp",value:function(o){var h=o.find(function(f){return f.type===Ht.VIDEO&&f.codecType===er.HEVC});return h?v.FTYPHEV1:v.FTYPAVC1}},{key:"initSegment",value:function(o){var h=v.ftyp(o),f=kt(h,v.moov(o));return f}},{key:"pssh",value:function(o){var h=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],Un(o.kid),[0,0,0,0]));return v.box(v.types.pssh,h)}},{key:"moov",value:function(o){if(o[0].useEME&&(o[0].encv||o[0].enca)){o[0].pssh||(o[0].pssh={kid:o[0].kid});var h=this.pssh(o[0].pssh);return v.box.apply(v,[v.types.moov,v.mvhd(o[0].mvhdDurtion||o[0].duration,o[0].mvhdTimecale||o[0].timescale),v.mvex(o)].concat(Vt(o.map(function(f){return v.trak(f)})),[h]))}else return v.box.apply(v,[v.types.moov,v.mvhd(o[0].mvhdDurtion||o[0].duration,o[0].mvhdTimecale||o[0].timescale)].concat(Vt(o.map(function(f){return v.trak(f)})),[v.mvex(o)]))}},{key:"mvhd",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=v.box(v.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255,o>>24&255,o>>16&255,o>>8&255,o&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(o){var h=v.box(v.types.trak,v.tkhd(o.id,o.tkhdDuration||0,o.width,o.height),v.mdia(o));return h}},{key:"tkhd",value:function(o,h){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,E=v.box(v.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,o>>24&255,o>>16&255,o>>8&255,o&255,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&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,g>>8&255,g&255,0,0]));return E}},{key:"mdia",value:function(o){var h=v.box(v.types.mdia,v.mdhd(o.duration,o.timescale),v.hdlr(o.type),v.minf(o));return h}},{key:"mdhd",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=v.box(v.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255,o>>24&255,o>>16&255,o>>8&255,o&255,85,196,0,0]));return f}},{key:"hdlr",value:function(o){var h=v.box(v.types.hdlr,v.HDLR_TYPES[o]);return h}},{key:"minf",value:function(o){var h=v.box(v.types.minf,o.type===Ht.VIDEO?v.VMHD:v.SMHD,v.DINF,v.stbl(o));return h}},{key:"stbl",value:function(o){var h=[];o&&o.ext&&o.ext.stss&&h.push(v.stss(o.ext.stss.entries));var f=v.box(v.types.stbl,v.stsd(o),v.STTS,h[0],v.STSC,v.STSZ,v.STCO);return f}},{key:"stsd",value:function(o){var h;o.type==="audio"?o.useEME&&o.enca?h=v.enca(o):o.codecType===ze.OPUS?h=v.opus(o):h=v.mp4a(o):o.useEME&&o.encv?h=v.encv(o):o.av1C?h=v.av01(o):h=v.avc1hev1(o);var f=v.box(v.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),h);return f}},{key:"enca",value:function(o){var h=o.enca.channelCount,f=o.enca.sampleRate,g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,h,0,16,0,0,0,0,f>>8&255,f&255,0,0]),E=v.esds(o.config),_=v.sinf(o.enca);return v.box(v.types.enca,g,E,_)}},{key:"encv",value:function(o){var h,f,g=o.sps.length>0?o.sps[0]:[],E=o.pps.length>0?o.pps[0]:[],_=o.width,S=o.height,D=o.sarRatio[0],P=o.sarRatio[1],F=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((h=(f=[1,g[1],g[2],g[3],255,225,g.length>>>8&255,g.length&255]).concat.apply(f,Vt(g)).concat([1,E.length>>>8&255,E.length&255])).concat.apply(h,Vt(E))),W=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),$=v.sinf(o.encv),ee=new Uint8Array([D>>24,D>>16&255,D>>8&255,D&255,P>>24,P>>16&255,P>>8&255,P&255]);return v.box(v.types.encv,F,v.box(v.types.avcC,H),v.box(v.types.btrt,W),$,v.box(v.types.pasp,ee))}},{key:"schi",value:function(o){var h=new Uint8Array([]),f=v.tenc(o);return v.box(v.types.schi,h,f)}},{key:"tenc",value:function(o){var h=new Uint8Array([0,0,0,0,0,0,o.default_IsEncrypted&255,o.default_IV_size&255].concat(Un(o.default_KID)));return v.box(v.types.tenc,h)}},{key:"sinf",value:function(o){var h=new Uint8Array([]),f=new Uint8Array([o.data_format.charCodeAt(0),o.data_format.charCodeAt(1),o.data_format.charCodeAt(2),o.data_format.charCodeAt(3)]),g=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),E=v.schi(o);return v.box(v.types.sinf,h,v.box(v.types.frma,f),v.box(v.types.schm,g),E)}},{key:"av01",value:function(o){return v.box(v.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,o.width>>8&255,o.width&255,o.height>>8&255,o.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.av1C,o.colr)}},{key:"avc1hev1",value:function(o){var h=o.codecType===er.HEVC,f=h?v.types.hvc1:v.types.avc1,g=h?v.hvcC(o):v.avcC(o),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,o.width>>8&255,o.width&255,o.height>>8&255,o.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]),g];return h?E.push(v.box(v.types.fiel,new Uint8Array([1,0]))):o.sarRatio&&o.sarRatio.length>1&&E.push(v.pasp(o.sarRatio)),v.box.apply(v,[f].concat(E))}},{key:"avcC",value:function(o){var h,f,g=[],E=[],_;return o.sps.forEach(function(S){_=S.byteLength,g.push(_>>>8&255),g.push(_&255),g.push.apply(g,Vt(S))}),o.pps.forEach(function(S){_=S.byteLength,E.push(_>>>8&255),E.push(_&255),E.push.apply(E,Vt(S))}),v.box(v.types.avcC,new Uint8Array((h=(f=[1,g[3],g[4],g[5],255,224|o.sps.length]).concat.apply(f,g).concat([o.pps.length])).concat.apply(h,E)))}},{key:"hvcC",value:function(o){var h=o.hvcC;if(h instanceof ArrayBuffer||h instanceof Uint8Array)return h;var f=o.vps,g=o.sps,E=o.pps,_;if(h){var S=h.generalProfileCompatibilityFlags,D=h.generalConstraintIndicatorFlags,P=(f.length&&1)+(g.length&&1)+(E.length&&1);_=[1,h.generalProfileSpace<<6|h.generalTierFlag<<5|h.generalProfileIdc,S>>>24,S>>>16,S>>>8,S,D[0],D[1],D[2],D[3],D[4],D[5],h.generalLevelIdc,240,0,252,h.chromaFormatIdc|252,h.bitDepthLumaMinus8|248,h.bitDepthChromaMinus8|248,0,0,h.numTemporalLayers<<3|h.temporalIdNested<<2|3,P];var F=function(W){var $;_.push(W.length>>8,W.length),($=_).push.apply($,Vt(W))};f.length&&(_.push(160,0,f.length),f.forEach(F)),g.length&&(_.push(161,0,g.length),g.forEach(F)),E.length&&(_.push(162,0,E.length),E.forEach(F))}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 v.box(v.types.hvcC,new Uint8Array(_))}},{key:"pasp",value:function(o){var h=bo(o,2),f=h[0],g=h[1];return v.box(v.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,g>>24,g>>16&255,g>>8&255,g&255]))}},{key:"mp4a",value:function(o){return v.box(v.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,o.channelCount,0,16,0,0,0,0,o.sampleRate>>8&255,o.sampleRate&255,0,0]),o.config.length?v.esds(o.config):void 0)}},{key:"esds",value:function(o){var h=o.length,f=v.box(v.types.esds,new Uint8Array([0,0,0,0,3,23+h,0,0,0,4,15+h,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([h]).concat(o).concat([6,1,2])));return f}},{key:"opus",value:function(o){var h=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,o.channelCount,0,16,0,0,0,0,o.sampleRate>>8&255,o.sampleRate&255,0,0]),f=o.config.length?v.dOps(o):[];return v.box(v.types.Opus,h,f)}},{key:"dOps",value:function(o){if(o.config)return o.config[4]=o.sampleRate>>>24&255,o.config[5]=o.sampleRate>>>16&255,o.config[6]=o.sampleRate>>>8&255,o.config[7]=o.sampleRate&255,v.box(v.types.dOps,o.config)}},{key:"mvex",value:function(o){var h=v.box.apply(v,[v.types.mvex].concat(Vt(o.map(function(f){return v.trex(f.id)}))));return h}},{key:"trex",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return h}},{key:"trex1",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return h}},{key:"trex2",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return h}},{key:"moof",value:function(o){var h=v.box.apply(v,[v.types.moof,v.mfhd(o[0].samples?o[0].samples[0].gopId:0)].concat(Vt(o.map(function(f){return v.traf(f)}))));return h}},{key:"mfhd",value:function(o){var h=v.box(v.types.mfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255]));return h}},{key:"traf",value:function(o){var h=v.tfhd(o.id),f=v.tfdt(o,o.baseMediaDecodeTime),g=0,E;if(o.isVideo&&o.videoSenc&&(E=o.videoSenc,E.forEach(function(U){g=g+8,U.subsamples&&U.subsamples.length&&(g=g+2,g=g+U.subsamples.length*6)})),o.videoSencLength=g,!o.useEME||!o.isVideoEncryption&&!o.isAudioEncryption){var _=v.sdtp(o),S=76;return v.box(v.types.traf,h,f,_,v.trun(o.samples,_.byteLength+S))}else if(o.isVideoEncryption)if(o.isVideo){var D=v.saiz(o),P=v.saio(o),F=v.trun1(o),H=v.senc(o),W=v.box(v.types.traf,h,f,D,P,F,H);return W}else if(o.isAudioEncryption){var Z=v.sbgp(),oe=v.saiz(o),ue=v.saio(o),Se=v.senc(o),he=v.trun1(o),se=v.box(v.types.traf,h,f,Z,oe,ue,Se,he);return se}else{var $=v.sbgp(),ee=v.trun1(o);return v.box(v.types.traf,h,f,$,ee)}else if(o.isVideo){var ce=v.trun1(o);return v.box(v.types.traf,h,f,ce)}else{var Me=v.sbgp(),We=v.saiz(o),ye=v.saio(o),Ie=v.senc(o),Ze=v.trun1(o),w=v.box(v.types.traf,h,f,Me,We,ye,Ie,Ze);return w}}},{key:"sdtp",value:function(o){var h=new ft;return o.samples.forEach(function(f){h.write(new Uint8Array(o.isVideo?[f.keyframe?32:16]:[16]))}),v.box(v.types.sdtp,this.extension(0,0),h.buffer)}},{key:"trun1",value:function(o){var h=new ft,f=ft.writeUint32(o.samples.length),g=null;if(o.isVideo){var E=o.videoSencLength;g=ft.writeUint32(o.samples.length*16+E+149),!o.isVideoEncryption&&o.isAudioEncryption&&(g=ft.writeUint32(o.samples.length*16+92))}else{var _=o.samples.length*12+124;o.isAudioEncryption&&(_=o.samples.length*12+8*o.audioSenc.length+177),g=ft.writeUint32(_)}return o.samples.forEach(function(S){h.write(ft.writeUint32(S.duration)),h.write(ft.writeUint32(S.size)),h.write(ft.writeUint32(S.keyframe?33554432:65536)),o.isVideo&&h.write(ft.writeUint32(S.cts?S.cts:0))}),v.box(v.types.trun,this.extension(0,o.flags),f,g,h.buffer)}},{key:"senc",value:function(o){var h=new ft,f=o.samples.length,g=o.isVideo?16:8,E=o.isVideo?2:0,_=[],S=0;return o.isVideo?(_=o.videoSenc,S=o.videoSencLength):_=o.audioSenc,S=S||g*f,h.write(ft.writeUint32(16+S),v.types.senc,this.extension(0,E)),h.write(ft.writeUint32(f)),_.forEach(function(D){for(var P=0;P<D.InitializationVector.length;P++)h.write(new Uint8Array([D.InitializationVector[P]]));D.subsamples&&D.subsamples.length&&(h.write(ft.writeUint16(D.subsamples.length)),D.subsamples.forEach(function(F){h.write(ft.writeUint16(F.BytesOfClearData)),h.write(ft.writeUint32(F.BytesOfProtectedData))}))}),h.buffer}},{key:"saio",value:function(o){var h=o.samples.length*12+141;!o.isVideo&&o.isAudioEncryption&&(h=149);var f=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255]);return v.box(v.types.saio,f)}},{key:"saiz",value:function(o){var h=o.samples.length,f=new Uint8Array([0,0,0,0,16,h>>24&255,h>>16&255,h>>8&255,h&255]);return v.box(v.types.saiz,f)}},{key:"sbgp",value:function(){var o=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return v.box(v.types.sbgp,this.extension(0,0),o)}},{key:"extension",value:function(o,h){return new Uint8Array([o,h>>16&255,h>>8&255,h&255])}},{key:"tfhd",value:function(o){return v.box(v.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255]))}},{key:"tfdt",value:function(o,h){var f=Math.floor(h/(jo+1)),g=Math.floor(h%(jo+1));return o.useEME&&(o.isVideoEncryption||o.isAudioEncryption)?v.box(v.types.tfdt,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])):v.box(v.types.tfdt,new Uint8Array([1,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,g>>24,g>>16&255,g>>8&255,g&255]))}},{key:"trun",value:function(o,h){var f=o.length,g=12+16*f;h+=8+g;var E=new Uint8Array(g);E.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255],0);for(var _=0;_<f;_++){var S=o[_],D=S.duration,P=S.size,F=S.flag,H=F===void 0?{}:F,W=S.cts,$=W===void 0?0:W;E.set([D>>>24&255,D>>>16&255,D>>>8&255,D&255,P>>>24&255,P>>>16&255,P>>>8&255,P&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,$>>>24&255,$>>>16&255,$>>>8&255,$&255],12+16*_)}return v.box(v.types.trun,E)}},{key:"moovMP4",value:function(o){return v.box.apply(v,[v.types.moov,v.mvhd(o[0].duration,o[0].timescale)].concat(Vt(o.map(function(h){return v.trackMP4(h)}))))}},{key:"trackMP4",value:function(o){return v.box(v.types.trak,v.tkhd(o.id,o.duration,o.width,o.height),v.mdiaMP4(o))}},{key:"mdiaMP4",value:function(o){return v.box(v.types.mdia,v.mdhd(o.duration,o.timescale),v.hdlr(o.type),v.minfMP4(o))}},{key:"minfMP4",value:function(o){return v.box(v.types.minf,o.type===Ht.VIDEO?v.VMHD:v.SMHD,v.DINF,v.stblMP4(o))}},{key:"stblMP4",value:function(o){var h=o.ext,f=[v.stsd(o),v.stts(h.stts),v.stsc(h.stsc),v.stsz(h.stsz),v.stco(h.stco)];return h.stss.length&&f.push(v.stss(h.stss)),h.ctts.length&&f.push(v.ctts(h.ctts)),v.box.apply(v,[v.types.stbl].concat(f))}},{key:"stts",value:function(o){var h=o.length,f=new Uint8Array(8*h),g=0;return o.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],g),g+=8}),v.box(v.types.stts,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stsc",value:function(o){var h=o.length,f=new Uint8Array(12*h),g=0;return o.forEach(function(E){var _=E.firstChunk,S=E.samplesPerChunk,D=E.sampleDescIndex;f.set([_>>24,_>>16&255,_>>8&255,_&255,S>>24,S>>16&255,S>>8&255,S&255,D>>24,D>>16&255,D>>8&255,D&255],g),g+=12}),v.box(v.types.stsc,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stsz",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stsz,kt(new Uint8Array([0,0,0,0,0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stco",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stco,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stss",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stss,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"ctts",value:function(o){var h=o.length,f=new Uint8Array(8*h),g=0;return o.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],g),g+=8}),v.box(v.types.ctts,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"styp",value:function(){return v.box(v.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(o){var h=o.timescale,f=o.samples[0].duration,g=f*o.samples.length,E=o.samples[0].sampleOffset*f,_=8;o.samples.forEach(function(H){_+=H.size});var S=0;if(o.isVideo){var D=0,P;o.videoSenc&&(P=o.videoSenc),o.isVideo&&P.forEach(function(H){D=D+8,H.subsamples&&H.subsamples.length&&(D=D+2,D=D+H.subsamples.length*6)}),o.videoSencLength=D,S=_+141+o.samples.length*16+D,o.useEME&&o.isAudioEncryption&&!o.isVideoEncryption&&(S=_+o.samples.length*16+84)}else S=_+116+o.samples.length*12,o.useEME&&o.isAudioEncryption&&(S=_+169+o.samples.length*12+8*o.audioSenc.length);var F=new Uint8Array([0,0,0,0,0,0,0,o.id&255,h>>24&255,h>>16&255,h>>8&255,h&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,g>>24&255,g>>16&255,g>>8&255,g&255,144,0,0,0]);return v.box(v.types.sidx,F)}},{key:"mdat",value:function(o){var h=v.box(v.types.mdat,o);return h}}]),v}();Q(Le,"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(v,m){return v[m]=[m.charCodeAt(0),m.charCodeAt(1),m.charCodeAt(2),m.charCodeAt(3)],v},Object.create(null)));Q(Le,"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(Le,"FTYPAVC1",Le.box(Le.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));Q(Le,"FTYPHEV1",Le.box(Le.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));Q(Le,"DINF",Le.box(Le.types.dinf,Le.box(Le.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(Le,"VMHD",Le.box(Le.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));Q(Le,"SMHD",Le.box(Le.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));Q(Le,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));Q(Le,"STTS",Le.box(Le.types.stts,Le.StblTable));Q(Le,"STSC",Le.box(Le.types.stsc,Le.StblTable));Q(Le,"STSZ",Le.box(Le.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));Q(Le,"STCO",Le.box(Le.types.stco,Le.StblTable));var Gn=function(){function v(m,o){Ae(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]"),v.disabled=o}return be(v,[{key:"debug",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).debug.apply(o,[this._prefix].concat(f))}}},{key:"log",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).log.apply(o,[this._prefix].concat(f))}}},{key:"warn",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).warn.apply(o,[this._prefix].concat(f))}}},{key:"error",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).error.apply(o,[this._prefix].concat(f))}}},{key:"table",value:function(){var o;v.disabled||(console.group(this._prefix),(o=console).table.apply(o,arguments),console.groupEnd())}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();Q(Gn,"disabled",!0);var Vn=function(){function v(m,o,h){Ae(this,v),this.videoTrack=m,this.audioTrack=o;var f=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=f&&Number(f[1])<50,this.log=new Gn("FMP4Remuxer",h&&h.openLog?!h.openLog:!0)}return be(v,[{key:"remux",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=this.videoTrack,g=this.audioTrack,E=f.exist(),_=g.exist(),S,D,P,F=[];o&&(h&&h.initMerge?(E&&F.push(this.videoTrack),_&&F.push(this.audioTrack),P=Le.initSegment(F)):(E&&(S=Le.initSegment([this.videoTrack])),_&&(D=Le.initSegment([this.audioTrack]))));var H,W;return E&&f.hasSample()&&(H=this._remuxVideo()),_&&g.hasSample()&&(W=this._remuxAudio()),f.samples=[],g.samples=[],{initSegment:P,videoInitSegment:S,audioInitSegment:D,videoSegment:H,audioSegment:W}}},{key:"_remuxVideo",value:function(){var o=this.videoTrack;this.forceFirstIDR&&(o.samples[0].flag={dependsOn:2,isNonSyncSample:0});var h=o.samples,f=/av01/.test(o.codec),g=0;f?h.forEach(function(Se){g+=Se.data.byteLength}):h.forEach(function(Se){g+=Se.units.reduce(function(he,se){return he+se.byteLength},0),g+=Se.units.length*4});var E=new Uint8Array(g);if(f)for(var _=0,S=h.length,D=0,P;_<S;_++)P=h[_],E.set(P.data,D),P.size=P.data.byteLength,D+=P.size;else for(var F=new DataView(E.buffer),H=function(he,se){se=h[W];var ce=0;se.units.forEach(function(Me){F.setUint32(he,Me.byteLength),he+=4,E.set(Me,he),he+=Me.byteLength,ce+=4+Me.byteLength}),se.size=ce,ee=he,Z=se},W=0,$=h.length,ee=0,Z;W<$;W++)H(ee,Z);var oe=Le.mdat(E),ue=Le.moof([o]);return kt(ue,oe)}},{key:"_remuxAudio",value:function(){var o=this.audioTrack,h=new Uint8Array(o.samples.reduce(function(E,_){return E+_.size},0));o.samples.reduce(function(E,_){return h.set(_.data,E),E+_.size},0);var f=Le.mdat(h),g=Le.moof([o]);return kt(g,f)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),v}();var Yo=function(){function v(){br(this,v),me(this,"_ttfb",0),me(this,"_demuxStart",0),me(this,"_demuxEnd",0),me(this,"_demuxCost",0),me(this,"_remuxStart",0),me(this,"_remuxEnd",0),me(this,"_remuxCost",0),me(this,"_appendStart",0),me(this,"_appendEnd",0),me(this,"_appendCost",0)}return Lr(v,[{key:"set",value:function(o,h){this["_".concat(o)]=h}},{key:"start",value:function(o){this["_".concat(o,"Start")]=Date.now()}},{key:"end",value:function(o){this["_".concat(o,"End")]=Date.now(),this["_".concat(o,"Cost")]=this["_".concat(o,"Cost")]+(this["_".concat(o,"End")]-this["_".concat(o,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),v}(),rr={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var ir=new Ct("BufferService"),zo=function(){function v(m,o){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};br(this,v),me(this,"flv",null),me(this,"_demuxer",new Pi),me(this,"_remuxer",null),me(this,"_mse",null),me(this,"_softVideo",null),me(this,"_sourceCreated",!1),me(this,"_needInitSegment",!0),me(this,"_discontinuity",!0),me(this,"_contiguous",!1),me(this,"_initSegmentId",""),me(this,"_cachedBuffer",null),me(this,"_demuxStartTime",0),me(this,"_opts",null),this.flv=m,this._opts=h,o?this._softVideo=o:(this._remuxer=new Vn(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new fr(null,{preferMMS:typeof h.preferMMS=="boolean"?h.preferMMS:!!h.perferMMS}),this._mse.bindMedia(m.media))}return Lr(v,[{key:"baseDts",get:function(){var o,h;return(o=this._demuxer)===null||o===void 0||(h=o._fixer)===null||h===void 0?void 0:h._baseDts}},{key:"blobUrl",get:function(){var o;return(o=this._mse)===null||o===void 0?void 0:o.url}},{key:"isFull",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fr.VIDEO;return this._mse.isFull(o)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(o){this._contiguous=!1,this._demuxStartTime=o}},{key:"reset",value:function(){var m=at(ke().mark(function h(){var f,g=arguments;return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=g.length>0&&g[0]!==void 0?g[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()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var m=at(ke().mark(function h(){return ke().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._mse){g.next=7;break}if(!this._sourceCreated){g.next=5;break}return g.next=4,this._mse.endOfStream();case 4:this.flv.emit(_e.BUFFEREOS);case 5:g.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"updateDuration",value:function(){var m=at(ke().mark(function h(f){return ke().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 ir.debug("update duration",f),E.next=7,this._mse.updateDuration(f);case 7:case"end":return E.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"destroy",value:function(){var m=at(ke().mark(function h(){return ke().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._mse){g.next=3;break}return g.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"appendBuffer",value:function(){var m=at(ke().mark(function h(f){var g=this,E,_,S,D,P,F,H,W,$,ee,Z,oe,ue,Se,he,se,ce,Me;return ke().wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:if(E=!1,this._cachedBuffer&&(f=bn(this._cachedBuffer,f),this._cachedBuffer=null),_=this._demuxer,!(!f||!f.length||!_)){ye.next=5;break}return ye.abrupt("return");case 5:ye.prev=5,this.flv._transferCost.start(rr.DEMUX),_.demuxAndFix(f,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(rr.DEMUX),ye.next=15;break;case 12:throw ye.prev=12,ye.t0=ye.catch(5),new pt(De.DEMUX,De.SUB_TYPES.FLV,ye.t0);case 15:if(S=_.videoTrack,D=_.audioTrack,P=_.metadataTrack,!this.seamlessLoadingSwitch){ye.next=25;break}if(F=S.samples.findIndex(function(Ie){return Ie.originDts===S.lastKeyFrameDts}),!(F>=0)){ye.next=25;break}return S.samples.splice(F),ye.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,f=null,E=!0;case 25:if(H=S.exist(),W=D.exist(),this._opts.onlyAudio&&(H=!1,S.present=!1),this._opts.onlyVideo&&(W=!1,D.present=!1),!(!H&&S.present||!W&&D.present)){ye.next=42;break}if($=0,ee=H?S:W?D:void 0,ee&&ee.samples.length&&($=(ee.samples[ee.samples.length-1].originPts-ee.samples[0].originPts)/ee.timescale*1e3),!($>this._opts.analyzeDuration)){ye.next=40;break}ir.warn("analyze duration exceeded, ".concat($,"ms"),ee),S.present=H,D.present=W,this.flv.emit(_e.ANALYZE_DURATION_EXCEEDED,{duration:$}),ye.next=42;break;case 40:return this._cachedBuffer=f,ye.abrupt("return");case 42:if(Z=S.type,oe=D.type,this._fireEvents(S,D,P),E||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),ue=this._mse,Se=function(){var Ze;if((Ze=g.flv)!==null&&Ze!==void 0&&Ze.emit){var w;(w=g.flv)===null||w===void 0||w.emit(_e.APPEND_BUFFER,{})}},this.flv.emit(_e.DEMUXED_TRACK,{videoTrack:S}),he="".concat(S.codec,"/").concat(S.width,"/").concat(S.height,"/").concat(D.codec,"/").concat(D.config),he!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=he,this._emitMetaParsedEvent(S,D)),!ue){ye.next=83;break}if(this._sourceCreated){ye.next=59;break}return ye.next=55,ue.open();case 55:H&&(ir.log("codec: video/mp4;codecs=".concat(S.codec)),ue.createSource(Z,"video/mp4;codecs=".concat(S.codec))),W&&(ir.log("codec: audio/mp4;codecs=".concat(D.codec)),ue.createSource(oe,"audio/mp4;codecs=".concat(D.codec))),this._sourceCreated=!0,this.flv.emit(_e.SOURCEBUFFER_CREATED);case 59:ye.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(S.duration=this._opts.durationForMSELowLatencyOff*S.timescale,D.duration=this._opts.durationForMSELowLatencyOff*W.timescale),this.flv._transferCost.start(rr.REMUX),se=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(rr.REMUX),ye.next=69;break;case 66:throw ye.prev=66,ye.t1=ye.catch(59),new pt(De.REMUX,De.SUB_TYPES.FMP4,ye.t1);case 69:if(!(this._needInitSegment&&!se.videoInitSegment&&!se.audioInitSegment)){ye.next=71;break}return ye.abrupt("return");case 71:return this._needInitSegment=!1,ce=[],se.videoInitSegment&&ce.push(ue.append(Z,se.videoInitSegment)),se.audioInitSegment&&ce.push(ue.append(oe,se.audioInitSegment)),se.videoSegment&&ce.push(ue.append(Z,se.videoSegment)),se.audioSegment&&ce.push(ue.append(oe,se.audioSegment)),this.flv._transferCost.start(rr.APPEND),Me=Promise.all(ce),Me.then(Se).then(function(){g.flv._transferCost.end(rr.APPEND),Se()}),ye.abrupt("return",Me);case 83:this._softVideo&&(this._softVideo.appendBuffer(S,D),Se());case 84:case"end":return ye.stop()}},h,this,[[5,12],[59,66]])}));function o(h){return m.apply(this,arguments)}return o}()},{key:"evictBuffer",value:function(){var m=at(ke().mark(function h(f){var g=this,E,_,S,D;return ke().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(E=this.flv.media,!(!this._mse||!this._demuxer||!E||!f||f<0)){F.next=3;break}return F.abrupt("return");case 3:if(_=E.currentTime,S=_-f,!(S<=0)){F.next=7;break}return F.abrupt("return");case 7:if(D=tt.start(tt.get(E)),!(D+1>=S)){F.next=10;break}return F.abrupt("return");case 10:return F.abrupt("return",this._mse.clearBuffer(0,S).then(function(){return g.flv.emit(_e.REMOVE_BUFFER,{removeEnd:S})}));case 11:case"end":return F.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"_emitMetaParsedEvent",value:function(o,h){o.exist()&&this.flv.emit(_e.METADATA_PARSED,{type:"video",track:o,meta:{codec:o.codec,timescale:o.timescale,width:o.width,height:o.height,sarRatio:o.sarRatio,baseDts:o.baseDts}}),h.exist()&&this.flv.emit(_e.METADATA_PARSED,{type:"audio",track:h,meta:{codec:h.codec,channelCount:h.channelCount,sampleRate:h.sampleRate,timescale:h.timescale,baseDts:h.baseDts}}),ir.debug("track parsed",o,h)}},{key:"_fireEvents",value:function(o,h,f){var g=this;ir.debug("videoTrack samples count: ".concat(o.samples.length,", audioTrack samples count: ").concat(h.samples.length)),f.flvScriptSamples.forEach(function(E){g.flv.emit(_e.FLV_SCRIPT_DATA,E),ir.debug("flvScriptData",E)}),o.samples.forEach(function(E){E.keyframe&&g.flv.emit(_e.KEYFRAME,{pts:E.originPts})}),o.warnings.forEach(function(E){var _;switch(E.type){case yt.LARGE_AV_SHIFT:_=_e.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case yt.LARGE_VIDEO_GAP:_=_e.LARGE_VIDEO_DTS_GAP_DETECT;break;case yt.LARGE_VIDEO_GAP_BETWEEN_CHUNK:_=_e.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}_&&g.flv.emit(_e.STREAM_EXCEPTION,It(It({},E),{},{type:_})),ir.warn("video exception",E)}),h.warnings.forEach(function(E){var _;switch(E.type){case yt.LARGE_AUDIO_GAP:_=_e.LARGE_AUDIO_DTS_GAP_DETECT;break;case yt.AUDIO_FILLED:_=_e.AUDIO_GAP_DETECT;break;case yt.AUDIO_DROPPED:_=_e.AUDIO_OVERLAP_DETECT;break}_&&g.flv.emit(_e.STREAM_EXCEPTION,It(It({},E),{},{type:_})),ir.warn("audio exception",E)}),f.seiSamples.forEach(function(E){g.flv.emit(_e.SEI,It(It({},E),{},{sei:{code:E.data.type,content:E.data.payload,dts:E.pts}}))})}}]),v}();function qo(v){var m=It({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},v);return m.isLive&&m.preloadTime&&(m.maxLatency||(m.maxLatency=m.preloadTime*2),m.targetLatency||(m.targetLatency=m.preloadTime),(m.disconnectTime===null||m.disconnectTime===void 0)&&(m.disconnectTime=m.maxLatency)),m}function Hn(v,m){var o=0,h=v.length-1,f=0,g=0,E=h;for(m<v[0]&&(o=0,g=E+1);g<=E;)if(f=g+Math.floor((E-g)/2),f===h||m>=v[f]&&m<v[f+1]){o=f;break}else v[f]<m?g=f+1:E=f-1;return o}var Xt=new Ct("flv"),Oi=.1,ud=.3,Dr=function(v){qs(o,v);var m=$s(o);function o(h){var f;return br(this,o),f=m.call(this),me(Pe(f),"media",null),me(Pe(f),"_loading",!1),me(Pe(f),"_opts",null),me(Pe(f),"_bufferService",null),me(Pe(f),"_gapService",null),me(Pe(f),"_stats",null),me(Pe(f),"_mediaLoader",null),me(Pe(f),"_maxChunkWaitTimer",null),me(Pe(f),"_tickTimer",null),me(Pe(f),"_tickInterval",500),me(Pe(f),"_urlSwitching",!1),me(Pe(f),"_seamlessSwitching",!1),me(Pe(f),"_disconnectRetryCount",0),me(Pe(f),"_preLoadEndPoint",0),me(Pe(f),"_keyframes",null),me(Pe(f),"_acceptRanges",!0),me(Pe(f),"_onProgress",function(){var g=at(ke().mark(function E(_,S,D,P){var F,H,W,$,ee,Z,oe,ue,Se,he;return ke().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(F=D.startTime,H=D.endTime,W=D.st,$=D.firstByteTime,f._loading=!S,f._firstProgressEmit){ce.next=13;break}if(f.media){ce.next=6;break}return(ee=f._mediaLoader)===null||ee===void 0||ee.cancel(),ce.abrupt("return");case 6:Z=P.headers,oe=W?$-W:H-F,f.emit(_e.TTFB,{url:f._opts.url,responseUrl:P.url,elapsed:oe}),f.emit(_e.LOAD_RESPONSE_HEADERS,{headers:Z}),f._transferCost.set(rr.TTFB,oe),f._acceptRanges=!!(Z!=null&&Z.get("Accept-Ranges"))||!!(Z!=null&&Z.get("Content-Range")),f._firstProgressEmit=!0;case 13:if(f._bufferService){ce.next=15;break}return ce.abrupt("return");case 15:return clearTimeout(f._maxChunkWaitTimer),f._bandwidthService.addChunkRecord(_?.byteLength,H-F),ce.prev=17,ce.next=20,f._bufferService.appendBuffer(_);case 20:(ue=f._bufferService)===null||ue===void 0||ue.evictBuffer(f._opts.bufferBehind),ce.next=33;break;case 23:if(ce.prev=23,ce.t0=ce.catch(17),!(!f.isLive&&f._bufferService.isFull())){ce.next=32;break}return ce.next=28,f._mediaLoader.cancel();case 28:return f._loading=!1,Se=f.bufferInfo().remaining,f._opts.preloadTime=parseInt(Se)/2,ce.abrupt("return");case 32:return ce.abrupt("return",f._emitError(pt.create(ce.t0)));case 33:if(f._urlSwitching&&(f._urlSwitching=!1,f.emit(_e.SWITCH_URL_SUCCESS,{url:f._opts.url})),f._seamlessSwitching&&(f._seamlessSwitching=!1,f._tick()),!(S&&!f.media.seeking)){ce.next=40;break}return f.emit(_e.LOAD_COMPLETE),Xt.debug("load done"),f.isLive&&f._disconnectRetryCount<=0&&f._end(),ce.abrupt("return");case 40:if(f.isLive){ce.next=42;break}return ce.abrupt("return");case 42:he=f._opts.maxReaderInterval,he&&f._firstProgressEmit&&(clearTimeout(f._maxChunkWaitTimer),f._maxChunkWaitTimer=setTimeout(function(){if(f._disconnectRetryCount){f._disconnectRetryCount--,f.load();return}Xt.debug("onMaxChunkWait",he),f._end()},he));case 44:case"end":return ce.stop()}},E,null,[[17,23]])}));return function(E,_,S,D){return g.apply(this,arguments)}}()),me(Pe(f),"_onRetryError",function(g,E){Xt.debug("load retry",g,E),f.emit(_e.LOAD_RETRY,{error:pt.network(g),retryTime:E})}),me(Pe(f),"_end",function(){f._clear(),f._bufferService&&f._bufferService.endOfStream(),Xt.debug("end stream")}),me(Pe(f),"_resetDisconnectCount",function(){f._disconnectRetryCount=f._opts.disconnectRetryCount}),me(Pe(f),"_tick",function(){clearTimeout(f._tickTimer);var g=Pe(f),E=g.media;if(E){f._tickTimer=setTimeout(f._tick,f._tickInterval);var _=tt.end(tt.get(E));if(!(_<Oi||!E.readyState)){var S=f._opts;if(Tn(E)&&E.currentTime)f._gapService&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);else{if(!E.currentTime&&f._gapService&&S.enableStartGapJump){var D=f._opts.mseLowLatency||f._opts.mseLowLatency===!1&&f.bufferInfo(ud).nextStart;D&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);return}S.isLive&&E.readyState===4&&_-E.currentTime>S.disconnectTime&&f.disconnect()}}}}),me(Pe(f),"_onPlay",function(){var g,E,_=f._opts.softDecode||((g=f.media)===null||g===void 0||(E=g.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)>Oi&&f._tick()}),me(Pe(f),"_onLoadeddata",function(){f.isLive&&!f._opts.mseLowLatency&&f.media.duration!==1/0&&f._bufferService.updateDuration(1/0).catch(function(g){})}),me(Pe(f),"_onSeeking",at(ke().mark(function g(){return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:!f.isLive&&f.seekable&&(f._preLoadEndPoint=-1,f._checkPreload());case 1:case"end":return _.stop()}},g)}))),me(Pe(f),"_onTimeupdate",function(){if(f.media){var g=f._opts,E=f.media.currentTime;if(g.isLive&&g.maxLatency&&g.targetLatency){var _=tt.end(tt.get(f.media)),S=_-E;S>=g.maxLatency&&(f.media.currentTime=_-g.targetLatency,f.emit(_e.CHASEFRAME,{currentTime:f.media.currentTime,latency:g.targetLatency}))}f._seiService.throw(E,!0),!(g.isLive||!f.seekable||f._loading)&&f._checkPreload()}}),me(Pe(f),"_onWaiting",function(){f.isLive&&!f._loading&&f._disconnectRetryCount&&(f._disconnectRetryCount--,f.load())}),me(Pe(f),"_onBufferUpdate",function(){if(!f._opts.isLive){var g=f.bufferInfo(),E=g.end,_=g.nextEnd;Math.abs((E||_)-f.media.duration)<1&&(f._end(),f.media.readyState<=2&&f._tick())}}),me(Pe(f),"_checkPreload",at(ke().mark(function g(){var E,_,S,D,P,F,H,W,$,ee;return ke().wrap(function(oe){for(;;)switch(oe.prev=oe.next){case 0:if(E=f.bufferInfo(),_=E.remaining,S=_===void 0?0:_,D=f._opts,P=f._keyframes.filepositions,F=f._keyframes.times,H=f.media.currentTime,!(S<D.preloadTime)){oe.next=19;break}if(W=Hn(f._keyframes.times,H+S+Oi),$=Hn(f._keyframes.times,H+S+f._opts.preloadTime),$===W&&($=W+1),f._preLoadEndPoint!==$){oe.next=11;break}return oe.abrupt("return");case 11:if(ee=P[W],ee!=null){oe.next=14;break}return oe.abrupt("return");case 14:return oe.next=16,f._mediaLoader.cancel();case 16:f._loadData(null,[ee,P[$]]),f._preLoadEndPoint=$,f._bufferService.unContiguous(F[W]);case 19:case"end":return oe.stop()}},g)}))),me(Pe(f),"_onFlvScriptData",function(g){var E,_,S,D,P=(E=g.data)===null||E===void 0||(_=E.onMetaData)===null||_===void 0?void 0:_.keyframes,F=(S=g.data)===null||S===void 0||(D=S.onMetaData)===null||D===void 0?void 0:D.duration;P&&(f._keyframes=P),!f._opts.isLive&&F&&f._bufferService.updateDuration(F)}),f._opts=qo(h),f.media=f._opts.media||document.createElement("video"),f._opts.media=null,f._firstProgressEmit=!1,f._mediaLoader=new xn(It(It({},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 Yo,f._bufferService=new zo(Pe(f),f._opts.softDecode?f.media:void 0,f._opts),f._seiService=new Cn(Pe(f)),f._bandwidthService=new kn({chunkCountForSpeed:f._opts.chunkCountForSpeed,skipChunkSize:f._opts.skipChunkSize,longtimeNoReceived:f._opts.longtimeNoReceived}),f._stats=new Dn(Pe(f)),f._opts.softDecode||(f._gapService=new Rn),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(_e.FLV_SCRIPT_DATA,f._onFlvScriptData),f}return Lr(o,[{key:"version",get:function(){return"3.0.21"}},{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,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Oi;return tt.info(tt.get(this.media),(f=this.media)===null||f===void 0?void 0:f.currentTime,g)}},{key:"playbackQuality",value:function(){return An(this.media)}},{key:"load",value:function(){var h=at(ke().mark(function g(E){var _,S=arguments;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(_=S.length>1&&S[1]!==void 0?S[1]:!1,this._bufferService){P.next=3;break}return P.abrupt("return");case 3:return P.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 P.stop()}},g,this)}));function f(g){return h.apply(this,arguments)}return f}()},{key:"replay",value:function(){var h=at(ke().mark(function g(){var E=this,_,S,D=arguments;return ke().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(_=D.length>0&&D[0]!==void 0?D[0]:this._opts.seamlesslyReload,S=D.length>1?D[1]:void 0,this.media){F.next=4;break}return F.abrupt("return");case 4:if(this._resetDisconnectCount(),!_){F.next=11;break}return F.next=8,this._clear();case 8:setTimeout(function(){E._seamlessSwitching=!0,E._loadData(E._opts.url),E._bufferService.seamlessSwitch()}),F.next=13;break;case 11:return F.next=13,this.load();case 13:return F.abrupt("return",this.media.play(!S).catch(function(){}));case 14:case"end":return F.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"disconnect",value:function(){var f;return Xt.debug("disconnect!"),(f=this._bufferService)===null||f===void 0||f.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var h=at(ke().mark(function g(E,_){var S=this;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this._bufferService){P.next=2;break}return P.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&_)){P.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var F=at(ke().mark(function H(W){return ke().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 F.apply(this,arguments)}}(),P.abrupt("return");case 6:if(!(!_||!this._opts.isLive)){P.next=11;break}return P.next=9,this.load(E);case 9:return this._urlSwitching=!0,P.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return P.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 P.stop()}},g,this)}));function f(g,E){return h.apply(this,arguments)}return f}()},{key:"destroy",value:function(){var h=at(ke().mark(function g(){return ke().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()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"_emitError",value:function(f){var g,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Xt.table(f),Xt.error(f),Xt.error((g=this.media)===null||g===void 0?void 0:g.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(_e.SWITCH_URL_FAILED,f)),this.emit(_e.ERROR,f),E&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var h=at(ke().mark(function g(){var E,_=arguments;return ke().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return E=_.length>0&&_[0]!==void 0?_[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),D.next=6,this._clear();case 6:return D.next=8,this._bufferService.reset(E);case 8:case"end":return D.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"_loadData",value:function(){var h=at(ke().mark(function g(E,_){var S;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(E&&(this._opts.url=E),S=E=this._opts.url,E){P.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(_e.LOAD_START,{url:S,seamlessSwitching:this._seamlessSwitching}),Xt.debug("load data, loading:",this._loading,S),!this._loading){P.next=11;break}return P.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,P.prev=12,P.next=15,this._mediaLoader.load({url:S,range:_});case 15:P.next=21;break;case 17:return P.prev=17,P.t0=P.catch(12),this._loading=!1,P.abrupt("return",this._emitError(pt.network(P.t0),!1));case 21:case"end":return P.stop()}},g,this,[[12,17]])}));function f(g,E){return h.apply(this,arguments)}return f}()},{key:"_clear",value:function(){var h=at(ke().mark(function g(){return ke().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()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()}],[{key:"isSupported",value:function(f){return!f||f==="video"||f==="audio"?fr.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){Ct.enable(),pr.enable()}},{key:"disableLogger",value:function(){Ct.disable(),pr.disable()}}]),o}($o.default);try{localStorage.getItem("xgd")?Dr.enableLogger():Dr.disableLogger()}catch{}var Wn=Ar(Qo(),1);
34
+
35
+ if(__exports != exports)module.exports = exports;return module.exports}));