lemon-mse 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/a.d.ts +3105 -0
- package/dist/es/flv.d.ts +587 -0
- package/dist/es/flv.js +6 -1
- package/dist/es/hls.d.ts +3 -0
- package/dist/es/hls.js +14 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +19 -1
- package/dist/flv.js +24 -0
- package/dist/hls.js +32 -0
- package/dist/index.js +37 -0
- package/dist/lemon.css +1 -1
- package/dist/lemon.js +1 -1
- package/dist/webmssdk.es5.js +2 -0
- package/package.json +7 -9
package/dist/index.js
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
(function (g, f) {var hasExports = typeof exports === 'object';if (typeof define === "function" && define.amd) {define([], f);} else if (typeof module === "object" && module.exports) {module.exports = f();} else {var m = hasExports ? f() : f();var root = hasExports ? exports : g;for(var i in m) root[i] = m[i];}}(typeof self !== 'undefined' ? self : typeof globalThis !== 'undefined' ? globalThis : this, () => {var exports = {};var module = { exports };
|
2
|
+
"use strict";var cf=Object.create;var ai=Object.defineProperty;var vf=Object.getOwnPropertyDescriptor;var pf=Object.getOwnPropertyNames;var mf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var Za=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports),yf=(c,g)=>{for(var n in g)ai(c,n,{get:g[n],enumerable:!0})},es=(c,g,n,l)=>{if(g&&typeof g=="object"||typeof g=="function")for(let f of pf(g))!gf.call(c,f)&&f!==n&&ai(c,f,{get:()=>g[f],enumerable:!(l=vf(g,f))||l.enumerable});return c};var gr=(c,g,n)=>(n=c!=null?cf(mf(c)):{},es(g||!c||!c.__esModule?ai(n,"default",{value:c,enumerable:!0}):n,c)),Ef=c=>es(ai({},"__esModule",{value:!0}),c);var _r=Za((nh,Xi)=>{"use strict";var xf=Object.prototype.hasOwnProperty,pt="~";function Rr(){}Object.create&&(Rr.prototype=Object.create(null),new Rr().__proto__||(pt=!1));function bf(c,g,n){this.fn=c,this.context=g,this.once=n||!1}function os(c,g,n,l,f){if(typeof n!="function")throw new TypeError("The listener must be a function");var v=new bf(n,l||c,f),E=pt?pt+g:g;return c._events[E]?c._events[E].fn?c._events[E]=[c._events[E],v]:c._events[E].push(v):(c._events[E]=v,c._eventsCount++),c}function oi(c,g){--c._eventsCount===0?c._events=new Rr:delete c._events[g]}function ht(){this._events=new Rr,this._eventsCount=0}ht.prototype.eventNames=function(){var g=[],n,l;if(this._eventsCount===0)return g;for(l in n=this._events)xf.call(n,l)&&g.push(pt?l.slice(1):l);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(n)):g};ht.prototype.listeners=function(g){var n=pt?pt+g:g,l=this._events[n];if(!l)return[];if(l.fn)return[l.fn];for(var f=0,v=l.length,E=new Array(v);f<v;f++)E[f]=l[f].fn;return E};ht.prototype.listenerCount=function(g){var n=pt?pt+g:g,l=this._events[n];return l?l.fn?1:l.length:0};ht.prototype.emit=function(g,n,l,f,v,E){var _=pt?pt+g:g;if(!this._events[_])return!1;var S=this._events[_],C=arguments.length,I,P;if(S.fn){switch(S.once&&this.removeListener(g,S.fn,void 0,!0),C){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,n),!0;case 3:return S.fn.call(S.context,n,l),!0;case 4:return S.fn.call(S.context,n,l,f),!0;case 5:return S.fn.call(S.context,n,l,f,v),!0;case 6:return S.fn.call(S.context,n,l,f,v,E),!0}for(P=1,I=new Array(C-1);P<C;P++)I[P-1]=arguments[P];S.fn.apply(S.context,I)}else{var H=S.length,W;for(P=0;P<H;P++)switch(S[P].once&&this.removeListener(g,S[P].fn,void 0,!0),C){case 1:S[P].fn.call(S[P].context);break;case 2:S[P].fn.call(S[P].context,n);break;case 3:S[P].fn.call(S[P].context,n,l);break;case 4:S[P].fn.call(S[P].context,n,l,f);break;default:if(!I)for(W=1,I=new Array(C-1);W<C;W++)I[W-1]=arguments[W];S[P].fn.apply(S[P].context,I)}}return!0};ht.prototype.on=function(g,n,l){return os(this,g,n,l,!1)};ht.prototype.once=function(g,n,l){return os(this,g,n,l,!0)};ht.prototype.removeListener=function(g,n,l,f){var v=pt?pt+g:g;if(!this._events[v])return this;if(!n)return oi(this,v),this;var E=this._events[v];if(E.fn)E.fn===n&&(!f||E.once)&&(!l||E.context===l)&&oi(this,v);else{for(var _=0,S=[],C=E.length;_<C;_++)(E[_].fn!==n||f&&!E[_].once||l&&E[_].context!==l)&&S.push(E[_]);S.length?this._events[v]=S.length===1?S[0]:S:oi(this,v)}return this};ht.prototype.removeAllListeners=function(g){var n;return g?(n=pt?pt+g:g,this._events[n]&&oi(this,n)):(this._events=new Rr,this._eventsCount=0),this};ht.prototype.off=ht.prototype.removeListener;ht.prototype.addListener=ht.prototype.on;ht.prefixed=pt;ht.EventEmitter=ht;typeof Xi<"u"&&(Xi.exports=ht)});var so=Za((ao,_n)=>{(function c(g){(function(n,l){typeof ao=="object"&&typeof _n<"u"?_n.exports=l():typeof define=="function"&&define.amd?define(l):(n=typeof globalThis<"u"?globalThis:n||self,n.Hls=l())})(this,function(){"use strict";function n(s,a){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(s);a&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})),i.push.apply(i,e)}return i}function l(s){for(var a=1;a<arguments.length;a++){var i=arguments[a]!=null?arguments[a]:{};a%2?n(Object(i),!0).forEach(function(e){S(s,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(i,e))})}return s}function f(s,a){if(typeof s!="object"||!s)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var e=i.call(s,a||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function v(s){var a=f(s,"string");return typeof a=="symbol"?a:String(a)}function E(s,a){for(var i=0;i<a.length;i++){var e=a[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,v(e.key),e)}}function _(s,a,i){return a&&E(s.prototype,a),i&&E(s,i),Object.defineProperty(s,"prototype",{writable:!1}),s}function S(s,a,i){return a=v(a),a in s?Object.defineProperty(s,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[a]=i,s}function C(){return C=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(s[e]=i[e])}return s},C.apply(this,arguments)}function I(s,a){s.prototype=Object.create(a.prototype),s.prototype.constructor=s,H(s,a)}function P(s){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},P(s)}function H(s,a){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(s,a)}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Y(s,a,i){return W()?Y=Reflect.construct.bind():Y=function(t,r,o){var u=[null];u.push.apply(u,r);var h=Function.bind.apply(t,u),d=new h;return o&&H(d,o.prototype),d},Y.apply(null,arguments)}function ee(s){try{return Function.toString.call(s).indexOf("[native code]")!==-1}catch{return typeof s=="function"}}function J(s){var a=typeof Map=="function"?new Map:void 0;return J=function(e){if(e===null||!ee(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(e))return a.get(e);a.set(e,t)}function t(){return Y(e,arguments,P(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),H(t,e)},J(s)}function ae(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function se(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _e={exports:{}};(function(s,a){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(h,d,m){if(m=m||{},h=h.trim(),d=d.trim(),!d){if(!m.alwaysNormalize)return h;var p=u.parseURL(h);if(!p)throw new Error("Error trying to parse base URL.");return p.path=u.normalizePath(p.path),u.buildURLFromParts(p)}var y=u.parseURL(d);if(!y)throw new Error("Error trying to parse relative URL.");if(y.scheme)return m.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var T=u.parseURL(h);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var x=t.exec(T.path);T.netLoc=x[1],T.path=x[2]}T.netLoc&&!T.path&&(T.path="/");var b={scheme:T.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(b.netLoc=T.netLoc,y.path[0]!=="/"))if(!y.path)b.path=T.path,y.params||(b.params=T.params,y.query||(b.query=T.query));else{var L=T.path,A=L.substring(0,L.lastIndexOf("/")+1)+y.path;b.path=u.normalizePath(A)}return b.path===null&&(b.path=m.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(b)},parseURL:function(h){var d=e.exec(h);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(h){for(h=h.split("").reverse().join("").replace(r,"");h.length!==(h=h.replace(o,"")).length;);return h.split("").reverse().join("")},buildURLFromParts:function(h){return h.scheme+h.netLoc+h.path+h.params+h.query+h.fragment}};s.exports=u})()})(_e);var oe=_e.exports,j=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},ue=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=Ve},Ve=Number.MAX_SAFE_INTEGER||9007199254740991,R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s}({}),le=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),G=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),He=function(){},F={trace:He,debug:He,log:He,warn:He,info:He,error:He},O=F;function B(s){var a=self.console[s];return a?a.bind(self.console,"["+s+"] >"):He}function re(s){for(var a=arguments.length,i=new Array(a>1?a-1:0),e=1;e<a;e++)i[e-1]=arguments[e];i.forEach(function(t){O[t]=s[t]?s[t].bind(s):B(t)})}function X(s,a){if(typeof console=="object"&&s===!0||typeof s=="object"){re(s,"debug","log","info","warn","error");try{O.log('Debug logs enabled for "'+a+'" in hls.js version 1.5.17')}catch{O=F}}else O=F}var k=O,ge=/^(\d+)x(\d+)$/,De=/(.+?)=(".*?"|.*?)(?:,|$)/g,pe=function(){function s(i){typeof i=="string"&&(i=s.parseAttrList(i)),C(this,i)}var a=s.prototype;return a.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),o=0;o<t.length/2;o++)r[o]=parseInt(t.slice(o*2,o*2+2),16);return r}else return null},a.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.decimalFloatingPoint=function(e){return parseFloat(this[e])},a.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},a.enumeratedString=function(e){return this[e]},a.bool=function(e){return this[e]==="YES"},a.decimalResolution=function(e){var t=ge.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={},o='"';for(De.lastIndex=0;(t=De.exec(e))!==null;){var u=t[2];u.indexOf(o)===0&&u.lastIndexOf(o)===u.length-1&&(u=u.slice(1,-1));var h=t[1].trim();r[h]=u}return r},_(s,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),s}();function Ne(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Qe(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var ke=function(){function s(a,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(a,t)&&a[t]!==e[t]){k.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+a.ID+'"'),this._badValueForSameId=t;break}a=C(new pe({}),e,a)}if(this.attr=a,this._startDate=new Date(a["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);j(r.getTime())&&(this._endDate=r)}}return _(s,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(j(i))return i}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),$t=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},Pe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},hr=function(){function s(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[Pe.AUDIO]=null,e[Pe.VIDEO]=null,e[Pe.AUDIOVIDEO]=null,e),this.baseurl=i}var a=s.prototype;return a.setByteRange=function(e,t){var r=e.split("@",2),o;r.length===1?o=t?.byteRangeEndOffset||0:o=parseInt(r[1]),this._byteRange=[o,parseInt(r[0])+o]},_(s,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=oe.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),s}(),dr=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new $t,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=a.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,o,u,h,d){d===void 0&&(d=!1);var m=this.elementaryStreams,p=m[t];if(!p){m[t]={startPTS:r,endPTS:o,startDTS:u,endDTS:h,partial:d};return}p.startPTS=Math.min(p.startPTS,r),p.endPTS=Math.max(p.endPTS,o),p.startDTS=Math.min(p.startDTS,u),p.endDTS=Math.max(p.endDTS,h)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Pe.AUDIO]=null,t[Pe.VIDEO]=null,t[Pe.AUDIOVIDEO]=null},_(a,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var o=Object.keys(this.levelkeys);if(o.length===1)return this._decryptdata=this.levelkeys[o[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!j(this.programDateTime))return null;var t=j(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),o=r.length;if(o>1||o===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),a}(hr),Tn=function(s){I(a,s);function a(i,e,t,r,o){var u;u=s.call(this,t)||this,u.fragOffset=0,u.duration=0,u.gap=!1,u.independent=!1,u.relurl=void 0,u.fragment=void 0,u.index=void 0,u.stats=new $t,u.duration=i.decimalFloatingPoint("DURATION"),u.gap=i.bool("GAP"),u.independent=i.bool("INDEPENDENT"),u.relurl=i.enumeratedString("URI"),u.fragment=e,u.index=r;var h=i.enumeratedString("BYTERANGE");return h&&u.setByteRange(h,o),o&&(u.fragOffset=o.fragOffset+o.duration),u}return _(a,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),a}(hr),Je=10,oo=function(){function s(i){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=i}var a=s.prototype;return a.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},_(s,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||Je}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}(),uo=void 0,lo=se(uo);function nr(s,a,i){return Uint8Array.prototype.slice?s.slice(a,i):new Uint8Array(Array.prototype.slice.call(s,a,i))}var gi=function(a,i){return i+10<=a.length&&a[i]===73&&a[i+1]===68&&a[i+2]===51&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},xn=function(a,i){return i+10<=a.length&&a[i]===51&&a[i+1]===68&&a[i+2]===73&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},Nr=function(a,i){for(var e=i,t=0;gi(a,i);){t+=10;var r=Ur(a,i+6);t+=r,xn(a,i+10)&&(t+=10),i+=t}if(t>0)return a.subarray(e,e+t)},Ur=function(a,i){var e=0;return e=(a[i]&127)<<21,e|=(a[i+1]&127)<<14,e|=(a[i+2]&127)<<7,e|=a[i+3]&127,e},fo=function(a,i){return gi(a,i)&&Ur(a,i+6)+10<=a.length-i},bn=function(a){for(var i=An(a),e=0;e<i.length;e++){var t=i[e];if(Ln(t))return go(t)}},Ln=function(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"},ho=function(a){var i=String.fromCharCode(a[0],a[1],a[2],a[3]),e=Ur(a,4),t=10;return{type:i,size:e,data:a.subarray(t,t+e)}},An=function(a){for(var i=0,e=[];gi(a,i);){var t=Ur(a,i+6);i+=10;for(var r=i+t;i+8<r;){var o=ho(a.subarray(i)),u=co(o);u&&e.push(u),i+=o.size+10}xn(a,i)&&(i+=10)}return e},co=function(a){return a.type==="PRIV"?vo(a):a.type[0]==="W"?mo(a):po(a)},vo=function(a){if(!(a.size<2)){var i=Qt(a.data,!0),e=new Uint8Array(a.data.subarray(i.length+1));return{key:a.type,info:i,data:e.buffer}}},po=function(a){if(!(a.size<2)){if(a.type==="TXXX"){var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data.subarray(1));return{key:a.type,data:r}}},mo=function(a){if(a.type==="WXXX"){if(a.size<2)return;var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data);return{key:a.type,data:r}},go=function(a){if(a.data.byteLength===8){var i=new Uint8Array(a.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Qt=function(a,i){i===void 0&&(i=!1);var e=yo();if(e){var t=e.decode(a);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var o=a.length,u,h,d,m="",p=0;p<o;){if(u=a[p++],u===0&&i)return m;if(u===0||u===3)continue;switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:m+=String.fromCharCode(u);break;case 12:case 13:h=a[p++],m+=String.fromCharCode((u&31)<<6|h&63);break;case 14:h=a[p++],d=a[p++],m+=String.fromCharCode((u&15)<<12|(h&63)<<6|(d&63)<<0);break}}return m},yi;function yo(){if(!navigator.userAgent.includes("PlayStation 4"))return!yi&&typeof self.TextDecoder<"u"&&(yi=new self.TextDecoder("utf-8")),yi}var Rn={hexDump:function(a){for(var i="",e=0;e<a.length;e++){var t=a[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},Br=Math.pow(2,32)-1,Eo=[].push,Cn={video:1,audio:2,id3:3,text:4};function nt(s){return String.fromCharCode.apply(null,s)}function Dn(s,a){var i=s[a]<<8|s[a+1];return i<0?65536+i:i}function ve(s,a){var i=In(s,a);return i<0?4294967296+i:i}function wn(s,a){var i=ve(s,a);return i*=Math.pow(2,32),i+=ve(s,a+4),i}function In(s,a){return s[a]<<24|s[a+1]<<16|s[a+2]<<8|s[a+3]}function Ei(s,a,i){s[a]=i>>24,s[a+1]=i>>16&255,s[a+2]=i>>8&255,s[a+3]=i&255}function _o(s){for(var a=s.byteLength,i=0;i<a;){var e=ve(s,i);if(e>8&&s[i+4]===109&&s[i+5]===111&&s[i+6]===111&&s[i+7]===102)return!0;i=e>1?i+e:a}return!1}function be(s,a){var i=[];if(!a.length)return i;for(var e=s.byteLength,t=0;t<e;){var r=ve(s,t),o=nt(s.subarray(t+4,t+8)),u=r>1?t+r:e;if(o===a[0])if(a.length===1)i.push(s.subarray(t+8,u));else{var h=be(s.subarray(t+8,u),a.slice(1));h.length&&Eo.apply(i,h)}t=u}return i}function So(s){var a=[],i=s[0],e=8,t=ve(s,e);e+=4;var r=0,o=0;i===0?(r=ve(s,e),o=ve(s,e+4),e+=8):(r=wn(s,e),o=wn(s,e+8),e+=16),e+=2;var u=s.length+o,h=Dn(s,e);e+=2;for(var d=0;d<h;d++){var m=e,p=ve(s,m);m+=4;var y=p&2147483647,T=(p&2147483648)>>>31;if(T===1)return k.warn("SIDX has hierarchical references (not supported)"),null;var x=ve(s,m);m+=4,a.push({referenceSize:y,subsegmentDuration:x,info:{duration:x/t,start:u,end:u+y-1}}),u+=y,m+=4,e=m}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:h,references:a}}function Pn(s){for(var a=[],i=be(s,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=be(t,["tkhd"])[0];if(r){var o=r[0],u=ve(r,o===0?12:20),h=be(t,["mdia","mdhd"])[0];if(h){o=h[0];var d=ve(h,o===0?12:20),m=be(t,["mdia","hdlr"])[0];if(m){var p=nt(m.subarray(8,12)),y={soun:Pe.AUDIO,vide:Pe.VIDEO}[p];if(y){var T=be(t,["mdia","minf","stbl","stsd"])[0],x=To(T);a[u]={timescale:d,type:y},a[y]=l({timescale:d,id:u},x)}}}}}var b=be(s,["moov","mvex","trex"]);return b.forEach(function(L){var A=ve(L,4),D=a[A];D&&(D.default={duration:ve(L,12),flags:ve(L,20)})}),a}function To(s){var a=s.subarray(8),i=a.subarray(86),e=nt(a.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var o=be(a,[e])[0],u=o.subarray(e==="enca"?28:78),h=be(u,["sinf"]);h.forEach(function(yt){var ft=be(yt,["schm"])[0];if(ft){var st=nt(ft.subarray(4,8));if(st==="cbcs"||st==="cenc"){var or=be(yt,["frma"])[0];or&&(t=nt(or))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var d=be(i,["avcC"])[0];t+="."+Gr(d[1])+Gr(d[2])+Gr(d[3]);break}case"mp4a":{var m=be(a,[e])[0],p=be(m.subarray(28),["esds"])[0];if(p&&p.length>12){var y=4;if(p[y++]!==3)break;y=_i(p,y),y+=2;var T=p[y++];if(T&128&&(y+=2),T&64&&(y+=p[y++]),p[y++]!==4)break;y=_i(p,y);var x=p[y++];if(x===64)t+="."+Gr(x);else break;if(y+=12,p[y++]!==5)break;y=_i(p,y);var b=p[y++],L=(b&248)>>3;L===31&&(L+=1+((b&7)<<3)+((p[y]&224)>>5)),t+="."+L}break}case"hvc1":case"hev1":{var A=be(i,["hvcC"])[0],D=A[1],w=["","A","B","C"][D>>6],N=D&31,U=ve(A,2),$=(D&32)>>5?"H":"L",V=A[12],M=A.subarray(6,12);t+="."+w+N,t+="."+U.toString(16).toUpperCase(),t+="."+$+V;for(var K="",z=M.length;z--;){var te=M[z];if(te||K){var Z=te.toString(16).toUpperCase();K="."+Z+K}}t+=K;break}case"dvh1":case"dvhe":{var ie=be(i,["dvcC"])[0],he=ie[2]>>1&127,fe=ie[2]<<5&32|ie[3]>>3&31;t+="."+Ut(he)+"."+Ut(fe);break}case"vp09":{var Le=be(i,["vpcC"])[0],Ee=Le[4],we=Le[5],Ae=Le[6]>>4&15;t+="."+Ut(Ee)+"."+Ut(we)+"."+Ut(Ae);break}case"av01":{var ye=be(i,["av1C"])[0],je=ye[1]>>>5,Fe=ye[1]&31,qe=ye[2]>>>7?"H":"M",Xe=(ye[2]&64)>>6,Ze=(ye[2]&32)>>5,ze=je===2&&Xe?Ze?12:10:Xe?10:8,Ue=(ye[2]&16)>>4,jt=(ye[2]&8)>>3,_t=(ye[2]&4)>>2,$e=ye[2]&3,ct=1,vt=1,et=1,Ke=0;t+="."+je+"."+Ut(Fe)+qe+"."+Ut(ze)+"."+Ue+"."+jt+_t+$e+"."+Ut(ct)+"."+Ut(vt)+"."+Ut(et)+"."+Ke;break}}return{codec:t,encrypted:r}}function _i(s,a){for(var i=a+5;s[a++]&128&&a<i;);return a}function Gr(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Ut(s){return(s<10?"0":"")+s}function xo(s,a){if(!s||!a)return s;var i=a.keyId;if(i&&a.isCommonEncryption){var e=be(s,["moov","trak"]);e.forEach(function(t){var r=be(t,["mdia","minf","stbl","stsd"])[0],o=r.subarray(8),u=be(o,["enca"]),h=u.length>0;h||(u=be(o,["encv"])),u.forEach(function(d){var m=h?d.subarray(28):d.subarray(78),p=be(m,["sinf"]);p.forEach(function(y){var T=bo(y);if(T){var x=T.subarray(8,24);x.some(function(b){return b!==0})||(k.log("[eme] Patching keyId in 'enc"+(h?"a":"v")+">sinf>>tenc' box: "+Rn.hexDump(x)+" -> "+Rn.hexDump(i)),T.set(i,8))}})})})}return s}function bo(s){var a=be(s,["schm"])[0];if(a){var i=nt(a.subarray(4,8));if(i==="cbcs"||i==="cenc")return be(s,["schi","tenc"])[0]}return null}function Lo(s,a){return be(a,["moof","traf"]).reduce(function(i,e){var t=be(e,["tfdt"])[0],r=t[0],o=be(e,["tfhd"]).reduce(function(u,h){var d=ve(h,4),m=s[d];if(m){var p=ve(t,4);if(r===1){if(p===Br)return k.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),u;p*=Br+1,p+=ve(t,8)}var y=m.timescale||9e4,T=p/y;if(j(T)&&(u===null||T<u))return T}return u},null);return o!==null&&j(o)&&(i===null||o<i)?o:i},null)}function Ao(s,a){for(var i=0,e=0,t=0,r=be(s,["moof","traf"]),o=0;o<r.length;o++){var u=r[o],h=be(u,["tfhd"])[0],d=ve(h,4),m=a[d];if(m){var p=m.default,y=ve(h,0)|p?.flags,T=p?.duration;y&8&&(y&2?T=ve(h,12):T=ve(h,8));for(var x=m.timescale||9e4,b=be(u,["trun"]),L=0;L<b.length;L++){if(i=Ro(b[L]),!i&&T){var A=ve(b[L],4);i=T*A}m.type===Pe.VIDEO?e+=i/x:m.type===Pe.AUDIO&&(t+=i/x)}}}if(e===0&&t===0){for(var D=1/0,w=0,N=0,U=be(s,["sidx"]),$=0;$<U.length;$++){var V=So(U[$]);if(V!=null&&V.references){D=Math.min(D,V.earliestPresentationTime/V.timescale);var M=V.references.reduce(function(K,z){return K+z.info.duration||0},0);w=Math.max(w,M+V.earliestPresentationTime/V.timescale),N=w-D}}if(N&&j(N))return N}return e||t}function Ro(s){var a=ve(s,0),i=8;a&1&&(i+=4),a&4&&(i+=4);for(var e=0,t=ve(s,4),r=0;r<t;r++){if(a&256){var o=ve(s,i);e+=o,i+=4}a&512&&(i+=4),a&1024&&(i+=4),a&2048&&(i+=4)}return e}function Co(s,a,i){be(a,["moof","traf"]).forEach(function(e){be(e,["tfhd"]).forEach(function(t){var r=ve(t,4),o=s[r];if(o){var u=o.timescale||9e4;be(e,["tfdt"]).forEach(function(h){var d=h[0],m=i*u;if(m){var p=ve(h,4);if(d===0)p-=m,p=Math.max(p,0),Ei(h,4,p);else{p*=Math.pow(2,32),p+=ve(h,8),p-=m,p=Math.max(p,0);var y=Math.floor(p/(Br+1)),T=Math.floor(p%(Br+1));Ei(h,4,y),Ei(h,8,T)}}})}})})}function Do(s){var a={valid:null,remainder:null},i=be(s,["moof"]);if(i.length<2)return a.remainder=s,a;var e=i[i.length-1];return a.valid=nr(s,0,e.byteOffset-8),a.remainder=nr(s,e.byteOffset-8),a}function At(s,a){var i=new Uint8Array(s.length+a.length);return i.set(s),i.set(a,s.length),i}function kn(s,a){var i=[],e=a.samples,t=a.timescale,r=a.id,o=!1,u=be(e,["moof"]);return u.map(function(h){var d=h.byteOffset-8,m=be(h,["traf"]);m.map(function(p){var y=be(p,["tfdt"]).map(function(T){var x=T[0],b=ve(T,4);return x===1&&(b*=Math.pow(2,32),b+=ve(T,8)),b/t})[0];return y!==void 0&&(s=y),be(p,["tfhd"]).map(function(T){var x=ve(T,4),b=ve(T,0)&16777215,L=(b&1)!==0,A=(b&2)!==0,D=(b&8)!==0,w=0,N=(b&16)!==0,U=0,$=(b&32)!==0,V=8;x===r&&(L&&(V+=8),A&&(V+=4),D&&(w=ve(T,V),V+=4),N&&(U=ve(T,V),V+=4),$&&(V+=4),a.type==="video"&&(o=wo(a.codec)),be(p,["trun"]).map(function(M){var K=M[0],z=ve(M,0)&16777215,te=(z&1)!==0,Z=0,ie=(z&4)!==0,he=(z&256)!==0,fe=0,Le=(z&512)!==0,Ee=0,we=(z&1024)!==0,Ae=(z&2048)!==0,ye=0,je=ve(M,4),Fe=8;te&&(Z=ve(M,Fe),Fe+=4),ie&&(Fe+=4);for(var qe=Z+d,Xe=0;Xe<je;Xe++){if(he?(fe=ve(M,Fe),Fe+=4):fe=w,Le?(Ee=ve(M,Fe),Fe+=4):Ee=U,we&&(Fe+=4),Ae&&(K===0?ye=ve(M,Fe):ye=In(M,Fe),Fe+=4),a.type===Pe.VIDEO)for(var Ze=0;Ze<Ee;){var ze=ve(e,qe);if(qe+=4,Io(o,e[qe])){var Ue=e.subarray(qe,qe+ze);On(Ue,o?2:1,s+ye/t,i)}qe+=ze,Ze+=ze+4}s+=fe/t}}))})})}),i}function wo(s){if(!s)return!1;var a=s.indexOf("."),i=a<0?s:s.substring(0,a);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function Io(s,a){if(s){var i=a>>1&63;return i===39||i===40}else{var e=a&31;return e===6}}function On(s,a,i,e){var t=Mn(s),r=0;r+=a;for(var o=0,u=0,h=0;r<t.length;){o=0;do{if(r>=t.length)break;h=t[r++],o+=h}while(h===255);u=0;do{if(r>=t.length)break;h=t[r++],u+=h}while(h===255);var d=t.length-r,m=r;if(u<d)r+=u;else if(u>d){k.error("Malformed SEI payload. "+u+" is too small, only "+d+" bytes left to parse.");break}if(o===4){var p=t[m++];if(p===181){var y=Dn(t,m);if(m+=2,y===49){var T=ve(t,m);if(m+=4,T===1195456820){var x=t[m++];if(x===3){var b=t[m++],L=31&b,A=64&b,D=A?2+L*3:0,w=new Uint8Array(D);if(A){w[0]=b;for(var N=1;N<D;N++)w[N]=t[m++]}e.push({type:x,payloadType:o,pts:i,bytes:w})}}}}}else if(o===5&&u>16){for(var U=[],$=0;$<16;$++){var V=t[m++].toString(16);U.push(V.length==1?"0"+V:V),($===3||$===5||$===7||$===9)&&U.push("-")}for(var M=u-16,K=new Uint8Array(M),z=0;z<M;z++)K[z]=t[m++];e.push({payloadType:o,pts:i,uuid:U.join(""),userData:Qt(K),userDataBytes:K})}}}function Mn(s){for(var a=s.byteLength,i=[],e=1;e<a-2;)s[e]===0&&s[e+1]===0&&s[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return s;var t=a-i.length,r=new Uint8Array(t),o=0;for(e=0;e<t;o++,e++)o===i[0]&&(o++,i.shift()),r[e]=s[o];return r}function Po(s){var a=s[0],i="",e="",t=0,r=0,o=0,u=0,h=0,d=0;if(a===0){for(;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1,t=ve(s,12),r=ve(s,16),u=ve(s,20),h=ve(s,24),d=28}else if(a===1){d+=4,t=ve(s,d),d+=4;var m=ve(s,d);d+=4;var p=ve(s,d);for(d+=4,o=Math.pow(2,32)*m+p,ue(o)||(o=Number.MAX_SAFE_INTEGER,k.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=ve(s,d),d+=4,h=ve(s,d),d+=4;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1}var y=s.subarray(d,s.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:o,presentationTimeDelta:r,eventDuration:u,id:h,payload:y}}var ko=function(){s.clearKeyUriToKeyIdMap=function(){};function s(i,e,t,r,o){r===void 0&&(r=[1]),o===void 0&&(o=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=o,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var a=s.prototype;return a.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},a.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&k.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=Oo(e),r=new s(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},s}();function Oo(s){for(var a=new Uint8Array(16),i=12;i<16;i++)a[i]=s>>8*(15-i)&255;return a}function ar(s){if(s===void 0&&(s=!0),!(typeof self>"u")){var a=(s||!self.MediaSource)&&self.ManagedMediaSource;return a||self.MediaSource||self.WebKitMediaSource}}function Mo(s){return typeof self<"u"&&s===self.ManagedMediaSource}var Vr={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Fo(s,a){var i=Vr[a];return!!i&&!!i[s.slice(0,4)]}function Si(s,a,i){return i===void 0&&(i=!0),!s.split(",").some(function(e){return!Fn(e,a,i)})}function Fn(s,a,i){var e;i===void 0&&(i=!0);var t=ar(i);return(e=t?.isTypeSupported(Ti(s,a)))!=null?e:!1}function Ti(s,a){return a+'/mp4;codecs="'+s+'"'}function Nn(s){if(s){var a=s.substring(0,4);return Vr.video[a]}return 2}function Hr(s){return s.split(",").reduce(function(a,i){var e=Vr.video[i];return e?(e*2+a)/(a?3:2):(Vr.audio[i]+a)/(a?2:1)},0)}var xi={};function No(s,a){if(a===void 0&&(a=!0),xi[s])return xi[s];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[s],e=0;e<i.length;e++)if(Fn(i[e],"audio",a))return xi[s]=i[e],i[e];return s}var Uo=/flac|opus/i;function Kr(s,a){return a===void 0&&(a=!0),s.replace(Uo,function(i){return No(i.toLowerCase(),a)})}function Un(s,a){return s&&s!=="mp4a"?s:a&&a.split(",")[0]}function Bo(s){for(var a=s.split(","),i=0;i<a.length;i++){var e=a[i].split(".");if(e.length>2){var t=e.shift()+".";t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),a[i]=t}}return a.join(",")}var Bn=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Gn=/#EXT-X-MEDIA:(.*)/g,Go=/^#EXT(?:INF|-X-TARGETDURATION):/m,Vn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Vo=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Lr=function(){function s(){}return s.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},s.resolve=function(i,e){return oe.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},s.isMediaPlaylist=function(i){return Go.test(i)},s.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},o=[];Bn.lastIndex=0;for(var u;(u=Bn.exec(i))!=null;)if(u[1]){var h,d=new pe(u[1]),m=u[2],p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:s.resolve(m,e)},y=d.decimalResolution("RESOLUTION");y&&(p.width=y.width,p.height=y.height),Ho(d.CODECS,p),(h=p.unknownCodecs)!=null&&h.length||o.push(p),r.levels.push(p)}else if(u[3]){var T=u[3],x=u[4];switch(T){case"SESSION-DATA":{var b=new pe(x),L=b["DATA-ID"];L&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[L]=b);break}case"SESSION-KEY":{var A=Hn(x,e);A.encrypted&&A.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(A)):k.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+x+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var D=new pe(x);r.contentSteering={uri:s.resolve(D["SERVER-URI"],e),pathwayId:D["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Kn(x);break}}}var w=o.length>0&&o.length<r.levels.length;return r.levels=w?o:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(i,e,t){var r,o={},u=t.levels,h={AUDIO:u.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),SUBTITLES:u.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),"CLOSED-CAPTIONS":[]},d=0;for(Gn.lastIndex=0;(r=Gn.exec(i))!==null;){var m=new pe(r[1]),p=m.TYPE;if(p){var y=h[p],T=o[p]||[];o[p]=T;var x=m.LANGUAGE,b=m["ASSOC-LANGUAGE"],L=m.CHANNELS,A=m.CHARACTERISTICS,D=m["INSTREAM-ID"],w={attrs:m,bitrate:0,id:d++,groupId:m["GROUP-ID"]||"",name:m.NAME||x||"",type:p,default:m.bool("DEFAULT"),autoselect:m.bool("AUTOSELECT"),forced:m.bool("FORCED"),lang:x,url:m.URI?s.resolve(m.URI,e):""};if(b&&(w.assocLang=b),L&&(w.channels=L),A&&(w.characteristics=A),D&&(w.instreamId=D),y!=null&&y.length){var N=s.findGroup(y,w.groupId)||y[0];Wn(w,N,"audioCodec"),Wn(w,N,"textCodec")}T.push(w)}}return o},s.parseLevelPlaylist=function(i,e,t,r,o,u){var h=new oo(e),d=h.fragments,m=null,p=0,y=0,T=0,x=0,b=null,L=new dr(r,e),A,D,w,N=-1,U=!1,$=null;for(Vn.lastIndex=0,h.m3u8=i,h.hasVariableRefs=!1;(A=Vn.exec(i))!==null;){U&&(U=!1,L=new dr(r,e),L.start=T,L.sn=p,L.cc=x,L.level=t,m&&(L.initSegment=m,L.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null,$&&(L.setByteRange($),$=null)));var V=A[1];if(V){L.duration=parseFloat(V);var M=(" "+A[2]).slice(1);L.title=M||null,L.tagList.push(M?["INF",V,M]:["INF",V])}else if(A[3]){if(j(L.duration)){L.start=T,w&&Yn(L,w,h),L.sn=p,L.level=t,L.cc=x,d.push(L);var K=(" "+A[3]).slice(1);L.relurl=K,jn(L,b),b=L,T+=L.duration,p++,y=0,U=!0}}else if(A[4]){var z=(" "+A[4]).slice(1);b?L.setByteRange(z,b):L.setByteRange(z)}else if(A[5])L.rawProgramDateTime=(" "+A[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),N===-1&&(N=d.length);else{if(A=A[0].match(Vo),!A){k.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<A.length&&!(typeof A[D]<"u");D++);var te=(" "+A[D]).slice(1),Z=(" "+A[D+1]).slice(1),ie=A[D+2]?(" "+A[D+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":h.type=Z.toUpperCase();break;case"MEDIA-SEQUENCE":p=h.startSN=parseInt(Z);break;case"SKIP":{var he=new pe(Z),fe=he.decimalInteger("SKIPPED-SEGMENTS");if(j(fe)){h.skippedSegments=fe;for(var Le=fe;Le--;)d.unshift(null);p+=fe}var Ee=he.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ee&&(h.recentlyRemovedDateranges=Ee.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(Z),1);break;case"VERSION":h.version=parseInt(Z);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(Z||ie)&&L.tagList.push(ie?[Z,ie]:[Z]);break;case"DISCONTINUITY":x++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([te]);break;case"BITRATE":L.tagList.push([te,Z]);break;case"DATERANGE":{var we=new pe(Z),Ae=new ke(we,h.dateRanges[we.ID]);Ae.isValid||h.skippedSegments?h.dateRanges[Ae.id]=Ae:k.warn('Ignoring invalid DATERANGE tag: "'+Z+'"'),L.tagList.push(["EXT-X-DATERANGE",Z]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":x=parseInt(Z);break;case"KEY":{var ye=Hn(Z,e);if(ye.isSupported()){if(ye.method==="NONE"){w=void 0;break}w||(w={}),w[ye.keyFormat]&&(w=C({},w)),w[ye.keyFormat]=ye}else k.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Z+'"');break}case"START":h.startTimeOffset=Kn(Z);break;case"MAP":{var je=new pe(Z);if(L.duration){var Fe=new dr(r,e);zn(Fe,je,t,w),m=Fe,L.initSegment=m,m.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=m.rawProgramDateTime)}else{var qe=L.byteRangeEndOffset;if(qe){var Xe=L.byteRangeStartOffset;$=qe-Xe+"@"+Xe}else $=null;zn(L,je,t,w),m=L,U=!0}break}case"SERVER-CONTROL":{var Ze=new pe(Z);h.canBlockReload=Ze.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=Ze.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&Ze.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=Ze.optionalFloat("PART-HOLD-BACK",0),h.holdBack=Ze.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ze=new pe(Z);h.partTarget=ze.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ue=h.partList;Ue||(Ue=h.partList=[]);var jt=y>0?Ue[Ue.length-1]:void 0,_t=y++,$e=new pe(Z),ct=new Tn($e,L,e,_t,jt);Ue.push(ct),L.duration+=ct.duration;break}case"PRELOAD-HINT":{var vt=new pe(Z);h.preloadHint=vt;break}case"RENDITION-REPORT":{var et=new pe(Z);h.renditionReports=h.renditionReports||[],h.renditionReports.push(et);break}default:k.warn("line parsed but not handled: "+A);break}}}b&&!b.relurl?(d.pop(),T-=b.duration,h.partList&&(h.fragmentHint=b)):h.partList&&(jn(L,b),L.cc=x,h.fragmentHint=L,w&&Yn(L,w,h));var Ke=d.length,yt=d[0],ft=d[Ke-1];if(T+=h.skippedSegments*h.targetduration,T>0&&Ke&&ft){h.averagetargetduration=T/Ke;var st=ft.sn;h.endSN=st!=="initSegment"?st:0,h.live||(ft.endList=!0),yt&&(h.startCC=yt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(T+=h.fragmentHint.duration),h.totalduration=T,h.endCC=x,N>0&&Ko(d,N),h},s}();function Hn(s,a,i){var e,t,r=new pe(s),o=(e=r.METHOD)!=null?e:"",u=r.URI,h=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,m=(t=r.KEYFORMAT)!=null?t:"identity";u&&r.IV&&!h&&k.error("Invalid IV: "+r.IV);var p=u?Lr.resolve(u,a):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new ko(o,p,m,y,h)}function Kn(s){var a=new pe(s),i=a.decimalFloatingPoint("TIME-OFFSET");return j(i)?i:null}function Ho(s,a){var i=(s||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return Fo(r,e)});t.length&&(a[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),a.unknownCodecs=i}function Wn(s,a,i){var e=a[i];e&&(s[i]=e)}function Ko(s,a){for(var i=s[a],e=a;e--;){var t=s[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function jn(s,a){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):a!=null&&a.programDateTime&&(s.programDateTime=a.endProgramDateTime),j(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function zn(s,a,i,e){s.relurl=a.URI,a.BYTERANGE&&s.setByteRange(a.BYTERANGE),s.level=i,s.sn="initSegment",e&&(s.levelkeys=e),s.initSegment=null}function Yn(s,a,i){s.levelkeys=a;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==a)&&Object.keys(a).some(function(t){return a[t].isCommonEncryption})&&e.push(s)}var Oe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Me={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function qn(s){var a=s.type;switch(a){case Oe.AUDIO_TRACK:return Me.AUDIO;case Oe.SUBTITLE_TRACK:return Me.SUBTITLE;default:return Me.MAIN}}function bi(s,a){var i=s.url;return(i===void 0||i.indexOf("data:")===0)&&(i=a.url),i}var Wo=function(){function s(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var a=s.prototype;return a.startLoad=function(e){},a.stopLoad=function(){this.destroyInternalLoaders()},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,o=t.loader,u=r||o,h=new u(t);return this.loaders[e.type]=h,h},a.getInternalLoader=function(e){return this.loaders[e.type]},a.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},a.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},a.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},a.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Oe.MANIFEST,url:r,deliveryDirectives:null})},a.onLevelLoading=function(e,t){var r=t.id,o=t.level,u=t.pathwayId,h=t.url,d=t.deliveryDirectives;this.load({id:r,level:o,pathwayId:u,responseType:"text",type:Oe.LEVEL,url:h,deliveryDirectives:d})},a.onAudioTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.AUDIO_TRACK,url:u,deliveryDirectives:h})},a.onSubtitleTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.SUBTITLE_TRACK,url:u,deliveryDirectives:h})},a.load=function(e){var t,r=this,o=this.hls.config,u=this.getInternalLoader(e);if(u){var h=u.context;if(h&&h.url===e.url&&h.level===e.level){k.trace("[playlist-loader]: playlist request ongoing");return}k.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}var d;if(e.type===Oe.MANIFEST?d=o.manifestLoadPolicy.default:d=C({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){var m;if(e.type===Oe.LEVEL&&e.level!==null?m=this.hls.levels[e.level].details:e.type===Oe.AUDIO_TRACK&&e.id!==null?m=this.hls.audioTracks[e.id].details:e.type===Oe.SUBTITLE_TRACK&&e.id!==null&&(m=this.hls.subtitleTracks[e.id].details),m){var p=m.partTarget,y=m.targetduration;if(p&&y){var T=Math.max(p*3,y*.8)*1e3;d=C({},d,{maxTimeToFirstByteMs:Math.min(T,d.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(T,d.maxTimeToFirstByteMs)})}}}var x=d.errorRetry||d.timeoutRetry||{},b={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:x.maxNumRetry||0,retryDelay:x.retryDelayMs||0,maxRetryDelay:x.maxRetryDelayMs||0},L={onSuccess:function(D,w,N,U){var $=r.getInternalLoader(N);r.resetInternalLoader(N.type);var V=D.data;if(V.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(D,N,new Error("no EXTM3U delimiter"),U||null,w);return}w.parsing.start=performance.now(),Lr.isMediaPlaylist(V)?r.handleTrackOrLevelPlaylist(D,w,N,U||null,$):r.handleMasterPlaylist(D,w,N,U)},onError:function(D,w,N,U){r.handleNetworkError(w,N,!1,D,U)},onTimeout:function(D,w,N){r.handleNetworkError(w,N,!0,void 0,D)}};u.load(e,b,L)},a.handleMasterPlaylist=function(e,t,r,o){var u=this.hls,h=e.data,d=bi(e,r),m=Lr.parseMasterPlaylist(h,d);if(m.playlistParsingError){this.handleManifestParsingError(e,r,m.playlistParsingError,o,t);return}var p=m.contentSteering,y=m.levels,T=m.sessionData,x=m.sessionKeys,b=m.startTimeOffset,L=m.variableList;this.variableList=L;var A=Lr.parseMasterPlaylistMedia(h,d,m),D=A.AUDIO,w=D===void 0?[]:D,N=A.SUBTITLES,U=A["CLOSED-CAPTIONS"];if(w.length){var $=w.some(function(V){return!V.url});!$&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(k.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new pe({}),bitrate:0,url:""}))}u.trigger(R.MANIFEST_LOADED,{levels:y,audioTracks:w,subtitles:N,captions:U,contentSteering:p,url:d,stats:t,networkDetails:o,sessionData:T,sessionKeys:x,startTimeOffset:b,variableList:L})},a.handleTrackOrLevelPlaylist=function(e,t,r,o,u){var h=this.hls,d=r.id,m=r.level,p=r.type,y=bi(e,r),T=0,x=j(m)?m:j(d)?d:0,b=qn(r),L=Lr.parseLevelPlaylist(e.data,y,x,b,T,this.variableList);if(p===Oe.MANIFEST){var A={attrs:new pe({}),bitrate:0,details:L,name:"",url:y};h.trigger(R.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:y,stats:t,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=L,this.handlePlaylistLoaded(L,e,t,r,o,u)},a.handleManifestParsingError=function(e,t,r,o,u){this.hls.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.MANIFEST_PARSING_ERROR,fatal:t.type===Oe.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:o,stats:u})},a.handleNetworkError=function(e,t,r,o,u){r===void 0&&(r=!1);var h="A network "+(r?"timeout":"error"+(o?" (status "+o.code+")":""))+" occurred while loading "+e.type;e.type===Oe.LEVEL?h+=": "+e.level+" id: "+e.id:(e.type===Oe.AUDIO_TRACK||e.type===Oe.SUBTITLE_TRACK)&&(h+=" id: "+e.id+' group-id: "'+e.groupId+'"');var d=new Error(h);k.warn("[playlist-loader]: "+h);var m=G.UNKNOWN,p=!1,y=this.getInternalLoader(e);switch(e.type){case Oe.MANIFEST:m=r?G.MANIFEST_LOAD_TIMEOUT:G.MANIFEST_LOAD_ERROR,p=!0;break;case Oe.LEVEL:m=r?G.LEVEL_LOAD_TIMEOUT:G.LEVEL_LOAD_ERROR,p=!1;break;case Oe.AUDIO_TRACK:m=r?G.AUDIO_TRACK_LOAD_TIMEOUT:G.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Oe.SUBTITLE_TRACK:m=r?G.SUBTITLE_TRACK_LOAD_TIMEOUT:G.SUBTITLE_LOAD_ERROR,p=!1;break}y&&this.resetInternalLoader(e.type);var T={type:le.NETWORK_ERROR,details:m,fatal:p,url:e.url,loader:y,context:e,error:d,networkDetails:t,stats:u};if(o){var x=t?.url||e.url;T.response=l({url:x,data:void 0},o)}this.hls.trigger(R.ERROR,T)},a.handlePlaylistLoaded=function(e,t,r,o,u,h){var d=this.hls,m=o.type,p=o.level,y=o.id,T=o.groupId,x=o.deliveryDirectives,b=bi(t,o),L=qn(o),A=typeof o.level=="number"&&L===Me.MAIN?p:void 0;if(!e.fragments.length){var D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:D,reason:D.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var w=e.playlistParsingError;if(w){d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:w,reason:w.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}switch(e.live&&h&&(h.getCacheAge&&(e.ageHeader=h.getCacheAge()||0),(!h.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),m){case Oe.MANIFEST:case Oe.LEVEL:d.trigger(R.LEVEL_LOADED,{details:e,level:A||0,id:y||0,stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break}},s}();function jo(s,a){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=s,a.dispatchEvent(i)}function zo(s){var a=s.mode;if(a==="disabled"&&(s.mode="hidden"),s.cues)for(var i=s.cues.length;i--;)s.removeCue(s.cues[i]);a==="disabled"&&(s.mode=a)}function Yo(s,a,i,e){var t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var r=Xo(s.cues,a,i),o=0;o<r.length;o++)(!e||e(r[o]))&&s.removeCue(r[o]);t==="disabled"&&(s.mode=t)}function qo(s,a){if(a<s[0].startTime)return 0;var i=s.length-1;if(a>s[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(a<s[r].startTime)t=r-1;else if(a>s[r].startTime&&e<i)e=r+1;else return r}return s[e].startTime-a<a-s[t].startTime?e:t}function Xo(s,a,i){var e=[],t=qo(s,a);if(t>-1)for(var r=t,o=s.length;r<o;r++){var u=s[r];if(u.startTime>=a&&u.endTime<=i)e.push(u);else if(u.startTime>i)return e}return e}var Rt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},$o=.25;function Li(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Xn(s,a,i,e,t){var r=new s(a,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new s(a,i,JSON.stringify(t?l({type:t},e):e))}return r}var Wr=function(){var s=Li();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Ai(s,a){return s.getTime()/1e3-a}function Qo(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Jo=function(){function s(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var a=s.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(e,t){this.media=t.media},a.onMediaDetaching=function(){this.id3Track&&(zo(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},a.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return jo(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,o=r.enableEmsgMetadataCues,u=r.enableID3MetadataCues;if(!(!o&&!u)){var h=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var d=Li();if(d)for(var m=0;m<h.length;m++){var p=h[m].type;if(!(p===Rt.emsg&&!o||!u)){var y=An(h[m].data);if(y){var T=h[m].pts,x=T+h[m].duration;x>Wr&&(x=Wr);var b=x-T;b<=0&&(x=T+$o);for(var L=0;L<y.length;L++){var A=y[L];if(!Ln(A)){this.updateId3CueEnds(T,p);var D=Xn(d,T,x,A,p);D&&this.id3Track.addCue(D)}}}}}}}},a.updateId3CueEnds=function(e,t){var r,o=(r=this.id3Track)==null?void 0:r.cues;if(o)for(var u=o.length;u--;){var h=o[u];h.type===t&&h.startTime<e&&h.endTime===Wr&&(h.endTime=e)}},a.onBufferFlushing=function(e,t){var r=t.startOffset,o=t.endOffset,u=t.type,h=this.id3Track,d=this.hls;if(d){var m=d.config,p=m.enableEmsgMetadataCues,y=m.enableID3MetadataCues;if(h&&(p||y)){var T;u==="audio"?T=function(b){return b.type===Rt.audioId3&&y}:u==="video"?T=function(b){return b.type===Rt.emsg&&p}:T=function(b){return b.type===Rt.audioId3&&y||b.type===Rt.emsg&&p},Yo(h,r,o,T)}}},a.onLevelUpdated=function(e,t){var r=this,o=t.details;if(!(!this.media||!o.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,h=this.id3Track,d=o.dateRanges,m=Object.keys(d);if(h)for(var p=Object.keys(u).filter(function(w){return!m.includes(w)}),y=function(){var N=p[T];Object.keys(u[N].cues).forEach(function(U){h.removeCue(u[N].cues[U])}),delete u[N]},T=p.length;T--;)y();var x=o.fragments[o.fragments.length-1];if(!(m.length===0||!j(x?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var b=x.programDateTime/1e3-x.start,L=Li(),A=function(){var N=m[D],U=d[N],$=Ai(U.startDate,b),V=u[N],M=V?.cues||{},K=V?.durationKnown||!1,z=Wr,te=U.endDate;if(te)z=Ai(te,b),K=!0;else if(U.endOnNext&&!K){var Z=m.reduce(function(Ae,ye){if(ye!==U.id){var je=d[ye];if(je.class===U.class&&je.startDate>U.startDate&&(!Ae||U.startDate<Ae.startDate))return je}return Ae},null);Z&&(z=Ai(Z.startDate,b),K=!0)}for(var ie=Object.keys(U.attr),he=0;he<ie.length;he++){var fe=ie[he];if(Ne(fe)){var Le=M[fe];if(Le)K&&!V.durationKnown&&(Le.endTime=z);else if(L){var Ee=U.attr[fe];Qe(fe)&&(Ee=Qo(Ee));var we=Xn(L,$,z,{key:fe,data:Ee},Rt.dateRange);we&&(we.id=N,r.id3Track.addCue(we),M[fe]=we)}}}u[N]={cues:M,dateRange:U,durationKnown:K}},D=0;D<m.length;D++)A()}}},s}(),Zo=function(){function s(i){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var a=s.prototype;return a.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)},a.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},a.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},a.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},a.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},a.onError=function(e,t){var r;t.details===G.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&k.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},a.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var o=this.config,u=o.lowLatencyMode,h=o.maxLiveSyncPlaybackRate;if(!(!u||h===1||!t.live)){var d=this.targetLatency;if(d!==null){var m=r-d,p=Math.min(this.maxLatency,d+t.targetduration),y=m<p;if(y&&m>.05&&this.forwardBufferLength>1){var T=Math.min(2,Math.max(1,h)),x=Math.round(2/(1+Math.exp(-.75*m-this.edgeStalled))*20)/20;e.playbackRate=Math.min(T,Math.max(1,x))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},a.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},a.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},_(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,o=e.targetduration,u=this.config,h=u.liveSyncDuration,d=u.liveSyncDurationCount,m=u.lowLatencyMode,p=this.hls.userConfig,y=m&&r||t;(p.liveSyncDuration||p.liveSyncDurationCount||y===0)&&(y=h!==void 0?h:d*o);var T=o,x=1;return y+Math.min(this.stallCount*x,T)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var o=r.edge,u=e-t-this.edgeStalled,h=o-r.totalduration,d=o-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(h,u),d)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),Ri=["NONE","TYPE-0","TYPE-1",null];function eu(s){return Ri.indexOf(s)>-1}var jr=["SDR","PQ","HLG"];function tu(s){return!!s&&jr.indexOf(s)>-1}var zr={No:"",Yes:"YES",v2:"v2"};function $n(s){var a=s.canSkipUntil,i=s.canSkipDateRanges,e=s.age,t=e<a/2;return a&&t?i?zr.v2:zr.Yes:zr.No}var Qn=function(){function s(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var a=s.prototype;return a.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},s}(),Ci=function(){function s(i){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var a=s.prototype;return a.hasAudioGroup=function(e){return Jn(this._audioGroups,e)},a.hasSubtitleGroup=function(e){return Jn(this._subtitleGroups,e)},a.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var o=this._subtitleGroups;o||(o=this._subtitleGroups=[]),o.indexOf(t)===-1&&o.push(t)}}},a.addFallback=function(){},_(s,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),s}();function Jn(s,a){return!a||!s?!1:s.indexOf(a)!==-1}function Di(s,a){var i=a.startPTS;if(j(i)){var e=0,t;a.sn>s.sn?(e=i-s.start,t=s):(e=s.start-i,t=a),t.duration!==e&&(t.duration=e)}else if(a.sn>s.sn){var r=s.cc===a.cc;r&&s.minEndPTS?a.start=s.start+(s.minEndPTS-s.start):a.start=s.start+s.duration}else a.start=Math.max(s.start-a.duration,0)}function Zn(s,a,i,e,t,r){var o=e-i;o<=0&&(k.warn("Fragment should have a positive duration",a),e=i+a.duration,r=t+a.duration);var u=i,h=e,d=a.startPTS,m=a.endPTS;if(j(d)){var p=Math.abs(d-i);j(a.deltaPTS)?a.deltaPTS=Math.max(p,a.deltaPTS):a.deltaPTS=p,u=Math.max(i,d),i=Math.min(i,d),t=Math.min(t,a.startDTS),h=Math.min(e,m),e=Math.max(e,m),r=Math.max(r,a.endDTS)}var y=i-a.start;a.start!==0&&(a.start=i),a.duration=e-a.start,a.startPTS=i,a.maxStartPTS=u,a.startDTS=t,a.endPTS=e,a.minEndPTS=h,a.endDTS=r;var T=a.sn;if(!s||T<s.startSN||T>s.endSN)return 0;var x,b=T-s.startSN,L=s.fragments;for(L[b]=a,x=b;x>0;x--)Di(L[x],L[x-1]);for(x=b;x<L.length-1;x++)Di(L[x],L[x+1]);return s.fragmentHint&&Di(L[L.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,y}function ru(s,a){for(var i=null,e=s.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var o=0,u;if(au(s,a,function(x,b){x.relurl&&(o=x.cc-b.cc),j(x.startPTS)&&j(x.endPTS)&&(b.start=b.startPTS=x.startPTS,b.startDTS=x.startDTS,b.maxStartPTS=x.maxStartPTS,b.endPTS=x.endPTS,b.endDTS=x.endDTS,b.minEndPTS=x.minEndPTS,b.duration=x.endPTS-x.startPTS,b.duration&&(u=b),a.PTSKnown=a.alignedSliding=!0),b.elementaryStreams=x.elementaryStreams,b.loader=x.loader,b.stats=x.stats,x.initSegment&&(b.initSegment=x.initSegment,i=x.initSegment)}),i){var h=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;h.forEach(function(x){var b;x&&(!x.initSegment||x.initSegment.relurl===((b=i)==null?void 0:b.relurl))&&(x.initSegment=i)})}if(a.skippedSegments)if(a.deltaUpdateFailed=a.fragments.some(function(x){return!x}),a.deltaUpdateFailed){k.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=a.skippedSegments;d--;)a.fragments.shift();a.startSN=a.fragments[0].sn,a.startCC=a.fragments[0].cc}else a.canSkipDateRanges&&(a.dateRanges=iu(s.dateRanges,a.dateRanges,a.recentlyRemovedDateranges));var m=a.fragments;if(o){k.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<m.length;p++)m[p].cc+=o}a.skippedSegments&&(a.startCC=a.fragments[0].cc),nu(s.partList,a.partList,function(x,b){b.elementaryStreams=x.elementaryStreams,b.stats=x.stats}),u?Zn(a,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):ea(s,a),m.length&&(a.totalduration=a.edge-m[0].start),a.driftStartTime=s.driftStartTime,a.driftStart=s.driftStart;var y=a.advancedDateTime;if(a.advanced&&y){var T=a.edge;a.driftStart||(a.driftStartTime=y,a.driftStart=T),a.driftEndTime=y,a.driftEnd=T}else a.driftEndTime=s.driftEndTime,a.driftEnd=s.driftEnd,a.advancedDateTime=s.advancedDateTime}function iu(s,a,i){var e=C({},s);return i&&i.forEach(function(t){delete e[t]}),Object.keys(a).forEach(function(t){var r=new ke(a[t].attr,e[t]);r.isValid?e[t]=r:k.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(a[t].attr)+'"')}),e}function nu(s,a,i){if(s&&a)for(var e=0,t=0,r=s.length;t<=r;t++){var o=s[t],u=a[t+e];o&&u&&o.index===u.index&&o.fragment.sn===u.fragment.sn?i(o,u):e--}}function au(s,a,i){for(var e=a.skippedSegments,t=Math.max(s.startSN,a.startSN)-a.startSN,r=(s.fragmentHint?1:0)+(e?a.endSN:Math.min(s.endSN,a.endSN))-a.startSN,o=a.startSN-s.startSN,u=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,h=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,d=t;d<=r;d++){var m=h[o+d],p=u[d];e&&!p&&d<e&&(p=a.fragments[d]=m),m&&p&&i(m,p)}}function ea(s,a){var i=a.startSN+a.skippedSegments-s.startSN,e=s.fragments;i<0||i>=e.length||su(a,e[i].start)}function su(s,a){if(a){for(var i=s.fragments,e=s.skippedSegments;e<i.length;e++)i[e].start+=a;s.fragmentHint&&(s.fragmentHint.start+=a)}}function ou(s,a){a===void 0&&(a=1/0);var i=1e3*s.targetduration;if(s.updated){var e=s.fragments,t=4;if(e.length&&i*t>a){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function uu(s,a,i){if(!(s!=null&&s.details))return null;var e=s.details,t=e.fragments[a-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===a)?t:a<e.startSN&&i&&i.sn===a?i:null}function ta(s,a,i){var e;return s!=null&&s.details?ra((e=s.details)==null?void 0:e.partList,a,i):null}function ra(s,a,i){if(s)for(var e=s.length;e--;){var t=s[e];if(t.index===i&&t.fragment.sn===a)return t}return null}function ia(s){s.forEach(function(a,i){var e=a.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function Yr(s){switch(s.details){case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_TIMEOUT:case G.LEVEL_LOAD_TIMEOUT:case G.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function na(s,a){var i=Yr(a);return s.default[(i?"timeout":"error")+"Retry"]}function wi(s,a){var i=s.backoff==="linear"?1:Math.pow(2,a);return Math.min(i*s.retryDelayMs,s.maxRetryDelayMs)}function aa(s){return l(l({},s),{errorRetry:null,timeoutRetry:null})}function qr(s,a,i,e){if(!s)return!1;var t=e?.code,r=a<s.maxNumRetry&&(lu(t)||!!i);return s.shouldRetry?s.shouldRetry(s,a,i,e,r):r}function lu(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}var sa={search:function(a,i){for(var e=0,t=a.length-1,r=null,o=null;e<=t;){r=(e+t)/2|0,o=a[r];var u=i(o);if(u>0)e=r+1;else if(u<0)t=r-1;else return o}return null}};function fu(s,a,i){if(a===null||!Array.isArray(s)||!s.length||!j(a))return null;var e=s[0].programDateTime;if(a<(e||0))return null;var t=s[s.length-1].endProgramDateTime;if(a>=(t||0))return null;i=i||0;for(var r=0;r<s.length;++r){var o=s[r];if(du(a,i,o))return o}return null}function oa(s,a,i,e,t){i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=.005);var r=null;if(s){r=a[s.sn-a[0].sn+1]||null;var o=s.endDTS-i;o>0&&o<15e-7&&(i+=15e-7)}else i===0&&a[0].start===0&&(r=a[0]);if(r&&((!s||s.level===r.level)&&ua(i,e,r)===0||hu(r,s,Math.min(t,e))))return r;var u=sa.search(a,ua.bind(null,i,e));return u&&(u!==s||!r)?u:r}function hu(s,a,i){if(a&&a.start===0&&a.level<s.level&&(a.endPTS||0)>0){var e=a.tagList.reduce(function(t,r){return r[0]==="INF"&&(t+=parseFloat(r[1])),t},i);return s.start<=e}return!1}function ua(s,a,i){if(s===void 0&&(s=0),a===void 0&&(a=0),i.start<=s&&i.start+i.duration>s)return 0;var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=s?1:i.start-e>s&&i.start?-1:0}function du(s,a,i){var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>s}function cu(s,a){return sa.search(s,function(i){return i.cc<a?1:i.cc>a?-1:0})}var ot={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ct={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},vu=function(){function s(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=k.log.bind(k,"[info]:"),this.warn=k.warn.bind(k,"[warning]:"),this.error=k.error.bind(k,"[error]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))},a.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},a.startLoad=function(e){},a.stopLoad=function(){this.playlistError=0},a.getVariantLevelIndex=function(e){return e?.type===Me.MAIN?e.level:this.hls.loadLevel},a.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},a.onLevelUpdated=function(){this.playlistError=0},a.onError=function(e,t){var r,o;if(!t.fatal){var u=this.hls,h=t.context;switch(t.details){case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case G.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ot.DoNothing,flags:Ct.None};return}case G.FRAG_GAP:case G.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ot.SendAlternateToPenaltyBox;return}case G.LEVEL_EMPTY_ERROR:case G.LEVEL_PARSING_ERROR:{var d,m,p=t.parent===Me.MAIN?t.level:u.loadLevel;t.details===G.LEVEL_EMPTY_ERROR&&((d=t.context)!=null&&(m=d.levelDetails)!=null&&m.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,p):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p))}return;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:typeof h?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,h.level));return;case G.AUDIO_TRACK_LOAD_ERROR:case G.AUDIO_TRACK_LOAD_TIMEOUT:case G.SUBTITLE_LOAD_ERROR:case G.SUBTITLE_TRACK_LOAD_TIMEOUT:if(h){var y=u.levels[u.loadLevel];if(y&&(h.type===Oe.AUDIO_TRACK&&y.hasAudioGroup(h.groupId)||h.type===Oe.SUBTITLE_TRACK&&y.hasSubtitleGroup(h.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u.loadLevel),t.errorAction.action=ot.SendAlternateToPenaltyBox,t.errorAction.flags=Ct.MoveAllAlternatesMatchingHost;return}}return;case G.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var T=u.levels[u.loadLevel],x=T?.attrs["HDCP-LEVEL"];x?t.errorAction={action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHDCP,hdcpLevel:x}:this.keySystemError(t)}return;case G.BUFFER_ADD_CODEC_ERROR:case G.REMUX_ALLOC_ERROR:case G.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:u.loadLevel);return;case G.INTERNAL_EXCEPTION:case G.BUFFER_APPENDING_ERROR:case G.BUFFER_FULL_ERROR:case G.LEVEL_SWITCH_ERROR:case G.BUFFER_STALLED_ERROR:case G.BUFFER_SEEK_OVER_HOLE:case G.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ot.DoNothing,flags:Ct.None};return}t.type===le.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},a.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},a.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,o=na(r.config.playlistLoadPolicy,e),u=this.playlistError++,h=qr(o,u,Yr(e),e.response);if(h)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:o,retryCount:u};var d=this.getLevelSwitchAction(e,t);return o&&(d.retryConfig=o,d.retryCount=u),d},a.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),o=t.levels[r],u=t.config,h=u.fragLoadPolicy,d=u.keyLoadPolicy,m=na(e.details.startsWith("key")?d:h,e),p=t.levels.reduce(function(x,b){return x+b.fragmentError},0);if(o){e.details!==G.FRAG_GAP&&o.fragmentError++;var y=qr(m,p,Yr(e),e.response);if(y)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:m,retryCount:p}}var T=this.getLevelSwitchAction(e,r);return m&&(T.retryConfig=m,T.retryCount=p),T},a.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var o=this.hls.levels[t];if(o){var u,h,d=e.details;o.loadError++,d===G.BUFFER_APPEND_ERROR&&o.fragmentError++;var m=-1,p=r.levels,y=r.loadLevel,T=r.minAutoLevel,x=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var b=(u=e.frag)==null?void 0:u.type,L=b===Me.AUDIO&&d===G.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),A=L&&p.some(function(z){var te=z.audioCodec;return o.audioCodec!==te}),D=e.sourceBufferName==="video"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),w=D&&p.some(function(z){var te=z.codecSet,Z=z.audioCodec;return o.codecSet!==te&&o.audioCodec===Z}),N=(h=e.context)!=null?h:{},U=N.type,$=N.groupId,V=function(){var te=(K+y)%p.length;if(te!==y&&te>=T&&te<=x&&p[te].loadError===0){var Z,ie,he=p[te];if(d===G.FRAG_GAP&&b===Me.MAIN&&e.frag){var fe=p[te].details;if(fe){var Le=oa(e.frag,fe.fragments,e.frag.start);if(Le!=null&&Le.gap)return 0}}else{if(U===Oe.AUDIO_TRACK&&he.hasAudioGroup($)||U===Oe.SUBTITLE_TRACK&&he.hasSubtitleGroup($))return 0;if(b===Me.AUDIO&&(Z=o.audioGroups)!=null&&Z.some(function(Ee){return he.hasAudioGroup(Ee)})||b===Me.SUBTITLE&&(ie=o.subtitleGroups)!=null&&ie.some(function(Ee){return he.hasSubtitleGroup(Ee)})||A&&o.audioCodec===he.audioCodec||!A&&o.audioCodec!==he.audioCodec||w&&o.codecSet===he.codecSet)return 0}return m=te,1}},M,K=p.length;K--&&(M=V(),!(M!==0&&M===1)););if(m>-1&&r.loadLevel!==m)return e.levelRetry=!0,this.playlistError=0,{action:ot.SendAlternateToPenaltyBox,flags:Ct.None,nextAutoLevel:m}}return{action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHost}},a.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ot.DoNothing:break;case ot.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==G.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}},a.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var o=r.flags,u=r.hdcpLevel,h=r.nextAutoLevel;switch(o){case Ct.None:this.switchLevel(e,h);break;case Ct.MoveAllAlternatesMatchingHDCP:u&&(t.maxHdcpLevel=Ri[Ri.indexOf(u)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,h)}},a.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},s}(),pu=function(){function s(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=k.log.bind(k,e+":"),this.warn=k.warn.bind(k,e+":"),this.hls=i}var a=s.prototype;return a.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},a.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},a.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},a.stopLoad=function(){this.canLoad=!1,this.clearTimer()},a.switchParams=function(e,t,r){var o=t?.renditionReports;if(o){for(var u=-1,h=0;h<o.length;h++){var d=o[h],m=void 0;try{m=new self.URL(d.URI,t.url).href}catch(L){k.warn("Could not construct new URL for Rendition Report: "+L),m=d.URI||""}if(m===e){u=h;break}else m===e.substring(0,m.length)&&(u=h)}if(u!==-1){var p=o[u],y=parseInt(p["LAST-MSN"])||t?.lastPartSn,T=parseInt(p["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var x=Math.min(t.age-t.partTarget,t.targetduration);T>=0&&x>t.partTarget&&(T+=1)}var b=r&&$n(r);return new Qn(y,T>=0?T:void 0,b)}}},a.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},a.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},a.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},a.playlistLoaded=function(e,t,r){var o=this,u=t.details,h=t.stats,d=self.performance.now(),m=h.loading.first?Math.max(0,d-h.loading.first):0;if(u.advancedDateTime=Date.now()-m,u.live||r!=null&&r.live){if(u.reloaded(r),r&&this.log("live playlist "+e+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:u.updated?"UPDATED":"MISSED")),r&&u.fragments.length>0&&ru(r,u),!this.canLoad||!u.live)return;var p,y=void 0,T=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var x=this.hls.config.lowLatencyMode,b=u.lastPartSn,L=u.endSN,A=u.lastPartIndex,D=A!==-1,w=b===L,N=x?0:A;D?(y=w?L+1:b,T=w?N:A+1):y=L+1;var U=u.age,$=U+u.ageHeader,V=Math.min($-u.partTarget,u.targetduration*1.5);if(V>0){if(r&&V>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+V+" with playlist age: "+u.age),V=0;else{var M=Math.floor(V/u.targetduration);if(y+=M,T!==void 0){var K=Math.round(V%u.targetduration/u.partTarget);T+=K}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+U.toFixed(2)+"s goal: "+V+" skip sn "+M+" to part "+T)}u.tuneInGoal=V}if(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T),x||!w){this.loadPlaylist(p);return}}else(u.canBlockReload||u.canSkipUntil)&&(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T));var z=this.hls.mainForwardBufferInfo,te=z?z.end-z.len:0,Z=(u.edge-te)*1e3,ie=ou(u,Z);u.updated&&d>this.requestScheduled+ie&&(this.requestScheduled=h.loading.start),y!==void 0&&u.canBlockReload?this.requestScheduled=h.loading.first+ie-(u.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+ie<d?this.requestScheduled=d:this.requestScheduled-d<=0&&(this.requestScheduled+=ie);var he=this.requestScheduled-d;he=Math.max(0,he),this.log("reload live playlist "+e+" in "+Math.round(he)+" ms"),this.timer=self.setTimeout(function(){return o.loadPlaylist(p)},he)}else this.clearTimer()},a.getDeliveryDirectives=function(e,t,r,o){var u=$n(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,o=t.part,u=zr.No),new Qn(r,o,u)},a.checkRetry=function(e){var t=this,r=e.details,o=Yr(e),u=e.errorAction,h=u||{},d=h.action,m=h.retryCount,p=m===void 0?0:m,y=h.retryConfig,T=!!u&&!!y&&(d===ot.RetryRequest||!u.resolved&&d===ot.SendAlternateToPenaltyBox);if(T){var x;if(this.requestScheduled=-1,p>=y.maxNumRetry)return!1;if(o&&(x=e.context)!=null&&x.deliveryDirectives)this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var b=wi(y,p);this.timer=self.setTimeout(function(){return t.loadPlaylist()},b),this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" in '+b+"ms")}e.levelRetry=!0,u.resolved=!0}return T},s}(),cr=function(){function s(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var a=s.prototype;return a.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},a.getTotalWeight=function(){return this.totalWeight_},a.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),mu=function(){function s(i,e,t,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new cr(i),this.fast_=new cr(e),this.defaultTTFB_=r,this.ttfb_=new cr(i)}var a=s.prototype;return a.update=function(e,t){var r=this.slow_,o=this.fast_,u=this.ttfb_;r.halfLife!==e&&(this.slow_=new cr(e,r.getEstimate(),r.getTotalWeight())),o.halfLife!==t&&(this.fast_=new cr(t,o.getEstimate(),o.getTotalWeight())),u.halfLife!==e&&(this.ttfb_=new cr(e,u.getEstimate(),u.getTotalWeight()))},a.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,o=e/1e3,u=r/o;this.fast_.sample(o,u),this.slow_.sample(o,u)},a.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},a.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},a.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},a.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},a.destroy=function(){},s}();function gu(){if(typeof matchMedia=="function"){var s=matchMedia("(dynamic-range: high)"),a=matchMedia("bad query");if(s.media!==a.media)return s.matches===!0}return!1}function yu(s,a){var i=!1,e=[];return s&&(i=s!=="SDR",e=[s]),a&&(e=a.allowedVideoRanges||jr.slice(0),i=a.preferHDR!==void 0?a.preferHDR:gu(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function Eu(s,a,i,e,t){for(var r=Object.keys(s),o=e?.channels,u=e?.audioCodec,h=o&&parseInt(o)===2,d=!0,m=!1,p=1/0,y=1/0,T=1/0,x=0,b=[],L=yu(a,t),A=L.preferHDR,D=L.allowedVideoRanges,w=function(){var K=s[r[N]];d=K.channels[2]>0,p=Math.min(p,K.minHeight),y=Math.min(y,K.minFramerate),T=Math.min(T,K.minBitrate);var z=D.filter(function(te){return K.videoRanges[te]>0});z.length>0&&(m=!0,b=z)},N=r.length;N--;)w();p=j(p)?p:0,y=j(y)?y:0;var U=Math.max(1080,p),$=Math.max(30,y);T=j(T)?T:i,i=Math.max(T,i),m||(a=void 0,b=[]);var V=r.reduce(function(M,K){var z=s[K];if(K===M)return M;if(z.minBitrate>i)return Ht(K,"min bitrate of "+z.minBitrate+" > current estimate of "+i),M;if(!z.hasDefaultAudio)return Ht(K,"no renditions with default or auto-select sound found"),M;if(u&&K.indexOf(u.substring(0,4))%5!==0)return Ht(K,'audio codec preference "'+u+'" not found'),M;if(o&&!h){if(!z.channels[o])return Ht(K,"no renditions with "+o+" channel sound found (channels options: "+Object.keys(z.channels)+")"),M}else if((!u||h)&&d&&z.channels[2]===0)return Ht(K,"no renditions with stereo sound found"),M;return z.minHeight>U?(Ht(K,"min resolution of "+z.minHeight+" > maximum of "+U),M):z.minFramerate>$?(Ht(K,"min framerate of "+z.minFramerate+" > maximum of "+$),M):b.some(function(te){return z.videoRanges[te]>0})?z.maxScore<x?(Ht(K,"max score of "+z.maxScore+" < selected max of "+x),M):M&&(Hr(K)>=Hr(M)||z.fragmentError>s[M].fragmentError)?M:(x=z.maxScore,K):(Ht(K,"no variants with VIDEO-RANGE of "+JSON.stringify(b)+" found"),M)},void 0);return{codecSet:V,videoRanges:b,preferHDR:A,minFramerate:y,minBitrate:T}}function Ht(s,a){k.log('[abr] start candidates with "'+s+'" ignored because '+a)}function _u(s){return s.reduce(function(a,i){var e=a.groups[i.groupId];e||(e=a.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(a.hasDefaultAudio=!0),e.hasAutoSelect&&(a.hasAutoSelectAudio=!0),a},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Su(s,a,i,e){return s.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var o=r.audioGroups,u=t[r.codecSet];u||(t[r.codecSet]=u={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),u.minBitrate=Math.min(u.minBitrate,r.bitrate);var h=Math.min(r.height,r.width);return u.minHeight=Math.min(u.minHeight,h),u.minFramerate=Math.min(u.minFramerate,r.frameRate),u.maxScore=Math.max(u.maxScore,r.score),u.fragmentError+=r.fragmentError,u.videoRanges[r.videoRange]=(u.videoRanges[r.videoRange]||0)+1,t},{})}var Tu=function(){function s(i){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var t=e.fragCurrent,r=e.partCurrent,o=e.hls,u=o.autoLevelEnabled,h=o.media;if(!(!t||!h)){var d=performance.now(),m=r?r.stats:t.stats,p=r?r.duration:t.duration,y=d-m.loading.start,T=o.minAutoLevel;if(m.aborted||m.loaded&&m.loaded===m.total||t.level<=T){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!u||h.paused||!h.playbackRate||!h.readyState)){var x=o.mainForwardBufferInfo;if(x!==null){var b=e.bwEstimator.getEstimateTTFB(),L=Math.abs(h.playbackRate);if(!(y<=Math.max(b,1e3*(p/(L*2))))){var A=x.len/L,D=m.loading.first?m.loading.first-m.loading.start:-1,w=m.loaded&&D>-1,N=e.getBwEstimate(),U=o.levels,$=U[t.level],V=m.total||Math.max(m.loaded,Math.round(p*$.averageBitrate/8)),M=w?y-D:y;M<1&&w&&(M=Math.min(y,m.loaded*8/N));var K=w?m.loaded*1e3/M:0,z=K?(V-m.loaded)/K:V*8/N+b/1e3;if(!(z<=A)){var te=K?K*8:N,Z=Number.POSITIVE_INFINITY,ie;for(ie=t.level-1;ie>T;ie--){var he=U[ie].maxBitrate;if(Z=e.getTimeToLoadFrag(b/1e3,te,p*he,!U[ie].details),Z<A)break}if(!(Z>=z)&&!(Z>p*10)){o.nextLoadLevel=o.nextAutoLevel=ie,w?e.bwEstimator.sample(y-Math.min(b,D),m.loaded):e.bwEstimator.sampleTTFB(y);var fe=U[ie].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>fe&&e.resetEstimator(fe),e.clearTimer(),k.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
|
3
|
+
Time to underbuffer: `+A.toFixed(3)+` s
|
4
|
+
Estimated load time for current fragment: `+z.toFixed(3)+` s
|
5
|
+
Estimated load time for down switch fragment: `+Z.toFixed(3)+` s
|
6
|
+
TTFB estimate: `+(D|0)+` ms
|
7
|
+
Current BW estimate: `+(j(N)?N|0:"Unknown")+` bps
|
8
|
+
New BW estimate: `+(e.getBwEstimate()|0)+` bps
|
9
|
+
Switching to level `+ie+" @ "+(fe|0)+" bps"),o.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:m})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var a=s.prototype;return a.resetEstimator=function(e){e&&(k.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},a.initEstimator=function(){var e=this.hls.config;return new mu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(R.ERROR,this.onError,this))},a.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},a.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},a.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},a.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},a.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var o;this.fragCurrent=r,this.partCurrent=(o=t.part)!=null?o:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},a.onLevelSwitching=function(e,t){this.clearTimer()},a.onError=function(e,t){if(!t.fatal)switch(t.details){case G.BUFFER_ADD_CODEC_ERROR:case G.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case G.FRAG_LOAD_TIMEOUT:{var r=t.frag,o=this.fragCurrent,u=this.partCurrent;if(r&&o&&r.sn===o.sn&&r.level===o.level){var h=performance.now(),d=u?u.stats:r.stats,m=h-d.loading.start,p=d.loading.first?d.loading.first-d.loading.start:-1,y=d.loaded&&p>-1;if(y){var T=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(m-Math.min(T,p),d.loaded)}else this.bwEstimator.sampleTTFB(m)}break}}},a.getTimeToLoadFrag=function(e,t,r,o){var u=e+r/t,h=o?this.lastLevelLoadSec:0;return u+h},a.onLevelLoaded=function(e,t){var r=this.hls.config,o=t.stats.loading,u=o.end-o.start;j(u)&&(this.lastLevelLoadSec=u/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part,u=o?o.stats:r.stats;if(r.type===Me.MAIN&&this.bwEstimator.sampleTTFB(u.loading.first-u.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var h=o?o.duration:r.duration,d=this.hls.levels[r.level],m=(d.loaded?d.loaded.bytes:0)+u.loaded,p=(d.loaded?d.loaded.duration:0)+h;d.loaded={bytes:m,duration:p},d.realBitrate=Math.round(8*m/p)}if(r.bitrateTest){var y={stats:u,frag:r,part:o,id:r.type};this.onFragBuffered(R.FRAG_BUFFERED,y),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},a.onFragBuffered=function(e,t){var r=t.frag,o=t.part,u=o!=null&&o.stats.loaded?o.stats:r.stats;if(!u.aborted&&!this.ignoreFragment(r)){var h=u.parsing.end-u.loading.start-Math.min(u.loading.first-u.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(h,u.loaded),u.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=h/1e3:this.bitrateTestDelay=0}},a.ignoreFragment=function(e){return e.type!==Me.MAIN||e.sn==="initSegment"},a.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},a.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},a.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,o=r.maxAutoLevel,u=r.config,h=r.minAutoLevel,d=t?t.duration:e?e.duration:0,m=this.getBwEstimate(),p=this.getStarvationDelay(),y=u.abrBandWidthFactor,T=u.abrBandWidthUpFactor;if(p){var x=this.findBestLevel(m,h,o,p,0,y,T);if(x>=0)return x}var b=d?Math.min(d,u.maxStarvationDelay):u.maxStarvationDelay;if(!p){var L=this.bitrateTestDelay;if(L){var A=d?Math.min(d,u.maxLoadingDelay):u.maxLoadingDelay;b=A-L,k.info("[abr] bitrate test took "+Math.round(1e3*L)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),y=T=1}}var D=this.findBestLevel(m,h,o,p,b,y,T);if(k.info("[abr] "+(p?"rebuffering expected":"buffer is empty")+", optimal quality level "+D),D>-1)return D;var w=r.levels[h],N=r.levels[r.loadLevel];return w?.bitrate<N?.bitrate?h:r.loadLevel},a.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,o=e.mainForwardBufferInfo;return(o?o.len:0)/r},a.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},a.findBestLevel=function(e,t,r,o,u,h,d){var m,p=this,y=o+u,T=this.lastLoadedFragLevel,x=T===-1?this.hls.firstLevel:T,b=this.fragCurrent,L=this.partCurrent,A=this.hls,D=A.levels,w=A.allAudioTracks,N=A.loadLevel,U=A.config;if(D.length===1)return 0;var $=D[x],V=!!($!=null&&(m=$.details)!=null&&m.live),M=N===-1||T===-1,K,z="SDR",te=$?.frameRate||0,Z=U.audioPreference,ie=U.videoPreference,he=this.audioTracksByGroup||(this.audioTracksByGroup=_u(w));if(M){if(this.firstSelection!==-1)return this.firstSelection;var fe=this.codecTiers||(this.codecTiers=Su(D,he,t,r)),Le=Eu(fe,z,e,Z,ie),Ee=Le.codecSet,we=Le.videoRanges,Ae=Le.minFramerate,ye=Le.minBitrate,je=Le.preferHDR;K=Ee,z=je?we[we.length-1]:we[0],te=Ae,e=Math.max(e,ye),k.log("[abr] picked start tier "+JSON.stringify(Le))}else K=$?.codecSet,z=$?.videoRange;for(var Fe=L?L.duration:b?b.duration:0,qe=this.bwEstimator.getEstimateTTFB()/1e3,Xe=[],Ze=function(){var _t,$e=D[Ue],ct=Ue>x;if(!$e)return 0;if(K&&$e.codecSet!==K||z&&$e.videoRange!==z||ct&&te>$e.frameRate||!ct&&te>0&&te<$e.frameRate||$e.supportedResult&&!((_t=$e.supportedResult.decodingInfoResults)!=null&&_t[0].smooth))return Xe.push(Ue),0;var vt=$e.details,et=(L?vt?.partTarget:vt?.averagetargetduration)||Fe,Ke;ct?Ke=d*e:Ke=h*e;var yt=Fe&&o>=Fe*2&&u===0?D[Ue].averageBitrate:D[Ue].maxBitrate,ft=p.getTimeToLoadFrag(qe,Ke,yt*et,vt===void 0),st=Ke>=yt&&(Ue===T||$e.loadError===0&&$e.fragmentError===0)&&(ft<=qe||!j(ft)||V&&!p.bitrateTestDelay||ft<y);if(st){var or=p.forcedAutoLevel;return Ue!==N&&(or===-1||or!==N)&&(Xe.length&&k.trace("[abr] Skipped level(s) "+Xe.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+D[Xe[0]].codecs+'" '+D[Xe[0]].videoRange+'; not compatible with "'+$.codecs+'" '+z),k.info("[abr] switch candidate:"+x+"->"+Ue+" adjustedbw("+Math.round(Ke)+")-bitrate="+Math.round(Ke-yt)+" ttfb:"+qe.toFixed(1)+" avgDuration:"+et.toFixed(1)+" maxFetchDuration:"+y.toFixed(1)+" fetchDuration:"+ft.toFixed(1)+" firstSelection:"+M+" codecSet:"+K+" videoRange:"+z+" hls.loadLevel:"+N)),M&&(p.firstSelection=Ue),{v:Ue}}},ze,Ue=r;Ue>=t;Ue--)if(ze=Ze(),ze!==0&&ze)return ze.v;return-1},_(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,o=this.getBwEstimate(),u=this.hls.config.maxStarvationDelay,h=this.findBestLevel(o,r,t,0,u,1,1);if(h>-1)return h;var d=this.hls.firstLevel,m=Math.min(Math.max(d,r),t);return k.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+d+" clamped to "+m),m}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),o=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!o||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var u=r&&o?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var h=this.hls.levels;if(h.length>Math.max(e,u)&&h[e].loadError<=h[u].loadError)return e}return this._nextAutoLevel=u,this.nextAutoLevelKey=this.getAutoLevelKey(),u},set:function(e){var t=this.hls,r=t.maxAutoLevel,o=t.minAutoLevel,u=Math.min(Math.max(e,o),r);this._nextAutoLevel!==u&&(this.nextAutoLevelKey="",this._nextAutoLevel=u)}}]),s}(),xu={length:0,start:function(){return 0},end:function(){return 0}},rt=function(){function s(){}return s.isBuffered=function(i,e){try{if(i){for(var t=s.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(i,e,t){try{if(i){var r=s.getBuffered(i),o=[],u;for(u=0;u<r.length;u++)o.push({start:r.start(u),end:r.end(u)});return this.bufferedInfo(o,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(L,A){var D=L.start-A.start;return D||A.end-L.end});var r=[];if(t)for(var o=0;o<i.length;o++){var u=r.length;if(u){var h=r[u-1].end;i[o].start-h<t?i[o].end>h&&(r[u-1].end=i[o].end):r.push(i[o])}else r.push(i[o])}else r=i;for(var d=0,m,p=e,y=e,T=0;T<r.length;T++){var x=r[T].start,b=r[T].end;if(e+t>=x&&e<b)p=x,y=b,d=y-e;else if(e+t<x){m=x;break}}return{len:d,start:p||0,end:y||0,nextStart:m}},s.getBuffered=function(i){try{return i.buffered}catch(e){return k.log("failed to get media.buffered",e),xu}},s}(),bu=function(){function s(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var a=s.prototype;return a.append=function(e,t,r){var o=this.queues[t];o.push(e),o.length===1&&!r&&this.executeNext(t)},a.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},a.appendBlocker=function(e){var t,r=new Promise(function(u){t=u}),o={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(o,e),r},a.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(u){k.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+u),r.onError(u);var o=this.buffers[e];o!=null&&o.updating||this.shiftAndExecuteNext(e)}}},a.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},a.current=function(e){return this.queues[e][0]},s}(),la=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Lu=function(){function s(i){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,o=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(R.MEDIA_ATTACHED,{media:r,mediaSource:o})),o&&o.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,o=e._objectUrl;r!==o&&k.error("Media element src was set while attaching MediaSource ("+o+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=Mo(ar(i.config.preferManagedMediaSource)),this.log=k.log.bind(k,t),this.warn=k.warn.bind(k,t),this.error=k.error.bind(k,t),this._initSourceBuffer(),this.registerListeners()}var a=s.prototype;return a.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},a.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},a.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)},a._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new bu(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},a.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},a.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},a.onMediaAttaching=function(e,t){var r=this.media=t.media,o=ar(this.appendSource);if(r&&o){var u,h=this.mediaSource=new o;this.log("created media source: "+((u=h.constructor)==null?void 0:u.name)),h.addEventListener("sourceopen",this._onMediaSourceOpen),h.addEventListener("sourceended",this._onMediaSourceEnded),h.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(h.addEventListener("startstreaming",this._onStartStreaming),h.addEventListener("endstreaming",this._onEndStreaming));var d=this._objectUrl=self.URL.createObjectURL(h);if(this.appendSource)try{r.removeAttribute("src");var m=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||m&&h instanceof m,fa(r),Au(r,d),r.load()}catch{r.src=d}else r.src=d;r.addEventListener("emptied",this._onMediaEmptied)}},a.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(o){this.warn("onMediaDetaching: "+o.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&fa(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)},a.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},a.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(o){this.warn("onBufferReset "+e,o)}},a.onBufferCodecs=function(e,t){var r=this,o=this.getSourceBufferTypes().length,u=Object.keys(t);if(u.forEach(function(d){if(o){var m=r.tracks[d];if(m&&typeof m.buffer.changeType=="function"){var p,y=t[d],T=y.id,x=y.codec,b=y.levelCodec,L=y.container,A=y.metadata,D=Un(m.codec,m.levelCodec),w=D?.replace(la,"$1"),N=Un(x,b),U=(p=N)==null?void 0:p.replace(la,"$1");if(N&&w!==U){d.slice(0,5)==="audio"&&(N=Kr(N,r.appendSource));var $=L+";codecs="+N;r.appendChangeType(d,$),r.log("switching codec "+D+" to "+N),r.tracks[d]={buffer:m.buffer,codec:x,container:L,levelCodec:b,metadata:A,id:T}}}}else r.pendingTracks[d]=t[d]}),!o){var h=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==h&&(this.log(h+" bufferCodec event(s) expected "+u.join(",")),this.bufferCodecEventsExpected=h),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},a.appendChangeType=function(e,t){var r=this,o=this.operationQueue,u={execute:function(){var d=r.sourceBuffer[e];d&&(r.log("changing "+e+" sourceBuffer type to "+t),d.changeType(t)),o.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(d){r.warn("Failed to change "+e+" SourceBuffer type",d)}};o.append(u,e,!!this.pendingTracks[e])},a.onBufferAppending=function(e,t){var r=this,o=this.hls,u=this.operationQueue,h=this.tracks,d=t.data,m=t.type,p=t.frag,y=t.part,T=t.chunkMeta,x=T.buffering[m],b=self.performance.now();x.start=b;var L=p.stats.buffering,A=y?y.stats.buffering:null;L.start===0&&(L.start=b),A&&A.start===0&&(A.start=b);var D=h.audio,w=!1;m==="audio"&&D?.container==="audio/mpeg"&&(w=!this.lastMpegAudioChunk||T.id===1||this.lastMpegAudioChunk.sn!==T.sn,this.lastMpegAudioChunk=T);var N=p.start,U={execute:function(){if(x.executeStart=self.performance.now(),w){var V=r.sourceBuffer[m];if(V){var M=N-V.timestampOffset;Math.abs(M)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+N+" (delta: "+M+") sn: "+p.sn+")"),V.timestampOffset=N)}}r.appendExecutor(d,m)},onStart:function(){},onComplete:function(){var V=self.performance.now();x.executeEnd=x.end=V,L.first===0&&(L.first=V),A&&A.first===0&&(A.first=V);var M=r.sourceBuffer,K={};for(var z in M)K[z]=rt.getBuffered(M[z]);r.appendErrors[m]=0,m==="audio"||m==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(R.BUFFER_APPENDED,{type:m,frag:p,part:y,chunkMeta:T,parent:p.type,timeRanges:K})},onError:function(V){var M={type:le.MEDIA_ERROR,parent:p.type,details:G.BUFFER_APPEND_ERROR,sourceBufferName:m,frag:p,part:y,chunkMeta:T,error:V,err:V,fatal:!1};if(V.code===DOMException.QUOTA_EXCEEDED_ERR)M.details=G.BUFFER_FULL_ERROR;else{var K=++r.appendErrors[m];M.details=G.BUFFER_APPEND_ERROR,r.warn("Failed "+K+"/"+o.config.appendErrorMaxRetry+' times to append segment in "'+m+'" sourceBuffer'),K>=o.config.appendErrorMaxRetry&&(M.fatal=!0)}o.trigger(R.ERROR,M)}};u.append(U,m,!!this.pendingTracks[m])},a.onBufferFlushing=function(e,t){var r=this,o=this.operationQueue,u=function(d){return{execute:r.removeExecutor.bind(r,d,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(R.BUFFER_FLUSHED,{type:d})},onError:function(p){r.warn("Failed to remove from "+d+" SourceBuffer",p)}}};t.type?o.append(u(t.type),t.type):this.getSourceBufferTypes().forEach(function(h){o.append(u(h),h)})},a.onFragParsed=function(e,t){var r=this,o=t.frag,u=t.part,h=[],d=u?u.elementaryStreams:o.elementaryStreams;d[Pe.AUDIOVIDEO]?h.push("audiovideo"):(d[Pe.AUDIO]&&h.push("audio"),d[Pe.VIDEO]&&h.push("video"));var m=function(){var y=self.performance.now();o.stats.buffering.end=y,u&&(u.stats.buffering.end=y);var T=u?u.stats:o.stats;r.hls.trigger(R.FRAG_BUFFERED,{frag:o,part:u,stats:T,id:o.type})};h.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(m,h)},a.onFragChanged=function(e,t){this.trimBuffers()},a.onBufferEos=function(e,t){var r=this,o=this.getSourceBufferTypes().reduce(function(u,h){var d=r.sourceBuffer[h];return d&&(!t.type||t.type===h)&&(d.ending=!0,d.ended||(d.ended=!0,r.log(h+" sourceBuffer now EOS"))),u&&!!(!d||d.ended)},!0);o&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(h){var d=r.sourceBuffer[h];d&&(d.ending=!1)});var u=r.mediaSource;if(!u||u.readyState!=="open"){u&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+u.readyState);return}r.log("Calling mediaSource.endOfStream()"),u.endOfStream()}))},a.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},a.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var o=this.getSourceBufferTypes();if(o.length){var u=e.config,h=r.currentTime,d=t.levelTargetDuration,m=t.live&&u.liveBackBufferLength!==null?u.liveBackBufferLength:u.backBufferLength;if(j(m)&&m>0){var p=Math.max(m,d),y=Math.floor(h/d)*d-p;this.flushBackBuffer(h,d,y)}if(j(u.frontBufferFlushThreshold)&&u.frontBufferFlushThreshold>0){var T=Math.max(u.maxBufferLength,u.frontBufferFlushThreshold),x=Math.max(T,d),b=Math.floor(h/d)*d+x;this.flushFrontBuffer(h,d,b)}}}},a.flushBackBuffer=function(e,t,r){var o=this,u=this.details,h=this.sourceBuffer,d=this.getSourceBufferTypes();d.forEach(function(m){var p=h[m];if(p){var y=rt.getBuffered(p);if(y.length>0&&r>y.start(0)){if(o.hls.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:r}),u!=null&&u.live)o.hls.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(p.ended&&y.end(y.length-1)-e<t*2){o.log("Cannot flush "+m+" back buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:m})}}})},a.flushFrontBuffer=function(e,t,r){var o=this,u=this.sourceBuffer,h=this.getSourceBufferTypes();h.forEach(function(d){var m=u[d];if(m){var p=rt.getBuffered(m),y=p.length;if(y<2)return;var T=p.start(y-1),x=p.end(y-1);if(r>T||e>=T&&e<=x)return;if(m.ended&&e-x<2*t){o.log("Cannot flush "+d+" front buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:T,endOffset:1/0,type:d})}})},a.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,o=this.mediaSource,u=e.fragments[0].start+e.totalduration,h=r.duration,d=j(o.duration)?o.duration:0;e.live&&t.config.liveDurationInfinity?(o.duration=1/0,this.updateSeekableRange(e)):(u>d&&u>h||!j(h))&&(this.log("Updating Media Source duration to "+u.toFixed(3)),o.duration=u)}},a.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,o=r.length;if(o&&e.live&&t!=null&&t.setLiveSeekableRange){var u=Math.max(0,r[0].start),h=Math.max(u,u+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+u+"-"+h+"."),t.setLiveSeekableRange(u,h)}},a.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,o=Object.keys(r).length;if(o&&(!e||o===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),u.forEach(function(d){t.executeNext(d)});else{var h=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:h,reason:h.message})}}},a.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var u=function(m){if(!r[m]){var p,y=e[m];if(!y)throw Error("source buffer exists for track "+m+", however track does not");var T=((p=y.levelCodec)==null?void 0:p.indexOf(","))===-1?y.levelCodec:y.codec;T&&m.slice(0,5)==="audio"&&(T=Kr(T,t.appendSource));var x=y.container+";codecs="+T;t.log("creating sourceBuffer("+x+")");try{var b=r[m]=o.addSourceBuffer(x),L=m;t.addBufferListener(L,"updatestart",t._onSBUpdateStart),t.addBufferListener(L,"updateend",t._onSBUpdateEnd),t.addBufferListener(L,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(L,"bufferedchange",function(A,D){var w=D.removedRanges;w!=null&&w.length&&t.hls.trigger(R.BUFFER_FLUSHED,{type:m})}),t.tracks[m]={buffer:b,codec:T,container:y.container,levelCodec:y.levelCodec,metadata:y.metadata,id:y.id}}catch(A){t.error("error while trying to add sourceBuffer: "+A.message),t.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:A,sourceBufferName:m,mimeType:x})}}};for(var h in e)u(h)},a._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},a._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,o=r.current(e);o.onComplete(),r.shiftAndExecuteNext(e)},a._onSBUpdateError=function(e,t){var r,o=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+o,t),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:o,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(o)},a.removeExecutor=function(e,t,r){var o=this.media,u=this.mediaSource,h=this.operationQueue,d=this.sourceBuffer,m=d[e];if(!o||!u||!m){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(e);return}var p=j(o.duration)?o.duration:1/0,y=j(u.duration)?u.duration:1/0,T=Math.max(0,t),x=Math.min(r,p,y);x>T&&(!m.ending||m.ended)?(m.ended=!1,this.log("Removing ["+T+","+x+"] from the "+e+" SourceBuffer"),m.remove(T,x)):h.shiftAndExecuteNext(e)},a.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},a.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var o=this.operationQueue,u=t.map(function(h){return o.appendBlocker(h)});Promise.all(u).then(function(){e(),t.forEach(function(h){var d=r.sourceBuffer[h];d!=null&&d.updating||o.shiftAndExecuteNext(h)})})},a.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},a.addBufferListener=function(e,t,r){var o=this.sourceBuffer[e];if(o){var u=r.bind(this,e);this.listeners[e].push({event:t,listener:u}),o.addEventListener(t,u)}},a.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},_(s,[{key:"mediaSrc",get:function(){var e,t,r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r?.src}}]),s}();function fa(s){var a=s.querySelectorAll("source");[].slice.call(a).forEach(function(i){s.removeChild(i)})}function Au(s,a){var i=self.document.createElement("source");i.type="video/mp4",i.src=a,s.appendChild(i)}var Ru=function(){function s(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var e=this.hls;e.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var e=this.hls;e.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},a.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},a.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onLevelsUpdated=function(e,t){this.timer&&j(this.autoLevelCapping)&&this.detectPlayerSize()},a.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&k.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},a.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var o=r.filter(function(u,h){return t.isLevelAllowed(u)&&h<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},a.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var o=function(y,T){return T?y.width!==T.width||y.height!==T.height:!0},u=e.length-1,h=Math.max(t,r),d=0;d<e.length;d+=1){var m=e[d];if((m.width>=h||m.height>=h)&&o(m,e[d+1])){u=d;break}}return u},_(s,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),s}(),Cu=function(){function s(i){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=i,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},a.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var o=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},a.checkFPS=function(e,t,r){var o=performance.now();if(t){if(this.lastTime){var u=o-this.lastTime,h=r-this.lastDroppedFrames,d=t-this.lastDecodedFrames,m=1e3*h/u,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:h,currentDecoded:d,totalDroppedFrames:r}),m>0&&h>p.config.fpsDroppedMonitoringThreshold*d){var y=p.currentLevel;k.warn("drop FPS ratio greater than max allowed value for currentLevel: "+y),y>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=y)&&(y=y-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:y,droppedLevel:p.currentLevel}),p.autoLevelCapping=y,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},a.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},s}(),Du=3e5,wu=function(){function s(i){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=i,this.log=k.log.bind(k,"[content-steering]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.ERROR,this.onError,this))},a.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},a.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},a.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},a.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},a.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},a.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},a.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},a.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},a.onError=function(e,t){var r=t.errorAction;if(r?.action===ot.SendAlternateToPenaltyBox&&r.flags===Ct.MoveAllAlternatesMatchingHost){var o=this.levels,u=this.pathwayPriority,h=this.pathwayId;if(t.context){var d=t.context,m=d.groupId,p=d.pathwayId,y=d.type;m&&o?h=this.getPathwayForGroupId(m,y,h):p&&(h=p)}h in this.penalizedPathways||(this.penalizedPathways[h]=performance.now()),!u&&o&&(u=o.reduce(function(T,x){return T.indexOf(x.pathwayId)===-1&&T.push(x.pathwayId),T},[])),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==h),r.resolved||k.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+h+" levels: "+(o&&o.length)+" priorities: "+JSON.stringify(u)+" penalized: "+JSON.stringify(this.penalizedPathways))}},a.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},a.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},a.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,o=performance.now();Object.keys(r).forEach(function(y){o-r[y]>Du&&delete r[y]});for(var u=0;u<e.length;u++){var h=e[u];if(!(h in r)){if(h===this.pathwayId)return;var d=this.hls.nextLoadLevel,m=this.hls.levels[d];if(t=this.getLevelsForPathway(h),t.length>0){this.log('Setting Pathway to "'+h+'"'),this.pathwayId=h,ia(t),this.hls.trigger(R.LEVELS_UPDATED,{levels:t});var p=this.hls.levels[d];m&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==m.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==m.bitrate&&this.log("Unstable Pathways change from bitrate "+m.bitrate+" to "+p.bitrate),this.hls.nextLoadLevel=d);break}}}},a.getPathwayForGroupId=function(e,t,r){for(var o=this.getLevelsForPathway(r).concat(this.levels||[]),u=0;u<o.length;u++)if(t===Oe.AUDIO_TRACK&&o[u].hasAudioGroup(e)||t===Oe.SUBTITLE_TRACK&&o[u].hasSubtitleGroup(e))return o[u].pathwayId;return r},a.clonePathways=function(e){var t=this,r=this.levels;if(r){var o={},u={};e.forEach(function(h){var d=h.ID,m=h["BASE-ID"],p=h["URI-REPLACEMENT"];if(!r.some(function(T){return T.pathwayId===d})){var y=t.getLevelsForPathway(m).map(function(T){var x=new pe(T.attrs);x["PATHWAY-ID"]=d;var b=x.AUDIO&&x.AUDIO+"_clone_"+d,L=x.SUBTITLES&&x.SUBTITLES+"_clone_"+d;b&&(o[x.AUDIO]=b,x.AUDIO=b),L&&(u[x.SUBTITLES]=L,x.SUBTITLES=L);var A=da(T.uri,x["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",p),D=new Ci({attrs:x,audioCodec:T.audioCodec,bitrate:T.bitrate,height:T.height,name:T.name,url:A,videoCodec:T.videoCodec,width:T.width});if(T.audioGroups)for(var w=1;w<T.audioGroups.length;w++)D.addGroupId("audio",T.audioGroups[w]+"_clone_"+d);if(T.subtitleGroups)for(var N=1;N<T.subtitleGroups.length;N++)D.addGroupId("text",T.subtitleGroups[N]+"_clone_"+d);return D});r.push.apply(r,y),ha(t.audioTracks,o,p,d),ha(t.subtitleTracks,u,p,d)}})}},a.loadSteeringManifest=function(e){var t=this,r=this.hls.config,o=r.loader;this.loader&&this.loader.destroy(),this.loader=new o(r);var u;try{u=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(u.protocol!=="data:"){var h=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;u.searchParams.set("_HLS_pathway",this.pathwayId),u.searchParams.set("_HLS_throughput",""+h)}var d={responseType:"json",url:u.href},m=r.steeringManifestLoadPolicy.default,p=m.errorRetry||m.timeoutRetry||{},y={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:p.maxNumRetry||0,retryDelay:p.retryDelayMs||0,maxRetryDelay:p.maxRetryDelayMs||0},T={onSuccess:function(b,L,A,D){t.log('Loaded steering manifest: "'+u+'"');var w=b.data;if(w.VERSION!==1){t.log("Steering VERSION "+w.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=w.TTL;var N=w["RELOAD-URI"],U=w["PATHWAY-CLONES"],$=w["PATHWAY-PRIORITY"];if(N)try{t.uri=new self.URL(N,u).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+N);return}t.scheduleRefresh(t.uri||A.url),U&&t.clonePathways(U);var V={steeringManifest:w,url:u.toString()};t.hls.trigger(R.STEERING_MANIFEST_LOADED,V),$&&t.updatePathwayPriority($)},onError:function(b,L,A,D){if(t.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+L.url+")"),t.stopLoad(),b.code===410){t.enabled=!1,t.log("Steering manifest "+L.url+" no longer available");return}var w=t.timeToLoad*1e3;if(b.code===429){var N=t.loader;if(typeof N?.getResponseHeader=="function"){var U=N.getResponseHeader("Retry-After");U&&(w=parseFloat(U)*1e3)}t.log("Steering manifest "+L.url+" rate limited");return}t.scheduleRefresh(t.uri||L.url,w)},onTimeout:function(b,L,A){t.log("Timeout loading steering manifest ("+L.url+")"),t.scheduleRefresh(t.uri||L.url)}};this.log("Requesting steering manifest: "+u),this.loader.load(d,y,T)},a.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var o,u=(o=r.hls)==null?void 0:o.media;if(u&&!u.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},s}();function ha(s,a,i,e){s&&Object.keys(a).forEach(function(t){var r=s.filter(function(o){return o.groupId===t}).map(function(o){var u=C({},o);return u.details=void 0,u.attrs=new pe(u.attrs),u.url=u.attrs.URI=da(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),u.groupId=u.attrs["GROUP-ID"]=a[t],u.attrs["PATHWAY-ID"]=e,u});s.push.apply(s,r)})}function da(s,a,i,e){var t=e.HOST,r=e.PARAMS,o=e[i],u;a&&(u=o?.[a],u&&(s=u));var h=new self.URL(s);return t&&!u&&(h.host=t),r&&Object.keys(r).sort().forEach(function(d){d&&h.searchParams.set(d,r[d])}),h.href}var Iu=/^age:\s*[\d.]+\s*$/im,ca=function(){function s(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new $t,this.retryDelay=0}var a=s.prototype;return a.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},a.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},a.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},a.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var o=this.loader=new self.XMLHttpRequest,u=this.stats;u.loading.first=0,u.loaded=0,u.aborted=!1;var h=this.xhrSetup;h?Promise.resolve().then(function(){if(!(e.loader!==o||e.stats.aborted))return h(o,r.url)}).catch(function(d){if(!(e.loader!==o||e.stats.aborted))return o.open("GET",r.url,!0),h(o,r.url)}).then(function(){e.loader!==o||e.stats.aborted||e.openAndSendXhr(o,r,t)}).catch(function(d){e.callbacks.onError({code:o.status,text:d.message},r,o,u)}):this.openAndSendXhr(o,r,t)}},a.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var o=t.headers,u=r.loadPolicy,h=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;if(o)for(var m in o)e.setRequestHeader(m,o[m]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=h&&j(h)?h:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},a.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var o=t.readyState,u=this.config;if(!r.aborted&&o>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),u.timeout!==u.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),u.timeout=u.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),u.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var h=t.status,d=t.responseType!=="text";if(h>=200&&h<300&&(d&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var m=d?t.response:t.responseText,p=t.responseType==="arraybuffer"?m.byteLength:m.length;if(r.loaded=r.total=p,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var y=this.callbacks.onProgress;if(y&&y(r,e,m,t),!this.callbacks)return;var T={url:t.responseURL,data:m,code:h};this.callbacks.onSuccess(T,r,e,t)}else{var x=u.loadPolicy.errorRetry,b=r.retry,L={url:e.url,data:void 0,code:h};qr(x,b,!1,L)?this.retry(x):(k.error(h+" while loading "+e.url),this.callbacks.onError({code:h,text:t.statusText},e,t,r))}}}},a.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(qr(e,t,!0))this.retry(e);else{var r;k.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}},a.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=wi(e,r.retry),r.retry++,k.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t?.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},a.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},a.getCacheAge=function(){var e=null;if(this.loader&&Iu.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),Pu=function(){function s(){this.chunks=[],this.dataLength=0}var a=s.prototype;return a.push=function(e){this.chunks.push(e),this.dataLength+=e.length},a.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=ku(e,t);else return new Uint8Array(0);return this.reset(),r},a.reset=function(){this.chunks.length=0,this.dataLength=0},s}();function ku(s,a){for(var i=new Uint8Array(a),e=0,t=0;t<s.length;t++){var r=s[t];i.set(r,e),e+=r.length}return i}function Ou(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Mu=/(\d+)-(\d+)\/(\d+)/,va=function(){function s(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||Bu,this.controller=new self.AbortController,this.stats=new $t}var a=s.prototype;return a.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},a.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(e,t,r){var o=this,u=this.stats;if(u.loading.start)throw new Error("Loader can only be used once.");u.loading.start=self.performance.now();var h=Fu(e,this.controller.signal),d=r.onProgress,m=e.responseType==="arraybuffer",p=m?"byteLength":"length",y=t.loadPolicy,T=y.maxTimeToFirstByteMs,x=y.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,h),self.clearTimeout(this.requestTimeout),t.timeout=T&&j(T)?T:x,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},t.timeout),self.fetch(this.request).then(function(b){o.response=o.loader=b;var L=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(o.requestTimeout),t.timeout=x,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},x-(L-u.loading.start)),!b.ok){var A=b.status,D=b.statusText;throw new Gu(D||"fetch, bad network response",A,b)}return u.loading.first=L,u.total=Uu(b.headers)||u.total,d&&j(t.highWaterMark)?o.loadProgressively(b,u,e,t.highWaterMark,d):m?b.arrayBuffer():e.responseType==="json"?b.json():b.text()}).then(function(b){var L=o.response;if(!L)throw new Error("loader destroyed");self.clearTimeout(o.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var A=b[p];A&&(u.loaded=u.total=A);var D={url:L.url,data:b,code:L.status};d&&!j(t.highWaterMark)&&d(u,e,b,L),r.onSuccess(D,u,e,L)}).catch(function(b){if(self.clearTimeout(o.requestTimeout),!u.aborted){var L=b&&b.code||0,A=b?b.message:null;r.onError({code:L,text:A},e,b?b.details:null,u)}})},a.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},a.loadProgressively=function(e,t,r,o,u){o===void 0&&(o=0);var h=new Pu,d=e.body.getReader(),m=function p(){return d.read().then(function(y){if(y.done)return h.dataLength&&u(t,r,h.flush(),e),Promise.resolve(new ArrayBuffer(0));var T=y.value,x=T.length;return t.loaded+=x,x<o||h.dataLength?(h.push(T),h.dataLength>=o&&u(t,r,h.flush(),e)):u(t,r,T,e),p()}).catch(function(){return Promise.reject()})};return m()},s}();function Fu(s,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(C({},s.headers))};return s.rangeEnd&&i.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),i}function Nu(s){var a=Mu.exec(s);if(a)return parseInt(a[2])-parseInt(a[1])+1}function Uu(s){var a=s.get("Content-Range");if(a){var i=Nu(a);if(j(i))return i}var e=s.get("Content-Length");if(e)return parseInt(e)}function Bu(s,a){return new self.Request(s.url,a)}var Gu=function(s){I(a,s);function a(i,e,t){var r;return r=s.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return a}(J(Error)),Vu={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},pa=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ca,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Tu,bufferController:Lu,capLevelController:Ru,errorController:vu,fpsController:Cu,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:Vu},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Hu()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:wu});function Hu(){return{cueHandler:lo,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Ku(s,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=Ii(s),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var o=(r==="level"?"playlist":r)+"LoadPolicy",u=a[o]===void 0,h=[];t.forEach(function(d){var m=r+"Loading"+d,p=a[m];if(p!==void 0&&u){h.push(m);var y=i[o].default;switch(a[o]={default:y},d){case"TimeOut":y.maxLoadTimeMs=p,y.maxTimeToFirstByteMs=p;break;case"MaxRetry":y.errorRetry.maxNumRetry=p,y.timeoutRetry.maxNumRetry=p;break;case"RetryDelay":y.errorRetry.retryDelayMs=p,y.timeoutRetry.retryDelayMs=p;break;case"MaxRetryTimeout":y.errorRetry.maxRetryDelayMs=p,y.timeoutRetry.maxRetryDelayMs=p;break}}}),h.length&&k.warn('hls.js config: "'+h.join('", "')+'" setting(s) are deprecated, use "'+o+'": '+JSON.stringify(a[o]))}),l(l({},i),a)}function Ii(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ii):Object.keys(s).reduce(function(a,i){return a[i]=Ii(s[i]),a},{}):s}function Wu(s){var a=s.loader;if(a!==va&&a!==ca)k.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var i=Ou();i&&(s.loader=va,s.progressive=!0,s.enableSoftwareAES=!0,k.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Pi,ju=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),s.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var o=this.hls.config.preferManagedMediaSource,u=[],h={},d={},m=!1,p=!1,y=!1;r.levels.forEach(function(T){var x,b,L=T.attrs,A=T.audioCodec,D=T.videoCodec;((x=A)==null?void 0:x.indexOf("mp4a.40.34"))!==-1&&(Pi||(Pi=/chrome|firefox/i.test(navigator.userAgent)),Pi&&(T.audioCodec=A=void 0)),A&&(T.audioCodec=A=Kr(A,o)),((b=D)==null?void 0:b.indexOf("avc1"))===0&&(D=T.videoCodec=Bo(D));var w=T.width,N=T.height,U=T.unknownCodecs;if(m||(m=!!(w&&N)),p||(p=!!D),y||(y=!!A),!(U!=null&&U.length||A&&!Si(A,"audio",o)||D&&!Si(D,"video",o))){var $=L.CODECS,V=L["FRAME-RATE"],M=L["HDCP-LEVEL"],K=L["PATHWAY-ID"],z=L.RESOLUTION,te=L["VIDEO-RANGE"],Z=(K||".")+"-",ie=""+Z+T.bitrate+"-"+z+"-"+V+"-"+$+"-"+te+"-"+M;if(h[ie])if(h[ie].uri!==T.url&&!T.attrs["PATHWAY-ID"]){var fe=d[ie]+=1;T.attrs["PATHWAY-ID"]=new Array(fe+1).join(".");var Le=new Ci(T);h[ie]=Le,u.push(Le)}else h[ie].addGroupId("audio",L.AUDIO),h[ie].addGroupId("text",L.SUBTITLES);else{var he=new Ci(T);h[ie]=he,d[ie]=1,u.push(he)}}}),this.filterAndSortMediaOptions(u,r,m,p,y)},i.filterAndSortMediaOptions=function(t,r,o,u,h){var d=this,m=[],p=[],y=t;if((o||u)&&h&&(y=y.filter(function(M){var K=M.videoCodec,z=M.videoRange,te=M.width,Z=M.height;return(!!K||!!(te&&Z))&&tu(z)})),y.length===0){Promise.resolve().then(function(){if(d.hls){r.levels.length&&d.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var M=new Error("no level with compatible codecs found in manifest");d.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:M,reason:M.message})}});return}if(r.audioTracks){var T=this.hls.config.preferManagedMediaSource;m=r.audioTracks.filter(function(M){return!M.audioCodec||Si(M.audioCodec,"audio",T)}),ma(m)}r.subtitles&&(p=r.subtitles,ma(p));var x=y.slice(0);y.sort(function(M,K){if(M.attrs["HDCP-LEVEL"]!==K.attrs["HDCP-LEVEL"])return(M.attrs["HDCP-LEVEL"]||"")>(K.attrs["HDCP-LEVEL"]||"")?1:-1;if(o&&M.height!==K.height)return M.height-K.height;if(M.frameRate!==K.frameRate)return M.frameRate-K.frameRate;if(M.videoRange!==K.videoRange)return jr.indexOf(M.videoRange)-jr.indexOf(K.videoRange);if(M.videoCodec!==K.videoCodec){var z=Nn(M.videoCodec),te=Nn(K.videoCodec);if(z!==te)return te-z}if(M.uri===K.uri&&M.codecSet!==K.codecSet){var Z=Hr(M.codecSet),ie=Hr(K.codecSet);if(Z!==ie)return ie-Z}return M.averageBitrate!==K.averageBitrate?M.averageBitrate-K.averageBitrate:0});var b=x[0];if(this.steering&&(y=this.steering.filterParsedLevels(y),y.length!==x.length)){for(var L=0;L<x.length;L++)if(x[L].pathwayId===y[0].pathwayId){b=x[L];break}}this._levels=y;for(var A=0;A<y.length;A++)if(y[A]===b){var D;this._firstLevel=A;var w=b.bitrate,N=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+w),((D=this.hls.userConfig)==null?void 0:D.abrEwmaDefaultEstimate)===void 0){var U=Math.min(w,this.hls.config.abrEwmaDefaultEstimateMax);U>N&&N===pa.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=U)}break}var $=h&&!u,V={levels:y,audioTracks:m,subtitleTracks:p,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:h,video:u,altAudio:!$&&m.some(function(M){return!!M.url})};this.hls.trigger(R.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Oe.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var o=r.frag;if(o!==void 0&&o.type===Me.MAIN){var u=o.elementaryStreams;if(!Object.keys(u).some(function(d){return!!u[d]}))return;var h=this._levels[o.level];h!=null&&h.loadError&&(this.log("Resetting level error count of "+h.loadError+" on frag buffered"),h.loadError=0)}},i.onLevelLoaded=function(t,r){var o,u=r.level,h=r.details,d=this._levels[u];if(!d){var m;this.warn("Invalid level index "+u),(m=r.deliveryDirectives)!=null&&m.skip&&(h.deltaUpdateFailed=!0);return}u===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(u,r,d.details)):(o=r.deliveryDirectives)!=null&&o.skip&&(h.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,o=this.currentLevel;if(o&&this.shouldLoadPlaylist(o)){var u=o.uri;if(t)try{u=t.addDirectives(u)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var h=o.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(h?" Pathway "+h:"")+" "+u),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:u,level:r,pathwayId:o.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,o,u=this._levels.filter(function(h,d){return d!==t?!0:(r.steering&&r.steering.removeLevel(h),h===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,h.details&&h.details.fragments.forEach(function(m){return m.level=-1})),!1)});ia(u),this._levels=u,this.currentLevelIndex>-1&&(o=this.currentLevel)!=null&&o.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(R.LEVELS_UPDATED,{levels:u})},i.onLevelsUpdated=function(t,r){var o=r.levels;this._levels=o},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,o=t.maxAutoLevel,u=t.maxHdcpLevel;this._maxAutoLevel!==o&&(this._maxAutoLevel=o,this.hls.trigger(R.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:o,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:u}))},_(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var o=new Error("invalid level idx"),u=t<0;if(this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.LEVEL_SWITCH_ERROR,level:t,fatal:u,error:o,reason:o.message}),u)return;t=Math.min(t,r.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,m=d?d.attrs["PATHWAY-ID"]:void 0,p=r[t],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=p,!(h===t&&p.details&&d&&m===y)){this.log("Switching to level "+t+" ("+(p.height?p.height+"p ":"")+(p.videoRange?p.videoRange+" ":"")+(p.codecSet?p.codecSet+" ":"")+"@"+p.bitrate+")"+(y?" with Pathway "+y:"")+" from level "+h+(m?" with Pathway "+m:""));var T={level:t,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(R.LEVEL_SWITCHING,T);var x=p.details;if(!x||x.live){var b=this.switchParams(p.uri,d?.details,x);this.loadPlaylist(b)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),a}(pu);function ma(s){var a={};s.forEach(function(i){var e=i.groupId||"";i.id=a[e]=a[e]||0,a[e]++})}var gt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},zu=function(){function s(i){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=i,this._registerListeners()}var a=s.prototype;return a._registerListeners=function(){var e=this.hls;e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)},a.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},a.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var o=r.length;o--;){var u=r[o];if(!u)break;var h=u.end;if(u.start<=e&&h!==null&&e<=h)return u}return this.getBufferedFrag(e,t)},a.getBufferedFrag=function(e,t){for(var r=this.fragments,o=Object.keys(r),u=o.length;u--;){var h=r[o[u]];if(h?.body.type===t&&h.buffered){var d=h.body;if(d.start<=e&&e<=d.end)return d}}return null},a.detectEvictedFragments=function(e,t,r,o){var u=this;this.timeRanges&&(this.timeRanges[e]=t);var h=o?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(d){var m=u.fragments[d];if(m&&!(h>=m.body.sn)){if(!m.buffered&&!m.loaded){m.body.type===r&&u.removeFragment(m.body);return}var p=m.range[e];p&&p.time.some(function(y){var T=!u.isTimeBuffered(y.startPTS,y.endPTS,t);return T&&u.removeFragment(m.body),T})}})},a.detectPartialFragments=function(e){var t=this,r=this.timeRanges,o=e.frag,u=e.part;if(!(!r||o.sn==="initSegment")){var h=vr(o),d=this.fragments[h];if(!(!d||d.buffered&&o.gap)){var m=!o.relurl;if(Object.keys(r).forEach(function(y){var T=o.elementaryStreams[y];if(T){var x=r[y],b=m||T.partial===!0;d.range[y]=t.getBufferedTimes(o,u,b,x)}}),d.loaded=null,Object.keys(d.range).length){d.buffered=!0;var p=d.body.endList=o.endList||d.body.endList;p&&(this.endListFragments[d.body.type]=d),Xr(d)||this.removeParts(o.sn-1,o.type)}else this.removeFragment(d.body)}}},a.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(o){return o.fragment.sn>=e}))},a.fragBuffered=function(e,t){var r=vr(e),o=this.fragments[r];!o&&t&&(o=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)},a.getBufferedTimes=function(e,t,r,o){for(var u={time:[],partial:r},h=e.start,d=e.end,m=e.minEndPTS||d,p=e.maxStartPTS||h,y=0;y<o.length;y++){var T=o.start(y)-this.bufferPadding,x=o.end(y)+this.bufferPadding;if(p>=T&&m<=x){u.time.push({startPTS:Math.max(h,o.start(y)),endPTS:Math.min(d,o.end(y))});break}else if(h<x&&d>T){var b=Math.max(h,o.start(y)),L=Math.min(d,o.end(y));L>b&&(u.partial=!0,u.time.push({startPTS:b,endPTS:L}))}else if(d<=T)break}return u},a.getPartialFragment=function(e){var t=null,r,o,u,h=0,d=this.bufferPadding,m=this.fragments;return Object.keys(m).forEach(function(p){var y=m[p];y&&Xr(y)&&(o=y.body.start-d,u=y.body.end+d,e>=o&&e<=u&&(r=Math.min(e-o,u-e),h<=r&&(t=y.body,h=r)))}),t},a.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||Xr(t))},a.getState=function(e){var t=vr(e),r=this.fragments[t];return r?r.buffered?Xr(r)?gt.PARTIAL:gt.OK:gt.APPENDING:gt.NOT_LOADED},a.isTimeBuffered=function(e,t,r){for(var o,u,h=0;h<r.length;h++){if(o=r.start(h)-this.bufferPadding,u=r.end(h)+this.bufferPadding,e>=o&&t<=u)return!0;if(t<=o)return!1}return!1},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var u=o?null:t,h=vr(r);this.fragments[h]={body:r,appendedPTS:null,loaded:u,buffered:!1,range:Object.create(null)}}},a.onBufferAppended=function(e,t){var r=this,o=t.frag,u=t.part,h=t.timeRanges;if(o.sn!=="initSegment"){var d=o.type;if(u){var m=this.activePartLists[d];m||(this.activePartLists[d]=m=[]),m.push(u)}this.timeRanges=h,Object.keys(h).forEach(function(p){var y=h[p];r.detectEvictedFragments(p,y,d,u)})}},a.onFragBuffered=function(e,t){this.detectPartialFragments(t)},a.hasFragment=function(e){var t=vr(e);return!!this.fragments[t]},a.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},a.removeFragmentsInRange=function(e,t,r,o,u){var h=this;o&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var m=h.fragments[d];if(m){var p=m.body;p.type!==r||o&&!p.gap||p.start<t&&p.end>e&&(m.buffered||u)&&h.removeFragment(p)}})},a.removeFragment=function(e){var t=vr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var o=e.sn;this.activePartLists[e.type]=r.filter(function(u){return u.fragment.sn!==o})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},a.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function Xr(s){var a,i,e;return s.buffered&&(s.body.gap||((a=s.range.video)==null?void 0:a.partial)||((i=s.range.audio)==null?void 0:i.partial)||((e=s.range.audiovideo)==null?void 0:e.partial))}function vr(s){return s.type+"_"+s.level+"_"+s.sn}var ga=Math.pow(2,17),Yu=function(){function s(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var a=s.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(e,t){var r=this,o=e.url;if(!o)return Promise.reject(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(o?"part list":"url")),networkDetails:null}));this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(L){return L[0]==="GAP"})){p(Ea(e));return}else e.gap=!1;var y=r.loader=e.loader=h?new h(u):new d(u),T=ya(e),x=aa(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ga};e.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){r.resetLoader(e,y);var U=A.data;w.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),m({frag:e,part:null,payload:U,networkDetails:N})},onError:function(A,D,w,N){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:l({url:o,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))},onProgress:function(A,D,w,N){t&&t({frag:e,part:null,payload:w,networkDetails:N})}})})},a.loadPart=function(e,t,r){var o=this;this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(o.loader&&o.loader.destroy(),e.gap||t.gap){p(Ea(e,t));return}var y=o.loader=e.loader=h?new h(u):new d(u),T=ya(e,t),x=aa(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ga};t.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){o.resetLoader(e,y),o.updateStatsFromPart(e,t);var U={frag:e,part:t,payload:A.data,networkDetails:N};r(U),m(U)},onError:function(A,D,w,N){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:l({url:T.url,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){e.stats.aborted=t.stats.aborted,o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))}})})},a.updateStatsFromPart=function(e,t){var r=e.stats,o=t.stats,u=o.total;if(r.loaded+=o.loaded,u){var h=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/u),h),m=h-d,p=m*Math.round(r.loaded/d);r.total=r.loaded+p}else r.total=Math.max(r.loaded,r.total);var y=r.loading,T=o.loading;y.start?y.first+=T.first-T.start:(y.start=T.start,y.first=T.first),y.end=T.end},a.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function ya(s,a){a===void 0&&(a=null);var i=a||s,e={frag:s,part:a,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(j(t)&&j(r)){var o,u=t,h=r;if(s.sn==="initSegment"&&((o=s.decryptdata)==null?void 0:o.method)==="AES-128"){var d=r-t;d%16&&(h=r+(16-d%16)),t!==0&&(e.resetIV=!0,u=t-16)}e.rangeStart=u,e.rangeEnd=h}return e}function Ea(s,a){var i=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),e={type:le.MEDIA_ERROR,details:G.FRAG_GAP,fatal:!1,frag:s,error:i,networkDetails:null};return a&&(e.part=a),(a||s).stats.aborted=!0,new Kt(e)}var Kt=function(s){I(a,s);function a(i){var e;return e=s.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return a}(J(Error)),qu=function(){function s(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var a=s.prototype;return a.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var o;if(e&&e!==((o=r.context)==null?void 0:o.frag.type))return;r.abort()}}},a.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},a.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},a.createKeyLoadError=function(e,t,r,o,u){return t===void 0&&(t=G.KEY_LOAD_ERROR),new Kt({type:le.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:u,error:r,networkDetails:o})},a.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var o=e.sn,u=e.cc,h=function(){var p=t[d];if(u<=p.cc&&(o==="initSegment"||p.sn==="initSegment"||o<p.sn))return r.emeController.selectKeySystemFormat(p).then(function(y){p.setKeyFormat(y)}),1},d=0;d<t.length&&!h();d++);},a.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},a.loadInternal=function(e,t){var r,o;t&&e.setKeyFormat(t);var u=e.decryptdata;if(!u){var h=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,h))}var d=u.uri;if(!d)return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+d+'"')));var m=this.keyUriToKeyInfo[d];if((r=m)!=null&&r.decryptdata.key)return u.key=m.decryptdata.key,Promise.resolve({frag:e,keyInfo:m});if((o=m)!=null&&o.keyLoadPromise){var p;switch((p=m.mediaKeySessionContext)==null?void 0:p.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return m.keyLoadPromise.then(function(y){return u.key=y.keyInfo.decryptdata.key,{frag:e,keyInfo:m}})}}switch(m=this.keyUriToKeyInfo[d]={decryptdata:u,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},u.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return u.keyFormat==="identity"?this.loadKeyHTTP(m,e):this.loadKeyEME(m,e);case"AES-128":return this.loadKeyHTTP(m,e);default:return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+u.method+'"')))}},a.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var o=this.emeController.loadKey(r);if(o)return(e.keyLoadPromise=o.then(function(u){return e.mediaKeySessionContext=u,r})).catch(function(u){throw e.keyLoadPromise=null,u})}return Promise.resolve(r)},a.loadKeyHTTP=function(e,t){var r=this,o=this.config,u=o.loader,h=new u(o);return t.keyLoader=e.loader=h,e.keyLoadPromise=new Promise(function(d,m){var p={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},y=o.keyLoadPolicy.default,T={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},x={onSuccess:function(L,A,D,w){var N=D.frag,U=D.keyInfo,$=D.url;if(!N.decryptdata||U!==r.keyUriToKeyInfo[$])return m(r.createKeyLoadError(N,G.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));U.decryptdata.key=N.decryptdata.key=new Uint8Array(L.data),N.keyLoader=null,U.loader=null,d({frag:N,keyInfo:U})},onError:function(L,A,D,w){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_ERROR,new Error("HTTP Error "+L.code+" loading key "+L.text),D,l({url:p.url,data:void 0},L)))},onTimeout:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),D))},onAbort:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.INTERNAL_ABORTED,new Error("key loading aborted"),D))}};h.load(p,T,x)})},a.resetLoader=function(e){var t=e.frag,r=e.keyInfo,o=e.url,u=r.loader;t.keyLoader===u&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[o],u&&u.destroy()},s}(),Xu=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var a=s.prototype;return a.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},a.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},a.onHandlerDestroyed=function(){},a.hasInterval=function(){return!!this._tickInterval},a.hasNextTick=function(){return!!this._tickTimer},a.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},a.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},a.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},a.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},a.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},a.doTick=function(){},s}(),_a=function(a,i,e,t,r,o){t===void 0&&(t=0),r===void 0&&(r=-1),o===void 0&&(o=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=$r(),this.buffering={audio:$r(),video:$r(),audiovideo:$r()},this.level=a,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=o};function $r(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Qr(s,a){for(var i=0,e=s.length;i<e;i++){var t;if(((t=s[i])==null?void 0:t.cc)===a)return s[i]}return null}function $u(s,a,i){return!!(a&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function Qu(s,a){var i=s.fragments,e=a.fragments;if(!e.length||!i.length){k.log("No fragments to align");return}var t=Qr(i,e[0].cc);if(!t||t&&!t.startPTS){k.log("No frag in previous level to align on");return}return t}function Sa(s,a){if(s){var i=s.start+a;s.start=s.startPTS=i,s.endPTS=i+s.duration}}function Ta(s,a){for(var i=a.fragments,e=0,t=i.length;e<t;e++)Sa(i[e],s);a.fragmentHint&&Sa(a.fragmentHint,s),a.alignedSliding=!0}function Ju(s,a,i){a&&(Zu(s,i,a),!i.alignedSliding&&a&&el(i,a),!i.alignedSliding&&a&&!i.skippedSegments&&ea(a,i))}function Zu(s,a,i){if($u(s,i,a)){var e=Qu(i,a);e&&j(e.start)&&(k.log("Adjusting PTS using last level due to CC increase within current level "+a.url),Ta(e.start,a))}}function el(s,a){if(!(!s.hasProgramDateTime||!a.hasProgramDateTime)){var i=s.fragments,e=a.fragments;if(!(!i.length||!e.length)){var t,r,o=Math.min(a.endCC,s.endCC);a.startCC<o&&s.startCC<o&&(t=Qr(e,o),r=Qr(i,o)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=Qr(i,t.cc)||i[Math.floor(i.length/2)]);var u=t.programDateTime,h=r.programDateTime;if(!(!u||!h)){var d=(h-u)/1e3-(r.start-t.start);Ta(d,s)}}}}var tl=function(){function s(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var a=s.prototype;return a.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},s}(),rl=function(){function s(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var a=s.prototype;return a.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}();function il(s){var a=s.byteLength,i=a&&new DataView(s.buffer).getUint8(a-1);return i?nr(s,0,a-i):s}var nl=function(){function s(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var a=s.prototype;return a.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),o=0;o<4;o++)r[o]=t.getUint32(o*4);return r},a.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,o=r[0],u=r[1],h=r[2],d=r[3],m=this.invSubMix,p=m[0],y=m[1],T=m[2],x=m[3],b=new Uint32Array(256),L=0,A=0,D=0;for(D=0;D<256;D++)D<128?b[D]=D<<1:b[D]=D<<1^283;for(D=0;D<256;D++){var w=A^A<<1^A<<2^A<<3^A<<4;w=w>>>8^w&255^99,e[L]=w,t[w]=L;var N=b[L],U=b[N],$=b[U],V=b[w]*257^w*16843008;o[L]=V<<24|V>>>8,u[L]=V<<16|V>>>16,h[L]=V<<8|V>>>24,d[L]=V,V=$*16843009^U*65537^N*257^L*16843008,p[w]=V<<24|V>>>8,y[w]=V<<16|V>>>16,T[w]=V<<8|V>>>24,x[w]=V,L?(L=N^b[b[b[$^N]]],A^=b[b[A]]):L=A=1}},a.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,o=0;o<t.length&&r;)r=t[o]===this.key[o],o++;if(!r){this.key=t;var u=this.keySize=t.length;if(u!==4&&u!==6&&u!==8)throw new Error("Invalid aes key size="+u);var h=this.ksRows=(u+6+1)*4,d,m,p=this.keySchedule=new Uint32Array(h),y=this.invKeySchedule=new Uint32Array(h),T=this.sBox,x=this.rcon,b=this.invSubMix,L=b[0],A=b[1],D=b[2],w=b[3],N,U;for(d=0;d<h;d++){if(d<u){N=p[d]=t[d];continue}U=N,d%u===0?(U=U<<8|U>>>24,U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255],U^=x[d/u|0]<<24):u>6&&d%u===4&&(U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255]),p[d]=N=(p[d-u]^U)>>>0}for(m=0;m<h;m++)d=h-m,m&3?U=p[d]:U=p[d-4],m<4||d<=4?y[m]=U:y[m]=L[T[U>>>24]]^A[T[U>>>16&255]]^D[T[U>>>8&255]]^w[T[U&255]],y[m]=y[m]>>>0}},a.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},a.decrypt=function(e,t,r){for(var o=this.keySize+6,u=this.invKeySchedule,h=this.invSBox,d=this.invSubMix,m=d[0],p=d[1],y=d[2],T=d[3],x=this.uint8ArrayToUint32Array_(r),b=x[0],L=x[1],A=x[2],D=x[3],w=new Int32Array(e),N=new Int32Array(w.length),U,$,V,M,K,z,te,Z,ie,he,fe,Le,Ee,we,Ae=this.networkToHostOrderSwap;t<w.length;){for(ie=Ae(w[t]),he=Ae(w[t+1]),fe=Ae(w[t+2]),Le=Ae(w[t+3]),K=ie^u[0],z=Le^u[1],te=fe^u[2],Z=he^u[3],Ee=4,we=1;we<o;we++)U=m[K>>>24]^p[z>>16&255]^y[te>>8&255]^T[Z&255]^u[Ee],$=m[z>>>24]^p[te>>16&255]^y[Z>>8&255]^T[K&255]^u[Ee+1],V=m[te>>>24]^p[Z>>16&255]^y[K>>8&255]^T[z&255]^u[Ee+2],M=m[Z>>>24]^p[K>>16&255]^y[z>>8&255]^T[te&255]^u[Ee+3],K=U,z=$,te=V,Z=M,Ee=Ee+4;U=h[K>>>24]<<24^h[z>>16&255]<<16^h[te>>8&255]<<8^h[Z&255]^u[Ee],$=h[z>>>24]<<24^h[te>>16&255]<<16^h[Z>>8&255]<<8^h[K&255]^u[Ee+1],V=h[te>>>24]<<24^h[Z>>16&255]<<16^h[K>>8&255]<<8^h[z&255]^u[Ee+2],M=h[Z>>>24]<<24^h[K>>16&255]<<16^h[z>>8&255]<<8^h[te&255]^u[Ee+3],N[t]=Ae(U^b),N[t+1]=Ae(M^L),N[t+2]=Ae(V^A),N[t+3]=Ae($^D),b=ie,L=he,A=fe,D=Le,t=t+4}return N.buffer},s}(),al=16,ki=function(){function s(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,o=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=i.enableSoftwareAES,this.removePKCS7Padding=o,o)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var a=s.prototype;return a.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},a.isSync=function(){return this.useSoftware},a.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?il(r):r},a.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},a.decrypt=function(e,t,r){var o=this;return this.useSoftware?new Promise(function(u,h){o.softwareDecrypt(new Uint8Array(e),t,r);var d=o.flush();d?u(d.buffer):h(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},a.softwareDecrypt=function(e,t,r){var o=this.currentIV,u=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(e=At(h,e),this.remainderData=null);var d=this.getValidChunk(e);if(!d.length)return null;o&&(r=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new nl),m.expandKey(t);var p=u;return this.currentResult=m.decrypt(d.buffer,0,r),this.currentIV=nr(d,-16).buffer,p||null},a.webCryptoDecrypt=function(e,t,r){var o=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new rl(this.subtle,t)}return this.fastAesKey.expandKey().then(function(u){if(!o.subtle)return Promise.reject(new Error("web crypto not initialized"));o.logOnce("WebCrypto AES decrypt");var h=new tl(o.subtle,new Uint8Array(r));return h.decrypt(e.buffer,u)}).catch(function(u){return k.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+u.name+": "+u.message),o.onWebCryptoError(e,t,r)})},a.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var o=this.flush();if(o)return o.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},a.getValidChunk=function(e){var t=e,r=e.length-e.length%al;return r!==e.length&&(t=nr(e,0,r),this.remainderData=nr(e,r)),t},a.logOnce=function(e){this.logEnabled&&(k.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),sl={toString:function(a){for(var i="",e=a.length,t=0;t<e;t++)i+="["+a.start(t).toFixed(3)+"-"+a.end(t).toFixed(3)+"]";return i}},ne={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ol=function(s){I(a,s);function a(e,t,r,o,u){var h;return h=s.call(this)||this,h.hls=void 0,h.fragPrevious=null,h.fragCurrent=null,h.fragmentTracker=void 0,h.transmuxer=null,h._state=ne.STOPPED,h.playlistType=void 0,h.media=null,h.mediaBuffer=null,h.config=void 0,h.bitrateTest=!1,h.lastCurrentTime=0,h.nextLoadPosition=0,h.startPosition=0,h.startTimeOffset=null,h.loadedmetadata=!1,h.retryDate=0,h.levels=null,h.fragmentLoader=void 0,h.keyLoader=void 0,h.levelLastLoaded=null,h.startFragRequested=!1,h.decrypter=void 0,h.initPTS=[],h.onvseeking=null,h.onvended=null,h.logPrefix="",h.log=void 0,h.warn=void 0,h.playlistType=u,h.logPrefix=o,h.log=k.log.bind(k,o+":"),h.warn=k.warn.bind(k,o+":"),h.hls=e,h.fragmentLoader=new Yu(e.config),h.keyLoader=r,h.fragmentTracker=t,h.config=e.config,h.decrypter=new ki(e.config),e.on(R.MANIFEST_LOADED,h.onManifestLoaded,ae(h)),h}var i=a.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ne.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var o=r.partList;if(o!=null&&o.length){var u=o[o.length-1],h=rt.isBuffered(this.media,u.start+u.duration/2);return h}var d=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var o=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),o.addEventListener("seeking",this.onvseeking),o.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===ne.STOPPED&&this.startLoad(u.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,o=this.media,u=this.mediaBuffer,h=this.state,d=o?o.currentTime:0,m=rt.bufferInfo(u||o,d,t.maxBufferHole);if(this.log("media seeking to "+(j(d)?d.toFixed(3):d)+", state: "+h),this.state===ne.ENDED)this.resetLoadingState();else if(r){var p=t.maxFragLookUpTolerance,y=r.start-p,T=r.start+r.duration+p;if(!m.len||T<m.start||y>m.end){var x=d>T;(d<y||x)&&(x&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}o&&(this.fragmentTracker.removeFragmentsInRange(d,1/0,this.playlistType,!0),this.lastCurrentTime=d),!this.loadedmetadata&&!m.len&&(this.nextLoadPosition=this.startPosition=d),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),s.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=ne.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,s.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,o){this._loadFragForPlayback(t,r,o)},i._loadFragForPlayback=function(t,r,o){var u=this,h=function(m){if(u.fragContextChanged(t)){u.warn("Fragment "+t.sn+(m.part?" p: "+m.part.index:"")+" of level "+t.level+" was dropped during download."),u.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,u._handleFragmentLoadProgress(m)};this._doFragLoad(t,r,o,h).then(function(d){if(d){var m=u.state;if(u.fragContextChanged(t)){(m===ne.FRAG_LOADING||!u.fragCurrent&&m===ne.PARSING)&&(u.fragmentTracker.removeFragment(t),u.state=ne.IDLE);return}"payload"in d&&(u.log("Loaded fragment "+t.sn+" of level "+t.level),u.hls.trigger(R.FRAG_LOADED,d)),u._handleFragmentLoadComplete(d)}}).catch(function(d){u.state===ne.STOPPED||u.state===ne.ERROR||(u.warn("Frag error: "+(d?.message||d)),u.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,o=this.fragmentTracker,u=o.getState(t);if(u===gt.APPENDING){var h=t.type,d=this.getFwdBufferInfo(this.mediaBuffer,h),m=Math.max(t.duration,d?d.len:this.config.maxBufferLength),p=this.backtrackFragment,y=p?t.sn-p.sn:0;(y===1||this.reduceMaxBufferLength(m,t.duration))&&o.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?o.removeAllFragments():o.hasParts(t.type)&&(o.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),o.getState(t)===gt.PARTIAL&&o.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,o){if(o===void 0&&(o=null),!!(t-r)){var u={startOffset:t,endOffset:r,type:o};this.hls.trigger(R.BUFFER_FLUSHING,u)}},i._loadInitSegment=function(t,r){var o=this;this._doFragLoad(t,r).then(function(u){if(!u||o.fragContextChanged(t)||!o.levels)throw new Error("init load aborted");return u}).then(function(u){var h=o.hls,d=u.payload,m=t.decryptdata;if(d&&d.byteLength>0&&m!=null&&m.key&&m.iv&&m.method==="AES-128"){var p=self.performance.now();return o.decrypter.decrypt(new Uint8Array(d),m.key.buffer,m.iv.buffer).catch(function(y){throw h.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_DECRYPT_ERROR,fatal:!1,error:y,reason:y.message,frag:t}),y}).then(function(y){var T=self.performance.now();return h.trigger(R.FRAG_DECRYPTED,{frag:t,payload:y,stats:{tstart:p,tdecrypt:T}}),u.payload=y,o.completeInitSegmentLoad(u)})}return o.completeInitSegmentLoad(u)}).catch(function(u){o.state===ne.STOPPED||o.state===ne.ERROR||(o.warn(u),o.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var o=t.frag.stats;this.state=ne.IDLE,t.frag.data=new Uint8Array(t.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var o,u,h,d,m=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===Me.MAIN?"level":"track")+" "+t.level+" (frag:["+((o=t.startPTS)!=null?o:NaN).toFixed(3)+"-"+((u=t.endPTS)!=null?u:NaN).toFixed(3)+"] > buffer:"+(m?sl.toString(rt.getBuffered(m)):"(detached)")+")"),t.sn!=="initSegment"){var p;if(t.type!==Me.SUBTITLE){var y=t.elementaryStreams;if(!Object.keys(y).some(function(x){return!!y[x]})){this.state=ne.IDLE;return}}var T=(p=this.levels)==null?void 0:p[t.level];T!=null&&T.fragmentError&&(this.log("Resetting level fragment error count of "+T.fragmentError+" on frag buffered"),T.fragmentError=0)}this.state=ne.IDLE,m&&(!this.loadedmetadata&&t.type==Me.MAIN&&m.buffered.length&&((h=this.fragCurrent)==null?void 0:h.sn)===((d=this.fragPrevious)==null?void 0:d.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var o=t.frag,u=t.part,h=t.partsLoaded,d=!h||h.length===0||h.some(function(p){return!p}),m=new _a(o.level,o.sn,o.stats.chunkCount+1,0,u?u.index:-1,!d);r.flush(m)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,o,u){var h,d=this;o===void 0&&(o=null);var m=r?.details;if(!this.levels||!m)throw new Error("frag load aborted, missing level"+(m?"":" detail")+"s");var p=null;if(t.encrypted&&!((h=t.decryptdata)!=null&&h.key)?(this.log("Loading key for "+t.sn+" of ["+m.startSN+"-"+m.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=ne.KEY_LOADING,this.fragCurrent=t,p=this.keyLoader.load(t).then(function(D){if(!d.fragContextChanged(D.frag))return d.hls.trigger(R.KEY_LOADED,D),d.state===ne.KEY_LOADING&&(d.state=ne.IDLE),D}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&m.encryptedFragments.length&&this.keyLoader.loadClear(t,m.encryptedFragments),o=Math.max(t.start,o||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var y=m.partList;if(y&&u){o>t.end&&m.fragmentHint&&(t=m.fragmentHint);var T=this.getNextPart(y,t,o);if(T>-1){var x=y[T];this.log("Loading part sn: "+t.sn+" p: "+x.index+" cc: "+t.cc+" of playlist ["+m.startSN+"-"+m.endSN+"] parts [0-"+T+"-"+(y.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),this.nextLoadPosition=x.start+x.duration,this.state=ne.FRAG_LOADING;var b;return p?b=p.then(function(D){return!D||d.fragContextChanged(D.frag)?null:d.doFragPartsLoad(t,x,r,u)}).catch(function(D){return d.handleFragLoadError(D)}):b=this.doFragPartsLoad(t,x,r,u).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:x,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}else if(!t.url||this.loadedEndOfParts(y,o))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(m?"of ["+m.startSN+"-"+m.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),j(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ne.FRAG_LOADING;var L=this.config.progressive,A;return L&&p?A=p.then(function(D){return!D||d.fragContextChanged(D?.frag)?null:d.fragmentLoader.load(t,u)}).catch(function(D){return d.handleFragLoadError(D)}):A=Promise.all([this.fragmentLoader.load(t,L?u:void 0),p]).then(function(D){var w=D[0];return!L&&w&&u&&u(w),w}).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):A},i.doFragPartsLoad=function(t,r,o,u){var h=this;return new Promise(function(d,m){var p,y=[],T=(p=o.details)==null?void 0:p.partList,x=function b(L){h.fragmentLoader.loadPart(t,L,u).then(function(A){y[L.index]=A;var D=A.part;h.hls.trigger(R.FRAG_LOADED,A);var w=ta(o,t.sn,L.index+1)||ra(T,t.sn,L.index+1);if(w)b(w);else return d({frag:t,part:D,partsLoaded:y})}).catch(m)};x(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===G.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(R.ERROR,r)}else this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==ne.PARSING){!this.fragCurrent&&this.state!==ne.STOPPED&&this.state!==ne.ERROR&&(this.state=ne.IDLE);return}var o=r.frag,u=r.part,h=r.level,d=self.performance.now();o.stats.parsing.end=d,u&&(u.stats.parsing.end=d),this.updateLevelTiming(o,u,h,t.partial)},i.getCurrentContext=function(t){var r=this.levels,o=this.fragCurrent,u=t.level,h=t.sn,d=t.part;if(!(r!=null&&r[u]))return this.warn("Levels object was unset while buffering fragment "+h+" of level "+u+". The current chunk will not be buffered."),null;var m=r[u],p=d>-1?ta(m,h,d):null,y=p?p.fragment:uu(m,h,o);return y?(o&&o!==y&&(y.stats=o.stats),{frag:y,part:p,level:m}):null},i.bufferFragmentData=function(t,r,o,u,h){var d;if(!(!t||this.state!==ne.PARSING)){var m=t.data1,p=t.data2,y=m;if(m&&p&&(y=At(m,p)),!!((d=y)!=null&&d.length)){var T={type:t.type,frag:r,part:o,chunkMeta:u,parent:r.type,data:y};if(this.hls.trigger(R.BUFFER_APPENDING,T),t.dropped&&t.independent&&!o){if(h)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!rt.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var o=r.currentTime,u=rt.bufferInfo(r,o,0),h=t.duration,d=Math.min(this.config.maxFragLookUpTolerance*2,h*.25),m=Math.max(Math.min(t.start-d,u.end-d),o+d);t.start-m>d&&this.flushMainBuffer(m,t.start)}},i.getFwdBufferInfo=function(t,r){var o=this.getLoadPosition();return j(o)?this.getFwdBufferInfoAtPos(t,o,r):null},i.getFwdBufferInfoAtPos=function(t,r,o){var u=this.config.maxBufferHole,h=rt.bufferInfo(t,r,u);if(h.len===0&&h.nextStart!==void 0){var d=this.fragmentTracker.getBufferedFrag(r,o);if(d&&h.nextStart<d.end)return rt.bufferInfo(t,r,Math.max(h.nextStart,u))}return h},i.getMaxBufferLength=function(t){var r=this.config,o;return t?o=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):o=r.maxBufferLength,Math.min(o,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t,r){var o=this.config,u=Math.max(Math.min(t-r,o.maxBufferLength),r),h=Math.max(t-r*3,o.maxMaxBufferLength/2,u);return h>=u?(o.maxMaxBufferLength=h,this.warn("Reduce max buffer length to "+h+"s"),!0):!1},i.getAppendedFrag=function(t,r){var o=this.fragmentTracker.getAppendedFrag(t,Me.MAIN);return o&&"fragment"in o?o.fragment:o},i.getNextFragment=function(t,r){var o=r.fragments,u=o.length;if(!u)return null;var h=this.config,d=o[0].start,m;if(r.live){var p=h.initialLiveManifestSize;if(u<p)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+p+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<d)&&(m=this.getInitialLiveFragment(r,o),this.startPosition=this.nextLoadPosition=m?this.hls.liveSyncPosition||m.start:t)}else t<=d&&(m=o[0]);if(!m){var y=h.lowLatencyMode?r.partEnd:r.fragmentEnd;m=this.getFragmentAtPosition(t,y,r)}return this.mapToInitFragWhenRequired(m)},i.isLoopLoading=function(t,r){var o=this.fragmentTracker.getState(t);return(o===gt.OK||o===gt.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,o,u,h){var d=t.gap,m=this.getNextFragment(this.nextLoadPosition,r);if(m===null)return m;if(t=m,d&&t&&!t.gap&&o.nextStart){var p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,o.nextStart,u);if(p!==null&&o.len+p.len>=h)return this.log('buffer full after gaps in "'+u+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,o){for(var u=-1,h=!1,d=!0,m=0,p=t.length;m<p;m++){var y=t[m];if(d=d&&!y.independent,u>-1&&o<y.start)break;var T=y.loaded;T?u=-1:(h||y.independent||d)&&y.fragment===r&&(u=m),h=T}return u},i.loadedEndOfParts=function(t,r){var o=t[t.length-1];return o&&r>o.start&&o.loaded},i.getInitialLiveFragment=function(t,r){var o=this.fragPrevious,u=null;if(o){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+o.programDateTime),u=fu(r,o.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var h=o.sn+1;if(h>=t.startSN&&h<=t.endSN){var d=r[h-t.startSN];o.cc===d.cc&&(u=d,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=cu(r,o.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?t.fragmentEnd:t.edge,t))}return u},i.getFragmentAtPosition=function(t,r,o){var u=this.config,h=this.fragPrevious,d=o.fragments,m=o.endSN,p=o.fragmentHint,y=u.maxFragLookUpTolerance,T=o.partList,x=!!(u.lowLatencyMode&&T!=null&&T.length&&p);x&&p&&!this.bitrateTest&&(d=d.concat(p),m=p.sn);var b;if(t<r){var L=t>r-y?0:y;b=oa(h,d,t,L)}else b=d[d.length-1];if(b){var A=b.sn-o.startSN,D=this.fragmentTracker.getState(b);if((D===gt.OK||D===gt.PARTIAL&&b.gap)&&(h=b),h&&b.sn===h.sn&&(!x||T[0].fragment.sn>b.sn)){var w=h&&b.level===h.level;if(w){var N=d[A+1];b.sn<m&&this.fragmentTracker.getState(N)!==gt.OK?b=N:b=null}}}return b},i.synchronizeToLiveEdge=function(t){var r=this.config,o=this.media;if(o){var u=this.hls.liveSyncPosition,h=o.currentTime,d=t.fragments[0].start,m=t.edge,p=h>=d-r.maxFragLookUpTolerance&&h<=m;if(u!==null&&o.duration>u&&(h<u||!p)){var y=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!p&&o.readyState<4||h<m-y)&&(this.loadedmetadata||(this.nextLoadPosition=u),o.readyState&&(this.warn("Playback: "+h.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),o.currentTime=u))}}},i.alignPlaylists=function(t,r,o){var u=t.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var h=t.fragments[0].start,d=!r,m=t.alignedSliding&&j(h);if(d||!m&&!h){var p=this.fragPrevious;Ju(p,o,t);var y=t.fragments[0].start;return this.log("Live playlist sliding: "+y.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(p?p.sn:"na")+" fragments: "+u),y}return h},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var o=this.startPosition;if(o<r&&(o=-1),o===-1||this.lastCurrentTime===-1){var u=this.startTimeOffset!==null,h=u?this.startTimeOffset:t.startTimeOffset;h!==null&&j(h)?(o=r+h,h<0&&(o+=t.totalduration),o=Math.min(Math.max(r,o),r+t.totalduration),this.log("Start time offset "+h+" found in "+(u?"multivariant":"media")+" playlist, adjust startPosition to "+o),this.startPosition=o):t.live?o=this.hls.liveSyncPosition||r:this.startPosition=o=0,this.lastCurrentTime=o}this.nextLoadPosition=o},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==ne.FRAG_LOADING_WAITING_RETRY)&&(this.state=ne.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var o=this.getCurrentContext(r.chunkMeta);o&&(r.frag=o.frag)}var u=r.frag;if(!(!u||u.type!==t||!this.levels)){if(this.fragContextChanged(u)){var h;this.warn("Frag load error must match current frag to retry "+u.url+" > "+((h=this.fragCurrent)==null?void 0:h.url));return}var d=r.details===G.FRAG_GAP;d&&this.fragmentTracker.fragBuffered(u,!0);var m=r.errorAction,p=m||{},y=p.action,T=p.retryCount,x=T===void 0?0:T,b=p.retryConfig;if(m&&y===ot.RetryRequest&&b){this.resetStartWhenNotLoaded(this.levelLastLoaded);var L=wi(b,x);this.warn("Fragment "+u.sn+" of "+t+" "+u.level+" errored with "+r.details+", retrying loading "+(x+1)+"/"+b.maxNumRetry+" in "+L+"ms"),m.resolved=!0,this.retryDate=self.performance.now()+L,this.state=ne.FRAG_LOADING_WAITING_RETRY}else if(b&&m)if(this.resetFragmentErrors(t),x<b.maxNumRetry)!d&&y!==ot.RemoveAlternatePermanently&&(m.resolved=!0);else{k.warn(r.details+" reached or exceeded max retry ("+x+")");return}else m?.action===ot.SendAlternateToPenaltyBox?this.state=ne.WAITING_LEVEL:this.state=ne.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===ne.PARSING||this.state===ne.PARSED){var r=t.frag,o=t.parent,u=this.getFwdBufferInfo(this.mediaBuffer,o),h=u&&u.len>.5;h&&this.reduceMaxBufferLength(u.len,r?.duration||10);var d=!h;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+o+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),d}return!1},i.resetFragmentErrors=function(t){t===Me.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.afterBufferFlushed=function(t,r,o){if(t){var u=rt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,u,o),this.state===ne.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ne.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,o,u){var h=this,d,m=o.details;if(!m){this.warn("level.details undefined");return}var p=Object.keys(t.elementaryStreams).reduce(function(T,x){var b=t.elementaryStreams[x];if(b){var L=b.endPTS-b.startPTS;if(L<=0)return h.warn("Could not parse fragment "+t.sn+" "+x+" duration reliably ("+L+")"),T||!1;var A=u?0:Zn(m,t,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return h.hls.trigger(R.LEVEL_PTS_UPDATED,{details:m,level:o,drift:A,type:x,frag:t,start:b.startPTS,end:b.endPTS}),!0}return T},!1);if(!p&&((d=this.transmuxer)==null?void 0:d.error)===null){var y=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(o.fragmentError===0&&(o.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(y.message),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+o.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=ne.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},_(a,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),a}(Xu);function xa(){return self.SourceBuffer||self.WebKitSourceBuffer}function ba(){var s=ar();if(!s)return!1;var a=xa();return!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function"}function ul(){if(!ba())return!1;var s=ar();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(a){return s.isTypeSupported(Ti(a,"video"))})||["mp4a.40.2","fLaC"].some(function(a){return s.isTypeSupported(Ti(a,"audio"))}))}function ll(){var s,a=xa();return typeof(a==null||(s=a.prototype)==null?void 0:s.changeType)=="function"}function Bt(s,a){return s===void 0&&(s=""),a===void 0&&(a=9e4),{type:s,id:-1,pid:-1,inputTimeScale:a,sequenceNumber:-1,samples:[],dropped:0}}var La=function(){function s(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},a.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},a.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},a.canParse=function(e,t){return!1},a.appendFrame=function(e,t,r){},a.demux=function(e,t){this.cachedData&&(e=At(this.cachedData,e),this.cachedData=null);var r=Nr(e,0),o=r?r.length:0,u,h=this._audioTrack,d=this._id3Track,m=r?bn(r):void 0,p=e.length;for((this.basePTS===null||this.frameIndex===0&&j(m))&&(this.basePTS=fl(m,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY});o<p;){if(this.canParse(e,o)){var y=this.appendFrame(h,e,o);y?(this.frameIndex++,this.lastPTS=y.sample.pts,o+=y.length,u=o):o=p}else fo(e,o)?(r=Nr(e,o),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY}),o+=r.length,u=o):o++;if(o===p&&u!==p){var T=nr(e,u);this.cachedData?this.cachedData=At(this.cachedData,T):this.cachedData=T}}return{audioTrack:h,videoTrack:Bt(),id3Track:d,textTrack:Bt()}},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},a.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bt(),id3Track:this._id3Track,textTrack:Bt()}},a.destroy=function(){},s}(),fl=function(a,i,e){if(j(a))return a*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function hl(s,a,i,e){var t,r,o,u,h=navigator.userAgent.toLowerCase(),d=e,m=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((a[i+2]&192)>>>6)+1;var p=(a[i+2]&60)>>>2;if(p>m.length-1){var y=new Error("invalid ADTS sampling index:"+p);s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message});return}return o=(a[i+2]&1)<<2,o|=(a[i+3]&192)>>>6,k.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+p),/firefox/i.test(h)?p>=6?(t=5,u=new Array(4),r=p-3):(t=2,u=new Array(2),r=p):h.indexOf("android")!==-1?(t=2,u=new Array(2),r=p):(t=5,u=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&p>=6?r=p-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(p>=6&&o===1||/vivaldi/i.test(h))||!e&&o===1)&&(t=2,u=new Array(2)),r=p)),u[0]=t<<3,u[0]|=(p&14)>>1,u[1]|=(p&1)<<7,u[1]|=o<<3,t===5&&(u[1]|=(r&14)>>1,u[2]=(r&1)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:m[p],channelCount:o,codec:"mp4a.40."+t,manifestCodec:d}}function Aa(s,a){return s[a]===255&&(s[a+1]&246)===240}function Ra(s,a){return s[a+1]&1?7:9}function Oi(s,a){return(s[a+3]&3)<<11|s[a+4]<<3|(s[a+5]&224)>>>5}function dl(s,a){return a+5<s.length}function Jr(s,a){return a+1<s.length&&Aa(s,a)}function cl(s,a){return dl(s,a)&&Aa(s,a)&&Oi(s,a)<=s.length-a}function vl(s,a){if(Jr(s,a)){var i=Ra(s,a);if(a+i>=s.length)return!1;var e=Oi(s,a);if(e<=i)return!1;var t=a+e;return t===s.length||Jr(s,t)}return!1}function Ca(s,a,i,e,t){if(!s.samplerate){var r=hl(a,i,e,t);if(!r)return;s.config=r.config,s.samplerate=r.samplerate,s.channelCount=r.channelCount,s.codec=r.codec,s.manifestCodec=r.manifestCodec,k.log("parsed codec:"+s.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function Da(s){return 1024*9e4/s}function pl(s,a){var i=Ra(s,a);if(a+i<=s.length){var e=Oi(s,a)-i;if(e>0)return{headerLength:i,frameLength:e}}}function wa(s,a,i,e,t){var r=Da(s.samplerate),o=e+t*r,u=pl(a,i),h;if(u){var d=u.frameLength,m=u.headerLength,p=m+d,y=Math.max(0,i+p-a.length);y?(h=new Uint8Array(p-m),h.set(a.subarray(i+m,a.length),0)):h=a.subarray(i+m,i+p);var T={unit:h,pts:o};return y||s.samples.push(T),{sample:T,length:p,missing:y}}var x=a.length-i;h=new Uint8Array(x),h.set(a.subarray(i,a.length),0);var b={unit:h,pts:o};return{sample:b,length:x,missing:-1}}var Zr=null,ml=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],gl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],yl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],El=[0,1,1,4];function Ia(s,a,i,e,t){if(!(i+24>a.length)){var r=Pa(a,i);if(r&&i+r.frameLength<=a.length){var o=r.samplesPerFrame*9e4/r.sampleRate,u=e+t*o,h={unit:a.subarray(i,i+r.frameLength),pts:u,dts:u};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(h),{sample:h,length:r.frameLength,missing:0}}}}function Pa(s,a){var i=s[a+1]>>3&3,e=s[a+1]>>1&3,t=s[a+2]>>4&15,r=s[a+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var o=s[a+2]>>1&1,u=s[a+3]>>6,h=i===3?3-e:e===3?3:4,d=ml[h*14+t-1]*1e3,m=i===3?0:i===2?1:2,p=gl[m*3+r],y=u===3?1:2,T=yl[i][e],x=El[e],b=T*8*x,L=Math.floor(T*d/p+o)*x;if(Zr===null){var A=navigator.userAgent||"",D=A.match(/Chrome\/(\d+)/i);Zr=D?parseInt(D[1]):0}var w=!!Zr&&Zr<=87;return w&&e===2&&d>=224e3&&u===0&&(s[a+3]=s[a+3]|128),{sampleRate:p,channelCount:y,frameLength:L,samplesPerFrame:b}}}function Mi(s,a){return s[a]===255&&(s[a+1]&224)===224&&(s[a+1]&6)!==0}function ka(s,a){return a+1<s.length&&Mi(s,a)}function _l(s,a){var i=4;return Mi(s,a)&&i<=s.length-a}function Oa(s,a){if(a+1<s.length&&Mi(s,a)){var i=4,e=Pa(s,a),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=a+t;return r===s.length||ka(s,r)}return!1}var Sl=function(s){I(a,s);function a(e,t){var r;return r=s.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(Oa(t,o))return!1;for(var u=t.length;o<u;o++)if(vl(t,o))return k.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return cl(t,r)},i.appendFrame=function(t,r,o){Ca(t,this.observer,r,o,t.manifestCodec);var u=wa(t,r,o,this.basePTS,this.frameIndex);if(u&&u.missing===0)return u},a}(La),Tl=/\/emsg[-/]ID3/i,xl=function(){function s(i,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var a=s.prototype;return a.resetTimeStamp=function(){},a.resetInitSegment=function(e,t,r,o){var u=this.videoTrack=Bt("video",1),h=this.audioTrack=Bt("audio",1),d=this.txtTrack=Bt("text",1);if(this.id3Track=Bt("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var m=Pn(e);if(m.video){var p=m.video,y=p.id,T=p.timescale,x=p.codec;u.id=y,u.timescale=d.timescale=T,u.codec=x}if(m.audio){var b=m.audio,L=b.id,A=b.timescale,D=b.codec;h.id=L,h.timescale=A,h.codec=D}d.id=Cn.text,u.sampleDuration=0,u.duration=h.duration=o}},a.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return _o(e)},a.demux=function(e,t){this.timeOffset=t;var r=e,o=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=At(this.remainderData,e));var h=Do(r);this.remainderData=h.remainder,o.samples=h.valid||new Uint8Array}else o.samples=r;var d=this.extractID3Track(o,t);return u.samples=kn(t,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},a.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var o=this.extractID3Track(t,this.timeOffset);return r.samples=kn(e,t),{videoTrack:t,audioTrack:Bt(),id3Track:o,textTrack:Bt()}},a.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var o=be(e.samples,["emsg"]);o&&o.forEach(function(u){var h=Po(u);if(Tl.test(h.schemeIdUri)){var d=j(h.presentationTime)?h.presentationTime/h.timeScale:t+h.presentationTimeDelta/h.timeScale,m=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;m<=.001&&(m=Number.POSITIVE_INFINITY);var p=h.payload;r.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Rt.emsg,duration:m})}})}return r},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},a.destroy=function(){},s}(),bl=function(a,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),o=new Uint32Array(1),u=new Uint8Array(1);t>0;){u[0]=a[i];var h=Math.min(t,8),d=8-h;o[0]=4278190080>>>24+d<<d,r[0]=(u[0]&o[0])>>d,e=e?e<<h|r[0]:r[0],i+=1,t-=h}return e},Ll=function(){function s(){this.VideoSample=null}var a=s.prototype;return a.createVideoSample=function(e,t,r,o){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:o,length:0}},a.getLastNalUnit=function(e){var t,r=this.VideoSample,o;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var u=r.units;o=u[u.length-1]}return o},a.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,o=r.length;if(o){var u=r[o-1];e.pts=u.pts,e.dts=u.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&k.log(e.pts+"/"+e.dts+":"+e.debug)},s}(),Ma=function(){function s(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var a=s.prototype;return a.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,o=new Uint8Array(4),u=Math.min(4,t);if(u===0)throw new Error("no bytes available");o.set(e.subarray(r,r+u)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=u*8,this.bytesAvailable-=u},a.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},a.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&k.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},a.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},a.skipUEG=function(){this.skipBits(1+this.skipLZ())},a.skipEG=function(){this.skipBits(1+this.skipLZ())},a.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},a.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},a.readBoolean=function(){return this.readBits(1)===1},a.readUByte=function(){return this.readBits(8)},a.readUShort=function(){return this.readBits(16)},a.readUInt=function(){return this.readBits(32)},a.skipScalingList=function(e){for(var t=8,r=8,o,u=0;u<e;u++)r!==0&&(o=this.readEG(),r=(t+o+256)%256),t=r===0?t:r},a.readSPS=function(){var e=0,t=0,r=0,o=0,u,h,d,m=this.readUByte.bind(this),p=this.readBits.bind(this),y=this.readUEG.bind(this),T=this.readBoolean.bind(this),x=this.skipBits.bind(this),b=this.skipEG.bind(this),L=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);m();var D=m();if(p(5),x(3),m(),L(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){var w=y();if(w===3&&x(1),L(),L(),x(1),T())for(h=w!==3?8:12,d=0;d<h;d++)T()&&(d<6?A(16):A(64))}L();var N=y();if(N===0)y();else if(N===1)for(x(1),b(),b(),u=y(),d=0;d<u;d++)b();L(),x(1);var U=y(),$=y(),V=p(1);V===0&&x(1),x(1),T()&&(e=y(),t=y(),r=y(),o=y());var M=[1,1];if(T()&&T()){var K=m();switch(K){case 1:M=[1,1];break;case 2:M=[12,11];break;case 3:M=[10,11];break;case 4:M=[16,11];break;case 5:M=[40,33];break;case 6:M=[24,11];break;case 7:M=[20,11];break;case 8:M=[32,11];break;case 9:M=[80,33];break;case 10:M=[18,11];break;case 11:M=[15,11];break;case 12:M=[64,33];break;case 13:M=[160,99];break;case 14:M=[4,3];break;case 15:M=[3,2];break;case 16:M=[2,1];break;case 255:{M=[m()<<8|m(),m()<<8|m()];break}}}return{width:Math.ceil((U+1)*16-e*2-t*2),height:(2-V)*($+1)*16-(V?2:4)*(r+o),pixelRatio:M}},a.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Al=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.parseAVCPES=function(t,r,o,u,h){var d=this,m=this.parseAVCNALu(t,o.data),p=this.VideoSample,y,T=!1;o.data=null,p&&m.length&&!t.audFound&&(this.pushAccessUnit(p,t),p=this.VideoSample=this.createVideoSample(!1,o.pts,o.dts,"")),m.forEach(function(x){var b;switch(x.type){case 1:{var L=!1;y=!0;var A=x.data;if(T&&A.length>4){var D=new Ma(A).readSliceType();(D===2||D===4||D===7||D===9)&&(L=!0)}if(L){var w;(w=p)!=null&&w.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null)}p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.frame=!0,p.key=L;break}case 5:y=!0,(b=p)!=null&&b.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null),p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.key=!0,p.frame=!0;break;case 6:{y=!0,On(x.data,1,o.pts,r.samples);break}case 7:{var N,U;y=!0,T=!0;var $=x.data,V=new Ma($),M=V.readSPS();if(!t.sps||t.width!==M.width||t.height!==M.height||((N=t.pixelRatio)==null?void 0:N[0])!==M.pixelRatio[0]||((U=t.pixelRatio)==null?void 0:U[1])!==M.pixelRatio[1]){t.width=M.width,t.height=M.height,t.pixelRatio=M.pixelRatio,t.sps=[$],t.duration=h;for(var K=$.subarray(1,4),z="avc1.",te=0;te<3;te++){var Z=K[te].toString(16);Z.length<2&&(Z="0"+Z),z+=Z}t.codec=z}break}case 8:y=!0,t.pps=[x.data];break;case 9:y=!0,t.audFound=!0,p&&d.pushAccessUnit(p,t),p=d.VideoSample=d.createVideoSample(!1,o.pts,o.dts,"");break;case 12:y=!0;break;default:y=!1,p&&(p.debug+="unknown NAL "+x.type+" ");break}if(p&&y){var ie=p.units;ie.push(x)}}),u&&p&&(this.pushAccessUnit(p,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var o=r.byteLength,u=t.naluState||0,h=u,d=[],m=0,p,y,T,x=-1,b=0;for(u===-1&&(x=0,b=r[0]&31,u=0,m=1);m<o;){if(p=r[m++],!u){u=p?0:1;continue}if(u===1){u=p?0:2;continue}if(!p)u=3;else if(p===1){if(y=m-u-1,x>=0){var L={data:r.subarray(x,y),type:b};d.push(L)}else{var A=this.getLastNalUnit(t.samples);A&&(h&&m<=4-h&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-h)),y>0&&(A.data=At(A.data,r.subarray(0,y)),A.state=0))}m<o?(T=r[m]&31,x=m,b=T,u=0):u=-1}else u=0}if(x>=0&&u>=0){var D={data:r.subarray(x,o),type:b,state:u};d.push(D)}if(d.length===0){var w=this.getLastNalUnit(t.samples);w&&(w.data=At(w.data,r))}return t.naluState=u,d},a}(Ll),Rl=function(){function s(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new ki(e,{removePKCS7Padding:!1})}var a=s.prototype;return a.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},a.decryptAacSample=function(e,t,r){var o=this,u=e[t].unit;if(!(u.length<=16)){var h=u.subarray(16,u.length-u.length%16),d=h.buffer.slice(h.byteOffset,h.byteOffset+h.length);this.decryptBuffer(d).then(function(m){var p=new Uint8Array(m);u.set(p,16),o.decrypter.isSync()||o.decryptAacSamples(e,t+1,r)})}},a.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},a.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)r.set(e.subarray(u,u+16),o);return r},a.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)e.set(r.subarray(o,o+16),u);return e},a.decryptAvcSample=function(e,t,r,o,u){var h=this,d=Mn(u.data),m=this.getAvcEncryptedData(d);this.decryptBuffer(m.buffer).then(function(p){u.data=h.getAvcDecryptedUnit(d,p),h.decrypter.isSync()||h.decryptAvcSamples(e,t,r+1,o)})},a.decryptAvcSamples=function(e,t,r,o){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){o();return}for(var u=e[t].units;!(r>=u.length);r++){var h=u[r];if(!(h.data.length<=48||h.type!==1&&h.type!==5)&&(this.decryptAvcSample(e,t,r,o,h),!this.decrypter.isSync()))return}}},s}(),at=188,Cl=function(){function s(i,e,t){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.videoParser=new Al}s.probe=function(e){var t=s.syncOffset(e);return t>0&&k.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(at*5,t-at)+1,o=0;o<r;){for(var u=!1,h=-1,d=0,m=o;m<t;m+=at)if(e[m]===71&&(t-m===at||e[m+at]===71)){if(d++,h===-1&&(h=m,h!==0&&(r=Math.min(h+at*99,e.length-at)+1)),u||(u=Fi(e,m)===0),u&&d>1&&(h===0&&d>2||m+at>r))return h}else{if(d)return-1;break}o++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Cn[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",o),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=o},a.resetTimeStamp=function(){},a.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},a.demux=function(e,t,r,o){r===void 0&&(r=!1),o===void 0&&(o=!1),r||(this.sampleAes=null);var u,h=this._videoTrack,d=this._audioTrack,m=this._id3Track,p=this._txtTrack,y=h.pid,T=h.pesData,x=d.pid,b=m.pid,L=d.pesData,A=m.pesData,D=null,w=this.pmtParsed,N=this._pmtId,U=e.length;if(this.remainderData&&(e=At(this.remainderData,e),U=e.length,this.remainderData=null),U<at&&!o)return this.remainderData=e,{audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};var $=Math.max(0,s.syncOffset(e));U-=(U-$)%at,U<e.byteLength&&!o&&(this.remainderData=new Uint8Array(e.buffer,U,e.buffer.byteLength-U));for(var V=0,M=$;M<U;M+=at)if(e[M]===71){var K=!!(e[M+1]&64),z=Fi(e,M),te=(e[M+3]&48)>>4,Z=void 0;if(te>1){if(Z=M+5+e[M+4],Z===M+at)continue}else Z=M+4;switch(z){case y:K&&(T&&(u=pr(T))&&this.videoParser.parseAVCPES(h,p,u,!1,this._duration),T={data:[],size:0}),T&&(T.data.push(e.subarray(Z,M+at)),T.size+=M+at-Z);break;case x:if(K){if(L&&(u=pr(L)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}L={data:[],size:0}}L&&(L.data.push(e.subarray(Z,M+at)),L.size+=M+at-Z);break;case b:K&&(A&&(u=pr(A))&&this.parseID3PES(m,u),A={data:[],size:0}),A&&(A.data.push(e.subarray(Z,M+at)),A.size+=M+at-Z);break;case 0:K&&(Z+=e[Z]+1),N=this._pmtId=Dl(e,Z);break;case N:{K&&(Z+=e[Z]+1);var ie=wl(e,Z,this.typeSupported,r,this.observer);y=ie.videoPid,y>0&&(h.pid=y,h.segmentCodec=ie.segmentVideoCodec),x=ie.audioPid,x>0&&(d.pid=x,d.segmentCodec=ie.segmentAudioCodec),b=ie.id3Pid,b>0&&(m.pid=b),D!==null&&!w&&(k.warn("MPEG-TS PMT found at "+M+" after unknown PID '"+D+"'. Backtracking to sync byte @"+$+" to parse all TS packets."),D=null,M=$-188),w=this.pmtParsed=!0;break}case 17:case 8191:break;default:D=z;break}}else V++;V>0&&ei(this.observer,new Error("Found "+V+" TS packet/s that do not start with 0x47")),h.pesData=T,d.pesData=L,m.pesData=A;var he={audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};return o&&this.extractRemainingSamples(he),he},a.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},a.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,o=e.id3Track,u=e.textTrack,h=r.pesData,d=t.pesData,m=o.pesData,p;if(h&&(p=pr(h))?(this.videoParser.parseAVCPES(r,u,p,!0,this._duration),r.pesData=null):r.pesData=h,d&&(p=pr(d))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,p);break;case"mp3":this.parseMPEGPES(t,p);break}t.pesData=null}else d!=null&&d.size&&k.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=d;m&&(p=pr(m))?(this.parseID3PES(o,p),o.pesData=null):o.pesData=m},a.demuxSampleAes=function(e,t,r){var o=this.demux(e,r,!0,!this.config.progressive),u=this.sampleAes=new Rl(this.observer,this.config,t);return this.decrypt(o,u)},a.decrypt=function(e,t){return new Promise(function(r){var o=e.audioTrack,u=e.videoTrack;o.samples&&o.segmentCodec==="aac"?t.decryptAacSamples(o.samples,0,function(){u.samples?t.decryptAvcSamples(u.samples,0,0,function(){r(e)}):r(e)}):u.samples&&t.decryptAvcSamples(u.samples,0,0,function(){r(e)})})},a.destroy=function(){this._duration=0},a.parseAACPES=function(e,t){var r=0,o=this.aacOverFlow,u=t.data;if(o){this.aacOverFlow=null;var h=o.missing,d=o.sample.unit.byteLength;if(h===-1)u=At(o.sample.unit,u);else{var m=d-h;o.sample.unit.set(u.subarray(0,h),m),e.samples.push(o.sample),r=o.missing}}var p,y;for(p=r,y=u.length;p<y-1&&!Jr(u,p);p++);if(p!==r){var T,x=p<y-1;if(x?T="AAC PES did not start with ADTS header,offset:"+p:T="No ADTS header found in AAC PES",ei(this.observer,new Error(T),x),!x)return}Ca(e,this.observer,u,p,this.audioCodec);var b;if(t.pts!==void 0)b=t.pts;else if(o){var L=Da(e.samplerate);b=o.sample.pts+L}else{k.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var A=0,D;p<y;)if(D=wa(e,u,p,b,A),p+=D.length,D.missing){this.aacOverFlow=D;break}else for(A++;p<y-1&&!Jr(u,p);p++);},a.parseMPEGPES=function(e,t){var r=t.data,o=r.length,u=0,h=0,d=t.pts;if(d===void 0){k.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;h<o;)if(ka(r,h)){var m=Ia(e,r,h,d,u);if(m)h+=m.length,u++;else break}else h++},a.parseAC3PES=function(e,t){},a.parseID3PES=function(e,t){if(t.pts===void 0){k.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=C({},t,{type:this._videoTrack?Rt.emsg:Rt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},s}();function Fi(s,a){return((s[a+1]&31)<<8)+s[a+2]}function Dl(s,a){return(s[a+10]&31)<<8|s[a+11]}function wl(s,a,i,e,t){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[a+1]&15)<<8|s[a+2],u=a+3+o-4,h=(s[a+10]&15)<<8|s[a+11];for(a+=12+h;a<u;){var d=Fi(s,a),m=(s[a+3]&15)<<8|s[a+4];switch(s[a]){case 207:if(!e){Ni("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=d);break;case 21:r.id3Pid===-1&&(r.id3Pid=d);break;case 219:if(!e){Ni("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=d,r.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?k.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=d,r.segmentAudioCodec="mp3");break;case 193:if(!e){Ni("AC-3");break}case 129:k.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&m>0)for(var p=a+5,y=m;y>2;){var T=s[p];switch(T){case 106:k.warn("AC-3 in M2TS support not included in build");break}var x=s[p+1]+2;p+=x,y-=x}break;case 194:case 135:return ei(t,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return ei(t,new Error("Unsupported HEVC in M2TS found")),r}a+=m+5}return r}function ei(s,a,i){k.warn("parsing error: "+a.message),s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:a,reason:a.message})}function Ni(s){k.log(s+" with AES-128-CBC encryption found in unencrypted stream")}function pr(s){var a=0,i,e,t,r,o,u=s.data;if(!s||s.size===0)return null;for(;u[0].length<19&&u.length>1;)u[0]=At(u[0],u[1]),u.splice(1,1);i=u[0];var h=(i[0]<<16)+(i[1]<<8)+i[2];if(h===1){if(e=(i[4]<<8)+i[5],e&&e>s.size-6)return null;var d=i[7];d&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,d&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-o>60*9e4&&(k.warn(Math.round((r-o)/9e4)+"s delta between PTS and DTS, align them"),r=o)):o=r),t=i[8];var m=t+9;if(s.size<=m)return null;s.size-=m;for(var p=new Uint8Array(s.size),y=0,T=u.length;y<T;y++){i=u[y];var x=i.byteLength;if(m)if(m>x){m-=x;continue}else i=i.subarray(m),x-=m,m=0;p.set(i,a),a+=x}return e&&(e-=t+3),{data:p,pts:r,dts:o,len:e}}return null}var Il=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(r&&t[o]===11&&t[o+1]===119&&bn(r)!==void 0&&bl(t,o)<=16)return!1;for(var u=t.length;o<u;o++)if(Oa(t,o))return k.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return _l(t,r)},i.appendFrame=function(t,r,o){if(this.basePTS!==null)return Ia(t,r,o,this.basePTS,this.frameIndex)},a}(La),Fa=function(){function s(){}return s.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},s}(),Jt=Math.pow(2,32)-1,ut=function(){function s(){}return s.init=function(){s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in s.types)s.types.hasOwnProperty(i)&&(s.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=o,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,u,d,u,h),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];for(var u=r.length,h=u;u--;)e+=r[u].byteLength;var d=new Uint8Array(e);for(d[0]=e>>24&255,d[1]=e>>16&255,d[2]=e>>8&255,d[3]=e&255,d.set(i,4),u=0,e=8;u<h;u++)d.set(r[u],e),e+=r[u].byteLength;return d},s.hdlr=function(i){return s.box(s.types.hdlr,s.HDLR_TYPES[i])},s.mdat=function(i){return s.box(s.types.mdat,i)},s.mdhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},s.mdia=function(i){return s.box(s.types.mdia,s.mdhd(i.timescale,i.duration),s.hdlr(i.type),s.minf(i))},s.mfhd=function(i){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},s.minf=function(i){return i.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(i)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(i))},s.moof=function(i,e,t){return s.box(s.types.moof,s.mfhd(i),s.traf(t,e))},s.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trak(i[e]);return s.box.apply(null,[s.types.moov,s.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(s.mvex(i)))},s.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trex(i[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,o)},s.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,o;for(r=0;r<e.length;r++)o=e[r].flags,t[r+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return s.box(s.types.sdtp,t)},s.stbl=function(i){return s.box(s.types.stbl,s.stsd(i),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(i){var e=[],t=[],r,o,u;for(r=0;r<i.sps.length;r++)o=i.sps[r],u=o.byteLength,e.push(u>>>8&255),e.push(u&255),e=e.concat(Array.prototype.slice.call(o));for(r=0;r<i.pps.length;r++)o=i.pps[r],u=o.byteLength,t.push(u>>>8&255),t.push(u&255),t=t.concat(Array.prototype.slice.call(o));var h=s.box(s.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),d=i.width,m=i.height,p=i.pixelRatio[0],y=i.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,m>>8&255,m&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&255])))},s.esds=function(i){var e=i.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(i.config).concat([6,1,2]))},s.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},s.mp4a=function(i){return s.box(s.types.mp4a,s.audioStsd(i),s.box(s.types.esds,s.esds(i)))},s.mp3=function(i){return s.box(s.types[".mp3"],s.audioStsd(i))},s.ac3=function(i){return s.box(s.types["ac-3"],s.audioStsd(i),s.box(s.types.dac3,i.config))},s.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(i)):i.segmentCodec==="ac3"?s.box(s.types.stsd,s.STSD,s.ac3(i)):s.box(s.types.stsd,s.STSD,s.mp4a(i)):s.box(s.types.stsd,s.STSD,s.avc1(i))},s.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,o=i.height,u=Math.floor(t/(Jt+1)),h=Math.floor(t%(Jt+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,h>>24,h>>16&255,h>>8&255,h&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,o>>8&255,o&255,0,0]))},s.traf=function(i,e){var t=s.sdtp(i),r=i.id,o=Math.floor(e/(Jt+1)),u=Math.floor(e%(Jt+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255])),s.trun(i,t.length+16+20+8+16+8+8),t)},s.trak=function(i){return i.duration=i.duration||4294967295,s.box(s.types.trak,s.tkhd(i),s.mdia(i))},s.trex=function(i){var e=i.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(i,e){var t=i.samples||[],r=t.length,o=12+16*r,u=new Uint8Array(o),h,d,m,p,y,T;for(e+=8+o,u.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),h=0;h<r;h++)d=t[h],m=d.duration,p=d.size,y=d.flags,T=d.cts,u.set([m>>>24&255,m>>>16&255,m>>>8&255,m&255,p>>>24&255,p>>>16&255,p>>>8&255,p&255,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.paddingValue<<1|y.isNonSync,y.degradPrio&61440,y.degradPrio&15,T>>>24&255,T>>>16&255,T>>>8&255,T&255],12+16*h);return s.box(s.types.trun,u)},s.initSegment=function(i){s.types||s.init();var e=s.moov(i),t=At(s.FTYP,e);return t},s}();ut.types=void 0,ut.HDLR_TYPES=void 0,ut.STTS=void 0,ut.STSC=void 0,ut.STCO=void 0,ut.STSZ=void 0,ut.VMHD=void 0,ut.SMHD=void 0,ut.STSD=void 0,ut.FTYP=void 0,ut.DINF=void 0;var Pl=9e4;function kl(s,a,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=s*a*i;return e?Math.round(t):t}function Ar(s,a){return a===void 0&&(a=!1),kl(s,1e3,1/Pl,a)}var Ol=10*1e3,Na=1024,Ml=1152,Fl=1536,mr=null,Ui=null,Bi=function(){function s(i,e,t,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,mr===null){var o=navigator.userAgent||"",u=o.match(/Chrome\/(\d+)/i);mr=u?parseInt(u[1]):0}if(Ui===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);Ui=h?parseInt(h[1]):0}}var a=s.prototype;return a.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},a.resetTimeStamp=function(e){k.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},a.resetNextTimestamp=function(){k.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},a.resetInitSegment=function(){k.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},a.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(o,u){var h=u.pts-o;return h<-4294967296?(t=!0,Dt(o,u.pts)):h>0?o:u.pts},e[0].pts);return t&&k.debug("PTS rollover detected"),r},a.remux=function(e,t,r,o,u,h,d,m){var p,y,T,x,b,L,A=u,D=u,w=e.pid>-1,N=t.pid>-1,U=t.samples.length,$=e.samples.length>0,V=d&&U>0||U>1,M=(!w||$)&&(!N||V)||this.ISGenerated||d;if(M){if(this.ISGenerated){var K,z,te,Z,ie=this.videoTrackConfig;ie&&(t.width!==ie.width||t.height!==ie.height||((K=t.pixelRatio)==null?void 0:K[0])!==((z=ie.pixelRatio)==null?void 0:z[0])||((te=t.pixelRatio)==null?void 0:te[1])!==((Z=ie.pixelRatio)==null?void 0:Z[1]))&&this.resetInitSegment()}else T=this.generateIS(e,t,u,h);var he=this.isVideoContiguous,fe=-1,Le;if(V&&(fe=Nl(t.samples),!he&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,fe>0){k.warn("[mp4-remuxer]: Dropped "+fe+" out of "+U+" video samples due to a missing keyframe");var Ee=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(fe),t.dropped+=fe,D+=(t.samples[0].pts-Ee)/t.inputTimeScale,Le=D}else fe===-1&&(k.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),L=!1);if(this.ISGenerated){if($&&V){var we=this.getVideoStartPts(t.samples),Ae=Dt(e.samples[0].pts,we)-we,ye=Ae/t.inputTimeScale;A+=Math.max(0,ye),D+=Math.max(0,-ye)}if($){if(e.samplerate||(k.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),T=this.generateIS(e,t,u,h)),y=this.remuxAudio(e,A,this.isAudioContiguous,h,N||V||m===Me.AUDIO?D:void 0),V){var je=y?y.endPTS-y.startPTS:0;t.inputTimeScale||(k.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),T=this.generateIS(e,t,u,h)),p=this.remuxVideo(t,D,he,je)}}else V&&(p=this.remuxVideo(t,D,he,0));p&&(p.firstKeyFrame=fe,p.independent=fe!==-1,p.firstKeyFramePTS=Le)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(b=Ua(r,u,this._initPTS,this._initDTS)),o.samples.length&&(x=Ba(o,u,this._initPTS))),{audio:y,video:p,initSegment:T,independent:L,text:x,id3:b}},a.generateIS=function(e,t,r,o){var u=e.samples,h=t.samples,d=this.typeSupported,m={},p=this._initPTS,y=!p||o,T="audio/mp4",x,b,L;if(y&&(x=b=1/0),e.config&&u.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(T="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}m.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):ut.initSegment([e]),metadata:{channelCount:e.channelCount}},y&&(L=e.inputTimeScale,!p||L!==p.timescale?x=b=u[0].pts-Math.round(L*r):y=!1)}if(t.sps&&t.pps&&h.length){if(t.timescale=t.inputTimeScale,m.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ut.initSegment([t]),metadata:{width:t.width,height:t.height}},y)if(L=t.inputTimeScale,!p||L!==p.timescale){var A=this.getVideoStartPts(h),D=Math.round(L*r);b=Math.min(b,Dt(h[0].dts,A)-D),x=Math.min(x,A-D)}else y=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(m).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:x,timescale:L},this._initDTS={baseTime:b,timescale:L}):x=L=void 0,{tracks:m,initPTS:x,timescale:L}},a.remuxVideo=function(e,t,r,o){var u=e.inputTimeScale,h=e.samples,d=[],m=h.length,p=this._initPTS,y=this.nextAvcDts,T=8,x=this.videoSampleDuration,b,L,A=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,w=!1;if(!r||y===null){var N=t*u,U=h[0].pts-Dt(h[0].dts,h[0].pts);mr&&y!==null&&Math.abs(N-U-y)<15e3?r=!0:y=N-U}for(var $=p.baseTime*u/p.timescale,V=0;V<m;V++){var M=h[V];M.pts=Dt(M.pts-$,y),M.dts=Dt(M.dts-$,y),M.dts<h[V>0?V-1:V].dts&&(w=!0)}w&&h.sort(function(ni,Ja){var hf=ni.dts-Ja.dts,df=ni.pts-Ja.pts;return hf||df}),b=h[0].dts,L=h[h.length-1].dts;var K=L-b,z=K?Math.round(K/(m-1)):x||e.inputTimeScale/30;if(r){var te=b-y,Z=te>z,ie=te<-1;if((Z||ie)&&(Z?k.warn("AVC: "+Ar(te,!0)+" ms ("+te+"dts) hole between fragments detected at "+t.toFixed(3)):k.warn("AVC: "+Ar(-te,!0)+" ms ("+te+"dts) overlapping between fragments detected at "+t.toFixed(3)),!ie||y>=h[0].pts||mr)){b=y;var he=h[0].pts-te;if(Z)h[0].dts=b,h[0].pts=he;else for(var fe=0;fe<h.length&&!(h[fe].dts>he);fe++)h[fe].dts-=te,h[fe].pts-=te;k.log("Video: Initial PTS/DTS adjusted: "+Ar(he,!0)+"/"+Ar(b,!0)+", delta: "+Ar(te,!0)+" ms")}}b=Math.max(0,b);for(var Le=0,Ee=0,we=b,Ae=0;Ae<m;Ae++){for(var ye=h[Ae],je=ye.units,Fe=je.length,qe=0,Xe=0;Xe<Fe;Xe++)qe+=je[Xe].data.length;Ee+=qe,Le+=Fe,ye.length=qe,ye.dts<we?(ye.dts=we,we+=z/4|0||1):we=ye.dts,A=Math.min(ye.pts,A),D=Math.max(ye.pts,D)}L=h[m-1].dts;var Ze=Ee+4*Le+8,ze;try{ze=new Uint8Array(Ze)}catch(ni){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:ni,bytes:Ze,reason:"fail allocating video mdat "+Ze});return}var Ue=new DataView(ze.buffer);Ue.setUint32(0,Ze),ze.set(ut.types.mdat,4);for(var jt=!1,_t=Number.POSITIVE_INFINITY,$e=Number.POSITIVE_INFINITY,ct=Number.NEGATIVE_INFINITY,vt=Number.NEGATIVE_INFINITY,et=0;et<m;et++){for(var Ke=h[et],yt=Ke.units,ft=0,st=0,or=yt.length;st<or;st++){var Ya=yt[st],rf=Ya.data,ji=Ya.data.byteLength;Ue.setUint32(T,ji),T+=4,ze.set(rf,T),T+=ji,ft+=4+ji}var ri=void 0;if(et<m-1)x=h[et+1].dts-Ke.dts,ri=h[et+1].pts-Ke.pts;else{var qa=this.config,ii=et>0?Ke.dts-h[et-1].dts:z;if(ri=et>0?Ke.pts-h[et-1].pts:z,qa.stretchShortVideoTrack&&this.nextAudioPts!==null){var nf=Math.floor(qa.maxBufferHole*u),zi=(o?A+o*u:this.nextAudioPts)-Ke.pts;zi>nf?(x=zi-ii,x<0?x=ii:jt=!0,k.log("[mp4-remuxer]: It is approximately "+zi/90+" ms to the next segment; using duration "+x/90+" ms for the last video frame.")):x=ii}else x=ii}var af=Math.round(Ke.pts-Ke.dts);_t=Math.min(_t,x),ct=Math.max(ct,x),$e=Math.min($e,ri),vt=Math.max(vt,ri),d.push(new Ga(Ke.key,x,ft,af))}if(d.length){if(mr){if(mr<70){var Xa=d[0].flags;Xa.dependsOn=2,Xa.isNonSync=0}}else if(Ui&&vt-$e<ct-_t&&z/ct<.025&&d[0].cts===0){k.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Yi=b,wt=0,$a=d.length;wt<$a;wt++){var Qa=Yi+d[wt].duration,sf=Yi+d[wt].cts;if(wt<$a-1){var of=Qa+d[wt+1].cts;d[wt].duration=of-sf}else d[wt].duration=wt?d[wt-1].duration:z;d[wt].cts=0,Yi=Qa}}}x=jt||!x?z:x,this.nextAvcDts=y=L+x,this.videoSampleDuration=x,this.isVideoContiguous=!0;var uf=ut.moof(e.sequenceNumber++,b,C({},e,{samples:d})),lf="video",ff={data1:uf,data2:ze,startPTS:A/u,endPTS:(D+x)/u,startDTS:b/u,endDTS:y/u,type:lf,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ff},a.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return Ml;case"ac3":return Fl;default:return Na}},a.remuxAudio=function(e,t,r,o,u){var h=e.inputTimeScale,d=e.samplerate?e.samplerate:h,m=h/d,p=this.getSamplesPerFrame(e),y=p*m,T=this._initPTS,x=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],L=u!==void 0,A=e.samples,D=x?0:8,w=this.nextAudioPts||-1,N=t*h,U=T.baseTime*h/T.timescale;if(this.isAudioContiguous=r=r||A.length&&w>0&&(o&&Math.abs(N-w)<9e3||Math.abs(Dt(A[0].pts-U,N)-w)<20*y),A.forEach(function(st){st.pts=Dt(st.pts-U,N)}),!r||w<0){if(A=A.filter(function(st){return st.pts>=0}),!A.length)return;u===0?w=0:o&&!L?w=Math.max(0,N):w=A[0].pts}if(e.segmentCodec==="aac")for(var $=this.config.maxAudioFramesDrift,V=0,M=w;V<A.length;V++){var K=A[V],z=K.pts,te=z-M,Z=Math.abs(1e3*te/h);if(te<=-$*y&&L)V===0&&(k.warn("Audio frame @ "+(z/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/h)+" ms."),this.nextAudioPts=w=M=z);else if(te>=$*y&&Z<Ol&&L){var ie=Math.round(te/y);M=z-ie*y,M<0&&(ie--,M+=y),V===0&&(this.nextAudioPts=w=M),k.warn("[mp4-remuxer]: Injecting "+ie+" audio frame @ "+(M/h).toFixed(3)+"s due to "+Math.round(1e3*te/h)+" ms gap.");for(var he=0;he<ie;he++){var fe=Math.max(M,0),Le=Fa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Le||(k.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=K.unit.subarray()),A.splice(V,0,{unit:Le,pts:fe}),M+=y,V++}}K.pts=M,M+=y}for(var Ee=null,we=null,Ae,ye=0,je=A.length;je--;)ye+=A[je].unit.byteLength;for(var Fe=0,qe=A.length;Fe<qe;Fe++){var Xe=A[Fe],Ze=Xe.unit,ze=Xe.pts;if(we!==null){var Ue=b[Fe-1];Ue.duration=Math.round((ze-we)/m)}else if(r&&e.segmentCodec==="aac"&&(ze=w),Ee=ze,ye>0){ye+=D;try{Ae=new Uint8Array(ye)}catch(st){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:st,bytes:ye,reason:"fail allocating audio mdat "+ye});return}if(!x){var jt=new DataView(Ae.buffer);jt.setUint32(0,ye),Ae.set(ut.types.mdat,4)}}else return;Ae.set(Ze,D);var _t=Ze.byteLength;D+=_t,b.push(new Ga(!0,p,_t,0)),we=ze}var $e=b.length;if($e){var ct=b[b.length-1];this.nextAudioPts=w=we+m*ct.duration;var vt=x?new Uint8Array(0):ut.moof(e.sequenceNumber++,Ee/m,C({},e,{samples:b}));e.samples=[];var et=Ee/h,Ke=w/h,yt="audio",ft={data1:vt,data2:Ae,startPTS:et,endPTS:Ke,startDTS:et,endDTS:Ke,type:yt,hasAudio:!0,hasVideo:!1,nb:$e};return this.isAudioContiguous=!0,ft}},a.remuxEmptyAudio=function(e,t,r,o){var u=e.inputTimeScale,h=e.samplerate?e.samplerate:u,d=u/h,m=this.nextAudioPts,p=this._initDTS,y=p.baseTime*9e4/p.timescale,T=(m!==null?m:o.startDTS*u)+y,x=o.endDTS*u+y,b=d*Na,L=Math.ceil((x-T)/b),A=Fa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(k.warn("[mp4-remuxer]: remux empty Audio"),!A){k.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var D=[],w=0;w<L;w++){var N=T+w*b;D.push({unit:A,pts:N,dts:N})}return e.samples=D,this.remuxAudio(e,t,r,!1)},s}();function Dt(s,a){var i;if(a===null)return s;for(a<s?i=-8589934592:i=8589934592;Math.abs(s-a)>4294967296;)s+=i;return s}function Nl(s){for(var a=0;a<s.length;a++)if(s[a].key)return a;return-1}function Ua(s,a,i,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,o=0;o<t;o++){var u=s.samples[o];u.pts=Dt(u.pts-i.baseTime*r/i.timescale,a*r)/r,u.dts=Dt(u.dts-e.baseTime*r/e.timescale,a*r)/r}var h=s.samples;return s.samples=[],{samples:h}}}function Ba(s,a,i){var e=s.samples.length;if(e){for(var t=s.inputTimeScale,r=0;r<e;r++){var o=s.samples[r];o.pts=Dt(o.pts-i.baseTime*t/i.timescale,a*t)/t}s.samples.sort(function(h,d){return h.pts-d.pts});var u=s.samples;return s.samples=[],{samples:u}}}var Ga=function(a,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}},Ul=function(){function s(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var a=s.prototype;return a.destroy=function(){},a.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},a.resetNextTimestamp=function(){this.lastEndTime=null},a.resetInitSegment=function(e,t,r,o){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(xo(e,o)),this.emitInitSegment=!0},a.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var o=this.initData=Pn(e);o.audio&&(t=Va(o.audio,Pe.AUDIO)),o.video&&(r=Va(o.video,Pe.VIDEO));var u={};o.audio&&o.video?u.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:o.audio?u.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:o.video?u.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:k.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=u},a.remux=function(e,t,r,o,u,h){var d,m,p=this.initPTS,y=this.lastEndTime,T={audio:void 0,video:void 0,text:o,id3:r,initSegment:void 0};j(y)||(y=this.lastEndTime=u||0);var x=t.samples;if(!(x!=null&&x.length))return T;var b={initPTS:void 0,timescale:1},L=this.initData;if((d=L)!=null&&d.length||(this.generateInitSegment(x),L=this.initData),!((m=L)!=null&&m.length))return k.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);var A=Ao(x,L),D=Lo(L,x),w=D===null?u:D;(Bl(p,w,u,A)||b.timescale!==p.timescale&&h)&&(b.initPTS=w-u,p&&p.timescale===1&&k.warn("Adjusting initPTS by "+(b.initPTS-p.baseTime)),this.initPTS=p={baseTime:b.initPTS,timescale:1});var N=e?w-p.baseTime/p.timescale:y,U=N+A;Co(L,x,p.baseTime/p.timescale),A>0?this.lastEndTime=U:(k.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var $=!!L.audio,V=!!L.video,M="";$&&(M+="audio"),V&&(M+="video");var K={data1:x,startPTS:N,startDTS:N,endPTS:U,endDTS:U,type:M,hasAudio:$,hasVideo:V,nb:1,dropped:0};return T.audio=K.type==="audio"?K:void 0,T.video=K.type!=="audio"?K:void 0,T.initSegment=b,T.id3=Ua(r,u,p,p),o.samples.length&&(T.text=Ba(o,u,p)),T},s}();function Bl(s,a,i,e){if(s===null)return!0;var t=Math.max(e,1),r=a-s.baseTime/s.timescale;return Math.abs(r-i)>t}function Va(s,a){var i=s?.codec;if(i&&i.length>4)return i;if(a===Pe.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return Kr(i,e)}var t="mp4a.40.5";return k.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return k.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Ha=typeof self<"u"?self:void 0,Wt;try{Wt=self.performance.now.bind(self.performance)}catch{k.debug("Unable to use Performance API on this environment"),Wt=Ha?.Date.now}var Gi=[{demux:xl,remux:Ul},{demux:Cl,remux:Bi},{demux:Sl,remux:Bi},{demux:Il,remux:Bi}],Vi=function(){function s(i,e,t,r,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=o}var a=s.prototype;return a.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},a.push=function(e,t,r,o){var u=this,h=r.transmuxing;h.executeStart=Wt();var d=new Uint8Array(e),m=this.currentTransmuxState,p=this.transmuxConfig;o&&(this.currentTransmuxState=o);var y=o||m,T=y.contiguous,x=y.discontinuity,b=y.trackSwitch,L=y.accurateTimeOffset,A=y.timeOffset,D=y.initSegmentChange,w=p.audioCodec,N=p.videoCodec,U=p.defaultInitPts,$=p.duration,V=p.initSegmentData,M=Gl(d,t);if(M&&M.method==="AES-128"){var K=this.getDecrypter();if(K.isSync()){var z=K.softwareDecrypt(d,M.key.buffer,M.iv.buffer),te=r.part>-1;if(te&&(z=K.flush()),!z)return h.executeEnd=Wt(),Hi(r);d=new Uint8Array(z)}else return this.decryptionPromise=K.webCryptoDecrypt(d,M.key.buffer,M.iv.buffer).then(function(Le){var Ee=u.push(Le,null,r);return u.decryptionPromise=null,Ee}),this.decryptionPromise}var Z=this.needsProbing(x,b);if(Z){var ie=this.configureTransmuxer(d);if(ie)return k.warn("[transmuxer] "+ie.message),this.observer.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:ie,reason:ie.message}),h.executeEnd=Wt(),Hi(r)}(x||b||D||Z)&&this.resetInitSegment(V,w,N,$,t),(x||D||Z)&&this.resetInitialTimestamp(U),T||this.resetContiguity();var he=this.transmux(d,M,A,L,r),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,h.executeEnd=Wt(),he},a.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Wt();var o=this.decrypter,u=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then(function(){return t.flush(e)});var d=[],m=u.timeOffset;if(o){var p=o.flush();p&&d.push(this.push(p,null,e))}var y=this.demuxer,T=this.remuxer;if(!y||!T)return r.executeEnd=Wt(),[Hi(e)];var x=y.flush(m);return sr(x)?x.then(function(b){return t.flushRemux(d,b,e),d}):(this.flushRemux(d,x,e),d)},a.flushRemux=function(e,t,r){var o=t.audioTrack,u=t.videoTrack,h=t.id3Track,d=t.textTrack,m=this.currentTransmuxState,p=m.accurateTimeOffset,y=m.timeOffset;k.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var T=this.remuxer.remux(o,u,h,d,y,p,!0,this.id);e.push({remuxResult:T,chunkMeta:r}),r.transmuxing.executeEnd=Wt()},a.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},a.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},a.resetInitSegment=function(e,t,r,o,u){var h=this.demuxer,d=this.remuxer;!h||!d||(h.resetInitSegment(e,t,r,o),d.resetInitSegment(e,t,r,u))},a.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},a.transmux=function(e,t,r,o,u){var h;return t&&t.method==="SAMPLE-AES"?h=this.transmuxSampleAes(e,t,r,o,u):h=this.transmuxUnencrypted(e,r,o,u),h},a.transmuxUnencrypted=function(e,t,r,o){var u=this.demuxer.demux(e,t,!1,!this.config.progressive),h=u.audioTrack,d=u.videoTrack,m=u.id3Track,p=u.textTrack,y=this.remuxer.remux(h,d,m,p,t,r,!1,this.id);return{remuxResult:y,chunkMeta:o}},a.transmuxSampleAes=function(e,t,r,o,u){var h=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(d){var m=h.remuxer.remux(d.audioTrack,d.videoTrack,d.id3Track,d.textTrack,r,o,!1,h.id);return{remuxResult:m,chunkMeta:u}})},a.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,o=this.typeSupported,u=this.vendor,h,d=0,m=Gi.length;d<m;d++){var p;if((p=Gi[d].demux)!=null&&p.probe(e)){h=Gi[d];break}}if(!h)return new Error("Failed to find demuxer by probing fragment data");var y=this.demuxer,T=this.remuxer,x=h.remux,b=h.demux;(!T||!(T instanceof x))&&(this.remuxer=new x(r,t,o,u)),(!y||!(y instanceof b))&&(this.demuxer=new b(r,t,o),this.probe=b.probe)},a.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},a.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new ki(this.config)),e},s}();function Gl(s,a){var i=null;return s.byteLength>0&&a?.key!=null&&a.iv!==null&&a.method!=null&&(i=a),i}var Hi=function(a){return{remuxResult:{},chunkMeta:a}};function sr(s){return"then"in s&&s.then instanceof Function}var Vl=function(a,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=a,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Hl=function(a,i,e,t,r,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=a,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=o},Ka={exports:{}};(function(s){var a=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(h,d,m){this.fn=h,this.context=d,this.once=m||!1}function r(h,d,m,p,y){if(typeof m!="function")throw new TypeError("The listener must be a function");var T=new t(m,p||h,y),x=i?i+d:d;return h._events[x]?h._events[x].fn?h._events[x]=[h._events[x],T]:h._events[x].push(T):(h._events[x]=T,h._eventsCount++),h}function o(h,d){--h._eventsCount===0?h._events=new e:delete h._events[d]}function u(){this._events=new e,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],m,p;if(this._eventsCount===0)return d;for(p in m=this._events)a.call(m,p)&&d.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(m)):d},u.prototype.listeners=function(d){var m=i?i+d:d,p=this._events[m];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,T=p.length,x=new Array(T);y<T;y++)x[y]=p[y].fn;return x},u.prototype.listenerCount=function(d){var m=i?i+d:d,p=this._events[m];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,m,p,y,T,x){var b=i?i+d:d;if(!this._events[b])return!1;var L=this._events[b],A=arguments.length,D,w;if(L.fn){switch(L.once&&this.removeListener(d,L.fn,void 0,!0),A){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,m),!0;case 3:return L.fn.call(L.context,m,p),!0;case 4:return L.fn.call(L.context,m,p,y),!0;case 5:return L.fn.call(L.context,m,p,y,T),!0;case 6:return L.fn.call(L.context,m,p,y,T,x),!0}for(w=1,D=new Array(A-1);w<A;w++)D[w-1]=arguments[w];L.fn.apply(L.context,D)}else{var N=L.length,U;for(w=0;w<N;w++)switch(L[w].once&&this.removeListener(d,L[w].fn,void 0,!0),A){case 1:L[w].fn.call(L[w].context);break;case 2:L[w].fn.call(L[w].context,m);break;case 3:L[w].fn.call(L[w].context,m,p);break;case 4:L[w].fn.call(L[w].context,m,p,y);break;default:if(!D)for(U=1,D=new Array(A-1);U<A;U++)D[U-1]=arguments[U];L[w].fn.apply(L[w].context,D)}}return!0},u.prototype.on=function(d,m,p){return r(this,d,m,p,!1)},u.prototype.once=function(d,m,p){return r(this,d,m,p,!0)},u.prototype.removeListener=function(d,m,p,y){var T=i?i+d:d;if(!this._events[T])return this;if(!m)return o(this,T),this;var x=this._events[T];if(x.fn)x.fn===m&&(!y||x.once)&&(!p||x.context===p)&&o(this,T);else{for(var b=0,L=[],A=x.length;b<A;b++)(x[b].fn!==m||y&&!x[b].once||p&&x[b].context!==p)&&L.push(x[b]);L.length?this._events[T]=L.length===1?L[0]:L:o(this,T)}return this},u.prototype.removeAllListeners=function(d){var m;return d?(m=i?i+d:d,this._events[m]&&o(this,m)):(this._events=new e,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,s.exports=u})(Ka);var Kl=Ka.exports,Ki=se(Kl);typeof g<"u"&&g&&Wl(self);function Wl(s){var a=new Ki,i=function(r,o){s.postMessage({event:r,data:o})};a.on(R.FRAG_DECRYPTED,i),a.on(R.ERROR,i);var e=function(){var r=function(h){var d=function(p){i("workerLog",{logType:h,message:p})};k[h]=d};for(var o in k)r(o)};s.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var o=JSON.parse(r.config);s.transmuxer=new Vi(a,r.typeSupported,o,"",r.id),X(o.debug,r.id),e(),i("init",null);break}case"configure":{s.transmuxer.configure(r.config);break}case"demux":{var u=s.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);sr(u)?(s.transmuxer.async=!0,u.then(function(p){Wi(s,p)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,Wi(s,u));break}case"flush":{var h=r.chunkMeta,d=s.transmuxer.flush(h),m=sr(d);m||s.transmuxer.async?(sr(d)||(d=Promise.resolve(d)),d.then(function(p){ja(s,p,h)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):ja(s,d,h);break}}})}function Wi(s,a){if(jl(a.remuxResult))return!1;var i=[],e=a.remuxResult,t=e.audio,r=e.video;return t&&Wa(i,t),r&&Wa(i,r),s.postMessage({event:"transmuxComplete",data:a},i),!0}function Wa(s,a){a.data1&&s.push(a.data1.buffer),a.data2&&s.push(a.data2.buffer)}function ja(s,a,i){var e=a.reduce(function(t,r){return Wi(s,r)||t},!1);e||s.postMessage({event:"transmuxComplete",data:a[0]}),s.postMessage({event:"flush",data:i})}function jl(s){return!s.audio&&!s.video&&!s.text&&!s.id3&&!s.initSegment}function zl(){return typeof c=="function"}function Yl(){var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+c.toString()+")(true);"],{type:"text/javascript"}),a=self.URL.createObjectURL(s),i=new self.Worker(a);return{worker:i,objectURL:a}}function ql(s){var a=new self.URL(s,self.location.href).href,i=new self.Worker(a);return{worker:i,scriptURL:a}}var Xl=function(){function s(i,e,t,r){var o=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var u=i.config;this.hls=i,this.id=e,this.useWorker=!!u.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var h=function(x,b){b=b||{},b.frag=o.frag,b.id=o.id,x===R.ERROR&&(o.error=b.error),o.hls.trigger(x,b)};this.observer=new Ki,this.observer.on(R.FRAG_DECRYPTED,h),this.observer.on(R.ERROR,h);var d=ar(u.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},m={mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&typeof Worker<"u"){var p=u.workerPath||zl();if(p){try{u.workerPath?(k.log("loading Web Worker "+u.workerPath+' for "'+e+'"'),this.workerContext=ql(u.workerPath)):(k.log('injecting Web Worker for "'+e+'"'),this.workerContext=Yl()),this.onwmsg=function(T){return o.onWorkerMessage(T)};var y=this.workerContext.worker;y.addEventListener("message",this.onwmsg),y.onerror=function(T){var x=new Error(T.message+" ("+T.filename+":"+T.lineno+")");u.enableWorker=!1,k.warn('Error in "'+e+'" Web Worker, fallback to inline'),o.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:x})},y.postMessage({cmd:"init",typeSupported:m,vendor:"",id:e,config:JSON.stringify(u)})}catch(T){k.warn('Error setting up "'+e+'" Web Worker, fallback to inline',T),this.resetWorker(),this.error=null,this.transmuxer=new Vi(this.observer,m,u,"",e)}return}}this.transmuxer=new Vi(this.observer,m,u,"",e)}var a=s.prototype;return a.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},a.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},a.push=function(e,t,r,o,u,h,d,m,p,y){var T,x,b=this;p.transmuxing.start=self.performance.now();var L=this.transmuxer,A=h?h.start:u.start,D=u.decryptdata,w=this.frag,N=!(w&&u.cc===w.cc),U=!(w&&p.level===w.level),$=w?p.sn-w.sn:-1,V=this.part?p.part-this.part.index:-1,M=$===0&&p.id>1&&p.id===w?.stats.chunkCount,K=!U&&($===1||$===0&&(V===1||M&&V<=0)),z=self.performance.now();(U||$||u.stats.parsing.start===0)&&(u.stats.parsing.start=z),h&&(V||!K)&&(h.stats.parsing.start=z);var te=!(w&&((T=u.initSegment)==null?void 0:T.url)===((x=w.initSegment)==null?void 0:x.url)),Z=new Hl(N,K,m,U,A,te);if(!K||N||te){k.log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
|
10
|
+
discontinuity: `+N+`
|
11
|
+
trackSwitch: `+U+`
|
12
|
+
contiguous: `+K+`
|
13
|
+
accurateTimeOffset: `+m+`
|
14
|
+
timeOffset: `+A+`
|
15
|
+
initSegmentChange: `+te);var ie=new Vl(r,o,t,d,y);this.configureTransmuxer(ie)}if(this.frag=u,this.part=h,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:D,chunkMeta:p,state:Z},e instanceof ArrayBuffer?[e]:[]);else if(L){var he=L.push(e,D,p,Z);sr(he)?(L.async=!0,he.then(function(fe){b.handleTransmuxComplete(fe)}).catch(function(fe){b.transmuxerError(fe,p,"transmuxer-interface push error")})):(L.async=!1,this.handleTransmuxComplete(he))}},a.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var o=r.flush(e),u=sr(o);u||r.async?(sr(o)||(o=Promise.resolve(o)),o.then(function(h){t.handleFlushResult(h,e)}).catch(function(h){t.transmuxerError(h,e,"transmuxer-interface flush error")})):this.handleFlushResult(o,e)}},a.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},a.handleFlushResult=function(e,t){var r=this;e.forEach(function(o){r.handleTransmuxComplete(o)}),this.onFlush(t)},a.onWorkerMessage=function(e){var t=e.data;if(!(t!=null&&t.event)){k.warn("worker message received with no "+(t?"event name":"data"));return}var r=this.hls;if(this.hls)switch(t.event){case"init":{var o,u=(o=this.workerContext)==null?void 0:o.objectURL;u&&self.URL.revokeObjectURL(u);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":k[t.data.logType]&&k[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}},a.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},a.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),$l=250,ti=2,Ql=.1,Jl=.05,Zl=function(){function s(i,e,t,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=i,this.media=e,this.fragmentTracker=t,this.hls=r}var a=s.prototype;return a.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},a.poll=function(e,t){var r=this.config,o=this.media,u=this.stalled;if(o!==null){var h=o.currentTime,d=o.seeking,m=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,h!==e){if(this.moved=!0,d||(this.nudgeRetry=0),u!==null){if(this.stallReported){var y=self.performance.now()-u;k.warn("playback not stuck anymore @"+h+", after "+Math.round(y)+"ms"),this.stallReported=!1}this.stalled=null}return}if(p||m){this.stalled=null;return}if(o.paused&&!d||o.ended||o.playbackRate===0||!rt.getBuffered(o).length){this.nudgeRetry=0;return}var T=rt.bufferInfo(o,h,0),x=T.nextStart||0;if(d){var b=T.len>ti,L=!x||t&&t.start<=h||x-h>ti&&!this.fragmentTracker.getPartialFragment(h);if(b||L)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A,D=T.len>0;if(!D&&!x)return;var w=Math.max(x,T.start||0)-h,N=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=N==null||(A=N.details)==null?void 0:A.live,$=U?N.details.targetduration*2:ti,V=this.fragmentTracker.getPartialFragment(h);if(w>0&&(w<=$||V)){o.paused||this._trySkipBufferHole(V);return}}var M=self.performance.now();if(u===null){this.stalled=M;return}var K=M-u;if(!(!d&&K>=$l&&(this._reportStall(T),!this.media))){var z=rt.bufferInfo(o,h,r.maxBufferHole);this._tryFixBufferStall(z,K)}}},a._tryFixBufferStall=function(e,t){var r=this.config,o=this.fragmentTracker,u=this.media;if(u!==null){var h=u.currentTime,d=o.getPartialFragment(h);if(d){var m=this._trySkipBufferHole(d);if(m||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-h<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(k.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},a._reportStall=function(e){var t=this.hls,r=this.media,o=this.stallReported;if(!o&&r){this.stallReported=!0;var u=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");k.warn(u.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,fatal:!1,error:u,buffer:e.len})}},a._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(o===null)return 0;var u=o.currentTime,h=rt.bufferInfo(o,u,0),d=u<h.start?h.start:h.nextStart;if(d){var m=h.len<=t.maxBufferHole,p=h.len>0&&h.len<1&&o.readyState<3,y=d-u;if(y>0&&(m||p)){if(y>t.maxBufferHole){var T=this.fragmentTracker,x=!1;if(u===0){var b=T.getAppendedFrag(0,Me.MAIN);b&&d<b.end&&(x=!0)}if(!x){var L=e||T.getAppendedFrag(u,Me.MAIN);if(L){for(var A=!1,D=L.end;D<d;){var w=T.getPartialFragment(D);if(w)D+=w.duration;else{A=!0;break}}if(A)return 0}}}var N=Math.max(d+Jl,u+Ql);if(k.warn("skipping hole, adjusting currentTime from "+u+" to "+N),this.moved=!0,this.stalled=null,o.currentTime=N,e&&!e.gap){var U=new Error("fragment loaded with buffer holes, seeking from "+u+" to "+N);r.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:U,reason:U.message,frag:e})}return N}}return 0},a._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,o=this.nudgeRetry;if(r!==null){var u=r.currentTime;if(this.nudgeRetry++,o<e.nudgeMaxRetry){var h=u+(o+1)*e.nudgeOffset,d=new Error("Nudging 'currentTime' from "+u+" to "+h);k.warn(d.message),r.currentTime=h,t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{var m=new Error("Playhead still not moving while enough data buffered @"+u+" after "+e.nudgeMaxRetry+" nudges");k.error(m.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,error:m,fatal:!0})}}},s}(),ef=100,tf=function(s){I(a,s);function a(e,t,r){var o;return o=s.call(this,e,t,r,"[stream-controller]",Me.MAIN)||this,o.audioCodecSwap=!1,o.gapController=null,o.level=-1,o._forceStartLoad=!1,o.altAudio=!1,o.audioOnly=!1,o.fragPlaying=null,o.onvplaying=null,o.onvseeked=null,o.fragLastKbps=0,o.couldBacktrack=!1,o.backtrackFragment=null,o.audioCodecSwitch=!1,o.videoBuffer=null,o._registerListeners(),o}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),s.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(ef),this.level=-1,!this.startFragRequested){var u=o.startLevel;u===-1&&(o.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=o.firstAutoLevel),o.nextLoadLevel=u,this.level=o.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=ne.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ne.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ne.WAITING_LEVEL:{var t=this.levels,r=this.level,o=t?.[r],u=o?.details;if(u&&(!u.live||this.levelLastLoaded===o)){if(this.waitForCdnTuneIn(u))break;this.state=ne.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=ne.IDLE;break}break}case ne.FRAG_LOADING_WAITING_RETRY:{var h,d=self.performance.now(),m=this.retryDate;if(!m||d>=m||(h=this.media)!=null&&h.seeking){var p=this.levels,y=this.level,T=p?.[y];this.resetStartWhenNotLoaded(T||null),this.state=ne.IDLE}}break}this.state===ne.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,o=this.levels,u=this.media;if(!(r===null||!u&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var h=t.nextLoadLevel;if(o!=null&&o[h]){var d=o[h],m=this.getMainFwdBufferInfo();if(m!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(m,p)){var y={};this.altAudio&&(y.type="video"),this.hls.trigger(R.BUFFER_EOS,y),this.state=ne.ENDED;return}t.loadLevel!==h&&t.manualLevel===-1&&this.log("Adapting to level "+h+" from level "+this.level),this.level=t.nextLoadLevel=h;var T=d.details;if(!T||this.state===ne.WAITING_LEVEL||T.live&&this.levelLastLoaded!==d){this.level=h,this.state=ne.WAITING_LEVEL;return}var x=m.len,b=this.getMaxBufferLength(d.maxBitrate);if(!(x>=b)){this.backtrackFragment&&this.backtrackFragment.start>m.end&&(this.backtrackFragment=null);var L=this.backtrackFragment?this.backtrackFragment.start:m.end,A=this.getNextFragment(L,T);if(this.couldBacktrack&&!this.fragPrevious&&A&&A.sn!=="initSegment"&&this.fragmentTracker.getState(A)!==gt.OK){var D,w=((D=this.backtrackFragment)!=null?D:A).sn,N=w-T.startSN,U=T.fragments[N-1];U&&A.cc===U.cc&&(A=U,this.fragmentTracker.removeFragment(U))}else this.backtrackFragment&&m.len&&(this.backtrackFragment=null);if(A&&this.isLoopLoading(A,L)){var $=A.gap;if(!$){var V=this.audioOnly&&!this.altAudio?Pe.AUDIO:Pe.VIDEO,M=(V===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;M&&this.afterBufferFlushed(M,V,Me.MAIN)}A=this.getNextFragmentLoopLoading(A,T,m,Me.MAIN,b)}A&&(A.initSegment&&!A.initSegment.data&&!this.bitrateTest&&(A=A.initSegment),this.loadFragment(A,d,L))}}}}},i.loadFragment=function(t,r,o){var u=this.fragmentTracker.getState(t);this.fragCurrent=t,u===gt.NOT_LOADED||u===gt.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,o)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Me.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var o,u=this.getAppendedFrag(r.currentTime);u&&u.start>1&&this.flushMainBuffer(0,u.start-1);var h=this.getLevelDetails();if(h!=null&&h.live){var d=this.getMainFwdBufferInfo();if(!d||d.len<h.targetduration*2)return}if(!r.paused&&t){var m=this.hls.nextLoadLevel,p=t[m],y=this.fragLastKbps;y&&this.fragCurrent?o=this.fragCurrent.duration*p.maxBitrate/(1e3*y)+1:o=0}else o=0;var T=this.getBufferedFrag(r.currentTime+o);if(T){var x=this.followingBufferedFrag(T);if(x){this.abortCurrentFrag();var b=x.maxStartPTS?x.maxStartPTS:x.start,L=x.duration,A=Math.max(T.end,b+Math.min(Math.max(L-this.config.maxFragLookUpTolerance,L*(this.couldBacktrack?.5:.125)),L*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(A,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case ne.KEY_LOADING:case ne.FRAG_LOADING:case ne.FRAG_LOADING_WAITING_RETRY:case ne.PARSING:case ne.PARSED:this.state=ne.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var o=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new Zl(this.config,o,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;j(r)&&this.log("Media seeked to "+r.toFixed(3));var o=this.getMainFwdBufferInfo();if(o===null||o.len===0){this.warn('Main forward buffer length on "seeked" event '+(o?o.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(t,r){var o=!1,u=!1;r.levels.forEach(function(h){var d=h.audioCodec;d&&(o=o||d.indexOf("mp4a.40.2")!==-1,u=u||d.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=o&&u&&!ll(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var o=this.levels;if(!(!o||this.state!==ne.IDLE)){var u=o[r.level];(!u.details||u.details.live&&this.levelLastLoaded!==u||this.waitForCdnTuneIn(u.details))&&(this.state=ne.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var o,u=this.levels,h=r.level,d=r.details,m=d.totalduration;if(!u){this.warn("Levels were reset while loading level "+h);return}this.log("Level "+h+" loaded ["+d.startSN+","+d.endSN+"]"+(d.lastPartSn?"[part-"+d.lastPartSn+"-"+d.lastPartIndex+"]":"")+", cc ["+d.startCC+", "+d.endCC+"] duration:"+m);var p=u[h],y=this.fragCurrent;y&&(this.state===ne.FRAG_LOADING||this.state===ne.FRAG_LOADING_WAITING_RETRY)&&y.level!==r.level&&y.loader&&this.abortCurrentFrag();var T=0;if(d.live||(o=p.details)!=null&&o.live){var x;if(this.checkLiveUpdate(d),d.deltaUpdateFailed)return;T=this.alignPlaylists(d,p.details,(x=this.levelLastLoaded)==null?void 0:x.details)}if(p.details=d,this.levelLastLoaded=p,this.hls.trigger(R.LEVEL_UPDATED,{details:d,level:h}),this.state===ne.WAITING_LEVEL){if(this.waitForCdnTuneIn(d))return;this.state=ne.IDLE}this.startFragRequested?d.live&&this.synchronizeToLiveEdge(d):this.setStartPosition(d,T),this.tick()},i._handleFragmentLoadProgress=function(t){var r,o=t.frag,u=t.part,h=t.payload,d=this.levels;if(!d){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var m=d[o.level],p=m.details;if(!p){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset"),this.fragmentTracker.removeFragment(o);return}var y=m.videoCodec,T=p.PTSKnown||!p.live,x=(r=o.initSegment)==null?void 0:r.data,b=this._getAudioCodec(m),L=this.transmuxer=this.transmuxer||new Xl(this.hls,Me.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=u?u.index:-1,D=A!==-1,w=new _a(o.level,o.sn,o.stats.chunkCount,h.byteLength,A,D),N=this.initPTS[o.cc];L.push(h,x,b,y,o,u,p.totalduration,T,w,N)},i.onAudioTrackSwitching=function(t,r){var o=this.altAudio,u=!!r.url;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var h=this.fragCurrent;h&&(this.log("Switching to main audio track, cancel main fragment load"),h.abortRequests(),this.fragmentTracker.removeFragment(h)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var d=this.hls;o&&(d.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),d.trigger(R.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var o=r.id,u=!!this.hls.audioTracks[o].url;if(u){var h=this.videoBuffer;h&&this.mediaBuffer!==h&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=h)}this.altAudio=u,this.tick()},i.onBufferCreated=function(t,r){var o=r.tracks,u,h,d=!1;for(var m in o){var p=o[m];if(p.id==="main"){if(h=m,u=p,m==="video"){var y=o[m];y&&(this.videoBuffer=y.buffer)}}else d=!0}d&&u?(this.log("Alternate track found, use "+h+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var o=r.frag,u=r.part;if(!(o&&o.type!==Me.MAIN)){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(u?" p: "+u.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===ne.PARSED&&(this.state=ne.IDLE);return}var h=u?u.stats:o.stats;this.fragLastKbps=Math.round(8*h.total/(h.buffering.end-h.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,u)}},i.onError=function(t,r){var o;if(r.fatal){this.state=ne.ERROR;return}switch(r.details){case G.FRAG_GAP:case G.FRAG_PARSING_ERROR:case G.FRAG_DECRYPT_ERROR:case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me.MAIN,r);break;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:case G.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===ne.WAITING_LEVEL&&((o=r.context)==null?void 0:o.type)===Oe.LEVEL&&(this.state=ne.IDLE);break;case G.BUFFER_APPEND_ERROR:case G.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===G.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case G.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!rt.getBuffered(t).length){var o=this.state!==ne.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,o)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=ne.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var o=r.type;if(o!==Pe.AUDIO||this.audioOnly&&!this.altAudio){var u=(o===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,o,Me.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,o=this.startPosition;if(o>=0&&r<o){if(t.seeking){this.log("could not seek to "+o+", already seeking at "+r);return}var u=rt.getBuffered(t),h=u.length?u.start(0):0,d=h-o;d>0&&(d<this.config.maxBufferHole||d<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+d+" to match buffer start"),o+=d,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+r),t.currentTime=o}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var o=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(u){var h=o.hls;if(!(!u||o.fragContextChanged(t))){r.fragmentError=0,o.state=ne.IDLE,o.startFragRequested=!1,o.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),h.trigger(R.FRAG_LOADED,u),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,o="main",u=this.hls,h=t.remuxResult,d=t.chunkMeta,m=this.getCurrentContext(d);if(!m){this.resetWhenMissingContext(d);return}var p=m.frag,y=m.part,T=m.level,x=h.video,b=h.text,L=h.id3,A=h.initSegment,D=T.details,w=this.altAudio?void 0:h.audio;if(this.fragContextChanged(p)){this.fragmentTracker.removeFragment(p);return}if(this.state=ne.PARSING,A){if(A!=null&&A.tracks){var N=p.initSegment||p;this._bufferInitSegment(T,A.tracks,N,d),u.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:o,tracks:A.tracks})}var U=A.initPTS,$=A.timescale;j(U)&&(this.initPTS[p.cc]={baseTime:U,timescale:$},u.trigger(R.INIT_PTS_FOUND,{frag:p,id:o,initPTS:U,timescale:$}))}if(x&&D&&p.sn!=="initSegment"){var V=D.fragments[p.sn-1-D.startSN],M=p.sn===D.startSN,K=!V||p.cc>V.cc;if(h.independent!==!1){var z=x.startPTS,te=x.endPTS,Z=x.startDTS,ie=x.endDTS;if(y)y.elementaryStreams[x.type]={startPTS:z,endPTS:te,startDTS:Z,endDTS:ie};else if(x.firstKeyFrame&&x.independent&&d.id===1&&!K&&(this.couldBacktrack=!0),x.dropped&&x.independent){var he=this.getMainFwdBufferInfo(),fe=(he?he.end:this.getLoadPosition())+this.config.maxBufferHole,Le=x.firstKeyFramePTS?x.firstKeyFramePTS:z;if(!M&&fe<Le-this.config.maxBufferHole&&!K){this.backtrack(p);return}else K&&(p.gap=!0);p.setElementaryStreamInfo(x.type,p.start,te,p.start,ie,!0)}else M&&z>ti&&(p.gap=!0);p.setElementaryStreamInfo(x.type,z,te,Z,ie),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(x,p,y,d,M||K)}else if(M||K)p.gap=!0;else{this.backtrack(p);return}}if(w){var Ee=w.startPTS,we=w.endPTS,Ae=w.startDTS,ye=w.endDTS;y&&(y.elementaryStreams[Pe.AUDIO]={startPTS:Ee,endPTS:we,startDTS:Ae,endDTS:ye}),p.setElementaryStreamInfo(Pe.AUDIO,Ee,we,Ae,ye),this.bufferFragmentData(w,p,y,d)}if(D&&L!=null&&(r=L.samples)!=null&&r.length){var je={id:o,frag:p,details:D,samples:L.samples};u.trigger(R.FRAG_PARSING_METADATA,je)}if(D&&b){var Fe={id:o,frag:p,details:D,samples:b.samples};u.trigger(R.FRAG_PARSING_USERDATA,Fe)}},i._bufferInitSegment=function(t,r,o,u){var h=this;if(this.state===ne.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,m=r.video,p=r.audiovideo;if(d){var y=t.audioCodec,T=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){y&&(y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5");var x=d.metadata;x&&"channelCount"in x&&(x.channelCount||1)!==1&&T.indexOf("firefox")===-1&&(y="mp4a.40.5")}y&&y.indexOf("mp4a.40.5")!==-1&&T.indexOf("android")!==-1&&d.container!=="audio/mpeg"&&(y="mp4a.40.2",this.log("Android: force audio codec to "+y)),t.audioCodec&&t.audioCodec!==y&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+y+'"'),d.levelCodec=y,d.id="main",this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(y||"")+"/"+(t.audioCodec||"")+"/"+d.codec+"]")}m&&(m.levelCodec=t.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+m.codec+"]")),p&&this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+t.codecs+"/"+p.codec+"]"),this.hls.trigger(R.BUFFER_CODECS,r),Object.keys(r).forEach(function(b){var L=r[b],A=L.initSegment;A!=null&&A.byteLength&&h.hls.trigger(R.BUFFER_APPENDING,{type:b,data:A,frag:o,part:null,chunkMeta:u,parent:o.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me.MAIN)},i.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=ne.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var o=t.currentTime;if(rt.isBuffered(t,o)?r=this.getAppendedFrag(o):rt.isBuffered(t,o+.1)&&(r=this.getAppendedFrag(o+.1)),r){this.backtrackFragment=null;var u=this.fragPlaying,h=r.level;(!u||r.sn!==u.sn||u.level!==h)&&(this.fragPlaying=r,this.hls.trigger(R.FRAG_CHANGED,{frag:r}),(!u||u.level!==h)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:h}))}}},_(a,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var r=t.currentTime,o=this.currentFrag;if(o&&j(r)&&j(o.programDateTime)){var u=o.programDateTime+(r-o.start)*1e3;return new Date(u)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),a}(ol),za=function(){s.isMSESupported=function(){return ba()},s.isSupported=function(){return ul()},s.getMediaSource=function(){return ar()};function s(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Ki,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,X(i.debug||!1,"Hls instance");var e=this.config=Ku(s.DefaultConfig,i);this.userConfig=i,e.progressive&&Wu(e);var t=e.abrController,r=e.bufferController,o=e.capLevelController,u=e.errorController,h=e.fpsController,d=new u(this),m=this.abrController=new t(this),p=this.bufferController=new r(this),y=this.capLevelController=new o(this),T=new h(this),x=new Wo(this),b=new Jo(this),L=e.contentSteeringController,A=L?new L(this):null,D=this.levelController=new ju(this,A),w=new zu(this),N=new qu(this.config),U=this.streamController=new tf(this,w,N);y.setStreamController(U),T.setStreamController(U);var $=[x,D,U];A&&$.splice(1,0,A),this.networkControllers=$;var V=[m,p,y,T,b,w];this.audioTrackController=this.createController(e.audioTrackController,$);var M=e.audioStreamController;M&&$.push(new M(this,w,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,$);var K=e.subtitleStreamController;K&&$.push(new K(this,w,N)),this.createController(e.timelineController,V),N.emeController=this.emeController=this.createController(e.emeController,V),this.cmcdController=this.createController(e.cmcdController,V),this.latencyController=this.createController(Zo,V),this.coreComponents=V,$.push(d);var z=d.onErrorOut;typeof z=="function"&&this.on(R.ERROR,z,d)}var a=s.prototype;return a.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},a.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},a.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},a.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},a.off=function(e,t,r,o){r===void 0&&(r=this),this._emitter.off(e,t,r,o)},a.listeners=function(e){return this._emitter.listeners(e)},a.emit=function(e,t,r){return this._emitter.emit(e,t,r)},a.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(o){if(k.error("An internal error happened while handling event "+e+'. Error message: "'+o.message+'". Here is a stacktrace:',o),!this.triggeringException){this.triggeringException=!0;var r=e===R.ERROR;this.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:r,event:e,error:o}),this.triggeringException=!1}}return!1},a.listenerCount=function(e){return this._emitter.listenerCount(e)},a.destroy=function(){k.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},a.attachMedia=function(e){k.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})},a.detachMedia=function(){k.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null},a.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,o=this.url=oe.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,k.log("loadSource:"+o),t&&r&&(r!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})},a.startLoad=function(e){e===void 0&&(e=-1),k.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},a.stopLoad=function(){k.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},a.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},a.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},a.swapAudioCodec=function(){k.log("swapAudioCodec"),this.streamController.swapAudioCodec()},a.recoverMediaError=function(){k.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},a.removeLevel=function(e){this.levelController.removeLevel(e)},a.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},a.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},_(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){k.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){k.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){k.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){k.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){k.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(k.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){eu(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,o=0;o<r;o++)if(e[o].maxBitrate>=t)return o;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,o;if(t===-1&&e!=null&&e.length?o=e.length-1:o=t,r)for(var u=o;u--;){var h=e[u].attrs["HDCP-LEVEL"];if(h&&h<=r)return u}return o}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return e?e.subtitleDisplay:!1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return R}},{key:"ErrorTypes",get:function(){return le}},{key:"ErrorDetails",get:function(){return G}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:pa},set:function(e){s.defaultConfig=e}}]),s}();return za.defaultConfig=void 0,za})})(!1)});var th={};yf(th,{Flv:()=>br,Hls:()=>Sn.default});module.exports=Ef(th);function ts(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function bt(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?ts(Object(n),!0).forEach(function(l){ce(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):ts(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Re(){Re=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function rs(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function it(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){rs(v,l,f,E,_,"next",S)}function _(S){rs(v,l,f,E,_,"throw",S)}E(void 0)})}}function yr(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function is(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ss(l.key),l)}}function Er(c,g,n){return g&&is(c.prototype,g),n&&is(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function ce(c,g,n){return g=ss(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function ns(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&qi(c,g)}function si(c){return si=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},si(c)}function qi(c,g){return qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},qi(c,g)}function _f(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ie(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Sf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ie(c)}function as(c){var g=_f();return function(){var l=si(c),f;if(g){var v=si(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Sf(this,f)}}function Tf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ss(c){var g=Tf(c,"string");return typeof g=="symbol"?g:String(g)}function us(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function er(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?us(Object(n),!0).forEach(function(l){q(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):us(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Ye(){Ye=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function Gt(c){"@babel/helpers - typeof";return Gt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},Gt(c)}function ls(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function St(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){ls(v,l,f,E,_,"next",S)}function _(S){ls(v,l,f,E,_,"throw",S)}E(void 0)})}}function Be(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function fs(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ps(l.key),l)}}function Ge(c,g,n){return g&&fs(c.prototype,g),n&&fs(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function q(c,g,n){return g=ps(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function It(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&Dr(c,g)}function Zt(c){return Zt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Zt(c)}function Dr(c,g){return Dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},Dr(c,g)}function ds(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ui(c,g,n){return ds()?ui=Reflect.construct.bind():ui=function(f,v,E){var _=[null];_.push.apply(_,v);var S=Function.bind.apply(f,_),C=new S;return E&&Dr(C,E.prototype),C},ui.apply(null,arguments)}function Lf(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function ur(c){var g=typeof Map=="function"?new Map:void 0;return ur=function(l){if(l===null||!Lf(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g<"u"){if(g.has(l))return g.get(l);g.set(l,f)}function f(){return ui(l,arguments,Zt(this).constructor)}return f.prototype=Object.create(l.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Dr(f,l)},ur(c)}function Af(c,g){if(c==null)return{};var n={},l=Object.keys(c),f,v;for(v=0;v<l.length;v++)f=l[v],!(g.indexOf(f)>=0)&&(n[f]=c[f]);return n}function cs(c,g){if(c==null)return{};var n=Af(c,g),l,f;if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(c);for(f=0;f<v.length;f++)l=v[f],!(g.indexOf(l)>=0)&&Object.prototype.propertyIsEnumerable.call(c,l)&&(n[l]=c[l])}return n}function de(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Rf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return de(c)}function Pt(c){var g=ds();return function(){var l=Zt(c),f;if(g){var v=Zt(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Rf(this,f)}}function Cf(c,g){for(;!Object.prototype.hasOwnProperty.call(c,g)&&(c=Zt(c),c!==null););return c}function Cr(){return typeof Reflect<"u"&&Reflect.get?Cr=Reflect.get.bind():Cr=function(g,n,l){var f=Cf(g,n);if(f){var v=Object.getOwnPropertyDescriptor(f,n);return v.get?v.get.call(arguments.length<3?g:l):v.value}},Cr.apply(this,arguments)}function Df(c,g){if(c){if(typeof c=="string")return hs(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return hs(c,g)}}function hs(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function vs(c,g){var n=typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(!n){if(Array.isArray(c)||(n=Df(c))||g&&c&&typeof c.length=="number"){n&&(c=n);var l=0,f=function(){};return{s:f,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(S){throw S},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
16
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var v=!0,E=!1,_;return{s:function(){n=n.call(c)},n:function(){var S=n.next();return v=S.done,S},e:function(S){E=!0,_=S},f:function(){try{!v&&n.return!=null&&n.return()}finally{if(E)throw _}}}}function wf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ps(c){var g=wf(c,"string");return typeof g=="symbol"?g:String(g)}var tt=function(){function c(){Be(this,c)}return Ge(c,null,[{key:"start",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6||n.length===1&&n.start(0)<0?0:n.start(0)}},{key:"end",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6?0:n.end(n.length-1)}},{key:"get",value:function(n){if(n)try{return n.buffered}catch{}}},{key:"buffers",value:function(n,l){if(!n||!n.length)return[];for(var f=[],v=0,E=n.length;v<E;v++){var _=f.length;if(!_||!l)f.push([n.start(v),n.end(v)]);else{var S=f[_-1],C=S[1],I=n.start(v);if(I-C<=l){var P=n.end(v);P>C&&(S[1]=P)}else f.push([n.start(v),n.end(v)])}}return f}},{key:"totalLength",value:function(n){return!n||!n.length?0:n.reduce(function(l,f){return l+=f[1]-f[0]},0)}},{key:"info",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!n||!n.length)return{start:0,end:0,buffers:[]};for(var v=0,E=0,_=0,S=0,C=0,I=0,P=0,H=c.buffers(n,f),W=0,Y=H.length;W<Y;W++){var ee=H[W];if(l+f>=ee[0]&&l<=ee[1])v=ee[0],E=ee[1],_=W;else if(l+f<ee[0]){S=ee[0],C=ee[1];break}else l+f>ee[1]&&(I=ee[0],P=ee[1])}return{start:v,end:E,index:_,buffers:H,nextStart:S,nextEnd:C,prevStart:I,prevEnd:P,currentTime:l,behind:l-v,remaining:E?E-l:0,length:c.totalLength&&c.totalLength(H)}}},{key:"isBuffered",value:function(n,l){if(n){var f=c.get(n);if(f!=null&&f.length){for(var v=0;v<f.length;v++)if(l>=f.start(v)&&l<=f.end(v))return!0}}return!1}}]),c}();var ms=typeof window<"u";var Et,Ce={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},li=(Et={},q(Et,Ce.MANIFEST,{HLS:1100,DASH:1200}),q(Et,Ce.NETWORK,2100),q(Et,Ce.NETWORK_TIMEOUT,2101),q(Et,Ce.NETWORK_FORBIDDEN,2103),q(Et,Ce.NETWORK_NOTFOUND,2104),q(Et,Ce.NETWROK_RANGE_NOT_SATISFIABLE,2116),q(Et,Ce.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),q(Et,Ce.REMUX,{FMP4:4100,MP4:4200}),q(Et,Ce.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),q(Et,Ce.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),q(Et,Ce.OTHER,8e3),q(Et,Ce.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),Et),dt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E,_){var S;return Be(this,n),S=g.call(this,_||v?.message),S.errorType=l===Ce.NETWORK_TIMEOUT?Ce.NETWORK:l,S.originError=v,S.ext=E,S.errorCode=li[l][f]||li[l],S.errorMessage=S.message,S.errorCode||(S.errorType=Ce.OTHER,S.errorCode=li[S.errorType]),S}return Ge(n,null,[{key:"create",value:function(f,v,E,_,S){return f instanceof n?f:(f instanceof Error&&(E=f,f=""),f||(f=Ce.OTHER),new n(f,v,E,_,S))}},{key:"network",value:function(f){var v;return new n(f!=null&&f.isTimeout?Ce.NETWORK_TIMEOUT:Ce.NETWORK,null,f instanceof Error?f:null,{url:f?.url,response:f?.response,httpCode:f==null||(v=f.response)===null||v===void 0?void 0:v.status})}}]),n}(ur(Error));var Ir={DEBUG:1,LOG:2,WARN:3,ERROR:4},If=200*1024,Pf=["Boolean","Number","String","Undefined","Null","Date","Object"],Tt=function(){function c(g,n){Be(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=n?.logCacheLevel||3,this.logMaxSize=n?.logMaxSize||If,this.logSize=0,this.logTextArray=[]}return Ge(c,[{key:"debug",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.DEBUG].concat(f)),!c.disabled&&(n=console).debug.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"log",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.LOG].concat(f)),!c.disabled&&(n=console).log.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"warn",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.WARN].concat(f)),!c.disabled&&(n=console).warn.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"error",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[Ir.ERROR].concat(f)),!c.disabled&&(n=console).error.apply(n,["[".concat(wr(),"]"),this._prefix].concat(f))}},{key:"logCache",value:function(n){if(!(n<this.logCacheLevel)){var l="";try{for(var f=arguments.length,v=new Array(f>1?f-1:0),E=1;E<f;E++)v[E-1]=arguments[E];var _=v.map(function(C){return gs(C)});l="[".concat(wr(),"]")+this._prefix+JSON.stringify(_)}catch{return}if(n>=this.logCacheLevel&&(this.logSize+=l.length,this.logTextArray.push(l)),this.logSize>this.logMaxSize){var S=this.logTextArray.shift();this.logSize-=S.length}}}},{key:"getLogCache",value:function(){var n=this.logTextArray.join(`
|
17
|
+
`);return this.reset(),n}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(n){this.logCacheLevel=n}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();q(Tt,"disabled",!0);function wr(){return new Date().toLocaleString()}function kf(c){if(Gt(c)!=="object")return c;var g=Object.prototype.toString.call(c).slice(8,-1);switch(g){case"Array":case"Uint8Array":case"ArrayBuffer":return g+"["+c.length+"]";case"Object":return"{}";default:return g}}function gs(c,g,n){n||(n=1),g||(g=2);var l={};if(!c||Gt(c)!=="object")return c;var f=Object.prototype.toString.call(c).slice(8,-1);if(!Pf.includes(f))return f;if(!(n>g)){for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(n===g?l[v]=kf(c[v]):Gt(c[v])==="object"?l[v]=gs(c[v],g,n+1):l[v]=c[v]);return l}}function tr(){var c,g,n=new Promise(function(l,f){c=l,g=f});return n.used=!1,n.resolve=function(){return n.used=!0,c.apply(void 0,arguments)},n.reject=function(){return n.used=!0,g.apply(void 0,arguments)},n}function lr(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ys={stringify:function(g){try{return JSON.stringify(g)}catch{return""}},parse:function(g){try{return JSON.parse(g)}catch{return}}};function Es(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return ms?c&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function $i(c){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(c))}function Of(c){var g=[];if(c instanceof TimeRanges)for(var n=0;n<c.length;n++)g.push({start:c.start(n),end:c.end(n)});return g}var fi={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var rr=function(){function c(g,n){var l=this;Be(this,c),q(this,"media",null),q(this,"mediaSource",null),q(this,"_openPromise",tr()),q(this,"_queue",Object.create(null)),q(this,"_sourceBuffer",Object.create(null)),q(this,"_mseFullFlag",{}),q(this,"_st",0),q(this,"_opst",0),q(this,"_logger",null),q(this,"_config",null),q(this,"_url",null),q(this,"_onStartStreaming",function(){l._logger.debug("startstreaming")}),q(this,"_onEndStreaming",function(){l._logger.debug("endstreaming")}),q(this,"_onSBUpdateEnd",function(f){var v=l._queue[f];if(v){var E=v[0];if(E?.opName!==fi.UPDATE_DURATION&&v.shift(),E){var _,S,C=lr()-l._opst;l._logger.debug("UpdateEnd(".concat(f,"/").concat(E.opName,")"),ys.stringify(Of((_=l._sourceBuffer[f])===null||_===void 0?void 0:_.buffered)),C,E.context),E.promise.resolve({name:E.opName,context:E.context,costtime:C});var I=(S=E.context)===null||S===void 0?void 0:S.callback;I&&typeof I=="function"&&I(E.context),l._startQueue(f)}}}),q(this,"_onSBUpdateError",function(f,v){var E=l._queue[f];if(E){var _=E[0];_&&(l._logger.error("UpdateError",f,_.opName,_.context),_.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_APPEND_BUFFER,v)))}}),this._config=Object.assign(c.getDefaultConfig(),n),g&&this.bindMedia(g),this._logger=new Tt("MSE"),this._config.openLog&&Tt.enable()}return Ge(c,[{key:"isOpened",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.readyState)==="open"}},{key:"hasOpTasks",get:function(){var n=this,l=!1;return Object.keys(this._queue).forEach(function(f){var v=n._queue[f];Array.isArray(v)&&(l||(l=v.length>0))}),l}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return $i(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(n){return n?this._mseFullFlag[n]:this._mseFullFlag[c.VIDEO]}},{key:"updateDuration",value:function(n){var l=this,f=this.mediaSource&&this.mediaSource.duration>n;if(this.mediaSource&&this.mediaSource.duration>n){var v=0;if(Object.keys(this._sourceBuffer).forEach(function(E){try{v=Math.max(l.bufferEnd(E)||0,v)}catch{}}),n<v)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(l.isEnded){l._logger.debug("setDuration but ended");return}l.mediaSource&&(l.mediaSource.duration=n,l._logger.debug("setDuration",n))},fi.UPDATE_DURATION,{isReduceDuration:f})}},{key:"open",value:function(){var n=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var l=this.mediaSource,f=function v(){var E=lr()-n._st;n._logger.debug("sourceopen",E),l.removeEventListener("sourceopen",v),n._openPromise.resolve({costtime:E})};l.addEventListener("sourceopen",f),this._openPromise=tr()}return this._openPromise}},{key:"bindMedia",value:function(){var g=St(Ye().mark(function l(f){var v=this,E,_,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(!(this.mediaSource||this.media)){P.next=3;break}return P.next=3,this.unbindMedia();case 3:if(E=Es(this._config.preferMMS),!(!f||!E)){P.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=f,_=this.mediaSource=new E,S=$i(_),this._st=lr(),C=function H(){var W=lr()-v._st;v._logger.debug("sourceopen"),_.removeEventListener("sourceopen",H),URL.revokeObjectURL(f.src),v._openPromise.resolve({costtime:W})},_.addEventListener("sourceopen",C),S&&(_.addEventListener("startstreaming",this._onStartStreaming),_.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(_),f.src=this._url,f.disableRemotePlayback=S,P.abrupt("return",this._openPromise);case 17:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"unbindMedia",value:function(){var g=St(Ye().mark(function l(){var f=this,v,E,_;return Ye().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),v=this.mediaSource,v){if(Object.keys(this._queue).forEach(function(I){var P=f._queue[I];P&&P.forEach(function(H){var W,Y;return(W=H.promise)===null||W===void 0||(Y=W.resolve)===null||Y===void 0?void 0:Y.call(W)})}),E=!!this.media&&this.media.readyState>=1,_=v.readyState==="open",E&&_)try{v.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(I){try{v.removeSourceBuffer(f._sourceBuffer[I])}catch{}}),$i(v)&&(v.removeEventListener("startstreaming",this._onStartStreaming),v.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=tr(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return C.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"createSource",value:function(n,l){if(!(this._sourceBuffer[n]||!this.mediaSource)){var f;try{f=this._sourceBuffer[n]=this.mediaSource.addSourceBuffer(l)}catch(v){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_ADD_SB,v)}f.mimeType=l,f.addEventListener("updateend",this._onSBUpdateEnd.bind(this,n)),f.addEventListener("error",this._onSBUpdateError.bind(this,n))}}},{key:"changeType",value:function(n,l){var f=this,v=this._sourceBuffer[n];return!this.mediaSource||!v||v.mimeType===l?Promise.resolve():typeof v.changeType!="function"?Promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(n,function(){try{v.changeType(l)}catch(E){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,E)}v.mimeType=l,f._onSBUpdateEnd(n)},"changeType",{mimeType:l})}},{key:"createOrChangeSource",value:function(n,l){return this.createSource(n,l),this.changeType(n,l)}},{key:"append",value:function(n,l,f){var v=this;return!l||!l.byteLength||!this._sourceBuffer[n]?Promise.resolve():this._enqueueOp(n,function(){var E;!v.mediaSource||v.media.error||(v._logger.debug("MSE APPEND START",f),v._opst=lr(),(E=v._sourceBuffer[n])===null||E===void 0||E.appendBuffer(l))},fi.APPEND,f)}},{key:"remove",value:function(n,l,f,v){var E=this,_=!1;return this._mseFullFlag[n]&&(_=!0),this._enqueueOp(n,function(){if(!(!E.mediaSource||E.media.error)){var S=E._sourceBuffer[n];if(l>=f||!S){E._onSBUpdateEnd(n);return}E._opst=lr(),E._logger.debug("MSE REMOVE START",n,l,f,v),S.remove(l,f)}},fi.REMOVE,v,_)}},{key:"clearBuffer",value:function(n,l){var f=this,v;return Object.keys(this._sourceBuffer).forEach(function(E){v=f.remove(E,n,l)}),v||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var n=this,l;return Object.keys(this._sourceBuffer).forEach(function(f){var v=n._sourceBuffer[f];l=n.remove(f,0,tt.end(tt.get(v)))}),l}},{key:"clearOpQueues",value:function(n,l){var f;this._logger.debug("MSE clearOpQueue START");var v=this._queue[n];if(l&&v){this._queue[n]=[];return}if(!(!v||!v[n]||v.length<5)){var E=[];v.forEach(function(_){_.context&&_.context.isinit&&E.push(_)}),this._queue[n]=v.slice(0,2),E.length>0&&(f=this._queue[n]).push.apply(f,E)}}},{key:"endOfStream",value:function(n){var l=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var f=l.mediaSource;!f||f.readyState!=="open"||(l._logger.debug("MSE endOfStream START"),n?f.endOfStream(n):f.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(n,l){var f=this.mediaSource;n<0||l<n||!(f!=null&&f.setLiveSeekableRange)||f.readyState!=="open"||f.setLiveSeekableRange(n,l)}},{key:"getSourceBuffer",value:function(n){return this._sourceBuffer[n]}},{key:"buffered",value:function(n){return tt.get(this._sourceBuffer[n])}},{key:"bufferStart",value:function(n){return tt.start(this.buffered(n))}},{key:"bufferEnd",value:function(n){return tt.end(this.buffered(n))}},{key:"_enqueueOp",value:function(n,l,f,v,E){var _=this;if(!this.mediaSource)return Promise.resolve();var S=this._queue[n]=this._queue[n]||[],C={exec:l,promise:tr(),opName:f,context:v};return E?(S.splice(0,0,C),this._mseFullFlag[n]=!1,this._startQueue(n)):S.push(C),this.isOpened||this.isEnded?S.length===1&&this._startQueue(n):this._openPromise.then(function(){S.length===1&&_._startQueue(n)}),C.promise}},{key:"_enqueueBlockingOp",value:function(){var g=St(Ye().mark(function l(f,v,E){var _=this,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.mediaSource){P.next=2;break}return P.abrupt("return",Promise.resolve());case 2:if(S=Object.keys(this._sourceBuffer),S.length){P.next=5;break}return P.abrupt("return",f());case 5:return C=[],S.forEach(function(H){var W=_._queue[H],Y=tr();C.push(Y),W.push({exec:function(){Y.resolve()},promise:Y,opName:v,context:E}),W.length===1&&_._startQueue(H)}),P.abrupt("return",Promise.all(C).then(function(){try{return f()}finally{S.forEach(function(H){var W=_._queue[H],Y=_._sourceBuffer[H];W?.shift(),(!Y||!Y.updating)&&_._startQueue(H)})}}));case 8:case"end":return P.stop()}},l,this)}));function n(l,f,v){return g.apply(this,arguments)}return n}()},{key:"_startQueue",value:function(n){var l=this._queue[n];if(l){var f=l[0];if(f&&!this._mseFullFlag[n])try{f.exec()}catch(v){v&&v.message&&v.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[n]=!0,f.context&&Gt(f.context)==="object"&&(f.context.isFull=!0),this._logger.error("[MSE error], context,",f.context," ,name,",f.opName,",err,SourceBuffer is full"),f.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_FULL,v))):(this._logger.error(v),f.promise.reject(v.constructor===dt?v:new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_OTHER,v)),l.shift(),this._startQueue(n))}}}},{key:"setTimeoffset",value:function(n,l,f){var v=this;return this._enqueueOp(n,function(){l<0&&(l+=.001),v._sourceBuffer[n].timestampOffset=l,v._onSBUpdateEnd(n)},"setTimeoffset",f)}},{key:"abort",value:function(n,l){var f=this;return this.isOpened?this._enqueueOp(n,function(){f._sourceBuffer[n].abort(),f._onSBUpdateEnd(n)},"abort",l):Promise.resolve()}}],[{key:"isSupported",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',l=Es();if(!l)return!1;try{return l.isTypeSupported(n)}catch(f){return this._logger.error(n,f),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),c}();q(rr,"VIDEO","video");q(rr,"AUDIO","audio");var kt={FETCH:"fetch",XHR:"xhr"},ir={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var Lt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E){var _;return Be(this,n),_=g.call(this,E),q(de(_),"retryCount",0),q(de(_),"isTimeout",!1),q(de(_),"loaderType",kt.FETCH),q(de(_),"startTime",0),q(de(_),"endTime",0),q(de(_),"options",{}),_.url=l,_.request=f,_.response=v,_}return Ge(n)}(ur(Error));var _s=Object.prototype.toString;function Ss(c){return c!==null&&Gt(c)==="object"}function Qi(c){if(_s.call(c)!=="[object Object]")return!1;var g=Object.getPrototypeOf(c);return g===null||g===Object.prototype}function Ts(c){return _s.call(c)==="[object Date]"}function hi(c){if(!(!c||c[0]===null||c[0]===void 0||c[0]===0&&(c[1]===null||c[1]===void 0))){var g="bytes="+c[0]+"-";return c[1]&&(g+=c[1]),g}}function xs(c){return encodeURIComponent(c).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function di(c,g){if(c){if(!g)return c;var n,l=Object.keys(g).map(function(v){if(n=g[v],n!=null)return Array.isArray(n)?v=v+"[]":n=[n],n.map(function(E){return Ts(E)?E=E.toISOString():Ss(E)&&(E=JSON.stringify(E)),"".concat(xs(v),"=").concat(xs(E))}).join("&")}).filter(Boolean).join("&");if(l){var f=c.indexOf("#");f!==-1&&(c=c.slice(0,f)),c+=(c.indexOf("?")===-1?"?":"&")+l}return c}}function Pr(c,g,n,l,f,v,E,_,S,C,I){f=f!=null?parseFloat(f):null,l=parseInt(l||"0",10),Number.isNaN(l)&&(l=0);var P={range:S,vid:C,index:_,contentLength:l,age:f,startTime:v,firstByteTime:E,endTime:Date.now(),priOptions:I};return{data:c,done:g,options:P,response:n}}function kr(c,g){return Math.round(c*8*1e3/g/1024)}var me={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var Ls=gr(_r()),bs=2*1024*1024,Or=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_abortController",null),q(de(l),"_timeoutTimer",null),q(de(l),"_reader",null),q(de(l),"_response",null),q(de(l),"_aborted",!1),q(de(l),"_index",-1),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_running",!1),q(de(l),"_logger",null),q(de(l),"_vid",""),q(de(l),"_onProcessMinLen",0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v,E=this,_=f.url,S=f.vid,C=f.timeout,I=f.responseType,P=f.onProgress,H=f.index,W=f.onTimeout,Y=f.onCancel,ee=f.range,J=f.transformResponse,ae=f.request,se=f.params,_e=f.logger,oe=f.method,j=f.headers,ue=f.body,Ve=f.mode,R=f.credentials,le=f.cache,G=f.redirect,He=f.referrer,F=f.referrerPolicy,O=f.onProcessMinLen,B=f.priOptions;this._logger=_e,this._aborted=!1,this._onProcessMinLen=O,this._onCancel=Y,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=H,this._range=ee||[0,0],this._vid=S||_,this._priOptions=B||{};var re={method:oe,headers:j,body:ue,mode:Ve,credentials:R,cache:le,redirect:G,referrer:He,referrerPolicy:F,signal:(v=this._abortController)===null||v===void 0?void 0:v.signal},X=!1;clearTimeout(this._timeoutTimer),_=di(_,se);var k=hi(ee);k&&(ae?j=ae.headers:j=re.headers=re.headers||(Headers?new Headers:{}),Headers&&j instanceof Headers?j.append("Range",k):j.Range=k),C&&(this._timeoutTimer=setTimeout(function(){if(X=!0,E.cancel(),W){var De=new Lt(_,re,null,"timeout");De.isTimeout=!0,W(De,{index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions})}},C));var ge=Date.now();return this._logger.debug("[fetch load start], index,",H,",range,",ee),new Promise(function(De,pe){fetch(ae||_,ae?void 0:re).then(function(){var Ne=St(Ye().mark(function Qe(ke){var $t,Pe,hr,dr;return Ye().wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(clearTimeout(E._timeoutTimer),E._response=ke,!(E._aborted||!E._running)){Je.next=4;break}return Je.abrupt("return");case 4:if(J&&(ke=J(ke,_)||ke),ke.ok){Je.next=7;break}throw new Lt(_,re,ke,"bad network response");case 7:if($t=Date.now(),I!==ir.TEXT){Je.next=15;break}return Je.next=11,ke.text();case 11:Pe=Je.sent,E._running=!1,Je.next=37;break;case 15:if(I!==ir.JSON){Je.next=22;break}return Je.next=18,ke.json();case 18:Pe=Je.sent,E._running=!1,Je.next=37;break;case 22:if(!P){Je.next=29;break}return E.resolve=De,E.reject=pe,E._loadChunk(ke,P,ge,$t),Je.abrupt("return");case 29:return Je.next=31,ke.arrayBuffer();case 31:Pe=Je.sent,Pe=new Uint8Array(Pe),E._running=!1,hr=Date.now()-ge,dr=kr(Pe.byteLength,hr),E.emit(me.REAL_TIME_SPEED,{speed:dr,len:Pe.byteLength,time:hr,vid:E._vid,index:E._index,range:E._range,priOptions:E._priOptions});case 37:E._logger.debug("[fetch load end], index,",H,",range,",ee),De(Pr(Pe,!0,ke,ke.headers.get("Content-Length"),ke.headers.get("age"),ge,$t,H,ee,E._vid,E._priOptions));case 39:case"end":return Je.stop()}},Qe)}));return function(Qe){return Ne.apply(this,arguments)}}()).catch(function(Ne){var Qe;clearTimeout(E._timeoutTimer),E._running=!1,!(E._aborted&&!X)&&(Ne=Ne instanceof Lt?Ne:new Lt(_,re,null,(Qe=Ne)===null||Qe===void 0?void 0:Qe.message),Ne.startTime=ge,Ne.endTime=Date.now(),Ne.isTimeout=X,Ne.options={index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions},pe(Ne))})})}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){return Ye().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._aborted){_.next=2;break}return _.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){_.next=14;break}if(_.prev=5,!this._reader){_.next=9;break}return _.next=9,this._reader.cancel();case 9:_.next=13;break;case 11:_.prev=11,_.t0=_.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return _.stop()}},v,this,[[5,11]])}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadChunk",value:function(f,v,E,_){var S=this;if(!f.body||!f.body.getReader){this._running=!1;var C=new Lt(f.url,"",f,"onProgress of bad response.body.getReader");C.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(C);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(bs),this._writeIdx=0);var I=this._reader=f.body.getReader(),P,H,W,Y=function(){var ee=St(Ye().mark(function J(){var ae,se,_e,oe,j,ue,Ve,R;return Ye().wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return H=Date.now(),G.prev=1,G.next=4,I.read();case 4:P=G.sent,W=Date.now(),G.next=13;break;case 8:return G.prev=8,G.t0=G.catch(1),W=Date.now(),S._aborted||(S._running=!1,G.t0.options={index:S._index,range:S._range,vid:S._vid,priOptions:S._priOptions},S.reject(G.t0)),G.abrupt("return");case 13:if(se=((ae=S._range)===null||ae===void 0?void 0:ae.length)>0?S._range[0]:0,_e=se+S._receivedLength,!S._aborted){G.next=19;break}return S._running=!1,v(void 0,!1,{range:[_e,_e],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),G.abrupt("return");case 19:oe=P.value?P.value.byteLength:0,S._receivedLength+=oe,S._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",S._range,", start,",_e,", end,",se+S._receivedLength,", done,",P.done),S._onProcessMinLen>0?S._writeIdx+oe>=S._onProcessMinLen||P.done?(j=new Uint8Array(S._writeIdx+oe),j.set(S._cache.slice(0,S._writeIdx),0),oe>0&&j.set(P.value,S._writeIdx),S._writeIdx=0,S._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",P.done,",len,",j.byteLength,", writeIdx,",S._writeIdx)):oe>0&&S._writeIdx+oe<bs?(S._cache.set(P.value,S._writeIdx),S._writeIdx+=oe,S._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",oe,", writeIdx,",S._writeIdx)):oe>0&&(ue=new Uint8Array(S._writeIdx+oe+2048),S._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",S._writeIdx+oe+2048,", datalen,",oe,", writeIdx,",S._writeIdx),ue.set(S._cache.slice(0,S._writeIdx),0),oe>0&&ue.set(P.value,S._writeIdx),S._writeIdx+=oe,delete S._cache,S._cache=ue,S._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",oe,", writeIdx,",S._writeIdx)):j=P.value,(j&&j.byteLength>0||P.done)&&v(j,P.done,{range:[S._range[0]+S._receivedLength-(j?j.byteLength:0),S._range[0]+S._receivedLength],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),P.done?(Ve=Date.now()-E,R=kr(S._receivedLength,Ve),S.emit(me.REAL_TIME_SPEED,{speed:R,len:S._receivedLength,time:Ve,vid:S._vid,index:S._index,range:S._range,priOptions:S._priOptions}),S._running=!1,S._logger.debug("[fetchLoader onProgress end],task,",S._range,",done,",P.done),S.resolve(Pr(P,!0,f,f.headers.get("Content-Length"),f.headers.get("age"),E,_,S._index,S._range,S._vid,S._priOptions))):Y();case 25:case"end":return G.stop()}},J,null,[[1,8]])}));return function(){return ee.apply(this,arguments)}}();Y()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),n}(Ls.default);function As(c){return er({loaderType:kt.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:ir.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},c)}var Rs=gr(_r()),Cs=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_xhr",null),q(de(l),"_aborted",!1),q(de(l),"_timeoutTimer",null),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_url",null),q(de(l),"_onProgress",null),q(de(l),"_index",-1),q(de(l),"_headers",null),q(de(l),"_currentChunkSizeKB",384),q(de(l),"_timeout",null),q(de(l),"_xhr",null),q(de(l),"_withCredentials",null),q(de(l),"_startTime",-1),q(de(l),"_loadCompleteResolve",null),q(de(l),"_loadCompleteReject",null),q(de(l),"_runing",!1),q(de(l),"_logger",!1),q(de(l),"_vid",""),q(de(l),"_responseType",void 0),q(de(l),"_credentials",void 0),q(de(l),"_method",void 0),q(de(l),"_transformResponse",void 0),q(de(l),"_firstRtt",void 0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v=this;clearTimeout(this._timeoutTimer),this._logger=f.logger,this._range=f.range,this._onProgress=f.onProgress,this._index=f.index,this._headers=f.headers,this._withCredentials=f.credentials==="include"||f.credentials==="same-origin",this._body=f.body||null,f.method&&(this._method=f.method),this._timeout=f.timeout||null,this._runing=!0,this._vid=f.vid||f.url,this._responseType=f.responseType,this._firstRtt=-1,this._onTimeout=f.onTimeout,this._onCancel=f.onCancel,this._request=f.request,this._priOptions=f.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=di(f.url,f.params);var E=Date.now();return new Promise(function(_,S){v._loadCompleteResolve=_,v._loadCompleteReject=S,v._startLoad()}).catch(function(_){if(clearTimeout(v._timeoutTimer),v._runing=!1,!v._aborted)throw _=_ instanceof Lt?_:new Lt(v._url,v._request),_.startTime=E,_.endTime=Date.now(),_.options={index:v._index,vid:v._vid,priOptions:v._priOptions},_})}},{key:"_startLoad",value:function(){var f=null;if(this._responseType===ir.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var v=this._currentChunkSizeKB*1024,E=this._range[0]+this._receivedLength,_=this._range[1];v<this._range[1]-E&&(_=E+v),f=[E,_],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",f)}else f=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",f);this._internalOpen(f)}},{key:"_internalOpen",value:function(f){var v=this;try{this._startTime=Date.now();var E=this._xhr=new XMLHttpRequest;E.open(this._method||"GET",this._url,!0),E.responseType=this._responseType,this._timeout&&(E.timeout=this._timeout),E.withCredentials=this._withCredentials,E.onload=this._onLoad.bind(this),E.onreadystatechange=this._onReadyStatechange.bind(this),E.onerror=function(C){var I,P,H;v._running=!1;var W=new Lt(v._url,v._request,C==null||(I=C.currentTarget)===null||I===void 0?void 0:I.response,"xhr.onerror.status:"+(C==null||(P=C.currentTarget)===null||P===void 0?void 0:P.status)+",statusText,"+(C==null||(H=C.currentTarget)===null||H===void 0?void 0:H.statusText));W.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(W)},E.ontimeout=function(C){v.cancel();var I=new Lt(v._url,v._request,{status:408},"timeout");v._onTimeout&&(I.isTimeout=!0,v._onTimeout(I,{index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions})),I.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(I)};var _=this._headers||{},S=hi(f);S&&(_.Range=S),_&&Object.keys(_).forEach(function(C){E.setRequestHeader(C,_[C])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",f),E.send(this._body)}catch(C){C.options={index:this._index,range:f,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(C)}}},{key:"_onReadyStatechange",value:function(f){var v=f.target;v.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(f){var v,E=f.target.status;if(E<200||E>299){var _=new Lt(this._url,null,er(er({},f.target.response),{},{status:E}),"bad response,status:"+E);return _.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(_)}var S=null,C=!1,I,P=((v=this._range)===null||v===void 0?void 0:v.length)>0?this._range[0]:0;if(this._responseType===ir.ARRAY_BUFFER){var H,W=new Uint8Array(f.target.response);if(I=P+this._receivedLength,W&&W.byteLength>0){this._receivedLength+=W.byteLength;var Y=Date.now()-this._startTime,ee=kr(this._receivedLength,Y);this.emit(me.REAL_TIME_SPEED,{speed:ee,len:this._receivedLength,time:Y,vid:this._vid,index:this._index,range:[I,P+this._receivedLength],priOptions:this._priOptions})}S=W,((H=this._range)===null||H===void 0?void 0:H.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?C=!1:C=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",I,"end ",P+this._receivedLength,",dataLen,",W?W.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",C)}else C=!0,S=f.target.response;var J={ok:E>=200&&E<300,status:E,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(J=this._transformResponse(J,this._url)||J),this._onProgress&&this._onProgress(S,C,{index:this._index,vid:this._vid,range:[I,P+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},J),C?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Pr(this._onProgress?null:S,C,J,J.headers["content-length"],J.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Cr(Zt(n.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}},{key:"_getHeaders",value:function(f){var v=f.getAllResponseHeaders().trim().split(`\r
|
18
|
+
`),E={},_=vs(v),S;try{for(_.s();!(S=_.n()).done;){var C=S.value,I=C.split(": ");E[I[0].toLowerCase()]=I.slice(1).join(": ")}}catch(P){_.e(P)}finally{_.f()}return E}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),n}(Rs.default);var Mf=["retry","retryDelay","onRetryError","transformError"],Ds=function(){function c(g,n){Be(this,c),this.promise=tr(),this.alive=!!n.onProgress,!n.logger&&(n.logger=new Tt("Loader")),this._loaderType=g,this._loader=g===kt.FETCH&&typeof fetch<"u"?new Or:new Cs,this._config=n,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=n.retryCheckFunc,this._logger=n.logger}return Ge(c,[{key:"exec",value:function(){var n=this,l=this._config,f=l.retry,v=l.retryDelay,E=l.onRetryError,_=l.transformError,S=cs(l,Mf),C=function(){var I=St(Ye().mark(function P(){var H,W,Y;return Ye().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.prev=0,J.next=3,n._loader.load(S);case 3:H=J.sent,n.promise.resolve(H),J.next=27;break;case 7:if(J.prev=7,J.t0=J.catch(0),n._loader.running=!1,n._logger.debug("[task request catch err]",J.t0),!n._canceled){J.next=13;break}return J.abrupt("return");case 13:if(J.t0.loaderType=n._loaderType,J.t0.retryCount=n._retryCount,W=J.t0,_&&(W=_(W)||W),E&&n._retryCount>0&&E(W,n._retryCount,{index:S.index,vid:S.vid,range:S.range,priOptions:S.priOptions}),n._retryCount++,Y=!0,n._retryCheckFunc&&(Y=n._retryCheckFunc(J.t0)),!(Y&&n._retryCount<=f)){J.next=26;break}return clearTimeout(n._retryTimer),n._logger.debug("[task request setTimeout],retry",n._retryCount,",retry range,",S.range),n._retryTimer=setTimeout(C,v),J.abrupt("return");case 26:n.promise.reject(W);case 27:case"end":return J.stop()}},P,null,[[0,7]])}));return function(){return I.apply(this,arguments)}}();return C(),this.promise}},{key:"cancel",value:function(){var g=St(Ye().mark(function l(){return Ye().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,v.abrupt("return",this._loader.cancel());case 4:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),c}();function Ji(c){return c&&!c.paused&&!c.ended&&c.playbackRate!==0&&c.readyState!==0}function Zi(c){if(!c)return{};if(typeof c.getVideoPlaybackQuality=="function"){var g=c.getVideoPlaybackQuality();return{droppedVideoFrames:g.droppedVideoFrames||g.corruptedVideoFrames,totalVideoFrames:g.totalVideoFrames,creationTime:g.creationTime}}return{droppedVideoFrames:c.webkitDroppedFrameCount,totalVideoFrames:c.webkitDecodedFrameCount,creationTime:performance.now()}}function en(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];if(g=g.filter(Boolean),g.length<2)return g[0];var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}function tn(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(g){return setTimeout(g,c)})}var ws=gr(_r()),rn=function(c){It(n,c);var g=Pt(n);function n(l){var f;return Be(this,n),f=g.call(this,l),q(de(f),"type",kt.FETCH),q(de(f),"_queue",[]),q(de(f),"_alive",[]),q(de(f),"_currentTask",null),q(de(f),"_finnalUrl",""),q(de(f),"_config",void 0),f._config=As(l),(f._config.loaderType===kt.XHR||!Or.isSupported())&&(f.type=kt.XHR),f.log=l.logger,f}return Ge(n,[{key:"isFetch",value:function(){return this.type===kt.FETCH}},{key:"load",value:function(f){var v=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof f=="string"||!f?E.url=f||E.url||this._config.url:E=f,E=Object.assign({},this._config,E),E.params&&(E.params=Object.assign({},E.params)),E.headers&&Qi(E.headers)&&(E.headers=Object.assign({},E.headers)),E.body&&Qi(E.body)&&(E.body=Object.assign({},E.body)),E.transformRequest&&(E=E.transformRequest(E)||E),E.logger=this.log;var _=new Ds(this.type,E);return _.loader.on(me.REAL_TIME_SPEED,function(S){v.emit(me.REAL_TIME_SPEED,S)}),this._queue.push(_),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),_.promise}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){var E;return Ye().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return E=this._queue.map(function(C){return C.cancel()}).concat(this._alive.map(function(C){return C.cancel()})),this._currentTask&&E.push(this._currentTask.cancel()),this._queue=[],this._alive=[],S.next=6,Promise.all(E);case 6:return S.next=8,tn();case 8:case"end":return S.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_processTask",value:function(){var f=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var v=this._currentTask.exec().catch(function(E){});v&&typeof v.finally=="function"&&v.finally(function(){var E,_;(E=f._currentTask)!==null&&E!==void 0&&E.alive&&((_=f._alive)===null||_===void 0?void 0:_.length)>0&&(f._alive=f._alive.filter(function(S){return S&&S!==f._currentTask})),f._processTask()})}}}],[{key:"isFetchSupport",value:function(){return Or.isSupported()}}]),n}(ws.default);var nn=function(){function c(){Be(this,c),q(this,"_prevCurrentTime",0)}return Ge(c,[{key:"do",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,f=arguments.length>2?arguments[2]:void 0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(n){var E=n.currentTime,_=0;if(this._prevCurrentTime===E){var S=tt.info(tt.get(n),E);if(!S.buffers.length)return;f&&S.nextStart||S.nextStart&&S.nextStart-E<l?_=S.nextStart+.1:S.end&&S.end-E>v&&!n.seeking&&(_=E+.1)}this._prevCurrentTime=E,_&&E!==_&&(n.currentTime=_)}}}]),c}();var an=function(){function c(g){var n=this;Be(this,c),q(this,"_seiSet",new Set),this.emitter=g,g.on(me.SEI,function(l){l&&n._seiSet.add(l)})}return Ge(c,[{key:"throw",value:function(n,l){var f=this;if(!(n==null||!this._seiSet.size)){var v=n-.2,E=n+.2,_=[];this._seiSet.forEach(function(S){S.time>=v&&S.time<=E&&_.push(S)}),_.forEach(function(S){f._seiSet.delete(S),f.emitter.emit(me.SEI_IN_TIME,S)}),l&&this._seiSet.forEach(function(S){S.time<n-5&&f._seiSet.delete(S)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),c}();var Ff=1e3,Nf=50,Uf=3,Bf=3e3,sn=function(){function c(g){Be(this,c),q(this,"_chunkSpeed",0),q(this,"_chunkCache",[]),q(this,"_speeds",[]),q(this,"_totalSize",0),q(this,"_totalCost",0),this._opts=g||{}}return Ge(c,[{key:"addRecord",value:function(n,l){!n||!l||(this._speeds.push(8e3*n/l),this._speeds=this._speeds.slice(-Uf))}},{key:"addChunkRecord",value:function(n,l){var f,v;if(!(!n||!l||n<(((f=this._opts)===null||f===void 0?void 0:f.skipChunkSize)||Ff))){this._totalSize+=n,this._totalCost+=l,this._chunkSpeed=8e3*n/l,this._chunkCache.push({size:n,duration:l,timestamp:performance.now()});var E=((v=this._opts)===null||v===void 0?void 0:v.chunkCountForSpeed)||Nf;this._chunkCache.length>E&&(this._chunkCache=this._chunkCache.slice(-E))}}},{key:"getAvgSpeed",value:function(){var n;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(_,S){return _+=S})/this._speeds.length;var l=this._chunkCache[this._chunkCache.length-1],f=performance.now()-l.timestamp;f>(((n=this._opts)===null||n===void 0?void 0:n.longtimeNoReceived)||Bf)&&this._chunkCache.push({size:0,duration:f,timestamp:performance.now()});var v=this._chunkCache.reduce(function(_,S){return _+=S.size},0),E=this._chunkCache.reduce(function(_,S){return _+=S.duration},0);return 8e3*v/E}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),c}();var yd=gr(_r());var Is=function(){function c(g){Be(this,c),q(this,"encodeType",""),q(this,"audioCodec",""),q(this,"videoCodec",""),q(this,"domain",""),q(this,"fps",0),q(this,"bitrate",0),q(this,"width",0),q(this,"height",0),q(this,"samplerate",0),q(this,"channelCount",0),q(this,"gop",0),q(this,"_bitsAccumulateSize",0),q(this,"_bitsAccumulateDuration",0),q(this,"_startGopId",-1),this._timescale=g}return Ge(c,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(n){this.encodeType=n}},{key:"setFpsFromScriptData",value:function(n){var l,f=n.data,v=f==null||(l=f.onMetaData)===null||l===void 0?void 0:l.framerate;v&&v>0&&v<100&&(this.fps=v)}},{key:"setVideoMeta",value:function(n){if(this.width=n.width,this.height=n.height,this.videoCodec=n.codec,this.encodeType=n.codecType,n.fpsNum&&n.fpsDen){var l=n.fpsNum/n.fpsDen;l>0&&l<100&&(this.fps=l)}}},{key:"setAudioMeta",value:function(n){this.audioCodec=n.codec,this.samplerate=n.sampleRate,this.channelCount=n.channelCount}},{key:"setDomain",value:function(n){this.domain=n.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(n){var l=this;if((!this.fps||this.fps>=100)&&n.length){var f=n.reduce(function(v,E){return v+=E.duration},0)/n.length;this.fps=Math.round(this._timescale/f)}n.forEach(function(v){l._startGopId===-1&&(l._startGopId=v.gopId),v.gopId===l._startGopId&&l.gop++,l._bitsAccumulateDuration+=v.duration/(l._timescale/1e3),l._bitsAccumulateSize+=v.units.reduce(function(E,_){return E+=_.length},0),l._bitsAccumulateDuration>=1e3&&(l.bitrate=l._bitsAccumulateSize*8,l._bitsAccumulateDuration=0,l._bitsAccumulateSize=0)})}}]),c}(),on=function(){function c(g){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;Be(this,c),q(this,"_core",null),q(this,"_samples",[]),this._core=g,this._timescale=n,this._stats=new Is(n),this._bindEvents()}return Ge(c,[{key:"getStats",value:function(){var n,l,f,v,E,_,S,C,I,P,H,W=((n=this._core)===null||n===void 0?void 0:n.media)||{},Y=W.currentTime,ee=Y===void 0?0:Y,J=W.decodeFps,ae=J===void 0?0:J;return er(er({},this._stats.getStats()),{},{downloadSpeed:((l=this._core)===null||l===void 0||(f=l.speedInfo)===null||f===void 0?void 0:f.call(l).speed)||0,avgSpeed:((v=this._core)===null||v===void 0||(E=v.speedInfo)===null||E===void 0?void 0:E.call(v).avgSpeed)||0,totalReceivedByte:((_=this._core)===null||_===void 0||(S=_.speedInfo)===null||S===void 0?void 0:S.call(_).totalSize)||0,totalReceivedCost:((C=this._core)===null||C===void 0||(I=C.speedInfo)===null||I===void 0?void 0:I.call(C).totalCost)||0,currentTime:ee,bufferEnd:((P=this._core)===null||P===void 0||(H=P.bufferInfo())===null||H===void 0?void 0:H.remaining)||0,decodeFps:ae})}},{key:"_bindEvents",value:function(){var n=this;this._core.on(me.DEMUXED_TRACK,function(l){var f=l.videoTrack;return n._stats.updateBitrate(f.samples)}),this._core.on(me.FLV_SCRIPT_DATA,function(l){n._stats.setFpsFromScriptData(l)}),this._core.on(me.METADATA_PARSED,function(l){l.type==="video"?n._stats.setVideoMeta(l.track):n._stats.setAudioMeta(l.track)}),this._core.on(me.TTFB,function(l){n._stats.setDomain(l.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Is(this._timescale)}}]),c}();var no=gr(_r());function Gf(c,g){var n=c==null?null:typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(n!=null){var l,f,v,E,_=[],S=!0,C=!1;try{if(v=(n=n.call(c)).next,g===0){if(Object(n)!==n)return;S=!1}else for(;!(S=(l=v.call(n)).done)&&(_.push(l.value),_.length!==g);S=!0);}catch(I){C=!0,f=I}finally{try{if(!S&&n.return!=null&&(E=n.return(),Object(E)!==E))return}finally{if(C)throw f}}return _}}function Se(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function Ps(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,Ms(l.key),l)}}function Te(c,g,n){return g&&Ps(c.prototype,g),n&&Ps(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function Q(c,g,n){return g=Ms(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function fn(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&un(c,g)}function ci(c){return ci=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ci(c)}function un(c,g){return un=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},un(c,g)}function Vf(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Hf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Kf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hf(c)}function hn(c){var g=Vf();return function(){var l=ci(c),f;if(g){var v=ci(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Kf(this,f)}}function ks(c,g){return jf(c)||Gf(c,g)||Os(c,g)||qf()}function Ot(c){return Wf(c)||zf(c)||Os(c)||Yf()}function Wf(c){if(Array.isArray(c))return ln(c)}function jf(c){if(Array.isArray(c))return c}function zf(c){if(typeof Symbol<"u"&&c[Symbol.iterator]!=null||c["@@iterator"]!=null)return Array.from(c)}function Os(c,g){if(c){if(typeof c=="string")return ln(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ln(c,g)}}function ln(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function Yf(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
19
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
20
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function Ms(c){var g=Xf(c,"string");return typeof g=="symbol"?g:String(g)}var Mt={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},zt={AV1:"av1",AVC:"avc",HEVC:"hevc"},We={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus"},mt={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var Fs=function(){function c(){Se(this,c),Q(this,"id",1),Q(this,"type",Mt.VIDEO),Q(this,"codecType",zt.AVC),Q(this,"pid",-1),Q(this,"hvcC",void 0),Q(this,"codec",""),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"sequenceNumber",0),Q(this,"baseMediaDecodeTime",0),Q(this,"baseDts",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"pps",[]),Q(this,"sps",[]),Q(this,"vps",[]),Q(this,"fpsNum",0),Q(this,"fpsDen",0),Q(this,"sarRatio",[]),Q(this,"width",0),Q(this,"height",0),Q(this,"nalUnitSize",4),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"isVideo",!0),Q(this,"lastKeyFrameDts",0),Q(this,"kid",null),Q(this,"pssh",null),Q(this,"ext",void 0)}return Te(c,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),c}();var Ns=function(){function c(){Se(this,c),Q(this,"id",2),Q(this,"type",Mt.AUDIO),Q(this,"codecType",We.AAC),Q(this,"pid",-1),Q(this,"codec",""),Q(this,"sequenceNumber",0),Q(this,"sampleDuration",0),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"baseMediaDecodeTime",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"baseDts",0),Q(this,"sampleSize",16),Q(this,"sampleRate",0),Q(this,"channelCount",0),Q(this,"objectType",0),Q(this,"sampleRateIndex",0),Q(this,"config",[]),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"kid",null),Q(this,"ext",void 0)}return Te(c,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&(this.codecType===We.AAC||this.codecType===We.G711PCMA||this.codecType===We.G711PCMU||this.codecType===We.OPUS))}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}}]),c}();var Us=function(){function c(g,n,l){Se(this,c),Q(this,"flag",{}),Q(this,"keyframe",!1),Q(this,"gopId",0),Q(this,"duration",0),Q(this,"size",0),Q(this,"units",[]),Q(this,"chromaFormat",420),this.originPts=this.pts=g,this.originDts=this.dts=n,l&&(this.units=l)}return Te(c,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),c}();var Sr=Te(function c(g,n,l,f){Se(this,c),Q(this,"duration",1024),Q(this,"flag",{dependsOn:2,isNonSyncSample:0}),Q(this,"keyframe",!0),this.originPts=this.pts=this.dts=g,this.data=n,this.size=n.byteLength,this.sampleOffset=f,l&&(this.duration=l)});var Bs=Te(function c(g,n){Se(this,c),Q(this,"time",0),this.data=g,this.originPts=this.pts=n}),Gs=function(c){fn(n,c);var g=hn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Bs),Vs=function(c){fn(n,c);var g=hn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Bs),Hs=function(){function c(){Se(this,c),Q(this,"id",3),Q(this,"type",Mt.METADATA),Q(this,"timescale",0),Q(this,"flvScriptSamples",[]),Q(this,"seiSamples",[])}return Te(c,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),c}();var fr=function(){function c(g){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]")}return Te(c,[{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(fr,"disabled",!0);var vi=typeof window<"u",dn=vi&&navigator.userAgent.toLocaleLowerCase(),Ks=vi&&/^((?!chrome|android).)*safari/.test(dn),Ws=vi&&dn.includes("firefox"),js=vi&&dn.includes("android");var Tr=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getRateIndexByRate",value:function(n){return c.FREQ.indexOf(n)}},{key:"parseADTS",value:function(n,l){for(var f=n.length,v=0;v+2<f&&!(n[v]===255&&(n[v+1]&246)===240);)v++;if(!(v>=f)){var E=v,_=[],S=(n[v+2]&60)>>>2,C=c.FREQ[S];if(!C)throw new Error("Invalid sampling index: ".concat(S));for(var I=((n[v+2]&192)>>>6)+1,P=(n[v+2]&1)<<2|(n[v+3]&192)>>>6,H=c._getConfig(S,P,I),W=H.config,Y=H.codec,ee,J,ae=0,se=c.getFrameDuration(C);v+7<f;){if(n[v]!==255||(n[v+1]&246)!==240){v++;continue}if(J=(n[v+3]&3)<<11|n[v+4]<<3|(n[v+5]&224)>>5,!J||f-v<J)break;ee=(~n[v+1]&1)*2,_.push({pts:l+ae*se,data:n.subarray(v+7+ee,v+J)}),ae++,v+=J}return{skip:E,remaining:v>=f?void 0:n.subarray(v),frames:_,samplingFrequencyIndex:S,sampleRate:C,objectType:I,channelCount:P,codec:Y,config:W,originCodec:"mp4a.40.".concat(I)}}}},{key:"parseAudioSpecificConfig",value:function(n){if(n.length){var l=n[0]>>>3,f=(n[0]&7)<<1|n[1]>>>7,v=(n[1]&120)>>>3,E=c.FREQ[f];if(E){var _=c._getConfig(f,v,l),S=_.config,C=_.codec;return{samplingFrequencyIndex:f,sampleRate:E,objectType:l,channelCount:v,config:S,codec:C,originCodec:"mp4a.40.".concat(l)}}}}},{key:"getFrameDuration",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*l/n}},{key:"_getConfig",value:function(n,l,f){var v=[],E,_;return Ws?n>=6?(E=5,_=n-3):(E=2,_=n):js?(E=2,_=n):(E=f===2||f===5?f:5,_=n,n>=6?_=n-3:l===1&&(E=2,_=n)),v[0]=E<<3,v[0]|=(n&14)>>1,v[1]=(n&1)<<7,v[1]|=l<<3,E===5&&(v[1]|=(_&14)>>1,v[2]=(_&1)<<7,v[2]|=8,v[3]=0),{config:v,codec:"mp4a.40.".concat(E)}}},{key:"getSilentFrame",value:function(n,l){switch(n){case"mp4a.40.2":if(l===1)return new Uint8Array([0,200,0,128,35,128]);if(l===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(l===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(l===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(l===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(l===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(l===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(l===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(l===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),c}();Q(Tr,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Mr=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getFrameDuration",value:function(n){return 20}},{key:"parseHeaderPackets",value:function(n){if(n.length){for(var l=new DataView(n.buffer,n.byteOffset,n.byteLength),f="",v=0;v<8;v++)f+=String.fromCodePoint(n[v]);if(f!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var E=n[9];console.log("Pre-skip",n[10],n[11]);var _=l.getUint32(12,!0),S=l.getInt16(16,!0);if(_){var C="opus",I="opus",P=new Uint8Array(n.buffer,n.byteOffset+8,n.byteLength-8);return{outputGain:S,sampleRate:_,channelCount:E,config:P,codec:C,originCodec:I}}}}}]),c}();var $f=500,zs=3,cn=1e3,vn=5e3,Qf=1e3,Jf=200,Ys=5e3,qs=5,Xs=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n,this.metadataTrack=l,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return Te(c,[{key:"fix",value:function(){var n=this,l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;l=Math.round(l*1e3);var E=this.videoTrack,_=this.audioTrack;(f||!v)&&(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),f&&!v&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(_,E),!v&&l&&(this._audioNextPts=this._videoNextDts=l);var S=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(S&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(_),this._keyFrameInNextChunk=!1,this._fixVideo(E),this.metadataTrack.exist()){var C=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C}),this.metadataTrack.flvScriptSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C})}E.samples.length&&(E.baseMediaDecodeTime=E.samples[0].dts),_.samples.length&&(_.baseMediaDecodeTime=_.samples[0].pts*_.timescale/1e3)}},{key:"_fixVideo",value:function(n){var l=this,f=n.samples;if(f.length){f.forEach(function(se){se.dts-=l._baseDts,se.pts-=l._baseDts,se.keyframe&&(l._keyFrameInNextChunk=!0)});var v;if(n.fpsNum&&n.fpsDen)v=n.timescale*(n.fpsDen/n.fpsNum);else if(n.length>1){var E=n.samples[0],_=n.samples[f.length-1];v=Math.floor((_.dts-E.dts)/(f.length-1))}else v=this._lastVideoDuration||40;var S=f.pop();if(this._videoLastSample&&f.unshift(this._videoLastSample),this._videoLastSample=S,!!f.length){if(this._videoNextDts===void 0){var C=f[0];this._videoNextDts=C.dts}var I=f.length,P=0,H=f[0],W=this._videoNextDts-H.dts;if(Math.abs(W)>Jf){if(Math.abs(H.dts-this._lastVideoExceptionChunkFirstDtsDot)>Ys){var Y;this._lastVideoExceptionChunkFirstDtsDot=H.dts,n.warnings.push({type:mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:H.dts,nextSampleDts:(Y=f[1])===null||Y===void 0?void 0:Y.dts,sampleDuration:W})}this._videoTimestampBreak>=qs?(this._videoNextDts=H.dts,this._videoTimestampBreak=0):(H.dts+=W,H.pts+=W,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var ee=0;ee<I;ee++){var J=f[ee].dts,ae=f[ee+1];ee<I-1?P=ae.dts-J:S?P=S.dts-J:P=v,(P>Qf||P<0)&&(this._videoTimestampBreak++,Math.abs(J-this._lastVideoExceptionLargeGapDot)>Ys&&(this._lastVideoExceptionLargeGapDot=J,n.warnings.push({type:mt.LARGE_VIDEO_GAP,time:J/n.timescale,dts:J,originDts:f[ee].originDts,nextDts:this._videoNextDts,sampleDuration:P,refSampleDuration:v})),P=v),f[ee].duration=P,this._videoNextDts+=P,this._lastVideoDuration=P}}}}},{key:"_fixAudio",value:function(n){var l=this,f=n.samples;f.length&&(f.forEach(function(v){v.dts=v.pts-=l._baseDts}),this._doFixAudioInternal(n,f,1e3))}},{key:"_calculateBaseDts",value:function(n,l){var f=n.samples,v=l.samples;if(!f.length&&!v.length)return!1;var E=1/0,_=1/0;f.length&&(n.baseDts=E=f[0].pts),v.length&&(l.baseDts=_=v[0].dts),this._baseDts=Math.min(E,_);var S=_-E;return Number.isFinite(S)&&Math.abs(S)>$f&&l.warnings.push({type:mt.LARGE_AV_SHIFT,videoBaseDts:_,audioBasePts:E,baseDts:this._baseDts,delta:S}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var n=this._calculateBaseDts(this.audioTrack,this.videoTrack);n&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(n,l,f){if(!n.sampleDuration)switch(n.codecType){case We.AAC:{n.sampleDuration=Tr.getFrameDuration(n.timescale,f);break}case We.OPUS:{n.sampleDuration=Mr.getFrameDuration(n.samples,f);break}case We.G711PCMA:case We.G711PCMU:{n.sampleDuration=this._getG711Duration(n);break}default:console.error("can't fix audio codecType:",n.codecType);break}var v=n.sampleDuration,E=n.codecType===We.OPUS?20:n.codecType===We.AAC?1024:v*n.timescale/1e3;if(this._audioNextPts===void 0){var _=l[0];this._audioNextPts=_.pts}for(var S=0;S<l.length;S++){var C=this._audioNextPts,I=l[S],P=I.pts-C;if(S===0&&this._audioTimestampBreak>=qs&&this._keyFrameInNextChunk&&(C=this._audioNextPts=I.dts,P=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&P>=zs*v&&P<=cn&&!Ks){var H=this._getSilentFrame(n)||l[0].data.subarray(),W=Math.floor(P/v);Math.abs(I.pts-this._lastAudioExceptionGapDot)>vn&&(this._lastAudioExceptionGapDot=I.pts,n.warnings.push({type:mt.AUDIO_FILLED,pts:I.pts,originPts:I.originPts,count:W,nextPts:C,refSampleDuration:v}));for(var Y=0;Y<W;Y++){var ee=new Sr(Math.floor(this._audioNextPts+v)-Math.floor(this._audioNextPts),H,E);ee.originPts=Math.floor(this._baseDts+C),l.splice(S,0,ee),this._audioNextPts+=v,S++}S--}else if(P<=-zs*v&&P>=-1*cn)Math.abs(I.pts-this._lastAudioExceptionOverlapDot)>vn&&(this._lastAudioExceptionOverlapDot=I.pts,n.warnings.push({type:mt.AUDIO_DROPPED,pts:I.pts,originPts:I.originPts,nextPts:C,refSampleDuration:v})),l.splice(S,1),S--;else{if(Math.abs(P)>cn&&(this._audioTimestampBreak++,Math.abs(I.pts-this._lastAudioExceptionLargeGapDot)>vn&&(this._lastAudioExceptionLargeGapDot=I.pts,n.warnings.push({type:mt.LARGE_AUDIO_GAP,time:I.pts/1e3,pts:I.pts,originPts:I.originPts,nextPts:C,sampleDuration:P,refSampleDuration:v}))),n.codecType===We.OPUS){var J=l[l.length-1];J&&(J.duration=I.pts-J.pts)}else I.dts=I.pts=C,I.duration=E;this._audioNextPts+=v}}}},{key:"_getG711Duration",value:function(n){var l=n.sampleSize,f=n.channelCount,v=n.sampleRate,E=n.samples[0];if(E)return E.data.byteLength*2/f/(l/8)/v*1e3}},{key:"_getSilentFrame",value:function(n){return n.codecType===We.AAC?Tr.getSilentFrame(n.codec,n.channelCount):new Uint8Array(8*n.sampleDuration*n.channelCount)}}]),c}();function xt(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];g=g.filter(Boolean);var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}var fc=Math.pow(2,32);function xr(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(c[g]<<24>>>0)+(c[g+1]<<16)+(c[g+2]<<8)+(c[g+3]||0)}function $s(c){for(var g="avc1.",n,l=0;l<3;l++)n=c[l].toString(16),n.length<2&&(n="0".concat(n)),g+=n;return g}function pn(c){if(!Array.isArray(c)){for(var g=[],n="",l=0;l<c.length;l++)l%2&&(n=c[l-1]+c[l],g.push(parseInt(n,16)),n="");return g}return c.map(function(f){return parseInt(f,16)})}var Yt=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAnnexB",value:function(n){for(var l=n.length,f=2,v=0;n[f]!==null&&n[f]!==void 0&&n[f]!==1;)f++;if(f++,v=f+2,v>=l)return[];for(var E=[];v<l;)switch(n[v]){case 0:if(n[v-1]!==0){v+=2;break}else if(n[v-2]!==0){v++;break}f!==v-2&&E.push(n.subarray(f,v-2));do v++;while(n[v]!==1&&v<l);f=v+1,v=f+2;break;case 1:if(n[v-1]!==0||n[v-2]!==0){v+=3;break}f!==v-2&&E.push(n.subarray(f,v-2)),f=v+1,v=f+2;break;default:v+=3;break}return f<l&&E.push(n.subarray(f)),E}},{key:"parseAvcC",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(n.length<4)){for(var f=n.length,v=[],E=0,_;E+l<f;)if(_=xr(n,E),l===3&&(_>>>=8),E+=l,!!_){if(E+_>f)break;v.push(n.subarray(E,E+_)),E+=_}return v}}},{key:"parseSEI",value:function(n,l){for(var f=n.length,v=l?2:1,E=0,_=0,S="";n[v]===255;)E+=255,v++;for(E+=n[v++];n[v]===255;)_+=255,v++;if(_+=n[v++],E===5&&f>v+16)for(var C=0;C<16;C++)S+=n[v].toString(16),v++;return{payload:n.subarray(v,v+_),type:E,size:_,uuid:S}}},{key:"removeEPB",value:function(n){for(var l=n.byteLength,f=[],v=1;v<l-2;)n[v]===0&&n[v+1]===0&&n[v+2]===3?(f.push(v+2),v+=2):v++;if(!f.length)return n;var E=l-f.length,_=new Uint8Array(E),S=0;for(v=0;v<E;S++,v++)S===f[0]&&(S++,f.shift()),_[v]=n[S];return _}}]),c}();var Fr=function(){function c(g){if(Se(this,c),Q(this,"_bytesAvailable",void 0),Q(this,"_bitsAvailable",0),Q(this,"_word",0),!g)throw new Error("ExpGolomb data params is required");this._data=g,this._bytesAvailable=g.byteLength,this._bytesAvailable&&this._loadWord()}return Te(c,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var n=this._data.byteLength-this._bytesAvailable,l=Math.min(4,this._bytesAvailable);if(l===0)throw new Error("No bytes available");var f=new Uint8Array(4);f.set(this._data.subarray(n,n+l)),this._word=new DataView(f.buffer).getUint32(0),this._bitsAvailable=l*8,this._bytesAvailable-=l}},{key:"skipBits",value:function(n){if(this._bitsAvailable>n)this._word<<=n,this._bitsAvailable-=n;else{n-=this._bitsAvailable;var l=Math.floor(n/8);n-=l*8,this._bytesAvailable-=l,this._loadWord(),this._word<<=n,this._bitsAvailable-=n}}},{key:"readBits",value:function(n){if(n>32)throw new Error("Cannot read more than 32 bits");var l=Math.min(this._bitsAvailable,n),f=this._word>>>32-l;return this._bitsAvailable-=l,this._bitsAvailable>0?this._word<<=l:this._bytesAvailable>0&&this._loadWord(),l=n-l,l>0&&this._bitsAvailable?f<<l|this.readBits(l):f}},{key:"skipLZ",value:function(){var n;for(n=0;n<this._bitsAvailable;++n)if(this._word&2147483648>>>n)return this._word<<=n,this._bitsAvailable-=n,n;return this._loadWord(),n+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var n=this.skipLZ();return this.readBits(n+1)-1}},{key:"readEG",value:function(){var n=this.readUEG();return 1&n?1+n>>>1:-1*(n>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(n){for(var l=8,f=8,v,E=0;E<n;E++)f!==0&&(v=this.readEG(),f=(l+v+256)%256),l=f===0?l:f}}]),c}();var Qs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(n){if(!(n.length<7)){for(var l=(n[4]&3)+1,f,v=[],E=[],_=6,S=n[5]&31,C,I=0;I<S;I++)if(C=n[_]<<8|n[_+1],_+=2,!!C){var P=n.subarray(_,_+C);_+=C,v.push(P),f||(f=c.parseSPS(Yt.removeEPB(P)))}var H=n[_];_++;for(var W,Y=0;Y<H;Y++)W=n[_]<<8|n[_+1],_+=2,W&&(E.push(n.subarray(_,_+W)),_+=W);return{sps:f,spsArr:v,ppsArr:E,nalUnitSize:l}}}},{key:"parseSPS",value:function(n){var l=new Fr(n);l.readUByte();var f=l.readUByte(),v=l.readUByte(),E=l.readUByte();l.skipUEG();var _=420;if(f===100||f===110||f===122||f===244||f===44||f===83||f===86||f===118||f===128||f===138||f===144){var S=l.readUEG();if(S<=3&&(_=[0,420,422,444][S]),S===3&&l.skipBits(1),l.skipUEG(),l.skipUEG(),l.skipBits(1),l.readBool())for(var C=S!==3?8:12,I=0;I<C;I++)l.readBool()&&(I<6?l.skipScalingList(16):l.skipScalingList(64))}l.skipUEG();var P=l.readUEG();if(P===0)l.readUEG();else if(P===1){l.skipBits(1),l.skipUEG(),l.skipUEG();for(var H=l.readUEG(),W=0;W<H;W++)l.skipUEG()}l.skipUEG(),l.skipBits(1);var Y=l.readUEG(),ee=l.readUEG(),J=l.readBits(1);J===0&&l.skipBits(1),l.skipBits(1);var ae=0,se=0,_e=0,oe=0;l.readBool()&&(ae=l.readUEG(),se=l.readUEG(),_e=l.readUEG(),oe=l.readUEG());var j,ue,Ve,R,le;if(l.readBool()){if(l.readBool()){var G=l.readUByte();switch(G){case 1:j=[1,1];break;case 2:j=[12,11];break;case 3:j=[10,11];break;case 4:j=[16,11];break;case 5:j=[40,33];break;case 6:j=[24,11];break;case 7:j=[20,11];break;case 8:j=[32,11];break;case 9:j=[80,33];break;case 10:j=[18,11];break;case 11:j=[15,11];break;case 12:j=[64,33];break;case 13:j=[160,99];break;case 14:j=[4,3];break;case 15:j=[3,2];break;case 16:j=[2,1];break;case 255:{j=[l.readUByte()<<8|l.readUByte(),l.readUByte()<<8|l.readUByte()];break}}}if(l.readBool()&&l.readBool(),l.readBool()&&(l.readBits(4),l.readBool()&&l.readBits(24)),l.readBool()&&(l.readUEG(),l.readUEG()),l.readBool()){var He=l.readBits(32),F=l.readBits(32);ue=l.readBool(),Ve=F,R=He*2,le=Ve/R}}return{codec:$s(n.subarray(1,4)),profileIdc:f,profileCompatibility:v,levelIdc:E,chromaFormat:_,width:Math.ceil((Y+1)*16-2*(ae+se)),height:(2-J)*(ee+1)*16-(J?2:4)*(_e+oe),sarRatio:j,fpsNum:Ve,fpsDen:R,fps:le,fixedFrame:ue}}}]),c}();var Js=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(n.length<23)){l=l||{};for(var f=(n[21]&3)+1,v,E,_=[],S=[],C=[],I=23,P=n[22],H,W,Y,ee=0;ee<P;ee++){H=n[I]&63,W=n[I+1]<<8|n[I+2],I+=3;for(var J=0;J<W;J++)if(Y=n[I]<<8|n[I+1],I+=2,!!Y){switch(H){case 32:{var ae=n.subarray(I,I+Y);v||(v=c.parseVPS(Yt.removeEPB(ae),l)),C.push(ae)}break;case 33:{var se=n.subarray(I,I+Y);E||(E=c.parseSPS(Yt.removeEPB(se),l)),_.push(se)}break;case 34:S.push(n.subarray(I,I+Y));break}I+=Y}}return{hvcC:l,sps:E,spsArr:_,ppsArr:S,vpsArr:C,nalUnitSize:f}}}},{key:"parseVPS",value:function(n,l){l=l||{};var f=new Fr(n);f.readUByte(),f.readUByte(),f.readBits(12);var v=f.readBits(3);return l.numTemporalLayers=Math.max(l.numTemporalLayers||0,v+1),f.readBits(17),c._parseProfileTierLevel(f,v,l),l}},{key:"parseSPS",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};l=l||{};var f=new Fr(n);f.readUByte(),f.readUByte(),f.readBits(4);var v=f.readBits(3);l.numTemporalLayers=Math.max(v+1,l.numTemporalLayers||0),l.temporalIdNested=f.readBits(1),c._parseProfileTierLevel(f,v,l),f.readUEG();var E=l.chromaFormatIdc=f.readUEG(),_=420;E<=3&&(_=[0,420,422,444][E]);var S=0;E===3&&(S=f.readBits(1));var C=f.readUEG(),I=f.readUEG(),P=f.readBits(1),H,W,Y,ee;if(P===1&&(H=f.readUEG(),W=f.readUEG(),Y=f.readUEG(),ee=f.readUEG()),l.bitDepthLumaMinus8=f.readUEG(),l.bitDepthChromaMinus8=f.readUEG(),P===1){var J=(E===1||E===2)&&S===0?2:1,ae=E===1&&S===0?2:1;C-=J*(W+H),I-=ae*(ee+Y)}return{codec:"hev1.1.6.L93.B0",width:C,height:I,chromaFormat:_,hvcC:l}}},{key:"_parseProfileTierLevel",value:function(n,l,f){var v=f.generalTierFlag||0;f.generalProfileSpace=n.readBits(2),f.generalTierFlag=Math.max(n.readBits(1),v),f.generalProfileIdc=Math.max(n.readBits(5),f.generalProfileIdc||0),f.generalProfileCompatibilityFlags=n.readBits(32),f.generalConstraintIndicatorFlags=[n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8)];var E=n.readBits(8);v<f.generalTierFlag?f.generalLevelIdc=E:f.generalLevelIdc=Math.max(E,f.generalLevelIdc||0);var _=[],S=[];if(l>n.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(l));for(var C=0;C<l;C++)_[C]=n.readBits(1),S[C]=n.readBits(1);l>0&&n.readBits((8-l)*2);for(var I=0;I<l;I++)_[I]!==0&&(n.readBits(2),n.readBits(1),n.readBits(5),n.readBits(16),n.readBits(16),n.readBits(4),n.readBits(16),n.readBits(16),n.readBits(12)),S[I]!==0&&n.readBits(8)}}]),c}();var mn=function(){function c(){Se(this,c)}return Te(c,null,[{key:"decode",value:function(n){for(var l=[],f=n,v=0,E=n.length;v<E;){if(f[v]<128){l.push(String.fromCharCode(f[v])),++v;continue}else if(!(f[v]<192)){if(f[v]<224){if(c._checkContinuation(f,v,1)){var _=(f[v]&31)<<6|f[v+1]&63;if(_>=128){l.push(String.fromCharCode(_&65535)),v+=2;continue}}}else if(f[v]<240){if(c._checkContinuation(f,v,2)){var S=(f[v]&15)<<12|(f[v+1]&63)<<6|f[v+2]&63;if(S>=2048&&(S&63488)!==55296){l.push(String.fromCharCode(S&65535)),v+=3;continue}}}else if(f[v]<248&&c._checkContinuation(f,v,3)){var C=(f[v]&7)<<18|(f[v+1]&63)<<12|(f[v+2]&63)<<6|f[v+3]&63;if(C>65536&&C<1114112){C-=65536,l.push(String.fromCharCode(C>>>10|55296)),l.push(String.fromCharCode(C&1023|56320)),v+=4;continue}}}l.push("\uFFFD"),++v}return l.join("")}},{key:"_checkContinuation",value:function(n,l,f){var v=n;if(l+f<v.length){for(;f--;)if((v[++l]&192)!==128)return!1;return!0}else return!1}}]),c}();var Zs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parse",value:function(n){if(!(n.length<3)){var l={},f=c._parseValue(new DataView(n.buffer,n.byteOffset,n.byteLength)),v=c._parseValue(new DataView(n.buffer,n.byteOffset+f.size,n.byteLength-f.size));return l[f.data]=v.data,l}}},{key:"_parseValue",value:function(n){var l=n.byteLength,f=n.getUint8(0),v=1,E=!1,_;switch(f){case 0:_=n.getFloat64(1),v+=8;break;case 1:{_=!!n.getUint8(1),v+=1;break}case 2:{var S=c._parseString(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),C=S.data,I=S.size;_=C,v+=I}break;case 3:{_={};var P=0;for((n.getUint32(l-4)&16777215)===9&&(P=3);v<l-4;){var H=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-P)),W=H.size,Y=H.data,ee=H.isEnd;if(ee)break;_[Y.name]=Y.value,v+=W}if(v<=l-3){var J=n.getUint32(v-1)&16777215;J===9&&(v+=3)}}break;case 8:{_={},v+=4;var ae=0;for((n.getUint32(l-4)&16777215)===9&&(ae=3);v<l-8;){var se=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-ae)),_e=se.size,oe=se.data,j=se.isEnd;if(j)break;_[oe.name]=oe.value,v+=_e}if(v<=l-3){var ue=n.getUint32(v-1)&16777215;ue===9&&(v+=3)}}break;case 9:_=void 0,v=1,E=!0;break;case 10:{_=[];var Ve=n.getUint32(1);v+=4;for(var R=0;R<Ve;R++){var le=c._parseValue(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),G=le.data,He=le.size;_.push(G),v+=He}}break;case 11:{var F=n.getFloat64(v)+n.getInt16(v+8)*6e4;_=new Date(F),v+=10}break;case 12:{var O=n.getUint32(1);v+=4,_="",O>0&&(_=mn.decode(new Uint8Array(n.buffer,n.byteOffset+v,O))),v+=O}break;default:v=l;break}return{data:_,size:v,isEnd:E}}},{key:"_parseString",value:function(n){var l=n.getUint16(0),f="";return l>0&&(f=mn.decode(new Uint8Array(n.buffer,n.byteOffset+2,l))),{data:f,size:2+l}}},{key:"_parseObject",value:function(n){if(!(n.byteLength<3)){var l=c._parseString(n),f=c._parseValue(new DataView(n.buffer,n.byteOffset+l.size,n.byteLength-l.size));return{data:{name:l.data,value:f.data},size:l.size+f.size,isEnd:f.isEnd}}}}]),c}();var Ft={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Nt=new fr("FlvDemuxer"),pi=function(){function c(g,n,l){Se(this,c),Q(this,"_headerParsed",!1),Q(this,"_remainingData",null),Q(this,"_gopId",0),Q(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=g||new Fs,this.audioTrack=n||new Ns,this.metadataTrack=l||new Hs,this._fixer=new Xs(this.videoTrack,this.audioTrack,this.metadataTrack)}return Te(c,[{key:"demux",value:function(n){var l,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,E=arguments.length>3?arguments[3]:void 0,_=this.audioTrack,S=this.videoTrack,C=this.metadataTrack;if((f||!v)&&(this._remainingData=null),f&&(this._headerParsed=!1),f?(S.reset(),_.reset(),C.reset()):(S.samples=[],_.samples=[],C.seiSamples=[],C.flvScriptSamples=[],S.warnings=[],_.warnings=[],this._remainingData&&(n=xt(this._remainingData,n),this._remainingData=null)),!n.length)return{videoTrack:S,audioTrack:_,metadataTrack:C};var I=0;if(!this._headerParsed){if(!c.probe(n))throw new Error("Invalid flv file");_.present=(n[4]&4)>>>2!==0,S.present=(n[4]&1)!==0,this._headerParsed=!0,I=xr(n,5)+4}for(var P=n.length,H,W,Y,ee,J;I+15<P&&(H=n[I],W=n[I+1]<<16|n[I+2]<<8|n[I+3],!(I+15+W>P));)Y=(n[I+7]<<24>>>0)+(n[I+4]<<16)+(n[I+5]<<8)+n[I+6],I+=11,ee=n.subarray(I,I+W),H===8?this._parseAudio(ee,Y):H===9?(E&&(this.seamlessLoadingSwitching=!0),this._parseVideo(ee,Y)):H===18?this._parseScript(ee,Y):Nt.warn("Invalid tag type: ".concat(H)),I+=W,J=xr(n,I),J!==11+W&&Nt.warn("Invalid PrevTagSize ".concat(J," (").concat(11+W,")")),I+=4;I<P&&(this._remainingData=n.subarray(I)),_.formatTimescale=S.formatTimescale=S.timescale=C.timescale=1e3,_.timescale=_.codecType===We.OPUS?1e3:_.sampleRate||0,!_.exist()&&_.hasSample()&&_.reset(),!S.exist()&&S.hasSample()&&S.reset();var ae=C.flvScriptSamples[C.flvScriptSamples.length-1],se=ae==null||(l=ae.data)===null||l===void 0?void 0:l.onMetaData;return se&&(S!=null&&S.exist()&&(se.hasOwnProperty("duration")&&(S.duration=se.duration*1e3),se.hasOwnProperty("width")&&se.hasOwnProperty("height")&&(S.width=se.width,S.height=se.height)),_!=null&&_.exist()&&se.hasOwnProperty("duration")&&(_.duration=se.duration*1e3)),{videoTrack:S,audioTrack:_,metadataTrack:C}}},{key:"fix",value:function(n,l,f){return this._fixer.fix(n,l,f),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(n,l,f,v,E){return this.demux(n,l,f,E),this.fix(v,l,f)}},{key:"_parseAudio",value:function(n,l){if(n.length){var f=(n[0]&240)>>>4,v=this.audioTrack;if(f!==Ft.AAC&&f!==Ft.G711A&&f!==Ft.G711M&&f!==Ft.OPUS){Nt.warn("Unsupported sound format: ".concat(f)),v.reset();return}if(f!==Ft.AAC&&f!==Ft.OPUS){var E=(n[0]&12)>>2,_=(n[0]&2)>>1,S=n[0]&1;v.sampleRate=c.AUDIO_RATE[E],v.sampleSize=_?16:8,v.channelCount=S+1}switch(f){case Ft.G711A:case Ft.G711M:this._parseG711(n,l,f);break;case Ft.AAC:this._parseAac(n,l);break;case Ft.OPUS:this._parseOpus(n,l);break}}}},{key:"_parseOpus",value:function(n,l){var f=this.audioTrack,v=n[1];switch(f.codecType=We.OPUS,v){case 0:{var E=Mr.parseHeaderPackets(n.subarray(2));E?(f.codec=E.codec,f.channelCount=E.channelCount,f.sampleRate=E.sampleRate,f.config=E.config,f.sampleDuration=Mr.getFrameDuration([],f.timescale)):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n));break}case 1:{if(l==null)return;var _=new Sr(l,n.subarray(2),f.sampleDuration);f.samples.push(_);break}default:Nt.warn("Unknown OpusPacketType: ".concat(v))}}},{key:"_parseG711",value:function(n,l,f){var v=this.audioTrack;v.codecType=f===7?We.G711PCMA:We.G711PCMU,v.sampleRate=8e3,v.codec=v.codecType,v.samples.push(new Sr(l,n.subarray(1)))}},{key:"_parseAac",value:function(n,l){var f=this.audioTrack;if(f.codecType=We.AAC,n[1]===0){var v=Tr.parseAudioSpecificConfig(n.subarray(2));v?(f.codec=v.codec,f.channelCount=v.channelCount,f.sampleRate=v.sampleRate,f.config=v.config,f.objectType=v.objectType,f.sampleRateIndex=v.samplingFrequencyIndex):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n))}else if(n[1]===1){if(l==null)return;f.samples.push(new Sr(l,n.subarray(2)))}else Nt.warn("Unknown AACPacketType: ".concat(n[1]))}},{key:"_parseVideo",value:function(n,l){var f=this;if(!(n.length<6)){var v=(n[0]&240)>>>4,E=n[0]&15,_=this.videoTrack;if(E!==7&&E!==12){_.reset(),Nt.warn("Unsupported codecId: ".concat(E));return}var S=E===12;_.codecType=S?zt.HEVC:zt.AVC;var C=n[1],I=(n[2]<<16|n[3]<<8|n[4])<<8>>8;if(C===0){var P=n.subarray(5),H=S?Js.parseHEVCDecoderConfigurationRecord(P):Qs.parseAVCDecoderConfigurationRecord(P);if(H){var W=H.hvcC,Y=H.sps,ee=H.ppsArr,J=H.spsArr,ae=H.vpsArr,se=H.nalUnitSize;W&&(_.hvcC=_.hvcC||W),Y&&(_.codec=Y.codec,_.width=Y.width,_.height=Y.height,_.sarRatio=Y.sarRatio,_.fpsNum=Y.fpsNum,_.fpsDen=Y.fpsDen),J.length&&(_.sps=J),ee.length&&(_.pps=ee),ae&&ae.length&&(_.vps=ae),se&&(_.nalUnitSize=se)}else Nt.warn("Cannot parse ".concat(S?"HEVC":"AVC","DecoderConfigurationRecord"),n)}else if(C===1){var _e=Yt.parseAvcC(n.subarray(5),_.nalUnitSize);if(_e=this._checkAddMetaNalToUnits(S,_e,_),_e&&_e.length){var oe=new Us(l+I,l,_e);if(this.seamlessLoadingSwitching&&l<_.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,v===1&&(oe.setToKeyframe(),_.lastKeyFrameDts=l),_.samples.push(oe),_e.forEach(function(j){var ue=S?j[0]>>>1&63:j[0]&31;switch(ue){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!S&&ue!==5||S&&ue===5)break;oe.setToKeyframe();break;case 6:case 39:case 40:if(!S&&ue!==6||S&&ue===6)break;f.metadataTrack.seiSamples.push(new Vs(Yt.parseSEI(Yt.removeEPB(j),S),l+I));break}}),oe.keyframe&&this._gopId++,oe.gopId=this._gopId}else Nt.warn("Cannot parse NALUs",n)}else C===2||Nt.warn("Unknown AVCPacketType: ".concat(C))}}},{key:"_checkAddMetaNalToUnits",value:function(n,l,f){if(!n||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,l;var v=l.map(function(E){return E[0]>>>1&63});return v.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,l):(l.unshift(f.pps[0]),l.unshift(f.sps[0]),l.unshift(f.vps[0]),l.filter(Boolean))}},{key:"_parseScript",value:function(n,l){this.metadataTrack.flvScriptSamples.push(new Gs(Zs.parse(n),l))}}],[{key:"probe",value:function(n){return n[0]!==70||n[1]!==76||n[2]!==86||n[3]!==1?!1:xr(n,5)>=9}}]),c}();Q(pi,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function Zf(c){for(var g=0,n=arguments.length,l=new Array(n>1?n-1:0),f=1;f<n;f++)l[f-1]=arguments[f];l.forEach(function(_){g+=_.length});var v=new c(g),E=0;return l.forEach(function(_){v.set(_,E),E+=_.length}),v}var lt=function(){function c(){Se(this,c),this.buffer=new Uint8Array(0)}return Te(c,[{key:"write",value:function(){for(var n=this,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];f.forEach(function(E){E?n.buffer=Zf(Uint8Array,n.buffer,E):window.console.warn(E)})}}],[{key:"writeUint16",value:function(n){return new Uint8Array([n>>8&255,n&255])}},{key:"writeUint32",value:function(n){return new Uint8Array([n>>24,n>>16&255,n>>8&255,n&255])}}]),c}();var eo=Math.pow(2,32)-1,xe=function(){function c(){Se(this,c)}return Te(c,null,[{key:"box",value:function(n){for(var l=arguments.length,f=new Array(l>1?l-1:0),v=1;v<l;v++)f[v-1]=arguments[v];f=f.filter(Boolean);var E=8+f.reduce(function(C,I){return C+I.byteLength},0),_=new Uint8Array(E);_[0]=E>>24&255,_[1]=E>>16&255,_[2]=E>>8&255,_[3]=E&255,_.set(n,4);var S=8;return f.forEach(function(C){_.set(C,S),S+=C.byteLength}),_}},{key:"ftyp",value:function(n){var l=n.find(function(f){return f.type===Mt.VIDEO&&f.codecType===zt.HEVC});return l?c.FTYPHEV1:c.FTYPAVC1}},{key:"initSegment",value:function(n){var l=c.ftyp(n),f=xt(l,c.moov(n));return f}},{key:"pssh",value:function(n){var l=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],pn(n.kid),[0,0,0,0]));return c.box(c.types.pssh,l)}},{key:"moov",value:function(n){if(n[0].useEME&&(n[0].encv||n[0].enca)){n[0].pssh||(n[0].pssh={kid:n[0].kid});var l=this.pssh(n[0].pssh);return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale),c.mvex(n)].concat(Ot(n.map(function(f){return c.trak(f)})),[l]))}else return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale)].concat(Ot(n.map(function(f){return c.trak(f)})),[c.mvex(n)]))}},{key:"mvhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return f}},{key:"trak",value:function(n){var l=c.box(c.types.trak,c.tkhd(n.id,n.tkhdDuration||0,n.width,n.height),c.mdia(n));return l}},{key:"tkhd",value:function(n,l){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,E=c.box(c.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,f>>8&255,f&255,0,0,v>>8&255,v&255,0,0]));return E}},{key:"mdia",value:function(n){var l=c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minf(n));return l}},{key:"mdhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,85,196,0,0]));return f}},{key:"hdlr",value:function(n){var l=c.box(c.types.hdlr,c.HDLR_TYPES[n]);return l}},{key:"minf",value:function(n){var l=c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stbl(n));return l}},{key:"stbl",value:function(n){var l=[];n&&n.ext&&n.ext.stss&&l.push(c.stss(n.ext.stss.entries));var f=c.box(c.types.stbl,c.stsd(n),c.STTS,l[0],c.STSC,c.STSZ,c.STCO);return f}},{key:"stsd",value:function(n){var l;n.type==="audio"?n.useEME&&n.enca?l=c.enca(n):n.codecType===We.OPUS?l=c.opus(n):l=c.mp4a(n):n.useEME&&n.encv?l=c.encv(n):n.av1C?l=c.av01(n):l=c.avc1hev1(n);var f=c.box(c.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),l);return f}},{key:"enca",value:function(n){var l=n.enca.channelCount,f=n.enca.sampleRate,v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,l,0,16,0,0,0,0,f>>8&255,f&255,0,0]),E=c.esds(n.config),_=c.sinf(n.enca);return c.box(c.types.enca,v,E,_)}},{key:"encv",value:function(n){var l,f,v=n.sps.length>0?n.sps[0]:[],E=n.pps.length>0?n.pps[0]:[],_=n.width,S=n.height,C=n.sarRatio[0],I=n.sarRatio[1],P=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_>>8&255,_&255,S>>8&255,S&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),H=new Uint8Array((l=(f=[1,v[1],v[2],v[3],255,225,v.length>>>8&255,v.length&255]).concat.apply(f,Ot(v)).concat([1,E.length>>>8&255,E.length&255])).concat.apply(l,Ot(E))),W=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),Y=c.sinf(n.encv),ee=new Uint8Array([C>>24,C>>16&255,C>>8&255,C&255,I>>24,I>>16&255,I>>8&255,I&255]);return c.box(c.types.encv,P,c.box(c.types.avcC,H),c.box(c.types.btrt,W),Y,c.box(c.types.pasp,ee))}},{key:"schi",value:function(n){var l=new Uint8Array([]),f=c.tenc(n);return c.box(c.types.schi,l,f)}},{key:"tenc",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,n.default_IsEncrypted&255,n.default_IV_size&255].concat(pn(n.default_KID)));return c.box(c.types.tenc,l)}},{key:"sinf",value:function(n){var l=new Uint8Array([]),f=new Uint8Array([n.data_format.charCodeAt(0),n.data_format.charCodeAt(1),n.data_format.charCodeAt(2),n.data_format.charCodeAt(3)]),v=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),E=c.schi(n);return c.box(c.types.sinf,l,c.box(c.types.frma,f),c.box(c.types.schm,v),E)}},{key:"av01",value:function(n){return c.box(c.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n.av1C,n.colr)}},{key:"avc1hev1",value:function(n){var l=n.codecType===zt.HEVC,f=l?c.types.hvc1:c.types.avc1,v=l?c.hvcC(n):c.avcC(n),E=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),v];return l?E.push(c.box(c.types.fiel,new Uint8Array([1,0]))):n.sarRatio&&n.sarRatio.length>1&&E.push(c.pasp(n.sarRatio)),c.box.apply(c,[f].concat(E))}},{key:"avcC",value:function(n){var l,f,v=[],E=[],_;return n.sps.forEach(function(S){_=S.byteLength,v.push(_>>>8&255),v.push(_&255),v.push.apply(v,Ot(S))}),n.pps.forEach(function(S){_=S.byteLength,E.push(_>>>8&255),E.push(_&255),E.push.apply(E,Ot(S))}),c.box(c.types.avcC,new Uint8Array((l=(f=[1,v[3],v[4],v[5],255,224|n.sps.length]).concat.apply(f,v).concat([n.pps.length])).concat.apply(l,E)))}},{key:"hvcC",value:function(n){var l=n.hvcC;if(l instanceof ArrayBuffer||l instanceof Uint8Array)return l;var f=n.vps,v=n.sps,E=n.pps,_;if(l){var S=l.generalProfileCompatibilityFlags,C=l.generalConstraintIndicatorFlags,I=(f.length&&1)+(v.length&&1)+(E.length&&1);_=[1,l.generalProfileSpace<<6|l.generalTierFlag<<5|l.generalProfileIdc,S>>>24,S>>>16,S>>>8,S,C[0],C[1],C[2],C[3],C[4],C[5],l.generalLevelIdc,240,0,252,l.chromaFormatIdc|252,l.bitDepthLumaMinus8|248,l.bitDepthChromaMinus8|248,0,0,l.numTemporalLayers<<3|l.temporalIdNested<<2|3,I];var P=function(W){var Y;_.push(W.length>>8,W.length),(Y=_).push.apply(Y,Ot(W))};f.length&&(_.push(160,0,f.length),f.forEach(P)),v.length&&(_.push(161,0,v.length),v.forEach(P)),E.length&&(_.push(162,0,E.length),E.forEach(P))}else _=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return c.box(c.types.hvcC,new Uint8Array(_))}},{key:"pasp",value:function(n){var l=ks(n,2),f=l[0],v=l[1];return c.box(c.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"mp4a",value:function(n){return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),n.config.length?c.esds(n.config):void 0)}},{key:"esds",value:function(n){var l=n.length,f=c.box(c.types.esds,new Uint8Array([0,0,0,0,3,23+l,0,0,0,4,15+l,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([l]).concat(n).concat([6,1,2])));return f}},{key:"opus",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),f=n.config.length?c.dOps(n):[];return c.box(c.types.Opus,l,f)}},{key:"dOps",value:function(n){if(n.config)return n.config[4]=n.sampleRate>>>24&255,n.config[5]=n.sampleRate>>>16&255,n.config[6]=n.sampleRate>>>8&255,n.config[7]=n.sampleRate&255,c.box(c.types.dOps,n.config)}},{key:"mvex",value:function(n){var l=c.box.apply(c,[c.types.mvex].concat(Ot(n.map(function(f){return c.trex(f.id)}))));return l}},{key:"trex",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return l}},{key:"trex1",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return l}},{key:"trex2",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return l}},{key:"moof",value:function(n){var l=c.box.apply(c,[c.types.moof,c.mfhd(n[0].samples?n[0].samples[0].gopId:0)].concat(Ot(n.map(function(f){return c.traf(f)}))));return l}},{key:"mfhd",value:function(n){var l=c.box(c.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]));return l}},{key:"traf",value:function(n){var l=c.tfhd(n.id),f=c.tfdt(n,n.baseMediaDecodeTime),v=0,E;if(n.isVideo&&n.videoSenc&&(E=n.videoSenc,E.forEach(function(O){v=v+8,O.subsamples&&O.subsamples.length&&(v=v+2,v=v+O.subsamples.length*6)})),n.videoSencLength=v,!n.useEME||!n.isVideoEncryption&&!n.isAudioEncryption){var _=c.sdtp(n),S=76;return c.box(c.types.traf,l,f,_,c.trun(n.samples,_.byteLength+S))}else if(n.isVideoEncryption)if(n.isVideo){var C=c.saiz(n),I=c.saio(n),P=c.trun1(n),H=c.senc(n),W=c.box(c.types.traf,l,f,C,I,P,H);return W}else if(n.isAudioEncryption){var J=c.sbgp(),ae=c.saiz(n),se=c.saio(n),_e=c.senc(n),oe=c.trun1(n),j=c.box(c.types.traf,l,f,J,ae,se,_e,oe);return j}else{var Y=c.sbgp(),ee=c.trun1(n);return c.box(c.types.traf,l,f,Y,ee)}else if(n.isVideo){var ue=c.trun1(n);return c.box(c.types.traf,l,f,ue)}else{var Ve=c.sbgp(),R=c.saiz(n),le=c.saio(n),G=c.senc(n),He=c.trun1(n),F=c.box(c.types.traf,l,f,Ve,R,le,G,He);return F}}},{key:"sdtp",value:function(n){var l=new lt;return n.samples.forEach(function(f){l.write(new Uint8Array(n.isVideo?[f.keyframe?32:16]:[16]))}),c.box(c.types.sdtp,this.extension(0,0),l.buffer)}},{key:"trun1",value:function(n){var l=new lt,f=lt.writeUint32(n.samples.length),v=null;if(n.isVideo){var E=n.videoSencLength;v=lt.writeUint32(n.samples.length*16+E+149),!n.isVideoEncryption&&n.isAudioEncryption&&(v=lt.writeUint32(n.samples.length*16+92))}else{var _=n.samples.length*12+124;n.isAudioEncryption&&(_=n.samples.length*12+8*n.audioSenc.length+177),v=lt.writeUint32(_)}return n.samples.forEach(function(S){l.write(lt.writeUint32(S.duration)),l.write(lt.writeUint32(S.size)),l.write(lt.writeUint32(S.keyframe?33554432:65536)),n.isVideo&&l.write(lt.writeUint32(S.cts?S.cts:0))}),c.box(c.types.trun,this.extension(0,n.flags),f,v,l.buffer)}},{key:"senc",value:function(n){var l=new lt,f=n.samples.length,v=n.isVideo?16:8,E=n.isVideo?2:0,_=[],S=0;return n.isVideo?(_=n.videoSenc,S=n.videoSencLength):_=n.audioSenc,S=S||v*f,l.write(lt.writeUint32(16+S),c.types.senc,this.extension(0,E)),l.write(lt.writeUint32(f)),_.forEach(function(C){for(var I=0;I<C.InitializationVector.length;I++)l.write(new Uint8Array([C.InitializationVector[I]]));C.subsamples&&C.subsamples.length&&(l.write(lt.writeUint16(C.subsamples.length)),C.subsamples.forEach(function(P){l.write(lt.writeUint16(P.BytesOfClearData)),l.write(lt.writeUint32(P.BytesOfProtectedData))}))}),l.buffer}},{key:"saio",value:function(n){var l=n.samples.length*12+141;!n.isVideo&&n.isAudioEncryption&&(l=149);var f=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saio,f)}},{key:"saiz",value:function(n){var l=n.samples.length,f=new Uint8Array([0,0,0,0,16,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saiz,f)}},{key:"sbgp",value:function(){var n=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return c.box(c.types.sbgp,this.extension(0,0),n)}},{key:"extension",value:function(n,l){return new Uint8Array([n,l>>16&255,l>>8&255,l&255])}},{key:"tfhd",value:function(n){return c.box(c.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"tfdt",value:function(n,l){var f=Math.floor(l/(eo+1)),v=Math.floor(l%(eo+1));return n.useEME&&(n.isVideoEncryption||n.isAudioEncryption)?c.box(c.types.tfdt,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])):c.box(c.types.tfdt,new Uint8Array([1,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"trun",value:function(n,l){var f=n.length,v=12+16*f;l+=8+v;var E=new Uint8Array(v);E.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255],0);for(var _=0;_<f;_++){var S=n[_],C=S.duration,I=S.size,P=S.flag,H=P===void 0?{}:P,W=S.cts,Y=W===void 0?0:W;E.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,H.isLeading<<2|(H.dependsOn===null||H.dependsOn===void 0?1:H.dependsOn),H.isDependedOn<<6|H.hasRedundancy<<4|H.paddingValue<<1|(H.isNonSyncSample===null||H.isNonSyncSample===void 0?1:H.isNonSyncSample),H.degradationPriority&61440,H.degradationPriority&15,Y>>>24&255,Y>>>16&255,Y>>>8&255,Y&255],12+16*_)}return c.box(c.types.trun,E)}},{key:"moovMP4",value:function(n){return c.box.apply(c,[c.types.moov,c.mvhd(n[0].duration,n[0].timescale)].concat(Ot(n.map(function(l){return c.trackMP4(l)}))))}},{key:"trackMP4",value:function(n){return c.box(c.types.trak,c.tkhd(n.id,n.duration,n.width,n.height),c.mdiaMP4(n))}},{key:"mdiaMP4",value:function(n){return c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minfMP4(n))}},{key:"minfMP4",value:function(n){return c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stblMP4(n))}},{key:"stblMP4",value:function(n){var l=n.ext,f=[c.stsd(n),c.stts(l.stts),c.stsc(l.stsc),c.stsz(l.stsz),c.stco(l.stco)];return l.stss.length&&f.push(c.stss(l.stss)),l.ctts.length&&f.push(c.ctts(l.ctts)),c.box.apply(c,[c.types.stbl].concat(f))}},{key:"stts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.stts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsc",value:function(n){var l=n.length,f=new Uint8Array(12*l),v=0;return n.forEach(function(E){var _=E.firstChunk,S=E.samplesPerChunk,C=E.sampleDescIndex;f.set([_>>24,_>>16&255,_>>8&255,_&255,S>>24,S>>16&255,S>>8&255,S&255,C>>24,C>>16&255,C>>8&255,C&255],v),v+=12}),c.box(c.types.stsc,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsz",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stsz,xt(new Uint8Array([0,0,0,0,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stco",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stco,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stss",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stss,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"ctts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.ctts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"styp",value:function(){return c.box(c.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(n){var l=n.timescale,f=n.samples[0].duration,v=f*n.samples.length,E=n.samples[0].sampleOffset*f,_=8;n.samples.forEach(function(H){_+=H.size});var S=0;if(n.isVideo){var C=0,I;n.videoSenc&&(I=n.videoSenc),n.isVideo&&I.forEach(function(H){C=C+8,H.subsamples&&H.subsamples.length&&(C=C+2,C=C+H.subsamples.length*6)}),n.videoSencLength=C,S=_+141+n.samples.length*16+C,n.useEME&&n.isAudioEncryption&&!n.isVideoEncryption&&(S=_+n.samples.length*16+84)}else S=_+116+n.samples.length*12,n.useEME&&n.isAudioEncryption&&(S=_+169+n.samples.length*12+8*n.audioSenc.length);var P=new Uint8Array([0,0,0,0,0,0,0,n.id&255,l>>24&255,l>>16&255,l>>8&255,l&255,E>>24&255,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,1,0,S>>16&255,S>>8&255,S&255,v>>24&255,v>>16&255,v>>8&255,v&255,144,0,0,0]);return c.box(c.types.sidx,P)}},{key:"mdat",value:function(n){var l=c.box(c.types.mdat,n);return l}}]),c}();Q(xe,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(c,g){return c[g]=[g.charCodeAt(0),g.charCodeAt(1),g.charCodeAt(2),g.charCodeAt(3)],c},Object.create(null)));Q(xe,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])});Q(xe,"FTYPAVC1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));Q(xe,"FTYPHEV1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));Q(xe,"DINF",xe.box(xe.types.dinf,xe.box(xe.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));Q(xe,"VMHD",xe.box(xe.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));Q(xe,"SMHD",xe.box(xe.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));Q(xe,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));Q(xe,"STTS",xe.box(xe.types.stts,xe.StblTable));Q(xe,"STSC",xe.box(xe.types.stsc,xe.StblTable));Q(xe,"STSZ",xe.box(xe.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));Q(xe,"STCO",xe.box(xe.types.stco,xe.StblTable));var gn=function(){function c(g,n){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),c.disabled=n}return Te(c,[{key:"debug",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).debug.apply(n,[this._prefix].concat(f))}}},{key:"log",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).log.apply(n,[this._prefix].concat(f))}}},{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}},{key:"error",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).error.apply(n,[this._prefix].concat(f))}}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(gn,"disabled",!0);var yn=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n;var f=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=f&&Number(f[1])<50,this.log=new gn("FMP4Remuxer",l&&l.openLog?!l.openLog:!0)}return Te(c,[{key:"remux",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=this.videoTrack,v=this.audioTrack,E=f.exist(),_=v.exist(),S,C,I,P=[];n&&(l&&l.initMerge?(E&&P.push(this.videoTrack),_&&P.push(this.audioTrack),I=xe.initSegment(P)):(E&&(S=xe.initSegment([this.videoTrack])),_&&(C=xe.initSegment([this.audioTrack]))));var H,W;return E&&f.hasSample()&&(H=this._remuxVideo()),_&&v.hasSample()&&(W=this._remuxAudio()),f.samples=[],v.samples=[],{initSegment:I,videoInitSegment:S,audioInitSegment:C,videoSegment:H,audioSegment:W}}},{key:"_remuxVideo",value:function(){var n=this.videoTrack;this.forceFirstIDR&&(n.samples[0].flag={dependsOn:2,isNonSyncSample:0});var l=n.samples,f=/av01/.test(n.codec),v=0;f?l.forEach(function(_e){v+=_e.data.byteLength}):l.forEach(function(_e){v+=_e.units.reduce(function(oe,j){return oe+j.byteLength},0),v+=_e.units.length*4});var E=new Uint8Array(v);if(f)for(var _=0,S=l.length,C=0,I;_<S;_++)I=l[_],E.set(I.data,C),I.size=I.data.byteLength,C+=I.size;else for(var P=new DataView(E.buffer),H=function(oe,j){j=l[W];var ue=0;j.units.forEach(function(Ve){P.setUint32(oe,Ve.byteLength),oe+=4,E.set(Ve,oe),oe+=Ve.byteLength,ue+=4+Ve.byteLength}),j.size=ue,ee=oe,J=j},W=0,Y=l.length,ee=0,J;W<Y;W++)H(ee,J);var ae=xe.mdat(E),se=xe.moof([n]);return xt(se,ae)}},{key:"_remuxAudio",value:function(){var n=this.audioTrack,l=new Uint8Array(n.samples.reduce(function(E,_){return E+_.size},0));n.samples.reduce(function(E,_){return l.set(_.data,E),E+_.size},0);var f=xe.mdat(l),v=xe.moof([n]);return xt(v,f)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),c}();var to=function(){function c(){yr(this,c),ce(this,"_ttfb",0),ce(this,"_demuxStart",0),ce(this,"_demuxEnd",0),ce(this,"_demuxCost",0),ce(this,"_remuxStart",0),ce(this,"_remuxEnd",0),ce(this,"_remuxCost",0),ce(this,"_appendStart",0),ce(this,"_appendEnd",0),ce(this,"_appendCost",0)}return Er(c,[{key:"set",value:function(n,l){this["_".concat(n)]=l}},{key:"start",value:function(n){this["_".concat(n,"Start")]=Date.now()}},{key:"end",value:function(n){this["_".concat(n,"End")]=Date.now(),this["_".concat(n,"Cost")]=this["_".concat(n,"Cost")]+(this["_".concat(n,"End")]-this["_".concat(n,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),c}(),qt={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var Xt=new Tt("BufferService"),ro=function(){function c(g,n){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};yr(this,c),ce(this,"flv",null),ce(this,"_demuxer",new pi),ce(this,"_remuxer",null),ce(this,"_mse",null),ce(this,"_softVideo",null),ce(this,"_sourceCreated",!1),ce(this,"_needInitSegment",!0),ce(this,"_discontinuity",!0),ce(this,"_contiguous",!1),ce(this,"_initSegmentId",""),ce(this,"_cachedBuffer",null),ce(this,"_demuxStartTime",0),ce(this,"_opts",null),this.flv=g,this._opts=l,n?this._softVideo=n:(this._remuxer=new yn(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new rr(null,{preferMMS:typeof l.preferMMS=="boolean"?l.preferMMS:!!l.perferMMS}),this._mse.bindMedia(g.media))}return Er(c,[{key:"baseDts",get:function(){var n,l;return(n=this._demuxer)===null||n===void 0||(l=n._fixer)===null||l===void 0?void 0:l._baseDts}},{key:"blobUrl",get:function(){var n;return(n=this._mse)===null||n===void 0?void 0:n.url}},{key:"isFull",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:rr.VIDEO;return this._mse.isFull(n)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(n){this._contiguous=!1,this._demuxStartTime=n}},{key:"reset",value:function(){var g=it(Re().mark(function l(){var f,v=arguments;return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=v.length>0&&v[0]!==void 0?v[0]:!1,!(this._mse&&!f)){_.next=6;break}return _.next=4,this._mse.unbindMedia();case 4:return _.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return _.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=7;break}if(!this._sourceCreated){v.next=5;break}return v.next=4,this._mse.endOfStream();case 4:this.flv.emit(me.BUFFEREOS);case 5:v.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"updateDuration",value:function(){var g=it(Re().mark(function l(f){return Re().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(!this._mse){E.next=7;break}if(this._mse.isOpened){E.next=4;break}return E.next=4,this._mse.open();case 4:return Xt.debug("update duration",f),E.next=7,this._mse.updateDuration(f);case 7:case"end":return E.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"destroy",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=3;break}return v.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"appendBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C,I,P,H,W,Y,ee,J,ae,se,_e,oe,j,ue;return Re().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(E=!1,this._cachedBuffer&&(f=en(this._cachedBuffer,f),this._cachedBuffer=null),_=this._demuxer,!(!f||!f.length||!_)){R.next=5;break}return R.abrupt("return");case 5:R.prev=5,this.flv._transferCost.start(qt.DEMUX),_.demuxAndFix(f,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(qt.DEMUX),R.next=15;break;case 12:throw R.prev=12,R.t0=R.catch(5),new dt(Ce.DEMUX,Ce.SUB_TYPES.FLV,R.t0);case 15:if(S=_.videoTrack,C=_.audioTrack,I=_.metadataTrack,!this.seamlessLoadingSwitch){R.next=25;break}if(P=S.samples.findIndex(function(le){return le.originDts===S.lastKeyFrameDts}),!(P>=0)){R.next=25;break}return S.samples.splice(P),R.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,f=null,E=!0;case 25:if(H=S.exist(),W=C.exist(),this._opts.onlyAudio&&(H=!1,S.present=!1),this._opts.onlyVideo&&(W=!1,C.present=!1),!(!H&&S.present||!W&&C.present)){R.next=42;break}if(Y=0,ee=H?S:W?C:void 0,ee&&ee.samples.length&&(Y=(ee.samples[ee.samples.length-1].originPts-ee.samples[0].originPts)/ee.timescale*1e3),!(Y>this._opts.analyzeDuration)){R.next=40;break}Xt.warn("analyze duration exceeded, ".concat(Y,"ms"),ee),S.present=H,C.present=W,this.flv.emit(me.ANALYZE_DURATION_EXCEEDED,{duration:Y}),R.next=42;break;case 40:return this._cachedBuffer=f,R.abrupt("return");case 42:if(J=S.type,ae=C.type,this._fireEvents(S,C,I),E||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),se=this._mse,_e=function(){var G;if((G=v.flv)!==null&&G!==void 0&&G.emit){var He;(He=v.flv)===null||He===void 0||He.emit(me.APPEND_BUFFER,{})}},this.flv.emit(me.DEMUXED_TRACK,{videoTrack:S}),oe="".concat(S.codec,"/").concat(S.width,"/").concat(S.height,"/").concat(C.codec,"/").concat(C.config),oe!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=oe,this._emitMetaParsedEvent(S,C)),!se){R.next=81;break}if(this._sourceCreated){R.next=59;break}return R.next=55,se.open();case 55:H&&(Xt.log("codec: video/mp4;codecs=".concat(S.codec)),se.createSource(J,"video/mp4;codecs=".concat(S.codec))),W&&(Xt.log("codec: audio/mp4;codecs=".concat(C.codec)),se.createSource(ae,"audio/mp4;codecs=".concat(C.codec))),this._sourceCreated=!0,this.flv.emit(me.SOURCEBUFFER_CREATED);case 59:R.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(S.duration=this._opts.durationForMSELowLatencyOff*S.timescale,C.duration=this._opts.durationForMSELowLatencyOff*W.timescale),this.flv._transferCost.start(qt.REMUX),j=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(qt.REMUX),R.next=69;break;case 66:throw R.prev=66,R.t1=R.catch(59),new dt(Ce.REMUX,Ce.SUB_TYPES.FMP4,R.t1);case 69:if(!(this._needInitSegment&&!j.videoInitSegment&&!j.audioInitSegment)){R.next=71;break}return R.abrupt("return");case 71:return this._needInitSegment=!1,ue=[],j.videoInitSegment&&ue.push(se.append(J,j.videoInitSegment)),j.audioInitSegment&&ue.push(se.append(ae,j.audioInitSegment)),j.videoSegment&&ue.push(se.append(J,j.videoSegment)),j.audioSegment&&ue.push(se.append(ae,j.audioSegment)),this.flv._transferCost.start(qt.APPEND),R.abrupt("return",Promise.all(ue).then(_e).then(function(){v.flv._transferCost.end(qt.APPEND),_e()}));case 81:this._softVideo&&(this._softVideo.appendBuffer(S,C),_e());case 82:case"end":return R.stop()}},l,this,[[5,12],[59,66]])}));function n(l){return g.apply(this,arguments)}return n}()},{key:"evictBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(E=this.flv.media,!(!this._mse||!this._demuxer||!E||!f||f<0)){P.next=3;break}return P.abrupt("return");case 3:if(_=E.currentTime,S=_-f,!(S<=0)){P.next=7;break}return P.abrupt("return");case 7:if(C=tt.start(tt.get(E)),!(C+1>=S)){P.next=10;break}return P.abrupt("return");case 10:return P.abrupt("return",this._mse.clearBuffer(0,S).then(function(){return v.flv.emit(me.REMOVE_BUFFER,{removeEnd:S})}));case 11:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"_emitMetaParsedEvent",value:function(n,l){n.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"video",track:n,meta:{codec:n.codec,timescale:n.timescale,width:n.width,height:n.height,sarRatio:n.sarRatio,baseDts:n.baseDts}}),l.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"audio",track:l,meta:{codec:l.codec,channelCount:l.channelCount,sampleRate:l.sampleRate,timescale:l.timescale,baseDts:l.baseDts}}),Xt.debug("track parsed",n,l)}},{key:"_fireEvents",value:function(n,l,f){var v=this;Xt.debug("videoTrack samples count: ".concat(n.samples.length,", audioTrack samples count: ").concat(l.samples.length)),f.flvScriptSamples.forEach(function(E){v.flv.emit(me.FLV_SCRIPT_DATA,E),Xt.debug("flvScriptData",E)}),n.samples.forEach(function(E){E.keyframe&&v.flv.emit(me.KEYFRAME,{pts:E.originPts})}),n.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AV_SHIFT:_=me.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP:_=me.LARGE_VIDEO_DTS_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK:_=me.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("video exception",E)}),l.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AUDIO_GAP:_=me.LARGE_AUDIO_DTS_GAP_DETECT;break;case mt.AUDIO_FILLED:_=me.AUDIO_GAP_DETECT;break;case mt.AUDIO_DROPPED:_=me.AUDIO_OVERLAP_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("audio exception",E)}),f.seiSamples.forEach(function(E){v.flv.emit(me.SEI,bt(bt({},E),{},{sei:{code:E.data.type,content:E.data.payload,dts:E.pts}}))})}}]),c}();function io(c){var g=bt({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},c);return g.isLive&&g.preloadTime&&(g.maxLatency||(g.maxLatency=g.preloadTime*2),g.targetLatency||(g.targetLatency=g.preloadTime),(g.disconnectTime===null||g.disconnectTime===void 0)&&(g.disconnectTime=g.maxLatency)),g}function En(c,g){var n=0,l=c.length-1,f=0,v=0,E=l;for(g<c[0]&&(n=0,v=E+1);v<=E;)if(f=v+Math.floor((E-v)/2),f===l||g>=c[f]&&g<c[f+1]){n=f;break}else c[f]<g?v=f+1:E=f-1;return n}var Vt=new Tt("flv"),mi=.1,eh=.3,br=function(c){ns(n,c);var g=as(n);function n(l){var f;return yr(this,n),f=g.call(this),ce(Ie(f),"media",null),ce(Ie(f),"_loading",!1),ce(Ie(f),"_opts",null),ce(Ie(f),"_bufferService",null),ce(Ie(f),"_gapService",null),ce(Ie(f),"_stats",null),ce(Ie(f),"_mediaLoader",null),ce(Ie(f),"_maxChunkWaitTimer",null),ce(Ie(f),"_tickTimer",null),ce(Ie(f),"_tickInterval",500),ce(Ie(f),"_urlSwitching",!1),ce(Ie(f),"_seamlessSwitching",!1),ce(Ie(f),"_disconnectRetryCount",0),ce(Ie(f),"_preLoadEndPoint",0),ce(Ie(f),"_keyframes",null),ce(Ie(f),"_acceptRanges",!0),ce(Ie(f),"_onProgress",function(){var v=it(Re().mark(function E(_,S,C,I){var P,H,W,Y,ee,J,ae,se,_e,oe;return Re().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(P=C.startTime,H=C.endTime,W=C.st,Y=C.firstByteTime,f._loading=!S,f._firstProgressEmit){ue.next=13;break}if(f.media){ue.next=6;break}return(ee=f._mediaLoader)===null||ee===void 0||ee.cancel(),ue.abrupt("return");case 6:J=I.headers,ae=W?Y-W:H-P,f.emit(me.TTFB,{url:f._opts.url,responseUrl:I.url,elapsed:ae}),f.emit(me.LOAD_RESPONSE_HEADERS,{headers:J}),f._transferCost.set(qt.TTFB,ae),f._acceptRanges=!!(J!=null&&J.get("Accept-Ranges"))||!!(J!=null&&J.get("Content-Range")),f._firstProgressEmit=!0;case 13:if(f._bufferService){ue.next=15;break}return ue.abrupt("return");case 15:return clearTimeout(f._maxChunkWaitTimer),f._bandwidthService.addChunkRecord(_?.byteLength,H-P),ue.prev=17,ue.next=20,f._bufferService.appendBuffer(_);case 20:(se=f._bufferService)===null||se===void 0||se.evictBuffer(f._opts.bufferBehind),ue.next=33;break;case 23:if(ue.prev=23,ue.t0=ue.catch(17),!(!f.isLive&&f._bufferService.isFull())){ue.next=32;break}return ue.next=28,f._mediaLoader.cancel();case 28:return f._loading=!1,_e=f.bufferInfo().remaining,f._opts.preloadTime=parseInt(_e)/2,ue.abrupt("return");case 32:return ue.abrupt("return",f._emitError(dt.create(ue.t0)));case 33:if(f._urlSwitching&&(f._urlSwitching=!1,f.emit(me.SWITCH_URL_SUCCESS,{url:f._opts.url})),f._seamlessSwitching&&(f._seamlessSwitching=!1,f._tick()),!(S&&!f.media.seeking)){ue.next=40;break}return f.emit(me.LOAD_COMPLETE),Vt.debug("load done"),f.isLive&&f._disconnectRetryCount<=0&&f._end(),ue.abrupt("return");case 40:if(f.isLive){ue.next=42;break}return ue.abrupt("return");case 42:oe=f._opts.maxReaderInterval,oe&&f._firstProgressEmit&&(clearTimeout(f._maxChunkWaitTimer),f._maxChunkWaitTimer=setTimeout(function(){if(f._disconnectRetryCount){f._disconnectRetryCount--,f.load();return}Vt.debug("onMaxChunkWait",oe),f._end()},oe));case 44:case"end":return ue.stop()}},E,null,[[17,23]])}));return function(E,_,S,C){return v.apply(this,arguments)}}()),ce(Ie(f),"_onRetryError",function(v,E){Vt.debug("load retry",v,E),f.emit(me.LOAD_RETRY,{error:dt.network(v),retryTime:E})}),ce(Ie(f),"_end",function(){f._clear(),f._bufferService&&f._bufferService.endOfStream(),Vt.debug("end stream")}),ce(Ie(f),"_resetDisconnectCount",function(){f._disconnectRetryCount=f._opts.disconnectRetryCount}),ce(Ie(f),"_tick",function(){clearTimeout(f._tickTimer);var v=Ie(f),E=v.media;if(E){f._tickTimer=setTimeout(f._tick,f._tickInterval);var _=tt.end(tt.get(E));if(!(_<mi||!E.readyState)){var S=f._opts;if(Ji(E)&&E.currentTime)f._gapService&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);else{if(!E.currentTime&&f._gapService&&S.enableStartGapJump){var C=f._opts.mseLowLatency||f._opts.mseLowLatency===!1&&f.bufferInfo(eh).nextStart;C&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);return}S.isLive&&E.readyState===4&&_-E.currentTime>S.disconnectTime&&f.disconnect()}}}}),ce(Ie(f),"_onPlay",function(){var v,E,_=f._opts.softDecode||((v=f.media)===null||v===void 0||(E=v.buffered)===null||E===void 0?void 0:E.length);if(f.isLive){!f._loading&&_&&f.replay(void 0,!0);return}var S=f.bufferInfo();(S.start||S.nextStart)>mi&&f._tick()}),ce(Ie(f),"_onLoadeddata",function(){f.isLive&&!f._opts.mseLowLatency&&f.media.duration!==1/0&&f._bufferService.updateDuration(1/0).catch(function(v){})}),ce(Ie(f),"_onSeeking",it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:!f.isLive&&f.seekable&&(f._preLoadEndPoint=-1,f._checkPreload());case 1:case"end":return _.stop()}},v)}))),ce(Ie(f),"_onTimeupdate",function(){if(f.media){var v=f._opts,E=f.media.currentTime;if(v.isLive&&v.maxLatency&&v.targetLatency){var _=tt.end(tt.get(f.media)),S=_-E;S>=v.maxLatency&&(f.media.currentTime=_-v.targetLatency,f.emit(me.CHASEFRAME,{currentTime:f.media.currentTime,latency:v.targetLatency}))}f._seiService.throw(E,!0),!(v.isLive||!f.seekable||f._loading)&&f._checkPreload()}}),ce(Ie(f),"_onWaiting",function(){f.isLive&&!f._loading&&f._disconnectRetryCount&&(f._disconnectRetryCount--,f.load())}),ce(Ie(f),"_onBufferUpdate",function(){if(!f._opts.isLive){var v=f.bufferInfo(),E=v.end,_=v.nextEnd;Math.abs((E||_)-f.media.duration)<1&&(f._end(),f.media.readyState<=2&&f._tick())}}),ce(Ie(f),"_checkPreload",it(Re().mark(function v(){var E,_,S,C,I,P,H,W,Y,ee;return Re().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(E=f.bufferInfo(),_=E.remaining,S=_===void 0?0:_,C=f._opts,I=f._keyframes.filepositions,P=f._keyframes.times,H=f.media.currentTime,!(S<C.preloadTime)){ae.next=19;break}if(W=En(f._keyframes.times,H+S+mi),Y=En(f._keyframes.times,H+S+f._opts.preloadTime),Y===W&&(Y=W+1),f._preLoadEndPoint!==Y){ae.next=11;break}return ae.abrupt("return");case 11:if(ee=I[W],ee!=null){ae.next=14;break}return ae.abrupt("return");case 14:return ae.next=16,f._mediaLoader.cancel();case 16:f._loadData(null,[ee,I[Y]]),f._preLoadEndPoint=Y,f._bufferService.unContiguous(P[W]);case 19:case"end":return ae.stop()}},v)}))),ce(Ie(f),"_onFlvScriptData",function(v){var E,_,S,C,I=(E=v.data)===null||E===void 0||(_=E.onMetaData)===null||_===void 0?void 0:_.keyframes,P=(S=v.data)===null||S===void 0||(C=S.onMetaData)===null||C===void 0?void 0:C.duration;I&&(f._keyframes=I),!f._opts.isLive&&P&&f._bufferService.updateDuration(P)}),f._opts=io(l),f.media=f._opts.media||document.createElement("video"),f._opts.media=null,f._firstProgressEmit=!1,f._mediaLoader=new rn(bt(bt({},f._opts.fetchOptions),{},{retry:f._opts.retryCount,retryDelay:f._opts.retryDelay,timeout:f._opts.loadTimeout,onRetryError:f._onRetryError,onProgress:f._onProgress,responseType:"arraybuffer"})),f._disconnectRetryCount=f._opts.disconnectRetryCount,f._transferCost=new to,f._bufferService=new ro(Ie(f),f._opts.softDecode?f.media:void 0,f._opts),f._seiService=new an(Ie(f)),f._bandwidthService=new sn({chunkCountForSpeed:f._opts.chunkCountForSpeed,skipChunkSize:f._opts.skipChunkSize,longtimeNoReceived:f._opts.longtimeNoReceived}),f._stats=new on(Ie(f)),f._opts.softDecode||(f._gapService=new nn),f.media.addEventListener("play",f._onPlay),f.media.addEventListener("loadeddata",f._onLoadeddata),f.media.addEventListener("seeking",f._onSeeking),f.media.addEventListener("timeupdate",f._onTimeupdate),f.media.addEventListener("progress",f._onBufferUpdate),f.media.addEventListener("waiting",f._onWaiting),f.on(me.FLV_SCRIPT_DATA,f._onFlvScriptData),f}return Er(n,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var f,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mi;return tt.info(tt.get(this.media),(f=this.media)===null||f===void 0?void 0:f.currentTime,v)}},{key:"playbackQuality",value:function(){return Zi(this.media)}},{key:"load",value:function(){var l=it(Re().mark(function v(E){var _,S=arguments;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(_=S.length>1&&S[1]!==void 0?S[1]:!1,this._bufferService){I.next=3;break}return I.abrupt("return");case 3:return I.next=5,this._reset(_);case 5:this._loadData(E,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return I.stop()}},v,this)}));function f(v){return l.apply(this,arguments)}return f}()},{key:"replay",value:function(){var l=it(Re().mark(function v(){var E=this,_,S,C=arguments;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(_=C.length>0&&C[0]!==void 0?C[0]:this._opts.seamlesslyReload,S=C.length>1?C[1]:void 0,this.media){P.next=4;break}return P.abrupt("return");case 4:if(this._resetDisconnectCount(),!_){P.next=11;break}return P.next=8,this._clear();case 8:setTimeout(function(){E._seamlessSwitching=!0,E._loadData(E._opts.url),E._bufferService.seamlessSwitch()}),P.next=13;break;case 11:return P.next=13,this.load();case 13:return P.abrupt("return",this.media.play(!S).catch(function(){}));case 14:case"end":return P.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"disconnect",value:function(){var f;return Vt.debug("disconnect!"),(f=this._bufferService)===null||f===void 0||f.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var l=it(Re().mark(function v(E,_){var S=this;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this._bufferService){I.next=2;break}return I.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&_)){I.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var P=it(Re().mark(function H(W){return Re().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ee.next=2,S._clear();case 2:S._bufferService.seamlessLoadingSwitching=!0,S._urlSwitching=!0,S._seamlessSwitching=!0,S._bufferService.seamlessSwitch(),S._loadData(E);case 7:case"end":return ee.stop()}},H)}));return function(H){return P.apply(this,arguments)}}(),I.abrupt("return");case 6:if(!(!_||!this._opts.isLive)){I.next=11;break}return I.next=9,this.load(E);case 9:return this._urlSwitching=!0,I.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return I.next=13,this._clear();case 13:setTimeout(function(){S._urlSwitching=!0,S._seamlessSwitching=!0,S._loadData(E),S._bufferService.seamlessSwitch()});case 14:case"end":return I.stop()}},v,this)}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"destroy",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.media){_.next=2;break}return _.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),_.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_emitError",value:function(f){var v,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Vt.table(f),Vt.error(f),Vt.error((v=this.media)===null||v===void 0?void 0:v.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(me.SWITCH_URL_FAILED,f)),this.emit(me.ERROR,f),E&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var l=it(Re().mark(function v(){var E,_=arguments;return Re().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return E=_.length>0&&_[0]!==void 0?_[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),C.next=6,this._clear();case 6:return C.next=8,this._bufferService.reset(E);case 8:case"end":return C.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadData",value:function(){var l=it(Re().mark(function v(E,_){var S;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(E&&(this._opts.url=E),S=E=this._opts.url,E){I.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(S=this._opts.preProcessUrl(E).url),this._mediaLoader.finnalUrl=S,this.emit(me.LOAD_START,{url:S,seamlessSwitching:this._seamlessSwitching}),Vt.debug("load data, loading:",this._loading,S),!this._loading){I.next=11;break}return I.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,I.prev=12,I.next=15,this._mediaLoader.load({url:S,range:_});case 15:I.next=21;break;case 17:return I.prev=17,I.t0=I.catch(12),this._loading=!1,I.abrupt("return",this._emitError(dt.network(I.t0),!1));case 21:case"end":return I.stop()}},v,this,[[12,17]])}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"_clear",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._mediaLoader){_.next=3;break}return _.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()}],[{key:"isSupported",value:function(f){return!f||f==="video"||f==="audio"?rr.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){Tt.enable(),fr.enable()}},{key:"disableLogger",value:function(){Tt.disable(),fr.disable()}}]),n}(no.default);try{localStorage.getItem("xgd")?br.enableLogger():br.disableLogger()}catch{}var Sn=gr(so(),1);
|
21
|
+
;if (typeof module.exports == "object" && typeof exports == "object") {
|
22
|
+
var __cp = (to, from, except, desc) => {
|
23
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
24
|
+
for (let key of Object.getOwnPropertyNames(from)) {
|
25
|
+
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
|
26
|
+
Object.defineProperty(to, key, {
|
27
|
+
get: () => from[key],
|
28
|
+
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
|
29
|
+
});
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return to;
|
33
|
+
};
|
34
|
+
module.exports = __cp(module.exports, exports);
|
35
|
+
}
|
36
|
+
return module.exports;
|
37
|
+
}))
|