forked from robinscholz/kirby-mux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
12 lines (12 loc) · 262 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
(function(){"use strict";var _e=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ne(G){return G&&G.__esModule&&Object.prototype.hasOwnProperty.call(G,"default")?G.default:G}var Me={exports:{}};(function(G,ne){typeof window!="undefined"&&function(C,g){G.exports=g()}(_e,function(){return function(K){var C={};function g(b){if(C[b])return C[b].exports;var O=C[b]={i:b,l:!1,exports:{}};return K[b].call(O.exports,O,O.exports,g),O.l=!0,O.exports}return g.m=K,g.c=C,g.d=function(b,O,L){g.o(b,O)||Object.defineProperty(b,O,{enumerable:!0,get:L})},g.r=function(b){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(b,"__esModule",{value:!0})},g.t=function(b,O){if(O&1&&(b=g(b)),O&8||O&4&&typeof b=="object"&&b&&b.__esModule)return b;var L=Object.create(null);if(g.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:b}),O&2&&typeof b!="string")for(var M in b)g.d(L,M,function(P){return b[P]}.bind(null,M));return L},g.n=function(b){var O=b&&b.__esModule?function(){return b.default}:function(){return b};return g.d(O,"a",O),O},g.o=function(b,O){return Object.prototype.hasOwnProperty.call(b,O)},g.p="/dist/",g(g.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,C,g){var b=Object.prototype.hasOwnProperty,O="~";function L(){}Object.create&&(L.prototype=Object.create(null),new L().__proto__||(O=!1));function M(a,u,o){this.fn=a,this.context=u,this.once=o||!1}function P(a,u,o,p,y){if(typeof o!="function")throw new TypeError("The listener must be a function");var m=new M(o,p||a,y),d=O?O+u:u;return a._events[d]?a._events[d].fn?a._events[d]=[a._events[d],m]:a._events[d].push(m):(a._events[d]=m,a._eventsCount++),a}function x(a,u){--a._eventsCount===0?a._events=new L:delete a._events[u]}function c(){this._events=new L,this._eventsCount=0}c.prototype.eventNames=function(){var u=[],o,p;if(this._eventsCount===0)return u;for(p in o=this._events)b.call(o,p)&&u.push(O?p.slice(1):p);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(o)):u},c.prototype.listeners=function(u){var o=O?O+u:u,p=this._events[o];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,m=p.length,d=new Array(m);y<m;y++)d[y]=p[y].fn;return d},c.prototype.listenerCount=function(u){var o=O?O+u:u,p=this._events[o];return p?p.fn?1:p.length:0},c.prototype.emit=function(u,o,p,y,m,d){var l=O?O+u:u;if(!this._events[l])return!1;var i=this._events[l],r=arguments.length,h,n;if(i.fn){switch(i.once&&this.removeListener(u,i.fn,void 0,!0),r){case 1:return i.fn.call(i.context),!0;case 2:return i.fn.call(i.context,o),!0;case 3:return i.fn.call(i.context,o,p),!0;case 4:return i.fn.call(i.context,o,p,y),!0;case 5:return i.fn.call(i.context,o,p,y,m),!0;case 6:return i.fn.call(i.context,o,p,y,m,d),!0}for(n=1,h=new Array(r-1);n<r;n++)h[n-1]=arguments[n];i.fn.apply(i.context,h)}else{var e=i.length,t;for(n=0;n<e;n++)switch(i[n].once&&this.removeListener(u,i[n].fn,void 0,!0),r){case 1:i[n].fn.call(i[n].context);break;case 2:i[n].fn.call(i[n].context,o);break;case 3:i[n].fn.call(i[n].context,o,p);break;case 4:i[n].fn.call(i[n].context,o,p,y);break;default:if(!h)for(t=1,h=new Array(r-1);t<r;t++)h[t-1]=arguments[t];i[n].fn.apply(i[n].context,h)}}return!0},c.prototype.on=function(u,o,p){return P(this,u,o,p,!1)},c.prototype.once=function(u,o,p){return P(this,u,o,p,!0)},c.prototype.removeListener=function(u,o,p,y){var m=O?O+u:u;if(!this._events[m])return this;if(!o)return x(this,m),this;var d=this._events[m];if(d.fn)d.fn===o&&(!y||d.once)&&(!p||d.context===p)&&x(this,m);else{for(var l=0,i=[],r=d.length;l<r;l++)(d[l].fn!==o||y&&!d[l].once||p&&d[l].context!==p)&&i.push(d[l]);i.length?this._events[m]=i.length===1?i[0]:i:x(this,m)}return this},c.prototype.removeAllListeners=function(u){var o;return u?(o=O?O+u:u,this._events[o]&&x(this,o)):(this._events=new L,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=O,c.EventEmitter=c,K.exports=c},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,C,g){(function(b){var O=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,L=/^([^\/?#]*)([^]*)$/,M=/(?:\/|^)\.(?=\/)/g,P=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,x={buildAbsoluteURL:function(c,a,u){if(u=u||{},c=c.trim(),a=a.trim(),!a){if(!u.alwaysNormalize)return c;var o=x.parseURL(c);if(!o)throw new Error("Error trying to parse base URL.");return o.path=x.normalizePath(o.path),x.buildURLFromParts(o)}var p=x.parseURL(a);if(!p)throw new Error("Error trying to parse relative URL.");if(p.scheme)return u.alwaysNormalize?(p.path=x.normalizePath(p.path),x.buildURLFromParts(p)):a;var y=x.parseURL(c);if(!y)throw new Error("Error trying to parse base URL.");if(!y.netLoc&&y.path&&y.path[0]!=="/"){var m=L.exec(y.path);y.netLoc=m[1],y.path=m[2]}y.netLoc&&!y.path&&(y.path="/");var d={scheme:y.scheme,netLoc:p.netLoc,path:null,params:p.params,query:p.query,fragment:p.fragment};if(!p.netLoc&&(d.netLoc=y.netLoc,p.path[0]!=="/"))if(!p.path)d.path=y.path,p.params||(d.params=y.params,p.query||(d.query=y.query));else{var l=y.path,i=l.substring(0,l.lastIndexOf("/")+1)+p.path;d.path=x.normalizePath(i)}return d.path===null&&(d.path=u.alwaysNormalize?x.normalizePath(p.path):p.path),x.buildURLFromParts(d)},parseURL:function(c){var a=O.exec(c);return a?{scheme:a[1]||"",netLoc:a[2]||"",path:a[3]||"",params:a[4]||"",query:a[5]||"",fragment:a[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(M,"");c.length!==(c=c.replace(P,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};K.exports=x})()},"./node_modules/webworkify-webpack/index.js":function(K,C,g){function b(u){var o={};function p(m){if(o[m])return o[m].exports;var d=o[m]={i:m,l:!1,exports:{}};return u[m].call(d.exports,d,d.exports,p),d.l=!0,d.exports}p.m=u,p.c=o,p.i=function(m){return m},p.d=function(m,d,l){p.o(m,d)||Object.defineProperty(m,d,{configurable:!1,enumerable:!0,get:l})},p.r=function(m){Object.defineProperty(m,"__esModule",{value:!0})},p.n=function(m){var d=m&&m.__esModule?function(){return m.default}:function(){return m};return p.d(d,"a",d),d},p.o=function(m,d){return Object.prototype.hasOwnProperty.call(m,d)},p.p="/",p.oe=function(m){throw console.error(m),m};var y=p(p.s=ENTRY_MODULE);return y.default||y}var O="[\\.|\\-|\\+|\\w|/|@]+",L="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+O+").*?\\)";function M(u){return(u+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function P(u){return!isNaN(1*u)}function x(u,o,p){var y={};y[p]=[];var m=o.toString(),d=m.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return y;for(var l=d[1],i=new RegExp("(\\\\n|\\W)"+M(l)+L,"g"),r;r=i.exec(m);)r[3]!=="dll-reference"&&y[p].push(r[3]);for(i=new RegExp("\\("+M(l)+'\\("(dll-reference\\s('+O+'))"\\)\\)'+L,"g");r=i.exec(m);)u[r[2]]||(y[p].push(r[1]),u[r[2]]=g(r[1]).m),y[r[2]]=y[r[2]]||[],y[r[2]].push(r[4]);for(var h=Object.keys(y),n=0;n<h.length;n++)for(var e=0;e<y[h[n]].length;e++)P(y[h[n]][e])&&(y[h[n]][e]=1*y[h[n]][e]);return y}function c(u){var o=Object.keys(u);return o.reduce(function(p,y){return p||u[y].length>0},!1)}function a(u,o){for(var p={main:[o]},y={main:[]},m={main:{}};c(p);)for(var d=Object.keys(p),l=0;l<d.length;l++){var i=d[l],r=p[i],h=r.pop();if(m[i]=m[i]||{},!(m[i][h]||!u[i][h])){m[i][h]=!0,y[i]=y[i]||[],y[i].push(h);for(var n=x(u,u[i][h],i),e=Object.keys(n),t=0;t<e.length;t++)p[e[t]]=p[e[t]]||[],p[e[t]]=p[e[t]].concat(n[e[t]])}}return y}K.exports=function(u,o){o=o||{};var p={main:g.m},y=o.all?{main:Object.keys(p.main)}:a(p,u),m="";Object.keys(y).filter(function(h){return h!=="main"}).forEach(function(h){for(var n=0;y[h][n];)n++;y[h].push(n),p[h][n]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",m=m+"var "+h+" = ("+b.toString().replace("ENTRY_MODULE",JSON.stringify(n))+")({"+y[h].map(function(e){return""+JSON.stringify(e)+": "+p[h][e].toString()}).join(",")+`});
`}),m=m+"new (("+b.toString().replace("ENTRY_MODULE",JSON.stringify(u))+")({"+y.main.map(function(h){return""+JSON.stringify(h)+": "+p.main[h].toString()}).join(",")+"}))(self);";var d=new window.Blob([m],{type:"text/javascript"});if(o.bare)return d;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,i=l.createObjectURL(d),r=new window.Worker(i);return r.objectURL=i,r}},"./src/config.ts":function(K,C,g){g.r(C),g.d(C,"hlsDefaultConfig",function(){return l}),g.d(C,"mergeConfig",function(){return r}),g.d(C,"enableStreamingMode",function(){return h});var b=g("./src/controller/abr-controller.ts"),O=g("./src/empty.js"),L=g.n(O),M=g("./src/controller/buffer-controller.ts"),P=g("./src/controller/cap-level-controller.ts"),x=g("./src/controller/fps-controller.ts"),c=g("./src/utils/xhr-loader.ts"),a=g("./src/utils/fetch-loader.ts"),u=g("./src/utils/mediakeys-helper.ts"),o=g("./src/utils/logger.ts");function p(){return p=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},p.apply(this,arguments)}function y(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);e&&(s=s.filter(function(E){return Object.getOwnPropertyDescriptor(n,E).enumerable})),t.push.apply(t,s)}return t}function m(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?y(Object(t),!0).forEach(function(s){d(n,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):y(Object(t)).forEach(function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(t,s))})}return n}function d(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var l=m(m({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength: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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:c.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:b.default,bufferController:M.default,capLevelController:P.default,fpsController:x.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:u.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},i()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0});function i(){return{cueHandler:L.a,enableCEA708Captions:!1,enableWebVTT:!1,enableIMSC1:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(n,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return p({},n,e)}function h(n){var e=n.loader;if(e!==a.default&&e!==c.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1;else{var t=Object(a.fetchSupported)();t&&(n.loader=a.default,n.progressive=!0,n.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,C,g){g.r(C);var b=g("./src/polyfills/number.ts"),O=g("./src/utils/ewma-bandwidth-estimator.ts"),L=g("./src/events.ts"),M=g("./src/utils/buffer-helper.ts"),P=g("./src/errors.ts"),x=g("./src/types/loader.ts"),c=g("./src/utils/logger.ts");function a(p,y){for(var m=0;m<y.length;m++){var d=y[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(p,d.key,d)}}function u(p,y,m){return y&&a(p.prototype,y),m&&a(p,m),p}var o=function(){function p(m){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=m;var d=m.config;this.bwEstimator=new O.default(d.abrEwmaSlowVoD,d.abrEwmaFastVoD,d.abrEwmaDefaultEstimate),this.registerListeners()}var y=p.prototype;return y.registerListeners=function(){var d=this.hls;d.on(L.Events.FRAG_LOADING,this.onFragLoading,this),d.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var d=this.hls;d.off(L.Events.FRAG_LOADING,this.onFragLoading,this),d.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(L.Events.ERROR,this.onError,this)},y.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},y.onFragLoading=function(d,l){var i=l.frag;if(i.type===x.PlaylistLevelType.MAIN&&!this.timer){var r;this.fragCurrent=i,this.partCurrent=(r=l.part)!=null?r:null,this.timer=self.setInterval(this.onCheck,100)}},y.onLevelLoaded=function(d,l){var i=this.hls.config;l.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},y._abandonRulesCheck=function(){var d=this.fragCurrent,l=this.partCurrent,i=this.hls,r=i.autoLevelEnabled,h=i.config,n=i.media;if(!(!d||!n)){var e=l?l.stats:d.stats,t=l?l.duration:d.duration;if(e.aborted){c.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!r||n.paused||!n.playbackRate||!n.readyState)){var s=performance.now()-e.loading.start,E=Math.abs(n.playbackRate);if(!(s<=500*t/E)){var f=i.levels,v=i.minAutoLevel,D=f[d.level],S=e.total||Math.max(e.loaded,Math.round(t*D.maxBitrate/8)),A=Math.max(1,e.bwEstimate?e.bwEstimate/8:e.loaded*1e3/s),T=(S-e.loaded)/A,R=n.currentTime,I=(M.BufferHelper.bufferInfo(n,R,h.maxBufferHole).end-R)/E;if(!(I>=2*t/E||T<=I)){var B=Number.POSITIVE_INFINITY,F;for(F=d.level-1;F>v;F--){var _=f[F].maxBitrate;if(B=t*_/(8*.8*A),B<I)break}if(!(B>=T)){var U=this.bwEstimator.getEstimate();c.logger.warn("Fragment "+d.sn+(l?" part "+l.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+F+`
Current BW estimate: `+(Object(b.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+T.toFixed(3)+` s
Estimated load time for the next fragment: `+B.toFixed(3)+` s
Time to underbuffer: `+I.toFixed(3)+" s"),i.nextLoadLevel=F,this.bwEstimator.sample(s,e.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),i.trigger(L.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:l,stats:e})}}}}}},y.onFragLoaded=function(d,l){var i=l.frag,r=l.part;if(i.type===x.PlaylistLevelType.MAIN&&Object(b.isFiniteNumber)(i.sn)){var h=r?r.stats:i.stats,n=r?r.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var e=this.hls.levels[i.level],t=(e.loaded?e.loaded.bytes:0)+h.loaded,s=(e.loaded?e.loaded.duration:0)+n;e.loaded={bytes:t,duration:s},e.realBitrate=Math.round(8*t/s)}if(i.bitrateTest){var E={stats:h,frag:i,part:r,id:i.type};this.onFragBuffered(L.Events.FRAG_BUFFERED,E),i.bitrateTest=!1}}},y.onFragBuffered=function(d,l){var i=l.frag,r=l.part,h=r?r.stats:i.stats;if(!h.aborted&&!(i.type!==x.PlaylistLevelType.MAIN||i.sn==="initSegment")){var n=h.parsing.end-h.loading.start;this.bwEstimator.sample(n,h.loaded),h.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},y.onError=function(d,l){switch(l.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break}},y.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},y.getNextABRAutoLevel=function(){var d=this.fragCurrent,l=this.partCurrent,i=this.hls,r=i.maxAutoLevel,h=i.config,n=i.minAutoLevel,e=i.media,t=l?l.duration:d?d.duration:0,s=e?e.currentTime:0,E=e&&e.playbackRate!==0?Math.abs(e.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():h.abrEwmaDefaultEstimate,v=(M.BufferHelper.bufferInfo(e,s,h.maxBufferHole).end-s)/E,D=this.findBestLevel(f,n,r,v,h.abrBandWidthFactor,h.abrBandWidthUpFactor);if(D>=0)return D;c.logger.trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=t?Math.min(t,h.maxStarvationDelay):h.maxStarvationDelay,A=h.abrBandWidthFactor,T=h.abrBandWidthUpFactor;if(!v){var R=this.bitrateTestDelay;if(R){var I=t?Math.min(t,h.maxLoadingDelay):h.maxLoadingDelay;S=I-R,c.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),A=T=1}}return D=this.findBestLevel(f,n,r,v+S,A,T),Math.max(D,0)},y.findBestLevel=function(d,l,i,r,h,n){for(var e,t=this.fragCurrent,s=this.partCurrent,E=this.lastLoadedFragLevel,f=this.hls.levels,v=f[E],D=!!(v!=null&&(e=v.details)!==null&&e!==void 0&&e.live),S=v==null?void 0:v.codecSet,A=s?s.duration:t?t.duration:0,T=i;T>=l;T--){var R=f[T];if(!(!R||S&&R.codecSet!==S)){var I=R.details,B=(s?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||A,F=void 0;T<=E?F=h*d:F=n*d;var _=f[T].maxBitrate,U=_*B/F;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(F)+"/"+_+"/"+B+"/"+r+"/"+U),F>_&&(!U||D&&!this.bitrateTestDelay||U<r))return T}}return-1},u(p,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,l=this.bwEstimator;if(d!==-1&&(!l||!l.canEstimate()))return d;var i=this.getNextABRAutoLevel();return d!==-1&&(i=Math.min(d,i)),i},set:function(d){this._nextAutoLevel=d}}]),p}();C.default=o},"./src/controller/base-playlist-controller.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return x});var b=g("./src/polyfills/number.ts"),O=g("./src/types/level.ts"),L=g("./src/controller/level-helper.ts"),M=g("./src/utils/logger.ts"),P=g("./src/errors.ts"),x=function(){function c(u,o){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,o+":"),this.warn=M.logger.warn.bind(M.logger,o+":"),this.hls=u}var a=c.prototype;return a.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},a.onError=function(o,p){p.fatal&&p.type===P.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},a.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},a.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},a.stopLoad=function(){this.canLoad=!1,this.clearTimer()},a.switchParams=function(o,p){var y=p==null?void 0:p.renditionReports;if(y)for(var m=0;m<y.length;m++){var d=y[m],l=""+d.URI;if(l===o.substr(-l.length)){var i=parseInt(d["LAST-MSN"]),r=parseInt(d["LAST-PART"]);if(p&&this.hls.config.lowLatencyMode){var h=Math.min(p.age-p.partTarget,p.targetduration);r!==void 0&&h>p.partTarget&&(r+=1)}if(Object(b.isFiniteNumber)(i))return new O.HlsUrlParameters(i,Object(b.isFiniteNumber)(r)?r:void 0,O.HlsSkip.No)}}},a.loadPlaylist=function(o){},a.shouldLoadTrack=function(o){return this.canLoad&&o&&!!o.url&&(!o.details||o.details.live)},a.playlistLoaded=function(o,p,y){var m=this,d=p.details,l=p.stats,i=l.loading.end?Math.max(0,self.performance.now()-l.loading.end):0;if(d.advancedDateTime=Date.now()-i,d.live||y!=null&&y.live){if(d.reloaded(y),y&&this.log("live playlist "+o+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),y&&d.fragments.length>0&&Object(L.mergeDetails)(y,d),!this.canLoad||!d.live)return;var r,h=void 0,n=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var e=this.hls.config.lowLatencyMode,t=d.lastPartSn,s=d.endSN,E=d.lastPartIndex,f=E!==-1,v=t===s,D=e?0:E;f?(h=v?s+1:t,n=v?D:E+1):h=s+1;var S=d.age,A=S+d.ageHeader,T=Math.min(A-d.partTarget,d.targetduration*1.5);if(T>0){if(y&&T>y.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+y.tuneInGoal+" to: "+T+" with playlist age: "+d.age),T=0;else{var R=Math.floor(T/d.targetduration);if(h+=R,n!==void 0){var I=Math.round(T%d.targetduration/d.partTarget);n+=I}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+S.toFixed(2)+"s goal: "+T+" skip sn "+R+" to part "+n)}d.tuneInGoal=T}if(r=this.getDeliveryDirectives(d,p.deliveryDirectives,h,n),e||!v){this.loadPlaylist(r);return}}else r=this.getDeliveryDirectives(d,p.deliveryDirectives,h,n);var B=Object(L.computeReloadInterval)(d,l);h!==void 0&&d.canBlockReload&&(B-=d.partTarget||1),this.log("reload live playlist "+o+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return m.loadPlaylist(r)},B)}else this.clearTimer()},a.getDeliveryDirectives=function(o,p,y,m){var d=Object(O.getSkipValue)(o,y);return p!=null&&p.skip&&o.deltaUpdateFailed&&(y=p.msn,m=p.part,d=O.HlsSkip.No),new O.HlsUrlParameters(y,m,d)},a.retryLoadingOrFail=function(o){var p=this,y=this.hls.config,m=this.retryCount<y.levelLoadingMaxRetry;if(m){var d;if(this.retryCount++,o.details.indexOf("LoadTimeOut")>-1&&(d=o.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+o.details+'"'),this.loadPlaylist();else{var l=Math.min(Math.pow(2,this.retryCount)*y.levelLoadingRetryDelay,y.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return p.loadPlaylist()},l),this.warn("retry playlist loading #"+this.retryCount+" in "+l+' ms after "'+o.details+'"')}}else this.warn('cannot recover from error "'+o.details+'"'),this.clearTimer(),o.fatal=!0;return m},c}()},"./src/controller/base-stream-controller.ts":function(K,C,g){g.r(C),g.d(C,"State",function(){return s}),g.d(C,"default",function(){return E});var b=g("./src/polyfills/number.ts"),O=g("./src/task-loop.ts"),L=g("./src/controller/fragment-tracker.ts"),M=g("./src/utils/buffer-helper.ts"),P=g("./src/utils/logger.ts"),x=g("./src/events.ts"),c=g("./src/errors.ts"),a=g("./src/types/transmuxer.ts"),u=g("./src/utils/mp4-tools.ts"),o=g("./src/utils/discontinuities.ts"),p=g("./src/controller/fragment-finders.ts"),y=g("./src/controller/level-helper.ts"),m=g("./src/loader/fragment-loader.ts"),d=g("./src/crypt/decrypter.ts"),l=g("./src/utils/time-ranges.ts"),i=g("./src/types/loader.ts");function r(f,v){for(var D=0;D<v.length;D++){var S=v[D];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(f,S.key,S)}}function h(f,v,D){return v&&r(f.prototype,v),D&&r(f,D),f}function n(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function e(f,v){f.prototype=Object.create(v.prototype),f.prototype.constructor=f,t(f,v)}function t(f,v){return t=Object.setPrototypeOf||function(S,A){return S.__proto__=A,S},t(f,v)}var s={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},E=function(f){e(v,f);function v(S,A,T){var R;return R=f.call(this)||this,R.hls=void 0,R.fragPrevious=null,R.fragCurrent=null,R.fragmentTracker=void 0,R.transmuxer=null,R._state=s.STOPPED,R.media=void 0,R.mediaBuffer=void 0,R.config=void 0,R.bitrateTest=!1,R.lastCurrentTime=0,R.nextLoadPosition=0,R.startPosition=0,R.loadedmetadata=!1,R.fragLoadError=0,R.retryDate=0,R.levels=null,R.fragmentLoader=void 0,R.levelLastLoaded=null,R.startFragRequested=!1,R.decrypter=void 0,R.initPTS=[],R.onvseeking=null,R.onvended=null,R.logPrefix="",R.log=void 0,R.warn=void 0,R.logPrefix=T,R.log=P.logger.log.bind(P.logger,T+":"),R.warn=P.logger.warn.bind(P.logger,T+":"),R.hls=S,R.fragmentLoader=new m.default(S.config),R.fragmentTracker=A,R.config=S.config,R.decrypter=new d.default(S,S.config),S.on(x.Events.KEY_LOADED,R.onKeyLoaded,n(R)),R}var D=v.prototype;return D.doTick=function(){this.onTickEnd()},D.onTickEnd=function(){},D.startLoad=function(A){},D.stopLoad=function(){this.fragmentLoader.abort();var A=this.fragCurrent;A&&this.fragmentTracker.removeFragment(A),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=s.STOPPED},D._streamEnded=function(A,T){var R=this.fragCurrent,I=this.fragmentTracker;if(!T.live&&R&&R.sn>=T.endSN&&!A.nextStart){var B=T.partList;if(B!=null&&B.length){var F=B[B.length-1],_=M.BufferHelper.isBuffered(this.media,F.start+F.duration/2);return _}var U=I.getState(R);return U===L.FragmentState.PARTIAL||U===L.FragmentState.OK}return!1},D.onMediaAttached=function(A,T){var R=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),R.addEventListener("seeking",this.onvseeking),R.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===s.STOPPED&&this.startLoad(I.startPosition)},D.onMediaDetaching=function(){var A=this.media;A!=null&&A.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),A&&(A.removeEventListener("seeking",this.onvseeking),A.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},D.onMediaSeeking=function(){var A=this.config,T=this.fragCurrent,R=this.media,I=this.mediaBuffer,B=this.state,F=R?R.currentTime:0,_=M.BufferHelper.bufferInfo(I||R,F,A.maxBufferHole);if(this.log("media seeking to "+(Object(b.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+B),B===s.ENDED)this.resetLoadingState();else if(T&&!_.len){var U=A.maxFragLookUpTolerance,N=T.start-U,k=T.start+T.duration+U,W=F>k;(F<N||W)&&(W&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}R&&(this.lastCurrentTime=F),!this.loadedmetadata&&!_.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},D.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},D.onKeyLoaded=function(A,T){if(!(this.state!==s.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)){this.state=s.IDLE;var R=this.levels[T.frag.level].details;R&&this.loadFragment(T.frag,R,T.frag.start)}},D.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},D.onHandlerDestroyed=function(){this.state=s.STOPPED,this.hls.off(x.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,f.prototype.onHandlerDestroyed.call(this)},D.loadKey=function(A,T){this.log("Loading key for "+A.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+A.level),this.state=s.KEY_LOADING,this.fragCurrent=A,this.hls.trigger(x.Events.KEY_LOADING,{frag:A})},D.loadFragment=function(A,T,R){this._loadFragForPlayback(A,T,R)},D._loadFragForPlayback=function(A,T,R){var I=this,B=function(_){if(I.fragContextChanged(A)){I.warn("Fragment "+A.sn+(_.part?" p: "+_.part.index:"")+" of level "+A.level+" was dropped during download."),I.fragmentTracker.removeFragment(A);return}A.stats.chunkCount++,I._handleFragmentLoadProgress(_)};this._doFragLoad(A,T,R,B).then(function(F){if(!!F){I.fragLoadError=0;var _=I.state;if(I.fragContextChanged(A)){(_===s.FRAG_LOADING||_===s.BACKTRACKING||!I.fragCurrent&&_===s.PARSING)&&(I.fragmentTracker.removeFragment(A),I.state=s.IDLE);return}if("payload"in F&&(I.log("Loaded fragment "+A.sn+" of level "+A.level),I.hls.trigger(x.Events.FRAG_LOADED,F),I.state===s.BACKTRACKING)){I.fragmentTracker.backtrack(A,F),I.resetFragmentLoading(A);return}I._handleFragmentLoadComplete(F)}}).catch(function(F){I.warn(F),I.resetFragmentLoading(A)})},D.flushMainBuffer=function(A,T,R){if(R===void 0&&(R=null),!!(A-T)){var I={startOffset:A,endOffset:T,type:R};this.fragLoadError=0,this.hls.trigger(x.Events.BUFFER_FLUSHING,I)}},D._loadInitSegment=function(A){var T=this;this._doFragLoad(A).then(function(R){if(!R||T.fragContextChanged(A)||!T.levels)throw new Error("init load aborted");return R}).then(function(R){var I=T.hls,B=R.payload,F=A.decryptdata;if(B&&B.byteLength>0&&F&&F.key&&F.iv&&F.method==="AES-128"){var _=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(B),F.key.buffer,F.iv.buffer).then(function(U){var N=self.performance.now();return I.trigger(x.Events.FRAG_DECRYPTED,{frag:A,payload:U,stats:{tstart:_,tdecrypt:N}}),R.payload=U,R})}return R}).then(function(R){var I=T.fragCurrent,B=T.hls,F=T.levels;if(!F)throw new Error("init load aborted, missing levels");var _=F[A.level].details;console.assert(_,"Level details are defined when init segment is loaded");var U=A.stats;T.state=s.IDLE,T.fragLoadError=0,A.data=new Uint8Array(R.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),R.frag===I&&B.trigger(x.Events.FRAG_BUFFERED,{stats:U,frag:I,part:null,id:A.type}),T.tick()}).catch(function(R){T.warn(R),T.resetFragmentLoading(A)})},D.fragContextChanged=function(A){var T=this.fragCurrent;return!A||!T||A.level!==T.level||A.sn!==T.sn||A.urlId!==T.urlId},D.fragBufferedComplete=function(A,T){var R=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+A.type+" sn: "+A.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+A.level+" "+l.default.toString(M.BufferHelper.getBuffered(R))),this.state=s.IDLE,this.tick()},D._handleFragmentLoadComplete=function(A){var T=this.transmuxer;if(!!T){var R=A.frag,I=A.part,B=A.partsLoaded,F=!B||B.length===0||B.some(function(U){return!U}),_=new a.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,I?I.index:-1,!F);T.flush(_)}},D._handleFragmentLoadProgress=function(A){},D._doFragLoad=function(A,T,R,I){var B=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");if(R=Math.max(A.start,R||0),this.config.lowLatencyMode&&T){var F=T.partList;if(F&&I){R>A.end&&T.fragmentHint&&(A=T.fragmentHint);var _=this.getNextPart(F,A,R);if(_>-1){var U=F[_];return this.log("Loading part sn: "+A.sn+" p: "+U.index+" cc: "+A.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+_+"-"+(F.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+A.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=s.FRAG_LOADING,this.hls.trigger(x.Events.FRAG_LOADING,{frag:A,part:F[_],targetBufferTime:R}),this.doFragPartsLoad(A,F,_,I).catch(function(N){return B.handleFragLoadError(N)})}else if(!A.url||this.loadedEndOfParts(F,R))return Promise.resolve(null)}}return this.log("Loading fragment "+A.sn+" cc: "+A.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+A.level+", target: "+parseFloat(R.toFixed(3))),Object(b.isFiniteNumber)(A.sn)&&!this.bitrateTest&&(this.nextLoadPosition=A.start+A.duration),this.state=s.FRAG_LOADING,this.hls.trigger(x.Events.FRAG_LOADING,{frag:A,targetBufferTime:R}),this.fragmentLoader.load(A,I).catch(function(N){return B.handleFragLoadError(N)})},D.doFragPartsLoad=function(A,T,R,I){var B=this;return new Promise(function(F,_){var U=[],N=function k(W){var w=T[W];B.fragmentLoader.loadPart(A,w,I).then(function(H){U[w.index]=H;var Y=H.part;B.hls.trigger(x.Events.FRAG_LOADED,H);var j=T[W+1];if(j&&j.fragment===A)k(W+1);else return F({frag:A,part:Y,partsLoaded:U})}).catch(_)};N(R)})},D.handleFragLoadError=function(A){var T=A.data;return T&&T.details===c.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(x.Events.ERROR,T),null},D._handleTransmuxerFlush=function(A){var T=this.getCurrentContext(A);if(!T||this.state!==s.PARSING){this.fragCurrent||(this.state=s.IDLE);return}var R=T.frag,I=T.part,B=T.level,F=self.performance.now();R.stats.parsing.end=F,I&&(I.stats.parsing.end=F),this.updateLevelTiming(R,I,B,A.partial)},D.getCurrentContext=function(A){var T=this.levels,R=A.level,I=A.sn,B=A.part;if(!T||!T[R])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+R+". The current chunk will not be buffered."),null;var F=T[R],_=B>-1?Object(y.getPartWith)(F,I,B):null,U=_?_.fragment:Object(y.getFragmentWithSN)(F,I,this.fragCurrent);return U?{frag:U,part:_,level:F}:null},D.bufferFragmentData=function(A,T,R,I){if(!(!A||this.state!==s.PARSING)){var B=A.data1,F=A.data2,_=B;if(B&&F&&(_=Object(u.appendUint8Array)(B,F)),!(!_||!_.length)){var U={type:A.type,frag:T,part:R,chunkMeta:I,parent:T.type,data:_};this.hls.trigger(x.Events.BUFFER_APPENDING,U),A.dropped&&A.independent&&!R&&this.flushBufferGap(T)}}},D.flushBufferGap=function(A){var T=this.media;if(!!T){if(!M.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,A.start);return}var R=T.currentTime,I=M.BufferHelper.bufferInfo(T,R,0),B=A.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),_=Math.max(Math.min(A.start-F,I.end-F),R+F);A.start-_>F&&this.flushMainBuffer(_,A.start)}},D.getFwdBufferInfo=function(A,T){var R=this.config,I=this.getLoadPosition();if(!Object(b.isFiniteNumber)(I))return null;var B=M.BufferHelper.bufferInfo(A,I,R.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(I,T);if(F&&B.nextStart<F.end)return M.BufferHelper.bufferInfo(A,I,Math.max(B.nextStart,R.maxBufferHole))}return B},D.getMaxBufferLength=function(A){var T=this.config,R;return A?R=Math.max(8*T.maxBufferSize/A,T.maxBufferLength):R=T.maxBufferLength,Math.min(R,T.maxMaxBufferLength)},D.reduceMaxBufferLength=function(A){var T=this.config,R=A||T.maxBufferLength;return T.maxMaxBufferLength>=R?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},D.getNextFragment=function(A,T){var R,I,B=T.fragments,F=B.length;if(!F)return null;var _=this.config,U=B[0].start,N;if(T.live){var k=_.initialLiveManifestSize;if(F<k)return this.warn("Not enough fragments to start playback (have: "+F+", need: "+k+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(N=this.getInitialLiveFragment(T,B),this.startPosition=N?this.hls.liveSyncPosition||N.start:A)}else A<=U&&(N=B[0]);if(!N){var W=_.lowLatencyMode?T.partEnd:T.fragmentEnd;N=this.getFragmentAtPosition(A,W,T)}return(R=N)!==null&&R!==void 0&&R.initSegment&&!((I=N)!==null&&I!==void 0&&I.initSegment.data)&&!this.bitrateTest&&(N=N.initSegment),N},D.getNextPart=function(A,T,R){for(var I=-1,B=!1,F=!0,_=0,U=A.length;_<U;_++){var N=A[_];if(F=F&&!N.independent,I>-1&&R<N.start)break;var k=N.loaded;!k&&(B||N.independent||F)&&N.fragment===T&&(I=_),B=k}return I},D.loadedEndOfParts=function(A,T){var R=A[A.length-1];return R&&T>R.start&&R.loaded},D.getInitialLiveFragment=function(A,T){var R=this.fragPrevious,I=null;if(R){if(A.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),I=Object(p.findFragmentByPDT)(T,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var B=R.sn+1;if(B>=A.startSN&&B<=A.endSN){var F=T[B-A.startSN];R.cc===F.cc&&(I=F,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(p.findFragWithCC)(T,R.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var _=this.hls.liveSyncPosition;_!==null&&(I=this.getFragmentAtPosition(_,this.bitrateTest?A.fragmentEnd:A.edge,A))}return I},D.getFragmentAtPosition=function(A,T,R){var I=this.config,B=this.fragPrevious,F=R.fragments,_=R.endSN,U=R.fragmentHint,N=I.maxFragLookUpTolerance,k=!!(I.lowLatencyMode&&R.partList&&U);k&&U&&!this.bitrateTest&&(F=F.concat(U),_=U.sn);var W;if(A<T){var w=A>T-N?0:N;W=Object(p.findFragmentByPTS)(B,F,A,w)}else W=F[F.length-1];if(W){var H=W.sn-R.startSN,Y=B&&W.level===B.level,j=F[H+1],Q=this.fragmentTracker.getState(W);if(Q===L.FragmentState.BACKTRACKED){W=null;for(var X=H;F[X]&&this.fragmentTracker.getState(F[X])===L.FragmentState.BACKTRACKED;)B?W=F[X--]:W=F[--X];W||(W=j)}else B&&W.sn===B.sn&&!k&&Y&&(W.sn<_&&this.fragmentTracker.getState(j)!==L.FragmentState.OK?(this.log("SN "+W.sn+" just loaded, load next one: "+j.sn),W=j):W=null)}return W},D.synchronizeToLiveEdge=function(A){var T=this.config,R=this.media;if(!!R){var I=this.hls.liveSyncPosition,B=R.currentTime,F=A.fragments[0].start,_=A.edge,U=B>=F-T.maxFragLookUpTolerance&&B<=_;if(I!==null&&R.duration>I&&(B<I||!U)){var N=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*A.targetduration;(!U&&R.readyState<4||B<_-N)&&(this.loadedmetadata||(this.nextLoadPosition=I),R.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+_+", reset currentTime to : "+I.toFixed(3)),R.currentTime=I))}}},D.alignPlaylists=function(A,T){var R=this.levels,I=this.levelLastLoaded,B=this.fragPrevious,F=I!==null?R[I]:null,_=A.fragments.length;if(!_)return this.warn("No fragments in live playlist"),0;var U=A.fragments[0].start,N=!T,k=A.alignedSliding&&Object(b.isFiniteNumber)(U);if(N||!k&&!U){Object(o.alignStream)(B,F,A);var W=A.fragments[0].start;return this.log("Live playlist sliding: "+W.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+A.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+_),W}return U},D.waitForCdnTuneIn=function(A){var T=3;return A.live&&A.canBlockReload&&A.tuneInGoal>Math.max(A.partHoldBack,A.partTarget*T)},D.setStartPosition=function(A,T){var R=this.startPosition;if(R<T&&(R=-1),R===-1||this.lastCurrentTime===-1){var I=A.startTimeOffset;Object(b.isFiniteNumber)(I)?(R=T+I,I<0&&(R+=A.totalduration),R=Math.min(Math.max(T,R),T+A.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+R),this.startPosition=R):A.live?R=this.hls.liveSyncPosition||T:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},D.getLoadPosition=function(){var A=this.media,T=0;return this.loadedmetadata&&A?T=A.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},D.handleFragLoadAborted=function(A,T){this.transmuxer&&A.sn!=="initSegment"&&A.stats.aborted&&(this.warn("Fragment "+A.sn+(T?" part"+T.index:"")+" of level "+A.level+" was aborted"),this.resetFragmentLoading(A))},D.resetFragmentLoading=function(A){(!this.fragCurrent||!this.fragContextChanged(A))&&(this.state=s.IDLE)},D.onFragmentOrKeyLoadError=function(A,T){if(!T.fatal){var R=T.frag;if(!(!R||R.type!==A)){var I=this.fragCurrent;console.assert(I&&R.sn===I.sn&&R.level===I.level&&R.urlId===I.urlId,"Frag load error must match current frag to retry");var B=this.config;if(this.fragLoadError+1<=B.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(R.level))return;var F=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+R.sn+" of "+A+" "+R.level+" failed to load, retrying in "+F+"ms"),this.retryDate=self.performance.now()+F,this.fragLoadError++,this.state=s.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(A===i.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=s.IDLE):(P.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=s.ERROR)}}},D.afterBufferFlushed=function(A,T,R){if(!!A){var I=M.BufferHelper.getBuffered(A);this.fragmentTracker.detectEvictedFragments(T,I,R),this.state===s.ENDED&&this.resetLoadingState()}},D.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=s.IDLE},D.resetLiveStartWhenNotLoaded=function(A){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[A].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},D.updateLevelTiming=function(A,T,R,I){var B=this,F=R.details;console.assert(!!F,"level.details must be defined");var _=Object.keys(A.elementaryStreams).reduce(function(U,N){var k=A.elementaryStreams[N];if(k){var W=k.endPTS-k.startPTS;if(W<=0)return B.warn("Could not parse fragment "+A.sn+" "+N+" duration reliably ("+W+") resetting transmuxer to fallback to playlist timing"),B.resetTransmuxer(),U||!1;var w=I?0:Object(y.updateFragPTSDTS)(F,A,k.startPTS,k.endPTS,k.startDTS,k.endDTS);return B.hls.trigger(x.Events.LEVEL_PTS_UPDATED,{details:F,level:R,drift:w,type:N,frag:A,start:k.startPTS,end:k.endPTS}),!0}return U},!1);_?(this.state=s.PARSED,this.hls.trigger(x.Events.FRAG_PARSED,{frag:A,part:T})):this.resetLoadingState()},D.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},h(v,[{key:"state",get:function(){return this._state},set:function(A){var T=this._state;T!==A&&(this._state=A,this.log(T+"->"+A))}}]),v}(O.default)},"./src/controller/buffer-controller.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return p});var b=g("./src/polyfills/number.ts"),O=g("./src/events.ts"),L=g("./src/utils/logger.ts"),M=g("./src/errors.ts"),P=g("./src/utils/buffer-helper.ts"),x=g("./src/utils/mediasource-helper.ts"),c=g("./src/loader/fragment.ts"),a=g("./src/controller/buffer-operation-queue.ts"),u=Object(x.getMediaSource)(),o=/([ha]vc.)(?:\.[^.,]+)+/,p=function(){function y(d){var l=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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=l.hls,r=l.media,h=l.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),r&&(l.updateMediaElementDuration(),i.trigger(O.Events.MEDIA_ATTACHED,{media:r})),h&&h.removeEventListener("sourceopen",l._onMediaSourceOpen),l.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var m=y.prototype;return m.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},m.destroy=function(){this.unregisterListeners(),this.details=null},m.registerListeners=function(){var l=this.hls;l.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.on(O.Events.BUFFER_RESET,this.onBufferReset,this),l.on(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),l.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),l.on(O.Events.BUFFER_EOS,this.onBufferEos,this),l.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),l.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),l.on(O.Events.FRAG_PARSED,this.onFragParsed,this),l.on(O.Events.FRAG_CHANGED,this.onFragChanged,this)},m.unregisterListeners=function(){var l=this.hls;l.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.off(O.Events.BUFFER_RESET,this.onBufferReset,this),l.off(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),l.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),l.off(O.Events.BUFFER_EOS,this.onBufferEos,this),l.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),l.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),l.off(O.Events.FRAG_PARSED,this.onFragParsed,this),l.off(O.Events.FRAG_CHANGED,this.onFragChanged,this)},m._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new a.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},m.onManifestParsed=function(l,i){var r=2;(i.audio&&!i.video||!i.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},m.onMediaAttaching=function(l,i){var r=this.media=i.media;if(r&&u){var h=this.mediaSource=new u;h.addEventListener("sourceopen",this._onMediaSourceOpen),h.addEventListener("sourceended",this._onMediaSourceEnded),h.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(h),this._objectUrl=r.src}},m.onMediaDetaching=function(){var l=this.media,i=this.mediaSource,r=this._objectUrl;if(i){if(L.logger.log("[buffer-controller]: media source detaching"),i.readyState==="open")try{i.endOfStream()}catch(h){L.logger.warn("[buffer-controller]: onMediaDetaching: "+h.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),l&&(r&&self.URL.revokeObjectURL(r),l.src===r?(l.removeAttribute("src"),l.load()):L.logger.warn("[buffer-controller]: media.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(O.Events.MEDIA_DETACHED,void 0)},m.onBufferReset=function(){var l=this;this.getSourceBufferTypes().forEach(function(i){var r=l.sourceBuffer[i];try{r&&(l.removeBufferListeners(i),l.mediaSource&&l.mediaSource.removeSourceBuffer(r),l.sourceBuffer[i]=void 0)}catch(h){L.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",h)}}),this._initSourceBuffer()},m.onBufferCodecs=function(l,i){var r=this,h=this.getSourceBufferTypes().length;Object.keys(i).forEach(function(n){if(h){var e=r.tracks[n];if(e&&typeof e.buffer.changeType=="function"){var t=i[n],s=t.codec,E=t.levelCodec,f=t.container,v=(e.levelCodec||e.codec).replace(o,"$1"),D=(E||s).replace(o,"$1");if(v!==D){var S=f+";codecs="+(E||s);r.appendChangeType(n,S)}}}else r.pendingTracks[n]=i[n]}),!h&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},m.appendChangeType=function(l,i){var r=this,h=this.operationQueue,n={execute:function(){var t=r.sourceBuffer[l];t&&(L.logger.log("[buffer-controller]: changing "+l+" sourceBuffer type to "+i),t.changeType(i)),h.shiftAndExecuteNext(l)},onStart:function(){},onComplete:function(){},onError:function(t){L.logger.warn("[buffer-controller]: Failed to change "+l+" SourceBuffer type",t)}};h.append(n,l)},m.onBufferAppending=function(l,i){var r=this,h=this.hls,n=this.operationQueue,e=this.tracks,t=i.data,s=i.type,E=i.frag,f=i.part,v=i.chunkMeta,D=v.buffering[s],S=self.performance.now();D.start=S;var A=E.stats.buffering,T=f?f.stats.buffering:null;A.start===0&&(A.start=S),T&&T.start===0&&(T.start=S);var R=e.audio,I=s==="audio"&&v.id===1&&(R==null?void 0:R.container)==="audio/mpeg",B={execute:function(){if(D.executeStart=self.performance.now(),I){var _=r.sourceBuffer[s];if(_){var U=E.start-_.timestampOffset;Math.abs(U)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+E.start+" (delta: "+U+") sn: "+E.sn+")"),_.timestampOffset=E.start)}}r.appendExecutor(t,s)},onStart:function(){},onComplete:function(){var _=self.performance.now();D.executeEnd=D.end=_,A.first===0&&(A.first=_),T&&T.first===0&&(T.first=_);var U=r.sourceBuffer,N={};for(var k in U)N[k]=P.BufferHelper.getBuffered(U[k]);r.appendError=0,r.hls.trigger(O.Events.BUFFER_APPENDED,{type:s,frag:E,part:f,chunkMeta:v,parent:E.type,timeRanges:N})},onError:function(_){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+s+" SourceBuffer",_);var U={type:M.ErrorTypes.MEDIA_ERROR,parent:E.type,details:M.ErrorDetails.BUFFER_APPEND_ERROR,err:_,fatal:!1};_.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=M.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,U.details=M.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>h.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+h.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),h.trigger(O.Events.ERROR,U)}};n.append(B,s)},m.onBufferFlushing=function(l,i){var r=this,h=this.operationQueue,n=function(t){return{execute:r.removeExecutor.bind(r,t,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(O.Events.BUFFER_FLUSHED,{type:t})},onError:function(E){L.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",E)}}};i.type?h.append(n(i.type),i.type):this.getSourceBufferTypes().forEach(function(e){h.append(n(e),e)})},m.onFragParsed=function(l,i){var r=this,h=i.frag,n=i.part,e=[],t=n?n.elementaryStreams:h.elementaryStreams;t[c.ElementaryStreamTypes.AUDIOVIDEO]?e.push("audiovideo"):(t[c.ElementaryStreamTypes.AUDIO]&&e.push("audio"),t[c.ElementaryStreamTypes.VIDEO]&&e.push("video"));var s=function(){var f=self.performance.now();h.stats.buffering.end=f,n&&(n.stats.buffering.end=f);var v=n?n.stats:h.stats;r.hls.trigger(O.Events.FRAG_BUFFERED,{frag:h,part:n,stats:v,id:h.type})};e.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+h.type+" level: "+h.level+" sn: "+h.sn),this.blockBuffers(s,e)},m.onFragChanged=function(l,i){this.flushBackBuffer()},m.onBufferEos=function(l,i){var r=this,h=this.getSourceBufferTypes().reduce(function(n,e){var t=r.sourceBuffer[e];return(!i.type||i.type===e)&&t&&!t.ended&&(t.ended=!0,L.logger.log("[buffer-controller]: "+e+" sourceBuffer now EOS")),n&&!!(!t||t.ended)},!0);h&&this.blockBuffers(function(){var n=r.mediaSource;!n||n.readyState!=="open"||n.endOfStream()})},m.onLevelUpdated=function(l,i){var r=i.details;!r.fragments.length||(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},m.flushBackBuffer=function(){var l=this.hls,i=this.details,r=this.media,h=this.sourceBuffer;if(!(!r||i===null)){var n=this.getSourceBufferTypes();if(!!n.length){var e=i.live&&l.config.liveBackBufferLength!==null?l.config.liveBackBufferLength:l.config.backBufferLength;if(!(!Object(b.isFiniteNumber)(e)||e<0)){var t=r.currentTime,s=i.levelTargetDuration,E=Math.max(e,s),f=Math.floor(t/s)*s-E;n.forEach(function(v){var D=h[v];if(D){var S=P.BufferHelper.getBuffered(D);S.length>0&&f>S.start(0)&&(l.trigger(O.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),i.live&&l.trigger(O.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),l.trigger(O.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:v}))}})}}}},m.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var l=this.details,i=this.hls,r=this.media,h=this.mediaSource,n=l.fragments[0].start+l.totalduration,e=r.duration,t=Object(b.isFiniteNumber)(h.duration)?h.duration:0;l.live&&i.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),h.duration=1/0,this.updateSeekableRange(l)):(n>t&&n>e||!Object(b.isFiniteNumber)(e))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+n.toFixed(3)),h.duration=n)}},m.updateSeekableRange=function(l){var i=this.mediaSource,r=l.fragments,h=r.length;if(h&&l.live&&i!==null&&i!==void 0&&i.setLiveSeekableRange){var n=Math.max(0,r[0].start),e=Math.max(n,n+l.totalduration);i.setLiveSeekableRange(n,e)}},m.checkPendingTracks=function(){var l=this.bufferCodecEventsExpected,i=this.operationQueue,r=this.pendingTracks,h=Object.keys(r).length;if(h&&!l||h===2){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length===0){this.hls.trigger(O.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}n.forEach(function(e){i.executeNext(e)})}},m.createSourceBuffers=function(l){var i=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var h=0;for(var n in l)if(!i[n]){var e=l[n];if(!e)throw Error("source buffer exists for track "+n+", however track does not");var t=e.levelCodec||e.codec,s=e.container+";codecs="+t;L.logger.log("[buffer-controller]: creating sourceBuffer("+s+")");try{var E=i[n]=r.addSourceBuffer(s),f=n;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[n]={buffer:E,codec:t,container:e.container,levelCodec:e.levelCodec,id:e.id},h++}catch(v){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(O.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:s})}}h&&this.hls.trigger(O.Events.BUFFER_CREATED,{tracks:this.tracks})},m._onSBUpdateStart=function(l){var i=this.operationQueue,r=i.current(l);r.onStart()},m._onSBUpdateEnd=function(l){var i=this.operationQueue,r=i.current(l);r.onComplete(),i.shiftAndExecuteNext(l)},m._onSBUpdateError=function(l,i){L.logger.error("[buffer-controller]: "+l+" SourceBuffer error",i),this.hls.trigger(O.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(l);r&&r.onError(i)},m.removeExecutor=function(l,i,r){var h=this.media,n=this.mediaSource,e=this.operationQueue,t=this.sourceBuffer,s=t[l];if(!h||!n||!s){L.logger.warn("[buffer-controller]: Attempting to remove from the "+l+" SourceBuffer, but it does not exist"),e.shiftAndExecuteNext(l);return}var E=Object(b.isFiniteNumber)(h.duration)?h.duration:1/0,f=Object(b.isFiniteNumber)(n.duration)?n.duration:1/0,v=Math.max(0,i),D=Math.min(r,E,f);D>v?(L.logger.log("[buffer-controller]: Removing ["+v+","+D+"] from the "+l+" SourceBuffer"),console.assert(!s.updating,l+" sourceBuffer must not be updating"),s.remove(v,D)):e.shiftAndExecuteNext(l)},m.appendExecutor=function(l,i){var r=this.operationQueue,h=this.sourceBuffer,n=h[i];if(!n){L.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(i);return}n.ended=!1,console.assert(!n.updating,i+" sourceBuffer must not be updating"),n.appendBuffer(l)},m.blockBuffers=function(l,i){var r=this;if(i===void 0&&(i=this.getSourceBufferTypes()),!i.length){L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(l);return}var h=this.operationQueue,n=i.map(function(e){return h.appendBlocker(e)});Promise.all(n).then(function(){l(),i.forEach(function(e){var t=r.sourceBuffer[e];(!t||!t.updating)&&h.shiftAndExecuteNext(e)})})},m.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},m.addBufferListener=function(l,i,r){var h=this.sourceBuffer[l];if(!!h){var n=r.bind(this,l);this.listeners[l].push({event:i,listener:n}),h.addEventListener(i,n)}},m.removeBufferListeners=function(l){var i=this.sourceBuffer[l];!i||this.listeners[l].forEach(function(r){i.removeEventListener(r.event,r.listener)})},y}()},"./src/controller/buffer-operation-queue.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return O});var b=g("./src/utils/logger.ts"),O=function(){function L(P){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=P}var M=L.prototype;return M.append=function(x,c){var a=this.queues[c];a.push(x),a.length===1&&this.buffers[c]&&this.executeNext(c)},M.insertAbort=function(x,c){var a=this.queues[c];a.unshift(x),this.executeNext(c)},M.appendBlocker=function(x){var c,a=new Promise(function(o){c=o}),u={execute:c,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(u,x),a},M.executeNext=function(x){var c=this.buffers,a=this.queues,u=c[x],o=a[x];if(o.length){var p=o[0];try{p.execute()}catch(y){b.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),p.onError(y),(!u||!u.updating)&&(o.shift(),this.executeNext(x))}}},M.shiftAndExecuteNext=function(x){this.queues[x].shift(),this.executeNext(x)},M.current=function(x){return this.queues[x][0]},L}()},"./src/controller/cap-level-controller.ts":function(K,C,g){g.r(C);var b=g("./src/events.ts");function O(P,x){for(var c=0;c<x.length;c++){var a=x[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(P,a.key,a)}}function L(P,x,c){return x&&O(P.prototype,x),c&&O(P,c),P}var M=function(){function P(c){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=c,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var x=P.prototype;return x.setStreamController=function(a){this.streamController=a},x.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},x.registerListeners=function(){var a=this.hls;a.on(b.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),a.on(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(b.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},x.unregisterListener=function(){var a=this.hls;a.off(b.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),a.off(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(b.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},x.onFpsDropLevelCapping=function(a,u){P.isLevelAllowed(u.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(u.droppedLevel)},x.onMediaAttaching=function(a,u){this.media=u.media instanceof HTMLVideoElement?u.media:null},x.onManifestParsed=function(a,u){var o=this.hls;this.restrictedLevels=[],this.firstLevel=u.firstLevel,o.config.capLevelToPlayerSize&&u.video&&this.startCapping()},x.onBufferCodecs=function(a,u){var o=this.hls;o.config.capLevelToPlayerSize&&u.video&&this.startCapping()},x.onMediaDetaching=function(){this.stopCapping()},x.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var a=this.hls.levels;if(a.length){var u=this.hls;u.autoLevelCapping=this.getMaxLevel(a.length-1),u.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=u.autoLevelCapping}}},x.getMaxLevel=function(a){var u=this,o=this.hls.levels;if(!o.length)return-1;var p=o.filter(function(y,m){return P.isLevelAllowed(m,u.restrictedLevels)&&m<=a});return this.clientRect=null,P.getMaxLevelByMediaSize(p,this.mediaWidth,this.mediaHeight)},x.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},x.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},x.getDimensions=function(){if(this.clientRect)return this.clientRect;var a=this.media,u={width:0,height:0};if(a){var o=a.getBoundingClientRect();u.width=o.width,u.height=o.height,!u.width&&!u.height&&(u.width=o.right-o.left||a.width||0,u.height=o.bottom-o.top||a.height||0)}return this.clientRect=u,u},P.isLevelAllowed=function(a,u){return u===void 0&&(u=[]),u.indexOf(a)===-1},P.getMaxLevelByMediaSize=function(a,u,o){if(!a||!a.length)return-1;for(var p=function(i,r){return r?i.width!==r.width||i.height!==r.height:!0},y=a.length-1,m=0;m<a.length;m+=1){var d=a[m];if((d.width>=u||d.height>=o)&&p(d,a[m+1])){y=m;break}}return y},L(P,[{key:"mediaWidth",get:function(){return this.getDimensions().width*P.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*P.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var a=1;try{a=self.devicePixelRatio}catch{}return a}}]),P}();C.default=M},"./src/controller/fps-controller.ts":function(K,C,g){g.r(C);var b=g("./src/events.ts"),O=g("./src/utils/logger.ts"),L=function(){function M(x){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=x,this.registerListeners()}var P=M.prototype;return P.setStreamController=function(c){this.streamController=c},P.registerListeners=function(){this.hls.on(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},P.unregisterListeners=function(){this.hls.off(b.Events.MEDIA_ATTACHING,this.onMediaAttaching)},P.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},P.onMediaAttaching=function(c,a){var u=this.hls.config;if(u.capLevelOnFPSDrop){var o=a.media instanceof self.HTMLVideoElement?a.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),u.fpsDroppedMonitoringPeriod)}},P.checkFPS=function(c,a,u){var o=performance.now();if(a){if(this.lastTime){var p=o-this.lastTime,y=u-this.lastDroppedFrames,m=a-this.lastDecodedFrames,d=1e3*y/p,l=this.hls;if(l.trigger(b.Events.FPS_DROP,{currentDropped:y,currentDecoded:m,totalDroppedFrames:u}),d>0&&y>l.config.fpsDroppedMonitoringThreshold*m){var i=l.currentLevel;O.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),i>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=i)&&(i=i-1,l.trigger(b.Events.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:l.currentLevel}),l.autoLevelCapping=i,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=u,this.lastDecodedFrames=a}},P.checkFPSInterval=function(){var c=this.media;if(c)if(this.isVideoPlaybackQualityAvailable){var a=c.getVideoPlaybackQuality();this.checkFPS(c,a.totalVideoFrames,a.droppedVideoFrames)}else this.checkFPS(c,c.webkitDecodedFrameCount,c.webkitDroppedFrameCount)},M}();C.default=L},"./src/controller/fragment-finders.ts":function(K,C,g){g.r(C),g.d(C,"findFragmentByPDT",function(){return L}),g.d(C,"findFragmentByPTS",function(){return M}),g.d(C,"fragmentWithinToleranceTest",function(){return P}),g.d(C,"pdtWithinToleranceTest",function(){return x}),g.d(C,"findFragWithCC",function(){return c});var b=g("./src/polyfills/number.ts"),O=g("./src/utils/binary-search.ts");function L(a,u,o){if(u===null||!Array.isArray(a)||!a.length||!Object(b.isFiniteNumber)(u))return null;var p=a[0].programDateTime;if(u<(p||0))return null;var y=a[a.length-1].endProgramDateTime;if(u>=(y||0))return null;o=o||0;for(var m=0;m<a.length;++m){var d=a[m];if(x(u,o,d))return d}return null}function M(a,u,o,p){o===void 0&&(o=0),p===void 0&&(p=0);var y=null;if(a?y=u[a.sn-u[0].sn+1]||null:o===0&&u[0].start===0&&(y=u[0]),y&&P(o,p,y)===0)return y;var m=O.default.search(u,P.bind(null,o,p));return m||y}function P(a,u,o){a===void 0&&(a=0),u===void 0&&(u=0);var p=Math.min(u,o.duration+(o.deltaPTS?o.deltaPTS:0));return o.start+o.duration-p<=a?1:o.start-p>a&&o.start?-1:0}function x(a,u,o){var p=Math.min(u,o.duration+(o.deltaPTS?o.deltaPTS:0))*1e3,y=o.endProgramDateTime||0;return y-p>a}function c(a,u){return O.default.search(a,function(o){return o.cc<u?1:o.cc>u?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,C,g){g.r(C),g.d(C,"FragmentState",function(){return L}),g.d(C,"FragmentTracker",function(){return M});var b=g("./src/events.ts"),O=g("./src/types/loader.ts"),L;(function(c){c.NOT_LOADED="NOT_LOADED",c.BACKTRACKED="BACKTRACKED",c.APPENDING="APPENDING",c.PARTIAL="PARTIAL",c.OK="OK"})(L||(L={}));var M=function(){function c(u){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=u,this._registerListeners()}var a=c.prototype;return a._registerListeners=function(){var o=this.hls;o.on(b.Events.BUFFER_APPENDED,this.onBufferAppended,this),o.on(b.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(b.Events.FRAG_LOADED,this.onFragLoaded,this)},a._unregisterListeners=function(){var o=this.hls;o.off(b.Events.BUFFER_APPENDED,this.onBufferAppended,this),o.off(b.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(b.Events.FRAG_LOADED,this.onFragLoaded,this)},a.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},a.getAppendedFrag=function(o,p){if(p===O.PlaylistLevelType.MAIN){var y=this.activeFragment,m=this.activeParts;if(!y)return null;if(m)for(var d=m.length;d--;){var l=m[d],i=l?l.end:y.appendedPTS;if(l.start<=o&&i!==void 0&&o<=i)return d>9&&(this.activeParts=m.slice(d-9)),l}else if(y.start<=o&&y.appendedPTS!==void 0&&o<=y.appendedPTS)return y}return this.getBufferedFrag(o,p)},a.getBufferedFrag=function(o,p){for(var y=this.fragments,m=Object.keys(y),d=m.length;d--;){var l=y[m[d]];if((l==null?void 0:l.body.type)===p&&l.buffered){var i=l.body;if(i.start<=o&&o<=i.end)return i}}return null},a.detectEvictedFragments=function(o,p,y){var m=this;Object.keys(this.fragments).forEach(function(d){var l=m.fragments[d];if(!!l){if(!l.buffered){l.body.type===y&&m.removeFragment(l.body);return}var i=l.range[o];!i||i.time.some(function(r){var h=!m.isTimeBuffered(r.startPTS,r.endPTS,p);return h&&m.removeFragment(l.body),h})}})},a.detectPartialFragments=function(o){var p=this,y=this.timeRanges,m=o.frag,d=o.part;if(!(!y||m.sn==="initSegment")){var l=x(m),i=this.fragments[l];!i||(Object.keys(y).forEach(function(r){var h=m.elementaryStreams[r];if(!!h){var n=y[r],e=d!==null||h.partial===!0;i.range[r]=p.getBufferedTimes(m,d,e,n)}}),i.backtrack=i.loaded=null,Object.keys(i.range).length?i.buffered=!0:this.removeFragment(i.body))}},a.fragBuffered=function(o){var p=x(o),y=this.fragments[p];y&&(y.backtrack=y.loaded=null,y.buffered=!0)},a.getBufferedTimes=function(o,p,y,m){for(var d={time:[],partial:y},l=p?p.start:o.start,i=p?p.end:o.end,r=o.minEndPTS||i,h=o.maxStartPTS||l,n=0;n<m.length;n++){var e=m.start(n)-this.bufferPadding,t=m.end(n)+this.bufferPadding;if(h>=e&&r<=t){d.time.push({startPTS:Math.max(l,m.start(n)),endPTS:Math.min(i,m.end(n))});break}else if(l<t&&i>e)d.partial=!0,d.time.push({startPTS:Math.max(l,m.start(n)),endPTS:Math.min(i,m.end(n))});else if(i<=e)break}return d},a.getPartialFragment=function(o){var p=null,y,m,d,l=0,i=this.bufferPadding,r=this.fragments;return Object.keys(r).forEach(function(h){var n=r[h];!n||P(n)&&(m=n.body.start-i,d=n.body.end+i,o>=m&&o<=d&&(y=Math.min(o-m,d-o),l<=y&&(p=n.body,l=y)))}),p},a.getState=function(o){var p=x(o),y=this.fragments[p];return y?y.buffered?P(y)?L.PARTIAL:L.OK:y.backtrack?L.BACKTRACKED:L.APPENDING:L.NOT_LOADED},a.backtrack=function(o,p){var y=x(o),m=this.fragments[y];if(!m||m.backtrack)return null;var d=m.backtrack=p||m.loaded;return m.loaded=null,d},a.getBacktrackData=function(o){var p=x(o),y=this.fragments[p];if(y){var m,d=y.backtrack;if(d!=null&&(m=d.payload)!==null&&m!==void 0&&m.byteLength)return d;this.removeFragment(o)}return null},a.isTimeBuffered=function(o,p,y){for(var m,d,l=0;l<y.length;l++){if(m=y.start(l)-this.bufferPadding,d=y.end(l)+this.bufferPadding,o>=m&&p<=d)return!0;if(p<=m)return!1}return!1},a.onFragLoaded=function(o,p){var y=p.frag,m=p.part;if(!(y.sn==="initSegment"||y.bitrateTest||m)){var d=x(y);this.fragments[d]={body:y,loaded:p,backtrack:null,buffered:!1,range:Object.create(null)}}},a.onBufferAppended=function(o,p){var y=this,m=p.frag,d=p.part,l=p.timeRanges;if(m.type===O.PlaylistLevelType.MAIN)if(this.activeFragment=m,d){var i=this.activeParts;i||(this.activeParts=i=[]),i.push(d)}else this.activeParts=null;this.timeRanges=l,Object.keys(l).forEach(function(r){var h=l[r];if(y.detectEvictedFragments(r,h),!d)for(var n=0;n<h.length;n++)m.appendedPTS=Math.max(h.end(n),m.appendedPTS||0)})},a.onFragBuffered=function(o,p){this.detectPartialFragments(p)},a.hasFragment=function(o){var p=x(o);return!!this.fragments[p]},a.removeFragmentsInRange=function(o,p,y){var m=this;Object.keys(this.fragments).forEach(function(d){var l=m.fragments[d];if(!!l&&l.buffered){var i=l.body;i.type===y&&i.start<p&&i.end>o&&m.removeFragment(i)}})},a.removeFragment=function(o){var p=x(o);o.stats.loaded=0,o.clearElementaryStreamInfo(),delete this.fragments[p]},a.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},c}();function P(c){var a,u;return c.buffered&&(((a=c.range.video)===null||a===void 0?void 0:a.partial)||((u=c.range.audio)===null||u===void 0?void 0:u.partial))}function x(c){return c.type+"_"+c.level+"_"+c.urlId+"_"+c.sn}},"./src/controller/gap-controller.ts":function(K,C,g){g.r(C),g.d(C,"STALL_MINIMUM_DURATION_MS",function(){return P}),g.d(C,"MAX_START_GAP_JUMP",function(){return x}),g.d(C,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return c}),g.d(C,"SKIP_BUFFER_RANGE_START",function(){return a}),g.d(C,"default",function(){return u});var b=g("./src/utils/buffer-helper.ts"),O=g("./src/errors.ts"),L=g("./src/events.ts"),M=g("./src/utils/logger.ts"),P=250,x=2,c=.1,a=.05,u=function(){function o(y,m,d,l){this.config=void 0,this.media=void 0,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=y,this.media=m,this.fragmentTracker=d,this.hls=l}var p=o.prototype;return p.destroy=function(){this.hls=this.fragmentTracker=this.media=null},p.poll=function(m){var d=this.config,l=this.media,i=this.stalled,r=l.currentTime,h=l.seeking,n=this.seeking&&!h,e=!this.seeking&&h;if(this.seeking=h,r!==m){if(this.moved=!0,i!==null){if(this.stallReported){var t=self.performance.now()-i;M.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(t)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((e||n)&&(this.stalled=null),!(l.paused||l.ended||l.playbackRate===0||!b.BufferHelper.getBuffered(l).length)){var s=b.BufferHelper.bufferInfo(l,r,0),E=s.len>0,f=s.nextStart||0;if(!(!E&&!f)){if(h){var v=s.len>x,D=!f||f-r>x&&!this.fragmentTracker.getPartialFragment(r);if(v||D)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,A=Math.max(f,s.start||0)-r,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=T==null||(S=T.details)===null||S===void 0?void 0:S.live,I=R?T.details.targetduration*2:x;if(A>0&&A<=I){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(i===null){this.stalled=B;return}var F=B-i;!h&&F>=P&&this._reportStall(s.len);var _=b.BufferHelper.bufferInfo(l,r,d.maxBufferHole);this._tryFixBufferStall(_,F)}}},p._tryFixBufferStall=function(m,d){var l=this.config,i=this.fragmentTracker,r=this.media,h=r.currentTime,n=i.getPartialFragment(h);if(n){var e=this._trySkipBufferHole(n);if(e)return}m.len>l.maxBufferHole&&d>l.highBufferWatchdogPeriod*1e3&&(M.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},p._reportStall=function(m){var d=this.hls,l=this.media,i=this.stallReported;i||(this.stallReported=!0,M.logger.warn("Playback stalling at @"+l.currentTime+" due to low buffer (buffer="+m+")"),d.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:m}))},p._trySkipBufferHole=function(m){for(var d=this.config,l=this.hls,i=this.media,r=i.currentTime,h=0,n=b.BufferHelper.getBuffered(i),e=0;e<n.length;e++){var t=n.start(e);if(r+d.maxBufferHole>=h&&r<t){var s=Math.max(t+a,i.currentTime+c);return M.logger.warn("skipping hole, adjusting currentTime from "+r+" to "+s),this.moved=!0,this.stalled=null,i.currentTime=s,m&&l.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+r+" to "+s,frag:m}),s}h=n.end(e)}return 0},p._tryNudgeBuffer=function(){var m=this.config,d=this.hls,l=this.media,i=l.currentTime,r=(this.nudgeRetry||0)+1;if(this.nudgeRetry=r,r<m.nudgeMaxRetry){var h=i+r*m.nudgeOffset;M.logger.warn("Nudging 'currentTime' from "+i+" to "+h),l.currentTime=h,d.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else M.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+m.nudgeMaxRetry+" nudges"),d.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},o}()},"./src/controller/id3-track-controller.ts":function(K,C,g){g.r(C);var b=g("./src/events.ts"),O=g("./src/utils/texttrack-utils.ts"),L=g("./src/demux/id3.ts"),M=.25,P=function(){function x(a){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=a,this._registerListeners()}var c=x.prototype;return c.destroy=function(){this._unregisterListeners()},c._registerListeners=function(){var u=this.hls;u.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(b.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),u.on(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},c._unregisterListeners=function(){var u=this.hls;u.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(b.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),u.off(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},c.onMediaAttached=function(u,o){this.media=o.media},c.onMediaDetaching=function(){!this.id3Track||(Object(O.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},c.getID3Track=function(u){if(!!this.media){for(var o=0;o<u.length;o++){var p=u[o];if(p.kind==="metadata"&&p.label==="id3")return Object(O.sendAddTrackEvent)(p,this.media),p}return this.media.addTextTrack("metadata","id3")}},c.onFragParsingMetadata=function(u,o){if(!!this.media){var p=o.frag,y=o.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var m=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,d=0;d<y.length;d++){var l=L.getID3Frames(y[d].data);if(l){var i=y[d].pts,r=d<y.length-1?y[d+1].pts:p.end,h=r-i;h<=0&&(r=i+M);for(var n=0;n<l.length;n++){var e=l[n];if(!L.isTimeStampFrame(e)){var t=new m(i,r,"");t.value=e,this.id3Track.addCue(t)}}}}}},c.onBufferFlushing=function(u,o){var p=o.startOffset,y=o.endOffset,m=o.type;if(!m||m==="audio"){var d=this.id3Track;d&&Object(O.removeCuesInRange)(d,p,y)}},x}();C.default=P},"./src/controller/latency-controller.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return x});var b=g("./src/errors.ts"),O=g("./src/events.ts"),L=g("./src/utils/logger.ts");function M(c,a){for(var u=0;u<a.length;u++){var o=a[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function P(c,a,u){return a&&M(c.prototype,a),u&&M(c,u),c}var x=function(){function c(u){var o=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 o.timeupdate()},this.hls=u,this.config=u.config,this.registerListeners()}var a=c.prototype;return a.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},a.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(O.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(O.Events.ERROR,this.onError)},a.onMediaAttached=function(o,p){this.media=p.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(o,p){var y=p.details;this.levelDetails=y,y.advanced&&this.timeupdate(),!y.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},a.onError=function(o,p){p.details===b.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},a.timeupdate=function(){var o=this.media,p=this.levelDetails;if(!(!o||!p)){this.currentTime=o.currentTime;var y=this.computeLatency();if(y!==null){this._latency=y;var m=this.config,d=m.lowLatencyMode,l=m.maxLiveSyncPlaybackRate;if(!(!d||l===1)){var i=this.targetLatency;if(i!==null){var r=y-i,h=Math.min(this.maxLatency,i+p.targetduration),n=r<h;if(p.live&&n&&r>.05&&this.forwardBufferLength>1){var e=Math.min(2,Math.max(1,l)),t=Math.round(2/(1+Math.exp(-.75*r-this.edgeStalled))*20)/20;o.playbackRate=Math.min(e,Math.max(1,t))}else o.playbackRate!==1&&o.playbackRate!==0&&(o.playbackRate=1)}}}}},a.estimateLiveEdge=function(){var o=this.levelDetails;return o===null?null:o.edge+o.age},a.computeLatency=function(){var o=this.estimateLiveEdge();return o===null?null:o-this.currentTime},P(c,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var o=this.config,p=this.levelDetails;return o.liveMaxLatencyDuration!==void 0?o.liveMaxLatencyDuration:p?o.liveMaxLatencyDurationCount*p.targetduration:0}},{key:"targetLatency",get:function(){var o=this.levelDetails;if(o===null)return null;var p=o.holdBack,y=o.partHoldBack,m=o.targetduration,d=this.config,l=d.liveSyncDuration,i=d.liveSyncDurationCount,r=d.lowLatencyMode,h=this.hls.userConfig,n=r&&y||p;(h.liveSyncDuration||h.liveSyncDurationCount||n===0)&&(n=l!==void 0?l:i*m);var e=m,t=1;return n+Math.min(this.stallCount*t,e)}},{key:"liveSyncPosition",get:function(){var o=this.estimateLiveEdge(),p=this.targetLatency,y=this.levelDetails;if(o===null||p===null||y===null)return null;var m=y.edge,d=o-p-this.edgeStalled,l=m-y.totalduration,i=m-(this.config.lowLatencyMode&&y.partTarget||y.targetduration);return Math.min(Math.max(l,d),i)}},{key:"drift",get:function(){var o=this.levelDetails;return o===null?1:o.drift}},{key:"edgeStalled",get:function(){var o=this.levelDetails;if(o===null)return 0;var p=(this.config.lowLatencyMode&&o.partTarget||o.targetduration)*3;return Math.max(o.age-p,0)}},{key:"forwardBufferLength",get:function(){var o=this.media,p=this.levelDetails;if(!o||!p)return 0;var y=o.buffered.length;return y?o.buffered.end(y-1):p.edge-this.currentTime}}]),c}()},"./src/controller/level-controller.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return d});var b=g("./src/types/level.ts"),O=g("./src/events.ts"),L=g("./src/errors.ts"),M=g("./src/utils/codecs.ts"),P=g("./src/controller/level-helper.ts"),x=g("./src/controller/base-playlist-controller.ts"),c=g("./src/types/loader.ts");function a(){return a=Object.assign||function(l){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var h in r)Object.prototype.hasOwnProperty.call(r,h)&&(l[h]=r[h])}return l},a.apply(this,arguments)}function u(l,i){for(var r=0;r<i.length;r++){var h=i[r];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(l,h.key,h)}}function o(l,i,r){return i&&u(l.prototype,i),r&&u(l,r),l}function p(l,i){l.prototype=Object.create(i.prototype),l.prototype.constructor=l,y(l,i)}function y(l,i){return y=Object.setPrototypeOf||function(h,n){return h.__proto__=n,h},y(l,i)}var m=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(l){p(i,l);function i(h){var n;return n=l.call(this,h,"[level-controller]")||this,n._levels=[],n._firstLevel=-1,n._startLevel=void 0,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.onParsedComplete=void 0,n._registerListeners(),n}var r=i.prototype;return r._registerListeners=function(){var n=this.hls;n.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),n.on(O.Events.ERROR,this.onError,this)},r._unregisterListeners=function(){var n=this.hls;n.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(O.Events.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,l.prototype.destroy.call(this)},r.startLoad=function(){var n=this._levels;n.forEach(function(e){e.loadError=0}),l.prototype.startLoad.call(this)},r.onManifestLoaded=function(n,e){var t=[],s=[],E=[],f,v={},D,S=!1,A=!1,T=!1;if(e.levels.forEach(function(F){var _=F.attrs;S=S||!!(F.width&&F.height),A=A||!!F.videoCodec,T=T||!!F.audioCodec,m&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var U=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;D=v[U],D?D.url.push(F.url):(D=new b.Level(F),v[U]=D,t.push(D)),_&&(_.AUDIO&&Object(P.addGroupId)(D,"audio",_.AUDIO),_.SUBTITLES&&Object(P.addGroupId)(D,"text",_.SUBTITLES))}),(S||A)&&T&&(t=t.filter(function(F){var _=F.videoCodec,U=F.width,N=F.height;return!!_||!!(U&&N)})),t=t.filter(function(F){var _=F.audioCodec,U=F.videoCodec;return(!_||Object(M.isCodecSupportedInMp4)(_,"audio"))&&(!U||Object(M.isCodecSupportedInMp4)(U,"video"))}),e.audioTracks&&(s=e.audioTracks.filter(function(F){return!F.audioCodec||Object(M.isCodecSupportedInMp4)(F.audioCodec,"audio")}),Object(P.assignTrackIdsByGroup)(s)),e.subtitles&&(E=e.subtitles,Object(P.assignTrackIdsByGroup)(E)),t.length>0){f=t[0].bitrate,t.sort(function(F,_){return F.bitrate-_.bitrate}),this._levels=t;for(var R=0;R<t.length;R++)if(t[R].bitrate===f){this._firstLevel=R,this.log("manifest loaded, "+t.length+" level(s) found, first bitrate: "+f);break}var I=T&&!A,B={levels:t,audioTracks:s,subtitleTracks:E,firstLevel:this._firstLevel,stats:e.stats,audio:T,video:A,altAudio:!I&&s.some(function(F){return!!F.url})};this.hls.trigger(O.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},r.onError=function(n,e){if(l.prototype.onError.call(this,n,e),!e.fatal){var t=e.context,s=this._levels[this.currentLevelIndex];if(t&&(t.type===c.PlaylistContextType.AUDIO_TRACK&&s.audioGroupIds&&t.groupId===s.audioGroupIds[s.urlId]||t.type===c.PlaylistContextType.SUBTITLE_TRACK&&s.textGroupIds&&t.groupId===s.textGroupIds[s.urlId])){this.redundantFailover(this.currentLevelIndex);return}var E=!1,f=!0,v;switch(e.details){case L.ErrorDetails.FRAG_LOAD_ERROR:case L.ErrorDetails.FRAG_LOAD_TIMEOUT:case L.ErrorDetails.KEY_LOAD_ERROR:case L.ErrorDetails.KEY_LOAD_TIMEOUT:if(e.frag){var D=this._levels[e.frag.level];D?(D.fragmentError++,D.fragmentError>this.hls.config.fragLoadingMaxRetry&&(v=e.frag.level)):v=e.frag.level}break;case L.ErrorDetails.LEVEL_LOAD_ERROR:case L.ErrorDetails.LEVEL_LOAD_TIMEOUT:t&&(t.deliveryDirectives&&(f=!1),v=t.level),E=!0;break;case L.ErrorDetails.REMUX_ALLOC_ERROR:v=e.level,E=!0;break}v!==void 0&&this.recoverLevel(e,v,E,f)}},r.recoverLevel=function(n,e,t,s){var E=n.details,f=this._levels[e];if(f.loadError++,t){var v=this.retryLoadingOrFail(n);if(v)n.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(s){var D=f.url.length;if(D>1&&f.loadError<D)n.levelRetry=!0,this.redundantFailover(e);else if(this.manualLevelIndex===-1){var S=e===0?this._levels.length-1:e-1;this.currentLevelIndex!==S&&this._levels[S].loadError===0&&(this.warn(E+": switch to "+S),n.levelRetry=!0,this.hls.nextAutoLevel=S)}}},r.redundantFailover=function(n){var e=this._levels[n],t=e.url.length;if(t>1){var s=(e.urlId+1)%t;this.warn("Switching to redundant URL-id "+s),this._levels.forEach(function(E){E.urlId=s}),this.level=n}},r.onFragLoaded=function(n,e){var t=e.frag;if(t!==void 0&&t.type===c.PlaylistLevelType.MAIN){var s=this._levels[t.level];s!==void 0&&(s.fragmentError=0,s.loadError=0)}},r.onLevelLoaded=function(n,e){var t,s=e.level,E=e.details,f=this._levels[s];if(!f){var v;this.warn("Invalid level index "+s),(v=e.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(E.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(s,e,f.details)):(t=e.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(E.deltaUpdateFailed=!0)},r.onAudioTrackSwitched=function(n,e){var t=this.hls.levels[this.currentLevelIndex];if(!!t&&t.audioGroupIds){for(var s=-1,E=this.hls.audioTracks[e.id].groupId,f=0;f<t.audioGroupIds.length;f++)if(t.audioGroupIds[f]===E){s=f;break}s!==t.urlId&&(t.urlId=s,this.startLoad())}},r.loadPlaylist=function(n){var e=this.currentLevelIndex,t=this._levels[e];if(this.canLoad&&t&&t.url.length>0){var s=t.urlId,E=t.url[s];if(n)try{E=n.addDirectives(E)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Attempt loading level index "+e+(n?" at sn "+n.msn+" part "+n.part:"")+" with URL-id "+s+" "+E),this.clearTimer(),this.hls.trigger(O.Events.LEVEL_LOADING,{url:E,level:e,id:s,deliveryDirectives:n||null})}},r.removeLevel=function(n,e){var t=function(f,v){return v!==e},s=this._levels.filter(function(E,f){return f!==n?!0:E.url.length>1&&e!==void 0?(E.url=E.url.filter(t),E.audioGroupIds&&(E.audioGroupIds=E.audioGroupIds.filter(t)),E.textGroupIds&&(E.textGroupIds=E.textGroupIds.filter(t)),E.urlId=0,!0):!1}).map(function(E,f){var v=E.details;return v!=null&&v.fragments&&v.fragments.forEach(function(D){D.level=f}),E});this._levels=s,this.hls.trigger(O.Events.LEVELS_UPDATED,{levels:s})},o(i,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(n){var e,t=this._levels;if(t.length!==0&&!(this.currentLevelIndex===n&&(e=t[n])!==null&&e!==void 0&&e.details)){if(n<0||n>=t.length){var s=n<0;if(this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.LEVEL_SWITCH_ERROR,level:n,fatal:s,reason:"invalid level idx"}),s)return;n=Math.min(n,t.length-1)}this.clearTimer();var E=this.currentLevelIndex,f=t[E],v=t[n];this.log("switching to level "+n+" from "+E),this.currentLevelIndex=n;var D=a({},v,{level:n,maxBitrate:v.maxBitrate,uri:v.uri,urlId:v.urlId});delete D._urlId,this.hls.trigger(O.Events.LEVEL_SWITCHING,D);var S=v.details;if(!S||S.live){var A=this.switchParams(v.uri,f==null?void 0:f.details);this.loadPlaylist(A)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(n){this.manualLevelIndex=n,this._startLevel===void 0&&(this._startLevel=n),n!==-1&&(this.level=n)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(n){this._firstLevel=n}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var n=this.hls.config.startLevel;return n!==void 0?n:this._firstLevel}else return this._startLevel},set:function(n){this._startLevel=n}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(n){this.level=n,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=n)}}]),i}(x.default)},"./src/controller/level-helper.ts":function(K,C,g){g.r(C),g.d(C,"addGroupId",function(){return L}),g.d(C,"assignTrackIdsByGroup",function(){return M}),g.d(C,"updatePTS",function(){return P}),g.d(C,"updateFragPTSDTS",function(){return c}),g.d(C,"mergeDetails",function(){return a}),g.d(C,"mapPartIntersection",function(){return u}),g.d(C,"mapFragmentIntersection",function(){return o}),g.d(C,"adjustSliding",function(){return p}),g.d(C,"addSliding",function(){return y}),g.d(C,"computeReloadInterval",function(){return m}),g.d(C,"getFragmentWithSN",function(){return d}),g.d(C,"getPartWith",function(){return l});var b=g("./src/polyfills/number.ts"),O=g("./src/utils/logger.ts");function L(i,r,h){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(h);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(h);break}}function M(i){var r={};i.forEach(function(h){var n=h.groupId||"";h.id=r[n]=r[n]||0,r[n]++})}function P(i,r,h){var n=i[r],e=i[h];x(n,e)}function x(i,r){var h=r.startPTS;if(Object(b.isFiniteNumber)(h)){var n=0,e;r.sn>i.sn?(n=h-i.start,e=i):(n=i.start-h,e=r),e.duration!==n&&(e.duration=n)}else if(r.sn>i.sn){var t=i.cc===r.cc;t&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function c(i,r,h,n,e,t){var s=n-h;s<=0&&(O.logger.warn("Fragment should have a positive duration",r),n=h+r.duration,t=e+r.duration);var E=h,f=n,v=r.startPTS,D=r.endPTS;if(Object(b.isFiniteNumber)(v)){var S=Math.abs(v-h);Object(b.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(S,r.deltaPTS):r.deltaPTS=S,E=Math.max(h,v),h=Math.min(h,v),e=Math.min(e,r.startDTS),f=Math.min(n,D),n=Math.max(n,D),t=Math.max(t,r.endDTS)}r.duration=n-h;var A=h-r.start;r.appendedPTS=n,r.start=r.startPTS=h,r.maxStartPTS=E,r.startDTS=e,r.endPTS=n,r.minEndPTS=f,r.endDTS=t;var T=r.sn;if(!i||T<i.startSN||T>i.endSN)return 0;var R,I=T-i.startSN,B=i.fragments;for(B[I]=r,R=I;R>0;R--)x(B[R],B[R-1]);for(R=I;R<B.length-1;R++)x(B[R],B[R+1]);return i.fragmentHint&&x(B[B.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,A}function a(i,r){for(var h=null,n=i.fragments,e=n.length-1;e>=0;e--){var t=n[e].initSegment;if(t){h=t;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var s=0,E;if(o(i,r,function(R,I){R.relurl&&(s=R.cc-I.cc),Object(b.isFiniteNumber)(R.startPTS)&&Object(b.isFiniteNumber)(R.endPTS)&&(I.start=I.startPTS=R.startPTS,I.startDTS=R.startDTS,I.appendedPTS=R.appendedPTS,I.maxStartPTS=R.maxStartPTS,I.endPTS=R.endPTS,I.endDTS=R.endDTS,I.minEndPTS=R.minEndPTS,I.duration=R.endPTS-R.startPTS,I.duration&&(E=I),r.PTSKnown=r.alignedSliding=!0),I.elementaryStreams=R.elementaryStreams,I.loader=R.loader,I.stats=R.stats,I.urlId=R.urlId,R.initSegment&&(I.initSegment=R.initSegment,h=R.initSegment)}),h){var f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.forEach(function(R){var I;(!R.initSegment||R.initSegment.relurl===((I=h)===null||I===void 0?void 0:I.relurl))&&(R.initSegment=h)})}if(r.skippedSegments&&(r.deltaUpdateFailed=r.fragments.some(function(R){return!R}),r.deltaUpdateFailed)){O.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}var D=r.fragments;if(s){O.logger.warn("discontinuity sliding from playlist, take drift into account");for(var S=0;S<D.length;S++)D[S].cc+=s}r.skippedSegments&&(r.startCC=r.fragments[0].cc),u(i.partList,r.partList,function(R,I){I.elementaryStreams=R.elementaryStreams,I.stats=R.stats}),E?c(r,E,E.startPTS,E.endPTS,E.startDTS,E.endDTS):p(i,r),D.length&&(r.totalduration=r.edge-D[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var A=r.advancedDateTime;if(r.advanced&&A){var T=r.edge;r.driftStart||(r.driftStartTime=A,r.driftStart=T),r.driftEndTime=A,r.driftEnd=T}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function u(i,r,h){if(i&&r)for(var n=0,e=0,t=i.length;e<=t;e++){var s=i[e],E=r[e+n];s&&E&&s.index===E.index&&s.fragment.sn===E.fragment.sn?h(s,E):n--}}function o(i,r,h){for(var n=r.skippedSegments,e=Math.max(i.startSN,r.startSN)-r.startSN,t=(i.fragmentHint?1:0)+(n?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,s=r.startSN-i.startSN,E=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=e;v<=t;v++){var D=f[s+v],S=E[v];n&&!S&&v<n&&(S=r.fragments[v]=D),D&&S&&h(D,S)}}function p(i,r){var h=r.startSN+r.skippedSegments-i.startSN,n=i.fragments;h<0||h>=n.length||y(r,n[h].start)}function y(i,r){if(r){for(var h=i.fragments,n=i.skippedSegments;n<h.length;n++)h[n].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function m(i,r){var h=1e3*i.levelTargetDuration,n=h/2,e=i.age,t=e>0&&e<h*3,s=r.loading.end-r.loading.start,E,f=i.availabilityDelay;if(i.updated===!1)if(t){var v=333*i.misses;E=Math.max(Math.min(n,s*2),v),i.availabilityDelay=(i.availabilityDelay||0)+E}else E=n;else t?(f=Math.min(f||h/2,e),i.availabilityDelay=f,E=f+h-e):E=h-s;return Math.round(E)}function d(i,r,h){if(!i||!i.details)return null;var n=i.details,e=n.fragments[r-n.startSN];return e||(e=n.fragmentHint,e&&e.sn===r)?e:r<n.startSN&&h&&h.sn===r?h:null}function l(i,r,h){if(!i||!i.details)return null;var n=i.details.partList;if(n)for(var e=n.length;e--;){var t=n[e];if(t.index===h&&t.fragment.sn===r)return t}return null}},"./src/controller/stream-controller.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return n});var b=g("./src/polyfills/number.ts"),O=g("./src/controller/base-stream-controller.ts"),L=g("./src/is-supported.ts"),M=g("./src/events.ts"),P=g("./src/utils/buffer-helper.ts"),x=g("./src/controller/fragment-tracker.ts"),c=g("./src/types/loader.ts"),a=g("./src/loader/fragment.ts"),u=g("./src/demux/transmuxer-interface.ts"),o=g("./src/types/transmuxer.ts"),p=g("./src/controller/gap-controller.ts"),y=g("./src/errors.ts"),m=g("./src/utils/logger.ts");function d(e,t){for(var s=0;s<t.length;s++){var E=t[s];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(e,E.key,E)}}function l(e,t,s){return t&&d(e.prototype,t),s&&d(e,s),e}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}function r(e,t){return r=Object.setPrototypeOf||function(E,f){return E.__proto__=f,E},r(e,t)}var h=100,n=function(e){i(t,e);function t(E,f){var v;return v=e.call(this,E,f,"[stream-controller]")||this,v.audioCodecSwap=!1,v.gapController=null,v.level=-1,v._forceStartLoad=!1,v.altAudio=!1,v.audioOnly=!1,v.fragPlaying=null,v.onvplaying=null,v.onvseeked=null,v.fragLastKbps=0,v.stalled=!1,v.couldBacktrack=!1,v.audioCodecSwitch=!1,v.videoBuffer=null,v._registerListeners(),v}var s=t.prototype;return s._registerListeners=function(){var f=this.hls;f.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.on(M.Events.ERROR,this.onError,this),f.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},s._unregisterListeners=function(){var f=this.hls;f.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.off(M.Events.ERROR,this.onError,this),f.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},s.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},s.startLoad=function(f){if(this.levels){var v=this.lastCurrentTime,D=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var S=D.startLevel;S===-1&&(D.config.testBandwidth?(S=0,this.bitrateTest=!0):S=D.nextAutoLevel),this.level=D.nextLoadLevel=S,this.loadedmetadata=!1}v>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+v.toFixed(3)),f=v),this.state=O.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=O.State.STOPPED},s.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},s.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_LEVEL:{var f,v=this.levels,D=this.level,S=v==null||(f=v[D])===null||f===void 0?void 0:f.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=O.State.IDLE;break}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var A,T=self.performance.now(),R=this.retryDate;(!R||T>=R||(A=this.media)!==null&&A!==void 0&&A.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=O.State.IDLE)}break}this.onTickEnd()},s.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},s.doTickIdle=function(){var f,v,D=this.hls,S=this.levelLastLoaded,A=this.levels,T=this.media,R=D.config,I=D.nextLoadLevel;if(!(S===null||!T&&(this.startFragRequested||!R.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!A||!A[I])){var B=A[I];this.level=D.nextLoadLevel=I;var F=B.details;if(!F||this.state===O.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==I){this.state=O.State.WAITING_LEVEL;return}var _=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,c.PlaylistLevelType.MAIN);if(_!==null){var U=_.len,N=this.getMaxBufferLength(B.maxBitrate);if(!(U>=N)){if(this._streamEnded(_,F)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(M.Events.BUFFER_EOS,k),this.state=O.State.ENDED;return}var W=_.end,w=this.getNextFragment(W,F);if(this.couldBacktrack&&!this.fragPrevious&&w&&w.sn!=="initSegment"){var H=w.sn-F.startSN;H>1&&(w=F.fragments[H-1],this.fragmentTracker.removeFragment(w))}if(w&&this.fragmentTracker.getState(w)===x.FragmentState.OK&&this.nextLoadPosition>W){var Y=this.audioOnly&&!this.altAudio?a.ElementaryStreamTypes.AUDIO:a.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,Y,c.PlaylistLevelType.MAIN),w=this.getNextFragment(this.nextLoadPosition,F)}!w||(w.initSegment&&!w.initSegment.data&&!this.bitrateTest&&(w=w.initSegment),((f=w.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((v=w.decryptdata)!==null&&v!==void 0&&v.key)?this.loadKey(w,F):this.loadFragment(w,F,W))}}}},s.loadFragment=function(f,v,D){var S,A=this.fragmentTracker.getState(f);if(this.fragCurrent=f,A===x.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(f);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else A=x.FragmentState.NOT_LOADED}A===x.FragmentState.NOT_LOADED||A===x.FragmentState.PARTIAL?f.sn==="initSegment"?this._loadInitSegment(f):this.bitrateTest?(f.bitrateTest=!0,this.log("Fragment "+f.sn+" of level "+f.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(f)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,f,v,D)):A===x.FragmentState.APPENDING?this.reduceMaxBufferLength(f.duration)&&this.fragmentTracker.removeFragment(f):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},s.getAppendedFrag=function(f){var v=this.fragmentTracker.getAppendedFrag(f,c.PlaylistLevelType.MAIN);return v&&"fragment"in v?v.fragment:v},s.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,c.PlaylistLevelType.MAIN)},s.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},s.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},s.nextLevelSwitch=function(){var f=this.levels,v=this.media;if(v!=null&&v.readyState){var D,S=this.getAppendedFrag(v.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!v.paused&&f){var A=this.hls.nextLoadLevel,T=f[A],R=this.fragLastKbps;R&&this.fragCurrent?D=this.fragCurrent.duration*T.maxBitrate/(1e3*R)+1:D=0}else D=0;var I=this.getBufferedFrag(v.currentTime+D);if(I){var B=this.followingBufferedFrag(I);if(B){this.abortCurrentFrag();var F=B.maxStartPTS?B.maxStartPTS:B.start,_=B.duration,U=Math.max(I.end,F+Math.min(Math.max(_-this.config.maxFragLookUpTolerance,_*.5),_*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},s.abortCurrentFrag=function(){var f=this.fragCurrent;this.fragCurrent=null,f!=null&&f.loader&&f.loader.abort(),this.state===O.State.KEY_LOADING&&(this.state=O.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},s.flushMainBuffer=function(f,v){e.prototype.flushMainBuffer.call(this,f,v,this.altAudio?"video":null)},s.onMediaAttached=function(f,v){e.prototype.onMediaAttached.call(this,f,v);var D=v.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),D.addEventListener("playing",this.onvplaying),D.addEventListener("seeked",this.onvseeked),this.gapController=new p.default(this.config,D,this.fragmentTracker,this.hls)},s.onMediaDetaching=function(){var f=this.media;f&&(f.removeEventListener("playing",this.onvplaying),f.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},s.onMediaPlaying=function(){this.tick()},s.onMediaSeeked=function(){var f=this.media,v=f?f.currentTime:null;Object(b.isFiniteNumber)(v)&&this.log("Media seeked to "+v.toFixed(3)),this.tick()},s.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},s.onManifestParsed=function(f,v){var D=!1,S=!1,A;v.levels.forEach(function(T){A=T.audioCodec,A&&(A.indexOf("mp4a.40.2")!==-1&&(D=!0),A.indexOf("mp4a.40.5")!==-1&&(S=!0))}),this.audioCodecSwitch=D&&S&&!Object(L.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=v.levels,this.startFragRequested=!1},s.onLevelLoading=function(f,v){var D=this.levels;if(!(!D||this.state!==O.State.IDLE)){var S=D[v.level];(!S.details||S.details.live&&this.levelLastLoaded!==v.level||this.waitForCdnTuneIn(S.details))&&(this.state=O.State.WAITING_LEVEL)}},s.onLevelLoaded=function(f,v){var D,S=this.levels,A=v.level,T=v.details,R=T.totalduration;if(!S){this.warn("Levels were reset while loading level "+A);return}this.log("Level "+A+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+R);var I=this.fragCurrent;I&&(this.state===O.State.FRAG_LOADING||this.state===O.State.FRAG_LOADING_WAITING_RETRY)&&I.level!==v.level&&I.loader&&(this.state=O.State.IDLE,I.loader.abort());var B=S[A],F=0;if(T.live||(D=B.details)!==null&&D!==void 0&&D.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;F=this.alignPlaylists(T,B.details)}if(B.details=T,this.levelLastLoaded=A,this.hls.trigger(M.Events.LEVEL_UPDATED,{details:T,level:A}),this.state===O.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=O.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,F),this.tick()},s._handleFragmentLoadProgress=function(f){var v,D=f.frag,S=f.part,A=f.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+D.sn+" of level "+D.level+" will not be buffered");return}var R=T[D.level],I=R.details;if(!I){this.warn("Dropping fragment "+D.sn+" of level "+D.level+" after level details were reset");return}var B=R.videoCodec,F=I.PTSKnown||!I.live,_=(v=D.initSegment)===null||v===void 0?void 0:v.data,U=this._getAudioCodec(R),N=this.transmuxer=this.transmuxer||new u.default(this.hls,c.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=S?S.index:-1,W=k!==-1,w=new o.ChunkMetadata(D.level,D.sn,D.stats.chunkCount,A.byteLength,k,W),H=this.initPTS[D.cc];N.push(A,_,U,B,D,S,I.totalduration,F,w,H)},s.onAudioTrackSwitching=function(f,v){var D=this.altAudio,S=!!v.url,A=v.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var R=this.hls;D&&R.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),R.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:A})}},s.onAudioTrackSwitched=function(f,v){var D=v.id,S=!!this.hls.audioTracks[D].url;if(S){var A=this.videoBuffer;A&&this.mediaBuffer!==A&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=A)}this.altAudio=S,this.tick()},s.onBufferCreated=function(f,v){var D=v.tracks,S,A,T=!1;for(var R in D){var I=D[R];if(I.id==="main"){if(A=R,S=I,R==="video"){var B=D[R];B&&(this.videoBuffer=B.buffer)}}else T=!0}T&&S?(this.log("Alternate track found, use "+A+".buffered to schedule main fragment loading"),this.mediaBuffer=S.buffer):this.mediaBuffer=this.media},s.onFragBuffered=function(f,v){var D=v.frag,S=v.part;if(!(D&&D.type!==c.PlaylistLevelType.MAIN)){if(this.fragContextChanged(D)){this.warn("Fragment "+D.sn+(S?" p: "+S.index:"")+" of level "+D.level+" finished buffering, but was aborted. state: "+this.state),this.state===O.State.PARSED&&(this.state=O.State.IDLE);return}var A=S?S.stats:D.stats;this.fragLastKbps=Math.round(8*A.total/(A.buffering.end-A.loading.first)),D.sn!=="initSegment"&&(this.fragPrevious=D),this.fragBufferedComplete(D,S)}},s.onError=function(f,v){switch(v.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.MAIN,v);break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==O.State.ERROR&&(v.fatal?(this.warn(""+v.details),this.state=O.State.ERROR):!v.levelRetry&&this.state===O.State.WAITING_LEVEL&&(this.state=O.State.IDLE));break;case y.ErrorDetails.BUFFER_FULL_ERROR:if(v.parent==="main"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var D=!0,S=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);S&&S.len>.5&&(D=!this.reduceMaxBufferLength(S.len)),D&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break}},s.checkBuffer=function(){var f=this.media,v=this.gapController;if(!(!f||!v||!f.readyState)){var D=P.BufferHelper.getBuffered(f);!this.loadedmetadata&&D.length?(this.loadedmetadata=!0,this.seekToStartPos()):v.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime}},s.onFragLoadEmergencyAborted=function(){this.state=O.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},s.onBufferFlushed=function(f,v){var D=v.type;if(D!==a.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(D===a.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,D,c.PlaylistLevelType.MAIN)}},s.onLevelsUpdated=function(f,v){this.levels=v.levels},s.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},s.seekToStartPos=function(){var f=this.media,v=f.currentTime,D=this.startPosition;if(D>=0&&v<D){if(f.seeking){m.logger.log("could not seek to "+D+", already seeking at "+v);return}var S=P.BufferHelper.getBuffered(f),A=S.length?S.start(0):0,T=A-D;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(m.logger.log("adjusting start position by "+T+" to match buffer start"),D+=T,this.startPosition=D),this.log("seek to target start position "+D+" from current time "+v),f.currentTime=D}},s._getAudioCodec=function(f){var v=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&v&&(this.log("Swapping audio codec"),v.indexOf("mp4a.40.5")!==-1?v="mp4a.40.2":v="mp4a.40.5"),v},s._loadBitrateTestFrag=function(f){var v=this;this._doFragLoad(f).then(function(D){var S=v.hls;if(!(!D||S.nextLoadLevel||v.fragContextChanged(f))){v.fragLoadError=0,v.state=O.State.IDLE,v.startFragRequested=!1,v.bitrateTest=!1;var A=f.stats;A.parsing.start=A.parsing.end=A.buffering.start=A.buffering.end=self.performance.now(),S.trigger(M.Events.FRAG_LOADED,D)}})},s._handleTransmuxComplete=function(f){var v,D="main",S=this.hls,A=f.remuxResult,T=f.chunkMeta,R=this.getCurrentContext(T);if(!R){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var I=R.frag,B=R.part,F=R.level,_=A.video,U=A.text,N=A.id3,k=A.initSegment,W=this.altAudio?void 0:A.audio;if(!this.fragContextChanged(I)){if(this.state=O.State.PARSING,k){k.tracks&&(this._bufferInitSegment(F,k.tracks,I,T),S.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:D,tracks:k.tracks}));var w=k.initPTS,H=k.timescale;Object(b.isFiniteNumber)(w)&&(this.initPTS[I.cc]=w,S.trigger(M.Events.INIT_PTS_FOUND,{frag:I,id:D,initPTS:w,timescale:H}))}if(_&&A.independent!==!1){if(F.details){var Y=_.startPTS,j=_.endPTS,Q=_.startDTS,X=_.endDTS;if(B)B.elementaryStreams[_.type]={startPTS:Y,endPTS:j,startDTS:Q,endDTS:X};else if(_.firstKeyFrame&&_.independent&&(this.couldBacktrack=!0),_.dropped&&_.independent){var V=this.getLoadPosition()+this.config.maxBufferHole;if(V<Y){this.backtrack(I);return}I.setElementaryStreamInfo(_.type,I.start,j,I.start,X,!0)}I.setElementaryStreamInfo(_.type,Y,j,Q,X),this.bufferFragmentData(_,I,B,T)}}else if(A.independent===!1){this.backtrack(I);return}if(W){var z=W.startPTS,$=W.endPTS,Z=W.startDTS,J=W.endDTS;B&&(B.elementaryStreams[a.ElementaryStreamTypes.AUDIO]={startPTS:z,endPTS:$,startDTS:Z,endDTS:J}),I.setElementaryStreamInfo(a.ElementaryStreamTypes.AUDIO,z,$,Z,J),this.bufferFragmentData(W,I,B,T)}if(N!=null&&(v=N.samples)!==null&&v!==void 0&&v.length){var te={frag:I,id:D,samples:N.samples};S.trigger(M.Events.FRAG_PARSING_METADATA,te)}if(U){var q={frag:I,id:D,samples:U.samples};S.trigger(M.Events.FRAG_PARSING_USERDATA,q)}}},s._bufferInitSegment=function(f,v,D,S){var A=this;if(this.state===O.State.PARSING){this.audioOnly=!!v.audio&&!v.video,this.altAudio&&!this.audioOnly&&delete v.audio;var T=v.audio,R=v.video,I=v.audiovideo;if(T){var B=f.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(B&&(B.indexOf("mp4a.40.5")!==-1?B="mp4a.40.2":B="mp4a.40.5"),T.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(B="mp4a.40.5")),F.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(B="mp4a.40.2",this.log("Android: force audio codec to "+B)),f.audioCodec&&f.audioCodec!==B&&this.log('Swapping manifest audio codec "'+f.audioCodec+'" for "'+B+'"'),T.levelCodec=B,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(B||"")+"/"+(f.audioCodec||"")+"/"+T.codec+"]")}R&&(R.levelCodec=f.videoCodec,R.id="main",this.log("Init video buffer, container:"+R.container+", codecs[level/parsed]=["+(f.videoCodec||"")+"/"+R.codec+"]")),I&&this.log("Init audiovideo buffer, container:"+I.container+", codecs[level/parsed]=["+(f.attrs.CODECS||"")+"/"+I.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,v),Object.keys(v).forEach(function(_){var U=v[_],N=U.initSegment;N!=null&&N.byteLength&&A.hls.trigger(M.Events.BUFFER_APPENDING,{type:_,data:N,frag:D,part:null,chunkMeta:S,parent:D.type})}),this.tick()}},s.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var v=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,v?this.resetFragmentLoading(f):this.state=O.State.BACKTRACKING},s.checkFragmentChanged=function(){var f=this.media,v=null;if(f&&f.readyState>1&&f.seeking===!1){var D=f.currentTime;if(P.BufferHelper.isBuffered(f,D)?v=this.getAppendedFrag(D):P.BufferHelper.isBuffered(f,D+.1)&&(v=this.getAppendedFrag(D+.1)),v){var S=this.fragPlaying,A=v.level;(!S||v.sn!==S.sn||S.level!==A||v.urlId!==S.urlId)&&(this.hls.trigger(M.Events.FRAG_CHANGED,{frag:v}),(!S||S.level!==A)&&this.hls.trigger(M.Events.LEVEL_SWITCHED,{level:A}),this.fragPlaying=v)}}},l(t,[{key:"nextLevel",get:function(){var f=this.nextBufferedFrag;return f?f.level:-1}},{key:"currentLevel",get:function(){var f=this.media;if(f){var v=this.getAppendedFrag(f.currentTime);if(v)return v.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var v=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(v)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(O.default)},"./src/crypt/aes-crypto.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return b});var b=function(){function O(M,P){this.subtle=void 0,this.aesIV=void 0,this.subtle=M,this.aesIV=P}var L=O.prototype;return L.decrypt=function(P,x){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},x,P)},O}()},"./src/crypt/aes-decryptor.ts":function(K,C,g){g.r(C),g.d(C,"removePadding",function(){return O}),g.d(C,"default",function(){return L});var b=g("./src/utils/typed-array.ts");function O(M){var P=M.byteLength,x=P&&new DataView(M.buffer).getUint8(P-1);return x?Object(b.sliceUint8)(M,0,P-x):M}var L=function(){function M(){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 P=M.prototype;return P.uint8ArrayToUint32Array_=function(c){for(var a=new DataView(c),u=new Uint32Array(4),o=0;o<4;o++)u[o]=a.getUint32(o*4);return u},P.initTable=function(){var c=this.sBox,a=this.invSBox,u=this.subMix,o=u[0],p=u[1],y=u[2],m=u[3],d=this.invSubMix,l=d[0],i=d[1],r=d[2],h=d[3],n=new Uint32Array(256),e=0,t=0,s=0;for(s=0;s<256;s++)s<128?n[s]=s<<1:n[s]=s<<1^283;for(s=0;s<256;s++){var E=t^t<<1^t<<2^t<<3^t<<4;E=E>>>8^E&255^99,c[e]=E,a[E]=e;var f=n[e],v=n[f],D=n[v],S=n[E]*257^E*16843008;o[e]=S<<24|S>>>8,p[e]=S<<16|S>>>16,y[e]=S<<8|S>>>24,m[e]=S,S=D*16843009^v*65537^f*257^e*16843008,l[E]=S<<24|S>>>8,i[E]=S<<16|S>>>16,r[E]=S<<8|S>>>24,h[E]=S,e?(e=f^n[n[n[D^f]]],t^=n[n[t]]):e=t=1}},P.expandKey=function(c){for(var a=this.uint8ArrayToUint32Array_(c),u=!0,o=0;o<a.length&&u;)u=a[o]===this.key[o],o++;if(!u){this.key=a;var p=this.keySize=a.length;if(p!==4&&p!==6&&p!==8)throw new Error("Invalid aes key size="+p);var y=this.ksRows=(p+6+1)*4,m,d,l=this.keySchedule=new Uint32Array(y),i=this.invKeySchedule=new Uint32Array(y),r=this.sBox,h=this.rcon,n=this.invSubMix,e=n[0],t=n[1],s=n[2],E=n[3],f,v;for(m=0;m<y;m++){if(m<p){f=l[m]=a[m];continue}v=f,m%p===0?(v=v<<8|v>>>24,v=r[v>>>24]<<24|r[v>>>16&255]<<16|r[v>>>8&255]<<8|r[v&255],v^=h[m/p|0]<<24):p>6&&m%p===4&&(v=r[v>>>24]<<24|r[v>>>16&255]<<16|r[v>>>8&255]<<8|r[v&255]),l[m]=f=(l[m-p]^v)>>>0}for(d=0;d<y;d++)m=y-d,d&3?v=l[m]:v=l[m-4],d<4||m<=4?i[d]=v:i[d]=e[r[v>>>24]]^t[r[v>>>16&255]]^s[r[v>>>8&255]]^E[r[v&255]],i[d]=i[d]>>>0}},P.networkToHostOrderSwap=function(c){return c<<24|(c&65280)<<8|(c&16711680)>>8|c>>>24},P.decrypt=function(c,a,u){for(var o=this.keySize+6,p=this.invKeySchedule,y=this.invSBox,m=this.invSubMix,d=m[0],l=m[1],i=m[2],r=m[3],h=this.uint8ArrayToUint32Array_(u),n=h[0],e=h[1],t=h[2],s=h[3],E=new Int32Array(c),f=new Int32Array(E.length),v,D,S,A,T,R,I,B,F,_,U,N,k,W,w=this.networkToHostOrderSwap;a<E.length;){for(F=w(E[a]),_=w(E[a+1]),U=w(E[a+2]),N=w(E[a+3]),T=F^p[0],R=N^p[1],I=U^p[2],B=_^p[3],k=4,W=1;W<o;W++)v=d[T>>>24]^l[R>>16&255]^i[I>>8&255]^r[B&255]^p[k],D=d[R>>>24]^l[I>>16&255]^i[B>>8&255]^r[T&255]^p[k+1],S=d[I>>>24]^l[B>>16&255]^i[T>>8&255]^r[R&255]^p[k+2],A=d[B>>>24]^l[T>>16&255]^i[R>>8&255]^r[I&255]^p[k+3],T=v,R=D,I=S,B=A,k=k+4;v=y[T>>>24]<<24^y[R>>16&255]<<16^y[I>>8&255]<<8^y[B&255]^p[k],D=y[R>>>24]<<24^y[I>>16&255]<<16^y[B>>8&255]<<8^y[T&255]^p[k+1],S=y[I>>>24]<<24^y[B>>16&255]<<16^y[T>>8&255]<<8^y[R&255]^p[k+2],A=y[B>>>24]<<24^y[T>>16&255]<<16^y[R>>8&255]<<8^y[I&255]^p[k+3],f[a]=w(v^n),f[a+1]=w(A^e),f[a+2]=w(S^t),f[a+3]=w(D^s),n=F,e=_,t=U,s=N,a=a+4}return f.buffer},M}()},"./src/crypt/decrypter.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return a});var b=g("./src/crypt/aes-crypto.ts"),O=g("./src/crypt/fast-aes-key.ts"),L=g("./src/crypt/aes-decryptor.ts"),M=g("./src/utils/logger.ts"),P=g("./src/utils/mp4-tools.ts"),x=g("./src/utils/typed-array.ts"),c=16,a=function(){function u(p,y,m){var d=m===void 0?{}:m,l=d.removePKCS7Padding,i=l===void 0?!0:l;if(this.logEnabled=!0,this.observer=void 0,this.config=void 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.observer=p,this.config=y,this.removePKCS7Padding=i,i)try{var r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var o=u.prototype;return o.destroy=function(){this.observer=null},o.isSync=function(){return this.config.enableSoftwareAES},o.flush=function(){var y=this.currentResult;if(!y){this.reset();return}var m=new Uint8Array(y);return this.reset(),this.removePKCS7Padding?Object(L.removePadding)(m):m},o.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},o.decrypt=function(y,m,d,l){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(y),m,d);var i=this.flush();i&&l(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(y),m,d).then(l)},o.softwareDecrypt=function(y,m,d){var l=this.currentIV,i=this.currentResult,r=this.remainderData;this.logOnce("JS AES decrypt"),r&&(y=Object(P.appendUint8Array)(r,y),this.remainderData=null);var h=this.getValidChunk(y);if(!h.length)return null;l&&(d=l);var n=this.softwareDecrypter;n||(n=this.softwareDecrypter=new L.default),n.expandKey(m);var e=i;return this.currentResult=n.decrypt(h.buffer,0,d),this.currentIV=Object(x.sliceUint8)(h,-16).buffer,e||null},o.webCryptoDecrypt=function(y,m,d){var l=this,i=this.subtle;return(this.key!==m||!this.fastAesKey)&&(this.key=m,this.fastAesKey=new O.default(i,m)),this.fastAesKey.expandKey().then(function(r){if(!i)return Promise.reject(new Error("web crypto not initialized"));var h=new b.default(i,d);return h.decrypt(y.buffer,r)}).catch(function(r){return l.onWebCryptoError(r,y,m,d)})},o.onWebCryptoError=function(y,m,d,l){return M.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",y),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(m,d,l)},o.getValidChunk=function(y){var m=y,d=y.length-y.length%c;return d!==y.length&&(m=Object(x.sliceUint8)(y,0,d),this.remainderData=Object(x.sliceUint8)(y,d)),m},o.logOnce=function(y){!this.logEnabled||(M.logger.log("[decrypter.ts]: "+y),this.logEnabled=!1)},u}()},"./src/crypt/fast-aes-key.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return b});var b=function(){function O(M,P){this.subtle=void 0,this.key=void 0,this.subtle=M,this.key=P}var L=O.prototype;return L.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},O}()},"./src/demux/aacdemuxer.ts":function(K,C,g){g.r(C);var b=g("./src/demux/base-audio-demuxer.ts"),O=g("./src/demux/adts.ts"),L=g("./src/utils/logger.ts"),M=g("./src/demux/id3.ts");function P(a,u){a.prototype=Object.create(u.prototype),a.prototype.constructor=a,x(a,u)}function x(a,u){return x=Object.setPrototypeOf||function(p,y){return p.__proto__=y,p},x(a,u)}var c=function(a){P(u,a);function u(p,y){var m;return m=a.call(this)||this,m.observer=void 0,m.config=void 0,m.observer=p,m.config=y,m}var o=u.prototype;return o.resetInitSegment=function(y,m,d){a.prototype.resetInitSegment.call(this,y,m,d),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:y,duration:d,inputTimeScale:9e4,dropped:0}},u.probe=function(y){if(!y)return!1;for(var m=M.getID3Data(y,0)||[],d=m.length,l=y.length;d<l;d++)if(O.probe(y,d))return L.logger.log("ADTS sync word found !"),!0;return!1},o.canParse=function(y,m){return O.canParse(y,m)},o.appendFrame=function(y,m,d){O.initTrackConfig(y,this.observer,m,d,y.manifestCodec);var l=O.appendFrame(y,m,d,this.initPTS,this.frameIndex);if(l&&l.missing===0)return l},u}(b.default);c.minProbeByteLength=9,C.default=c},"./src/demux/adts.ts":function(K,C,g){g.r(C),g.d(C,"getAudioConfig",function(){return M}),g.d(C,"isHeaderPattern",function(){return P}),g.d(C,"getHeaderLength",function(){return x}),g.d(C,"getFullFrameLength",function(){return c}),g.d(C,"canGetFrameLength",function(){return a}),g.d(C,"isHeader",function(){return u}),g.d(C,"canParse",function(){return o}),g.d(C,"probe",function(){return p}),g.d(C,"initTrackConfig",function(){return y}),g.d(C,"getFrameDuration",function(){return m}),g.d(C,"parseFrameHeader",function(){return d}),g.d(C,"appendFrame",function(){return l});var b=g("./src/utils/logger.ts"),O=g("./src/errors.ts"),L=g("./src/events.ts");function M(i,r,h,n){var e,t,s,E,f=navigator.userAgent.toLowerCase(),v=n,D=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];e=((r[h+2]&192)>>>6)+1;var S=(r[h+2]&60)>>>2;if(S>D.length-1){i.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S});return}return s=(r[h+2]&1)<<2,s|=(r[h+3]&192)>>>6,b.logger.log("manifest codec:"+n+", ADTS type:"+e+", samplingIndex:"+S),/firefox/i.test(f)?S>=6?(e=5,E=new Array(4),t=S-3):(e=2,E=new Array(2),t=S):f.indexOf("android")!==-1?(e=2,E=new Array(2),t=S):(e=5,E=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&S>=6?t=S-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(S>=6&&s===1||/vivaldi/i.test(f))||!n&&s===1)&&(e=2,E=new Array(2)),t=S)),E[0]=e<<3,E[0]|=(S&14)>>1,E[1]|=(S&1)<<7,E[1]|=s<<3,e===5&&(E[1]|=(t&14)>>1,E[2]=(t&1)<<7,E[2]|=2<<2,E[3]=0),{config:E,samplerate:D[S],channelCount:s,codec:"mp4a.40."+e,manifestCodec:v}}function P(i,r){return i[r]===255&&(i[r+1]&246)===240}function x(i,r){return i[r+1]&1?7:9}function c(i,r){return(i[r+3]&3)<<11|i[r+4]<<3|(i[r+5]&224)>>>5}function a(i,r){return r+5<i.length}function u(i,r){return r+1<i.length&&P(i,r)}function o(i,r){return a(i,r)&&P(i,r)&&c(i,r)<=i.length-r}function p(i,r){if(u(i,r)){var h=x(i,r);if(r+h>=i.length)return!1;var n=c(i,r);if(n<=h)return!1;var e=r+n;return e===i.length||u(i,e)}return!1}function y(i,r,h,n,e){if(!i.samplerate){var t=M(r,h,n,e);if(!t)return;i.config=t.config,i.samplerate=t.samplerate,i.channelCount=t.channelCount,i.codec=t.codec,i.manifestCodec=t.manifestCodec,b.logger.log("parsed codec:"+i.codec+", rate:"+t.samplerate+", channels:"+t.channelCount)}}function m(i){return 1024*9e4/i}function d(i,r,h,n,e){var t=x(i,r),s=c(i,r);if(s-=t,s>0){var E=h+n*e;return{headerLength:t,frameLength:s,stamp:E}}}function l(i,r,h,n,e){var t=m(i.samplerate),s=d(r,h,n,e,t);if(s){var E=s.frameLength,f=s.headerLength,v=s.stamp,D=f+E,S=Math.max(0,h+D-r.length),A;S?(A=new Uint8Array(D-f),A.set(r.subarray(h+f,r.length),0)):A=r.subarray(h+f,h+D);var T={unit:A,pts:v};return S||i.samples.push(T),{sample:T,length:D,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(K,C,g){g.r(C),g.d(C,"initPTSFn",function(){return c});var b=g("./src/polyfills/number.ts"),O=g("./src/demux/id3.ts"),L=g("./src/demux/dummy-demuxed-track.ts"),M=g("./src/utils/mp4-tools.ts"),P=g("./src/utils/typed-array.ts"),x=function(){function a(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var u=a.prototype;return u.resetInitSegment=function(p,y,m){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},u.resetTimeStamp=function(){},u.resetContiguity=function(){},u.canParse=function(p,y){return!1},u.appendFrame=function(p,y,m){},u.demux=function(p,y){this.cachedData&&(p=Object(M.appendUint8Array)(this.cachedData,p),this.cachedData=null);var m=O.getID3Data(p,0),d=m?m.length:0,l,i,r=this._audioTrack,h=this._id3Track,n=m?O.getTimeStamp(m):void 0,e=p.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=c(n,y)),m&&m.length>0&&h.samples.push({pts:this.initPTS,dts:this.initPTS,data:m}),i=this.initPTS;d<e;){if(this.canParse(p,d)){var t=this.appendFrame(r,p,d);t?(this.frameIndex++,i=t.sample.pts,d+=t.length,l=d):d=e}else O.canParse(p,d)?(m=O.getID3Data(p,d),h.samples.push({pts:i,dts:i,data:m}),d+=m.length,l=d):d++;if(d===e&&l!==e){var s=Object(P.sliceUint8)(p,l);this.cachedData?this.cachedData=Object(M.appendUint8Array)(this.cachedData,s):this.cachedData=s}}return{audioTrack:r,avcTrack:Object(L.dummyTrack)(),id3Track:h,textTrack:Object(L.dummyTrack)()}},u.demuxSampleAes=function(p,y,m){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},u.flush=function(p){var y=this.cachedData;return y&&(this.cachedData=null,this.demux(y,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(L.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(L.dummyTrack)()}},u.destroy=function(){},a}(),c=function(u,o){return Object(b.isFiniteNumber)(u)?u*90:o*9e4};C.default=x},"./src/demux/chunk-cache.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return b});var b=function(){function L(){this.chunks=[],this.dataLength=0}var M=L.prototype;return M.push=function(x){this.chunks.push(x),this.dataLength+=x.length},M.flush=function(){var x=this.chunks,c=this.dataLength,a;if(x.length)x.length===1?a=x[0]:a=O(x,c);else return new Uint8Array(0);return this.reset(),a},M.reset=function(){this.chunks.length=0,this.dataLength=0},L}();function O(L,M){for(var P=new Uint8Array(M),x=0,c=0;c<L.length;c++){var a=L[c];P.set(a,x),x+=a.length}return P}},"./src/demux/dummy-demuxed-track.ts":function(K,C,g){g.r(C),g.d(C,"dummyTrack",function(){return b});function b(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,C,g){g.r(C);var b=g("./src/utils/logger.ts"),O=function(){function L(P){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=P,this.bytesAvailable=P.byteLength,this.word=0,this.bitsAvailable=0}var M=L.prototype;return M.loadWord=function(){var x=this.data,c=this.bytesAvailable,a=x.byteLength-c,u=new Uint8Array(4),o=Math.min(4,c);if(o===0)throw new Error("no bytes available");u.set(x.subarray(a,a+o)),this.word=new DataView(u.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o},M.skipBits=function(x){var c;this.bitsAvailable>x?(this.word<<=x,this.bitsAvailable-=x):(x-=this.bitsAvailable,c=x>>3,x-=c>>3,this.bytesAvailable-=c,this.loadWord(),this.word<<=x,this.bitsAvailable-=x)},M.readBits=function(x){var c=Math.min(this.bitsAvailable,x),a=this.word>>>32-c;return x>32&&b.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=c,this.bitsAvailable>0?this.word<<=c:this.bytesAvailable>0&&this.loadWord(),c=x-c,c>0&&this.bitsAvailable?a<<c|this.readBits(c):a},M.skipLZ=function(){var x;for(x=0;x<this.bitsAvailable;++x)if((this.word&2147483648>>>x)!==0)return this.word<<=x,this.bitsAvailable-=x,x;return this.loadWord(),x+this.skipLZ()},M.skipUEG=function(){this.skipBits(1+this.skipLZ())},M.skipEG=function(){this.skipBits(1+this.skipLZ())},M.readUEG=function(){var x=this.skipLZ();return this.readBits(x+1)-1},M.readEG=function(){var x=this.readUEG();return 1&x?1+x>>>1:-1*(x>>>1)},M.readBoolean=function(){return this.readBits(1)===1},M.readUByte=function(){return this.readBits(8)},M.readUShort=function(){return this.readBits(16)},M.readUInt=function(){return this.readBits(32)},M.skipScalingList=function(x){for(var c=8,a=8,u,o=0;o<x;o++)a!==0&&(u=this.readEG(),a=(c+u+256)%256),c=a===0?c:a},M.readSPS=function(){var x=0,c=0,a=0,u=0,o,p,y,m=this.readUByte.bind(this),d=this.readBits.bind(this),l=this.readUEG.bind(this),i=this.readBoolean.bind(this),r=this.skipBits.bind(this),h=this.skipEG.bind(this),n=this.skipUEG.bind(this),e=this.skipScalingList.bind(this);m();var t=m();if(d(5),r(3),m(),n(),t===100||t===110||t===122||t===244||t===44||t===83||t===86||t===118||t===128){var s=l();if(s===3&&r(1),n(),n(),r(1),i())for(p=s!==3?8:12,y=0;y<p;y++)i()&&(y<6?e(16):e(64))}n();var E=l();if(E===0)l();else if(E===1)for(r(1),h(),h(),o=l(),y=0;y<o;y++)h();n(),r(1);var f=l(),v=l(),D=d(1);D===0&&r(1),r(1),i()&&(x=l(),c=l(),a=l(),u=l());var S=[1,1];if(i()&&i()){var A=m();switch(A){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:{S=[m()<<8|m(),m()<<8|m()];break}}}return{width:Math.ceil((f+1)*16-x*2-c*2),height:(2-D)*(v+1)*16-(D?2:4)*(a+u),pixelRatio:S}},M.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},L}();C.default=O},"./src/demux/id3.ts":function(K,C,g){g.r(C),g.d(C,"isHeader",function(){return b}),g.d(C,"isFooter",function(){return O}),g.d(C,"getID3Data",function(){return L}),g.d(C,"canParse",function(){return P}),g.d(C,"getTimeStamp",function(){return x}),g.d(C,"isTimeStampFrame",function(){return c}),g.d(C,"getID3Frames",function(){return u}),g.d(C,"decodeFrame",function(){return o}),g.d(C,"utf8ArrayToStr",function(){return l}),g.d(C,"testables",function(){return i});var b=function(e,t){return t+10<=e.length&&e[t]===73&&e[t+1]===68&&e[t+2]===51&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},O=function(e,t){return t+10<=e.length&&e[t]===51&&e[t+1]===68&&e[t+2]===73&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},L=function(e,t){for(var s=t,E=0;b(e,t);){E+=10;var f=M(e,t+6);E+=f,O(e,t+10)&&(E+=10),t+=E}if(E>0)return e.subarray(s,s+E)},M=function(e,t){var s=0;return s=(e[t]&127)<<21,s|=(e[t+1]&127)<<14,s|=(e[t+2]&127)<<7,s|=e[t+3]&127,s},P=function(e,t){return b(e,t)&&M(e,t+6)+10<=e.length-t},x=function(e){for(var t=u(e),s=0;s<t.length;s++){var E=t[s];if(c(E))return d(E)}},c=function(e){return e&&e.key==="PRIV"&&e.info==="com.apple.streaming.transportStreamTimestamp"},a=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),s=M(e,4),E=10;return{type:t,size:s,data:e.subarray(E,E+s)}},u=function(e){for(var t=0,s=[];b(e,t);){var E=M(e,t+6);t+=10;for(var f=t+E;t+8<f;){var v=a(e.subarray(t)),D=o(v);D&&s.push(D),t+=v.size+10}O(e,t)&&(t+=10)}return s},o=function(e){return e.type==="PRIV"?p(e):e.type[0]==="W"?m(e):y(e)},p=function(e){if(!(e.size<2)){var t=l(e.data,!0),s=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:s.buffer}}},y=function(e){if(!(e.size<2)){if(e.type==="TXXX"){var t=1,s=l(e.data.subarray(t),!0);t+=s.length+1;var E=l(e.data.subarray(t));return{key:e.type,info:s,data:E}}var f=l(e.data.subarray(1));return{key:e.type,data:f}}},m=function(e){if(e.type==="WXXX"){if(e.size<2)return;var t=1,s=l(e.data.subarray(t),!0);t+=s.length+1;var E=l(e.data.subarray(t));return{key:e.type,info:s,data:E}}var f=l(e.data);return{key:e.type,data:f}},d=function(e){if(e.data.byteLength===8){var t=new Uint8Array(e.data),s=t[3]&1,E=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return E/=45,s&&(E+=4772185884e-2),Math.round(E)}},l=function(e,t){t===void 0&&(t=!1);var s=h();if(s){var E=s.decode(e);if(t){var f=E.indexOf("\0");return f!==-1?E.substring(0,f):E}return E.replace(/\0/g,"")}for(var v=e.length,D,S,A,T="",R=0;R<v;){if(D=e[R++],D===0&&t)return T;if(D===0||D===3)continue;switch(D>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(D);break;case 12:case 13:S=e[R++],T+=String.fromCharCode((D&31)<<6|S&63);break;case 14:S=e[R++],A=e[R++],T+=String.fromCharCode((D&15)<<12|(S&63)<<6|(A&63)<<0);break}}return T},i={decodeTextFrame:y},r;function h(){return!r&&typeof self.TextDecoder!="undefined"&&(r=new self.TextDecoder("utf-8")),r}},"./src/demux/mp3demuxer.ts":function(K,C,g){g.r(C);var b=g("./src/demux/base-audio-demuxer.ts"),O=g("./src/demux/id3.ts"),L=g("./src/utils/logger.ts"),M=g("./src/demux/mpegaudio.ts");function P(a,u){a.prototype=Object.create(u.prototype),a.prototype.constructor=a,x(a,u)}function x(a,u){return x=Object.setPrototypeOf||function(p,y){return p.__proto__=y,p},x(a,u)}var c=function(a){P(u,a);function u(){return a.apply(this,arguments)||this}var o=u.prototype;return o.resetInitSegment=function(y,m,d){a.prototype.resetInitSegment.call(this,y,m,d),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:y,duration:d,inputTimeScale:9e4,dropped:0}},u.probe=function(y){if(!y)return!1;for(var m=O.getID3Data(y,0)||[],d=m.length,l=y.length;d<l;d++)if(M.probe(y,d))return L.logger.log("MPEG Audio sync word found !"),!0;return!1},o.canParse=function(y,m){return M.canParse(y,m)},o.appendFrame=function(y,m,d){if(this.initPTS!==null)return M.appendFrame(y,m,d,this.initPTS,this.frameIndex)},u}(b.default);c.minProbeByteLength=4,C.default=c},"./src/demux/mp4demuxer.ts":function(K,C,g){g.r(C);var b=g("./src/utils/mp4-tools.ts"),O=g("./src/demux/dummy-demuxed-track.ts"),L=function(){function M(x,c){this.remainderData=null,this.config=void 0,this.config=c}var P=M.prototype;return P.resetTimeStamp=function(){},P.resetInitSegment=function(){},P.resetContiguity=function(){},M.probe=function(c){return Object(b.findBox)({data:c,start:0,end:Math.min(c.length,16384)},["moof"]).length>0},P.demux=function(c){var a=c,u=Object(O.dummyTrack)();if(this.config.progressive){this.remainderData&&(a=Object(b.appendUint8Array)(this.remainderData,c));var o=Object(b.segmentValidRange)(a);this.remainderData=o.remainder,u.samples=o.valid||new Uint8Array}else u.samples=a;return{audioTrack:Object(O.dummyTrack)(),avcTrack:u,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},P.flush=function(){var c=Object(O.dummyTrack)();return c.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(O.dummyTrack)(),avcTrack:c,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},P.demuxSampleAes=function(c,a,u){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},P.destroy=function(){},M}();L.minProbeByteLength=1024,C.default=L},"./src/demux/mpegaudio.ts":function(K,C,g){g.r(C),g.d(C,"appendFrame",function(){return x}),g.d(C,"parseHeader",function(){return c}),g.d(C,"isHeaderPattern",function(){return a}),g.d(C,"isHeader",function(){return u}),g.d(C,"canParse",function(){return o}),g.d(C,"probe",function(){return p});var b=null,O=[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],L=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],M=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],P=[0,1,1,4];function x(y,m,d,l,i){if(!(d+24>m.length)){var r=c(m,d);if(r&&d+r.frameLength<=m.length){var h=r.samplesPerFrame*9e4/r.sampleRate,n=l+i*h,e={unit:m.subarray(d,d+r.frameLength),pts:n,dts:n};return y.config=[],y.channelCount=r.channelCount,y.samplerate=r.sampleRate,y.samples.push(e),{sample:e,length:r.frameLength,missing:0}}}}function c(y,m){var d=y[m+1]>>3&3,l=y[m+1]>>1&3,i=y[m+2]>>4&15,r=y[m+2]>>2&3;if(d!==1&&i!==0&&i!==15&&r!==3){var h=y[m+2]>>1&1,n=y[m+3]>>6,e=d===3?3-l:l===3?3:4,t=O[e*14+i-1]*1e3,s=d===3?0:d===2?1:2,E=L[s*3+r],f=n===3?1:2,v=M[d][l],D=P[l],S=v*8*D,A=Math.floor(v*t/E+h)*D;if(b===null){var T=navigator.userAgent||"",R=T.match(/Chrome\/(\d+)/i);b=R?parseInt(R[1]):0}var I=!!b&&b<=87;return I&&l===2&&t>=224e3&&n===0&&(y[m+3]=y[m+3]|128),{sampleRate:E,channelCount:f,frameLength:A,samplesPerFrame:S}}}function a(y,m){return y[m]===255&&(y[m+1]&224)===224&&(y[m+1]&6)!==0}function u(y,m){return m+1<y.length&&a(y,m)}function o(y,m){var d=4;return a(y,m)&&d<=y.length-m}function p(y,m){if(m+1<y.length&&a(y,m)){var d=4,l=c(y,m),i=d;l!=null&&l.frameLength&&(i=l.frameLength);var r=m+i;return r===y.length||u(y,r)}return!1}},"./src/demux/sample-aes.ts":function(K,C,g){g.r(C);var b=g("./src/crypt/decrypter.ts"),O=g("./src/demux/tsdemuxer.ts"),L=function(){function M(x,c,a){this.keyData=void 0,this.decrypter=void 0,this.keyData=a,this.decrypter=new b.default(x,c,{removePKCS7Padding:!1})}var P=M.prototype;return P.decryptBuffer=function(c,a){this.decrypter.decrypt(c,this.keyData.key.buffer,this.keyData.iv.buffer,a)},P.decryptAacSample=function(c,a,u,o){var p=c[a].unit,y=p.subarray(16,p.length-p.length%16),m=y.buffer.slice(y.byteOffset,y.byteOffset+y.length),d=this;this.decryptBuffer(m,function(l){var i=new Uint8Array(l);p.set(i,16),o||d.decryptAacSamples(c,a+1,u)})},P.decryptAacSamples=function(c,a,u){for(;;a++){if(a>=c.length){u();return}if(!(c[a].unit.length<32)){var o=this.decrypter.isSync();if(this.decryptAacSample(c,a,u,o),!o)return}}},P.getAvcEncryptedData=function(c){for(var a=Math.floor((c.length-48)/160)*16+16,u=new Int8Array(a),o=0,p=32;p<c.length-16;p+=160,o+=16)u.set(c.subarray(p,p+16),o);return u},P.getAvcDecryptedUnit=function(c,a){for(var u=new Uint8Array(a),o=0,p=32;p<c.length-16;p+=160,o+=16)c.set(u.subarray(o,o+16),p);return c},P.decryptAvcSample=function(c,a,u,o,p,y){var m=Object(O.discardEPB)(p.data),d=this.getAvcEncryptedData(m),l=this;this.decryptBuffer(d.buffer,function(i){p.data=l.getAvcDecryptedUnit(m,i),y||l.decryptAvcSamples(c,a,u+1,o)})},P.decryptAvcSamples=function(c,a,u,o){if(c instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;a++,u=0){if(a>=c.length){o();return}for(var p=c[a].units;!(u>=p.length);u++){var y=p[u];if(!(y.data.length<=48||y.type!==1&&y.type!==5)){var m=this.decrypter.isSync();if(this.decryptAvcSample(c,a,u,o,y,m),!m)return}}}},M}();C.default=L},"./src/demux/transmuxer-interface.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return u});var b=g("./node_modules/webworkify-webpack/index.js"),O=g("./src/events.ts"),L=g("./src/demux/transmuxer.ts"),M=g("./src/utils/logger.ts"),P=g("./src/errors.ts"),x=g("./src/utils/mediasource-helper.ts"),c=g("./node_modules/eventemitter3/index.js"),a=Object(x.getMediaSource)()||{isTypeSupported:function(){return!1}},u=function(){function o(y,m,d,l){var i=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=y,this.id=m,this.onTransmuxComplete=d,this.onFlush=l;var r=y.config,h=function(E,f){f=f||{},f.frag=i.frag,f.id=i.id,y.trigger(E,f)};this.observer=new c.EventEmitter,this.observer.on(O.Events.FRAG_DECRYPTED,h),this.observer.on(O.Events.ERROR,h);var n={mp4:a.isTypeSupported("video/mp4"),mpeg:a.isTypeSupported("audio/mpeg"),mp3:a.isTypeSupported('audio/mp4; codecs="mp3"')},e=navigator.vendor;if(r.enableWorker&&typeof Worker!="undefined"){M.logger.log("demuxing in webworker");var t;try{t=this.worker=b("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(s){y.trigger(O.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(s.message+" ("+s.filename+":"+s.lineno+")")})},t.postMessage({cmd:"init",typeSupported:n,vendor:e,id:m,config:JSON.stringify(r)})}catch(s){M.logger.warn("Error in worker:",s),M.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new L.default(this.observer,n,r,e,m),this.worker=null}}else this.transmuxer=new L.default(this.observer,n,r,e,m)}var p=o.prototype;return p.destroy=function(){var m=this.worker;if(m)m.removeEventListener("message",this.onwmsg),m.terminate(),this.worker=null;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var l=this.observer;l&&l.removeAllListeners(),this.observer=null},p.push=function(m,d,l,i,r,h,n,e,t,s){var E,f,v=this;t.transmuxing.start=self.performance.now();var D=this.transmuxer,S=this.worker,A=h?h.start:r.start,T=r.decryptdata,R=this.frag,I=!(R&&r.cc===R.cc),B=!(R&&t.level===R.level),F=R?t.sn-R.sn:-1,_=this.part?t.part-this.part.index:1,U=!B&&(F===1||F===0&&_===1),N=self.performance.now();(B||F||r.stats.parsing.start===0)&&(r.stats.parsing.start=N),h&&(_||!U)&&(h.stats.parsing.start=N);var k=!(R&&((E=r.initSegment)===null||E===void 0?void 0:E.url)===((f=R.initSegment)===null||f===void 0?void 0:f.url)),W=new L.TransmuxState(I,U,e,B,A,k);if(!U||I||k){M.logger.log("[transmuxer-interface, "+r.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
discontinuity: `+I+`
trackSwitch: `+B+`
contiguous: `+U+`
accurateTimeOffset: `+e+`
timeOffset: `+A+`
initSegmentChange: `+k);var w=new L.TransmuxConfig(l,i,d,n,s);this.configureTransmuxer(w)}if(this.frag=r,this.part=h,S)S.postMessage({cmd:"demux",data:m,decryptdata:T,chunkMeta:t,state:W},m instanceof ArrayBuffer?[m]:[]);else if(D){var H=D.push(m,T,t,W);Object(L.isPromise)(H)?H.then(function(Y){v.handleTransmuxComplete(Y)}):this.handleTransmuxComplete(H)}},p.flush=function(m){var d=this;m.transmuxing.start=self.performance.now();var l=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:m});else if(l){var r=l.flush(m);Object(L.isPromise)(r)?r.then(function(h){d.handleFlushResult(h,m)}):this.handleFlushResult(r,m)}},p.handleFlushResult=function(m,d){var l=this;m.forEach(function(i){l.handleTransmuxComplete(i)}),this.onFlush(d)},p.onWorkerMessage=function(m){var d=m.data,l=this.hls;switch(d.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,l.trigger(d.event,d.data);break}}},p.configureTransmuxer=function(m){var d=this.worker,l=this.transmuxer;d?d.postMessage({cmd:"configure",config:m}):l&&l.configure(m)},p.handleTransmuxComplete=function(m){m.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(m)},o}()},"./src/demux/transmuxer-worker.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return P});var b=g("./src/demux/transmuxer.ts"),O=g("./src/events.ts"),L=g("./src/utils/logger.ts"),M=g("./node_modules/eventemitter3/index.js");function P(o){var p=new M.EventEmitter,y=function(d,l){o.postMessage({event:d,data:l})};p.on(O.Events.FRAG_DECRYPTED,y),p.on(O.Events.ERROR,y),o.addEventListener("message",function(m){var d=m.data;switch(d.cmd){case"init":{var l=JSON.parse(d.config);o.transmuxer=new b.default(p,d.typeSupported,l,d.vendor,d.id),Object(L.enableLogs)(l.debug),y("init",null);break}case"configure":{o.transmuxer.configure(d.config);break}case"demux":{var i=o.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);Object(b.isPromise)(i)?i.then(function(n){x(o,n)}):x(o,i);break}case"flush":{var r=d.chunkMeta,h=o.transmuxer.flush(r);Object(b.isPromise)(h)?h.then(function(n){a(o,n,r)}):a(o,h,r);break}}})}function x(o,p){if(!u(p.remuxResult)){var y=[],m=p.remuxResult,d=m.audio,l=m.video;d&&c(y,d),l&&c(y,l),o.postMessage({event:"transmuxComplete",data:p},y)}}function c(o,p){p.data1&&o.push(p.data1.buffer),p.data2&&o.push(p.data2.buffer)}function a(o,p,y){p.forEach(function(m){x(o,m)}),o.postMessage({event:"flush",data:y})}function u(o){return!o.audio&&!o.video&&!o.text&&!o.id3&&!o.initSegment}},"./src/demux/transmuxer.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return i}),g.d(C,"isPromise",function(){return n}),g.d(C,"TransmuxConfig",function(){return e}),g.d(C,"TransmuxState",function(){return t});var b=g("./src/events.ts"),O=g("./src/errors.ts"),L=g("./src/crypt/decrypter.ts"),M=g("./src/demux/aacdemuxer.ts"),P=g("./src/demux/mp4demuxer.ts"),x=g("./src/demux/tsdemuxer.ts"),c=g("./src/demux/mp3demuxer.ts"),a=g("./src/remux/mp4-remuxer.ts"),u=g("./src/remux/passthrough-remuxer.ts"),o=g("./src/demux/chunk-cache.ts"),p=g("./src/utils/mp4-tools.ts"),y=g("./src/utils/logger.ts"),m;try{m=self.performance.now.bind(self.performance)}catch{y.logger.debug("Unable to use Performance API on this environment"),m=self.Date.now}var d=[{demux:x.default,remux:a.default},{demux:P.default,remux:u.default},{demux:M.default,remux:a.default},{demux:c.default,remux:a.default}],l=1024;d.forEach(function(s){var E=s.demux;l=Math.max(l,E.minProbeByteLength)});var i=function(){function s(f,v,D,S,A){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.cache=new o.default,this.observer=f,this.typeSupported=v,this.config=D,this.vendor=S,this.id=A}var E=s.prototype;return E.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},E.push=function(v,D,S,A){var T=this,R=S.transmuxing;R.executeStart=m();var I=new Uint8Array(v),B=this.cache,F=this.config,_=this.currentTransmuxState,U=this.transmuxConfig;A&&(this.currentTransmuxState=A);var N=r(I,D);if(N&&N.method==="AES-128"){var k=this.getDecrypter();if(F.enableSoftwareAES){var W=k.softwareDecrypt(I,N.key.buffer,N.iv.buffer);if(!W)return R.executeEnd=m(),h(S);I=new Uint8Array(W)}else return this.decryptionPromise=k.webCryptoDecrypt(I,N.key.buffer,N.iv.buffer).then(function(ie){var oe=T.push(ie,null,S);return T.decryptionPromise=null,oe}),this.decryptionPromise}var w=A||_,H=w.contiguous,Y=w.discontinuity,j=w.trackSwitch,Q=w.accurateTimeOffset,X=w.timeOffset,V=w.initSegmentChange,z=U.audioCodec,$=U.videoCodec,Z=U.defaultInitPts,J=U.duration,te=U.initSegmentData;if((Y||j||V)&&this.resetInitSegment(te,z,$,J),(Y||V)&&this.resetInitialTimestamp(Z),H||this.resetContiguity(),this.needsProbing(I,Y,j)){if(B.dataLength){var q=B.flush();I=Object(p.appendUint8Array)(q,I)}this.configureTransmuxer(I,U)}var re=this.transmux(I,N,X,Q,S),se=this.currentTransmuxState;return se.contiguous=!0,se.discontinuity=!1,se.trackSwitch=!1,R.executeEnd=m(),re},E.flush=function(v){var D=this,S=v.transmuxing;S.executeStart=m();var A=this.decrypter,T=this.cache,R=this.currentTransmuxState,I=this.decryptionPromise;if(I)return I.then(function(){return D.flush(v)});var B=[],F=R.timeOffset;if(A){var _=A.flush();_&&B.push(this.push(_,null,v))}var U=T.dataLength;T.reset();var N=this.demuxer,k=this.remuxer;if(!N||!k)return U>=l&&this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),S.executeEnd=m(),[h(v)];var W=N.flush(F);return n(W)?W.then(function(w){return D.flushRemux(B,w,v),B}):(this.flushRemux(B,W,v),B)},E.flushRemux=function(v,D,S){var A=D.audioTrack,T=D.avcTrack,R=D.id3Track,I=D.textTrack,B=this.currentTransmuxState,F=B.accurateTimeOffset,_=B.timeOffset;y.logger.log("[transmuxer.ts]: Flushed fragment "+S.sn+(S.part>-1?" p: "+S.part:"")+" of level "+S.level);var U=this.remuxer.remux(A,T,R,I,_,F,!0,this.id);v.push({remuxResult:U,chunkMeta:S}),S.transmuxing.executeEnd=m()},E.resetInitialTimestamp=function(v){var D=this.demuxer,S=this.remuxer;!D||!S||(D.resetTimeStamp(v),S.resetTimeStamp(v))},E.resetContiguity=function(){var v=this.demuxer,D=this.remuxer;!v||!D||(v.resetContiguity(),D.resetNextTimestamp())},E.resetInitSegment=function(v,D,S,A){var T=this.demuxer,R=this.remuxer;!T||!R||(T.resetInitSegment(D,S,A),R.resetInitSegment(v,D,S))},E.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},E.transmux=function(v,D,S,A,T){var R;return D&&D.method==="SAMPLE-AES"?R=this.transmuxSampleAes(v,D,S,A,T):R=this.transmuxUnencrypted(v,S,A,T),R},E.transmuxUnencrypted=function(v,D,S,A){var T=this.demuxer.demux(v,D,!1,!this.config.progressive),R=T.audioTrack,I=T.avcTrack,B=T.id3Track,F=T.textTrack,_=this.remuxer.remux(R,I,B,F,D,S,!1,this.id);return{remuxResult:_,chunkMeta:A}},E.transmuxSampleAes=function(v,D,S,A,T){var R=this;return this.demuxer.demuxSampleAes(v,D,S).then(function(I){var B=R.remuxer.remux(I.audioTrack,I.avcTrack,I.id3Track,I.textTrack,S,A,!1,R.id);return{remuxResult:B,chunkMeta:T}})},E.configureTransmuxer=function(v,D){for(var S=this.config,A=this.observer,T=this.typeSupported,R=this.vendor,I=D.audioCodec,B=D.defaultInitPts,F=D.duration,_=D.initSegmentData,U=D.videoCodec,N,k=0,W=d.length;k<W;k++)if(d[k].demux.probe(v)){N=d[k];break}N||(y.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),N={demux:P.default,remux:u.default});var w=this.demuxer,H=this.remuxer,Y=N.remux,j=N.demux;(!H||!(H instanceof Y))&&(this.remuxer=new Y(A,S,T,R)),(!w||!(w instanceof j))&&(this.demuxer=new j(A,S,T),this.probe=j.probe),this.resetInitSegment(_,I,U,F),this.resetInitialTimestamp(B)},E.needsProbing=function(v,D,S){return!this.demuxer||!this.remuxer||D||S},E.getDecrypter=function(){var v=this.decrypter;return v||(v=this.decrypter=new L.default(this.observer,this.config)),v},s}();function r(s,E){var f=null;return s.byteLength>0&&E!=null&&E.key!=null&&E.iv!==null&&E.method!=null&&(f=E),f}var h=function(E){return{remuxResult:{},chunkMeta:E}};function n(s){return"then"in s&&s.then instanceof Function}var e=function(E,f,v,D,S){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=E,this.videoCodec=f,this.initSegmentData=v,this.duration=D,this.defaultInitPts=S},t=function(E,f,v,D,S,A){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=E,this.contiguous=f,this.accurateTimeOffset=v,this.trackSwitch=D,this.timeOffset=S,this.initSegmentChange=A}},"./src/demux/tsdemuxer.ts":function(K,C,g){g.r(C),g.d(C,"discardEPB",function(){return h});var b=g("./src/demux/adts.ts"),O=g("./src/demux/mpegaudio.ts"),L=g("./src/demux/exp-golomb.ts"),M=g("./src/demux/id3.ts"),P=g("./src/demux/sample-aes.ts"),x=g("./src/events.ts"),c=g("./src/utils/mp4-tools.ts"),a=g("./src/utils/logger.ts"),u=g("./src/errors.ts"),o={video:1,audio:2,id3:3,text:4},p=function(){function n(t,s,E){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=s,this.typeSupported=E}n.probe=function(s){var E=n.syncOffset(s);return E<0?!1:(E&&a.logger.warn("MPEG2-TS detected but first sync word found @ offset "+E+", junk ahead ?"),!0)},n.syncOffset=function(s){for(var E=Math.min(1e3,s.length-564),f=0;f<E;){if(s[f]===71&&s[f+188]===71&&s[f+2*188]===71)return f;f++}return-1},n.createTrack=function(s,E){return{container:s==="video"||s==="audio"?"video/mp2t":void 0,type:s,id:o[s],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:s==="audio"?E:void 0}};var e=n.prototype;return e.resetInitSegment=function(s,E,f){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video",f),this._audioTrack=n.createTrack("audio",f),this._id3Track=n.createTrack("id3",f),this._txtTrack=n.createTrack("text",f),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=s,this.videoCodec=E,this._duration=f},e.resetTimeStamp=function(){},e.resetContiguity=function(){var s=this._audioTrack,E=this._avcTrack,f=this._id3Track;s&&(s.pesData=null),E&&(E.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},e.demux=function(s,E,f,v){f===void 0&&(f=!1),v===void 0&&(v=!1),f||(this.sampleAes=null);var D,S=this._avcTrack,A=this._audioTrack,T=this._id3Track,R=S.pid,I=S.pesData,B=A.pid,F=T.pid,_=A.pesData,U=T.pesData,N=!1,k=this.pmtParsed,W=this._pmtId,w=s.length;if(this.remainderData&&(s=Object(c.appendUint8Array)(this.remainderData,s),w=s.length,this.remainderData=null),w<188&&!v)return this.remainderData=s,{audioTrack:A,avcTrack:S,id3Track:T,textTrack:this._txtTrack};var H=Math.max(0,n.syncOffset(s));w-=(w+H)%188,w<s.byteLength&&!v&&(this.remainderData=new Uint8Array(s.buffer,w,s.buffer.byteLength-w));for(var Y=0,j=H;j<w;j+=188)if(s[j]===71){var Q=!!(s[j+1]&64),X=((s[j+1]&31)<<8)+s[j+2],V=(s[j+3]&48)>>4,z=void 0;if(V>1){if(z=j+5+s[j+4],z===j+188)continue}else z=j+4;switch(X){case R:Q&&(I&&(D=l(I))&&this.parseAVCPES(D,!1),I={data:[],size:0}),I&&(I.data.push(s.subarray(z,j+188)),I.size+=j+188-z);break;case B:Q&&(_&&(D=l(_))&&(A.isAAC?this.parseAACPES(D):this.parseMPEGPES(D)),_={data:[],size:0}),_&&(_.data.push(s.subarray(z,j+188)),_.size+=j+188-z);break;case F:Q&&(U&&(D=l(U))&&this.parseID3PES(D),U={data:[],size:0}),U&&(U.data.push(s.subarray(z,j+188)),U.size+=j+188-z);break;case 0:Q&&(z+=s[z]+1),W=this._pmtId=m(s,z);break;case W:{Q&&(z+=s[z]+1);var $=d(s,z,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);R=$.avc,R>0&&(S.pid=R),B=$.audio,B>0&&(A.pid=B,A.isAAC=$.isAAC),F=$.id3,F>0&&(T.pid=F),N&&!k&&(a.logger.log("reparse from beginning"),N=!1,j=H-188),k=this.pmtParsed=!0;break}case 17:case 8191:break;default:N=!0;break}}else Y++;Y>0&&this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),S.pesData=I,A.pesData=_,T.pesData=U;var Z={audioTrack:A,avcTrack:S,id3Track:T,textTrack:this._txtTrack};return v&&this.extractRemainingSamples(Z),Z},e.flush=function(){var s=this.remainderData;this.remainderData=null;var E;return s?E=this.demux(s,-1,!1,!0):E={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(E),this.sampleAes?this.decrypt(E,this.sampleAes):E},e.extractRemainingSamples=function(s){var E=s.audioTrack,f=s.avcTrack,v=s.id3Track,D=f.pesData,S=E.pesData,A=v.pesData,T;D&&(T=l(D))?(this.parseAVCPES(T,!0),f.pesData=null):f.pesData=D,S&&(T=l(S))?(E.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),E.pesData=null):(S!=null&&S.size&&a.logger.log("last AAC PES packet truncated,might overlap between fragments"),E.pesData=S),A&&(T=l(A))?(this.parseID3PES(T),v.pesData=null):v.pesData=A},e.demuxSampleAes=function(s,E,f){var v=this.demux(s,f,!0,!this.config.progressive),D=this.sampleAes=new P.default(this.observer,this.config,E);return this.decrypt(v,D)},e.decrypt=function(s,E){return new Promise(function(f){var v=s.audioTrack,D=s.avcTrack;v.samples&&v.isAAC?E.decryptAacSamples(v.samples,0,function(){D.samples?E.decryptAvcSamples(D.samples,0,0,function(){f(s)}):f(s)}):D.samples&&E.decryptAvcSamples(D.samples,0,0,function(){f(s)})})},e.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},e.parseAVCPES=function(s,E){var f=this,v=this._avcTrack,D=this.parseAVCNALu(s.data),S=this.avcSample,A,T=!1;s.data=null,S&&D.length&&!v.audFound&&(i(S,v),S=this.avcSample=y(!1,s.pts,s.dts,"")),D.forEach(function(R){switch(R.type){case 1:{A=!0,S||(S=f.avcSample=y(!0,s.pts,s.dts,"")),S.frame=!0;var I=R.data;if(T&&I.length>4){var B=new L.default(I).readSliceType();(B===2||B===4||B===7||B===9)&&(S.key=!0)}break}case 5:A=!0,S||(S=f.avcSample=y(!0,s.pts,s.dts,"")),S.key=!0,S.frame=!0;break;case 6:{A=!0;var F=new L.default(h(R.data));F.readUByte();for(var _=0,U=0,N=!1,k=0;!N&&F.bytesAvailable>1;){_=0;do k=F.readUByte(),_+=k;while(k===255);U=0;do k=F.readUByte(),U+=k;while(k===255);if(_===4&&F.bytesAvailable!==0){N=!0;var W=F.readUByte();if(W===181){var w=F.readUShort();if(w===49){var H=F.readUInt();if(H===1195456820){var Y=F.readUByte();if(Y===3){for(var j=F.readUByte(),Q=F.readUByte(),X=31&j,V=[j,Q],z=0;z<X;z++)V.push(F.readUByte()),V.push(F.readUByte()),V.push(F.readUByte());r(f._txtTrack.samples,{type:3,pts:s.pts,bytes:V})}}}}}else if(_===5&&F.bytesAvailable!==0){if(N=!0,U>16){for(var $=[],Z=0;Z<16;Z++)$.push(F.readUByte().toString(16)),(Z===3||Z===5||Z===7||Z===9)&&$.push("-");for(var J=U-16,te=new Uint8Array(J),q=0;q<J;q++)te[q]=F.readUByte();r(f._txtTrack.samples,{pts:s.pts,payloadType:_,uuid:$.join(""),userData:Object(M.utf8ArrayToStr)(te),userDataBytes:te})}}else if(U<F.bytesAvailable)for(var re=0;re<U;re++)F.readUByte()}break}case 7:if(A=!0,T=!0,!v.sps){var se=new L.default(R.data),ie=se.readSPS();v.width=ie.width,v.height=ie.height,v.pixelRatio=ie.pixelRatio,v.sps=[R.data],v.duration=f._duration;for(var oe=R.data.subarray(1,4),ae="avc1.",le=0;le<3;le++){var ee=oe[le].toString(16);ee.length<2&&(ee="0"+ee),ae+=ee}v.codec=ae}break;case 8:A=!0,v.pps||(v.pps=[R.data]);break;case 9:A=!1,v.audFound=!0,S&&i(S,v),S=f.avcSample=y(!1,s.pts,s.dts,"");break;case 12:A=!1;break;default:A=!1,S&&(S.debug+="unknown NAL "+R.type+" ");break}if(S&&A){var pe=S.units;pe.push(R)}}),E&&S&&(i(S,v),this.avcSample=null)},e.getLastNalUnit=function(){var s,E=this.avcSample,f;if(!E||E.units.length===0){var v=this._avcTrack.samples;E=v[v.length-1]}if((s=E)!==null&&s!==void 0&&s.units){var D=E.units;f=D[D.length-1]}return f},e.parseAVCNALu=function(s){var E=s.byteLength,f=this._avcTrack,v=f.naluState||0,D=v,S=[],A=0,T,R,I,B=-1,F=0;for(v===-1&&(B=0,F=s[0]&31,v=0,A=1);A<E;){if(T=s[A++],!v){v=T?0:1;continue}if(v===1){v=T?0:2;continue}if(!T)v=3;else if(T===1){if(B>=0){var _={data:s.subarray(B,A-v-1),type:F};S.push(_)}else{var U=this.getLastNalUnit();if(U&&(D&&A<=4-D&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-D)),R=A-v-1,R>0)){var N=new Uint8Array(U.data.byteLength+R);N.set(U.data,0),N.set(s.subarray(0,R),U.data.byteLength),U.data=N,U.state=0}}A<E?(I=s[A]&31,B=A,F=I,v=0):v=-1}else v=0}if(B>=0&&v>=0){var k={data:s.subarray(B,E),type:F,state:v};S.push(k)}if(S.length===0){var W=this.getLastNalUnit();if(W){var w=new Uint8Array(W.data.byteLength+s.byteLength);w.set(W.data,0),w.set(s,W.data.byteLength),W.data=w}}return f.naluState=v,S},e.parseAACPES=function(s){var E=0,f=this._audioTrack,v=this.aacOverFlow,D=s.data;if(v){this.aacOverFlow=null;var S=v.sample.unit.byteLength,A=Math.min(v.missing,S),T=S-A;v.sample.unit.set(D.subarray(0,A),T),f.samples.push(v.sample),E=v.missing}var R,I;for(R=E,I=D.length;R<I-1&&!b.isHeader(D,R);R++);if(R!==E){var B,F;if(R<I-1?(B="AAC PES did not start with ADTS header,offset:"+R,F=!1):(B="no ADTS header found in AAC PES",F=!0),a.logger.warn("parsing error:"+B),this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.FRAG_PARSING_ERROR,fatal:F,reason:B}),F)return}b.initTrackConfig(f,this.observer,D,R,this.audioCodec);var _;if(s.pts!==void 0)_=s.pts;else if(v){var U=b.getFrameDuration(f.samplerate);_=v.sample.pts+U}else{a.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var N=0;R<I;)if(b.isHeader(D,R)){if(R+5<I){var k=b.appendFrame(f,D,R,_,N);if(k)if(k.missing)this.aacOverFlow=k;else{R+=k.length,N++;continue}}break}else R++},e.parseMPEGPES=function(s){var E=s.data,f=E.length,v=0,D=0,S=s.pts;if(S===void 0){a.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;D<f;)if(O.isHeader(E,D)){var A=O.appendFrame(this._audioTrack,E,D,S,v);if(A)D+=A.length,v++;else break}else D++},e.parseID3PES=function(s){if(s.pts===void 0){a.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(s)},n}();p.minProbeByteLength=188;function y(n,e,t,s){return{key:n,frame:!1,pts:e,dts:t,units:[],debug:s,length:0}}function m(n,e){return(n[e+10]&31)<<8|n[e+11]}function d(n,e,t,s){var E={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(n[e+1]&15)<<8|n[e+2],v=e+3+f-4,D=(n[e+10]&15)<<8|n[e+11];for(e+=12+D;e<v;){var S=(n[e+1]&31)<<8|n[e+2];switch(n[e]){case 207:if(!s){a.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:E.audio===-1&&(E.audio=S);break;case 21:E.id3===-1&&(E.id3=S);break;case 219:if(!s){a.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:E.avc===-1&&(E.avc=S);break;case 3:case 4:t?E.audio===-1&&(E.audio=S,E.isAAC=!1):a.logger.log("MPEG audio found, not supported in this browser");break;case 36:a.logger.warn("Unsupported HEVC stream type found");break}e+=((n[e+3]&15)<<8|n[e+4])+5}return E}function l(n){var e=0,t,s,E,f,v,D=n.data;if(!n||n.size===0)return null;for(;D[0].length<19&&D.length>1;){var S=new Uint8Array(D[0].length+D[1].length);S.set(D[0]),S.set(D[1],D[0].length),D[0]=S,D.splice(1,1)}t=D[0];var A=(t[0]<<16)+(t[1]<<8)+t[2];if(A===1){if(s=(t[4]<<8)+t[5],s&&s>n.size-6)return null;var T=t[7];T&192&&(f=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,T&64?(v=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,f-v>60*9e4&&(a.logger.warn(Math.round((f-v)/9e4)+"s delta between PTS and DTS, align them"),f=v)):v=f),E=t[8];var R=E+9;if(n.size<=R)return null;n.size-=R;for(var I=new Uint8Array(n.size),B=0,F=D.length;B<F;B++){t=D[B];var _=t.byteLength;if(R)if(R>_){R-=_;continue}else t=t.subarray(R),_-=R,R=0;I.set(t,e),e+=_}return s&&(s-=E+3),{data:I,pts:f,dts:v,len:s}}return null}function i(n,e){if(n.units.length&&n.frame){if(n.pts===void 0){var t=e.samples,s=t.length;if(s){var E=t[s-1];n.pts=E.pts,n.dts=E.dts}else{e.dropped++;return}}e.samples.push(n)}n.debug.length&&a.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function r(n,e){var t=n.length;if(t>0){if(e.pts>=n[t-1].pts)n.push(e);else for(var s=t-1;s>=0;s--)if(e.pts<n[s].pts){n.splice(s,0,e);break}}else n.push(e)}function h(n){for(var e=n.byteLength,t=[],s=1;s<e-2;)n[s]===0&&n[s+1]===0&&n[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return n;var E=e-t.length,f=new Uint8Array(E),v=0;for(s=0;s<E;v++,s++)v===t[0]&&(v++,t.shift()),f[s]=n[v];return f}C.default=p},"./src/empty.js":function(K,C){K.exports=void 0},"./src/errors.ts":function(K,C,g){g.r(C),g.d(C,"ErrorTypes",function(){return b}),g.d(C,"ErrorDetails",function(){return O});var b;(function(L){L.NETWORK_ERROR="networkError",L.MEDIA_ERROR="mediaError",L.KEY_SYSTEM_ERROR="keySystemError",L.MUX_ERROR="muxError",L.OTHER_ERROR="otherError"})(b||(b={}));var O;(function(L){L.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",L.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",L.KEY_SYSTEM_NO_SESSION="keySystemNoSession",L.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",L.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",L.MANIFEST_LOAD_ERROR="manifestLoadError",L.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",L.MANIFEST_PARSING_ERROR="manifestParsingError",L.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",L.LEVEL_EMPTY_ERROR="levelEmptyError",L.LEVEL_LOAD_ERROR="levelLoadError",L.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",L.LEVEL_SWITCH_ERROR="levelSwitchError",L.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",L.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",L.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",L.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",L.FRAG_LOAD_ERROR="fragLoadError",L.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",L.FRAG_DECRYPT_ERROR="fragDecryptError",L.FRAG_PARSING_ERROR="fragParsingError",L.REMUX_ALLOC_ERROR="remuxAllocError",L.KEY_LOAD_ERROR="keyLoadError",L.KEY_LOAD_TIMEOUT="keyLoadTimeOut",L.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",L.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",L.BUFFER_APPEND_ERROR="bufferAppendError",L.BUFFER_APPENDING_ERROR="bufferAppendingError",L.BUFFER_STALLED_ERROR="bufferStalledError",L.BUFFER_FULL_ERROR="bufferFullError",L.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",L.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",L.INTERNAL_EXCEPTION="internalException",L.INTERNAL_ABORTED="aborted",L.UNKNOWN="unknown"})(O||(O={}))},"./src/events.ts":function(K,C,g){g.r(C),g.d(C,"Events",function(){return b});var b;(function(O){O.MEDIA_ATTACHING="hlsMediaAttaching",O.MEDIA_ATTACHED="hlsMediaAttached",O.MEDIA_DETACHING="hlsMediaDetaching",O.MEDIA_DETACHED="hlsMediaDetached",O.BUFFER_RESET="hlsBufferReset",O.BUFFER_CODECS="hlsBufferCodecs",O.BUFFER_CREATED="hlsBufferCreated",O.BUFFER_APPENDING="hlsBufferAppending",O.BUFFER_APPENDED="hlsBufferAppended",O.BUFFER_EOS="hlsBufferEos",O.BUFFER_FLUSHING="hlsBufferFlushing",O.BUFFER_FLUSHED="hlsBufferFlushed",O.MANIFEST_LOADING="hlsManifestLoading",O.MANIFEST_LOADED="hlsManifestLoaded",O.MANIFEST_PARSED="hlsManifestParsed",O.LEVEL_SWITCHING="hlsLevelSwitching",O.LEVEL_SWITCHED="hlsLevelSwitched",O.LEVEL_LOADING="hlsLevelLoading",O.LEVEL_LOADED="hlsLevelLoaded",O.LEVEL_UPDATED="hlsLevelUpdated",O.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",O.LEVELS_UPDATED="hlsLevelsUpdated",O.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",O.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",O.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",O.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",O.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",O.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",O.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",O.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",O.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",O.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",O.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",O.CUES_PARSED="hlsCuesParsed",O.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",O.INIT_PTS_FOUND="hlsInitPtsFound",O.FRAG_LOADING="hlsFragLoading",O.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",O.FRAG_LOADED="hlsFragLoaded",O.FRAG_DECRYPTED="hlsFragDecrypted",O.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",O.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",O.FRAG_PARSING_METADATA="hlsFragParsingMetadata",O.FRAG_PARSED="hlsFragParsed",O.FRAG_BUFFERED="hlsFragBuffered",O.FRAG_CHANGED="hlsFragChanged",O.FPS_DROP="hlsFpsDrop",O.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",O.ERROR="hlsError",O.DESTROYING="hlsDestroying",O.KEY_LOADING="hlsKeyLoading",O.KEY_LOADED="hlsKeyLoaded",O.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",O.BACK_BUFFER_REACHED="hlsBackBufferReached"})(b||(b={}))},"./src/hls.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return r});var b=g("./node_modules/url-toolkit/src/url-toolkit.js"),O=g("./src/loader/playlist-loader.ts"),L=g("./src/loader/key-loader.ts"),M=g("./src/controller/id3-track-controller.ts"),P=g("./src/controller/latency-controller.ts"),x=g("./src/controller/level-controller.ts"),c=g("./src/controller/fragment-tracker.ts"),a=g("./src/controller/stream-controller.ts"),u=g("./src/is-supported.ts"),o=g("./src/utils/logger.ts"),p=g("./src/config.ts"),y=g("./node_modules/eventemitter3/index.js"),m=g("./src/events.ts"),d=g("./src/errors.ts");function l(h,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(h,t.key,t)}}function i(h,n,e){return n&&l(h.prototype,n),e&&l(h,e),h}var r=function(){h.isSupported=function(){return Object(u.isSupported)()};function h(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.EventEmitter,this._autoLevelCapping=void 0,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;var t=this.config=Object(p.mergeConfig)(h.DefaultConfig,e);this.userConfig=e,Object(o.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(p.enableStreamingMode)(t);var s=t.abrController,E=t.bufferController,f=t.capLevelController,v=t.fpsController,D=this.abrController=new s(this),S=this.bufferController=new E(this),A=this.capLevelController=new f(this),T=new v(this),R=new O.default(this),I=new L.default(this),B=new M.default(this),F=this.levelController=new x.default(this),_=new c.FragmentTracker(this),U=this.streamController=new a.default(this,_);A.setStreamController(U),T.setStreamController(U);var N=[F,U];this.networkControllers=N;var k=[R,I,D,S,A,T,B,_];this.audioTrackController=this.createController(t.audioTrackController,null,N),this.createController(t.audioStreamController,_,N),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,N),this.createController(t.subtitleStreamController,_,N),this.createController(t.timelineController,null,k),this.emeController=this.createController(t.emeController,null,k),this.cmcdController=this.createController(t.cmcdController,null,k),this.latencyController=this.createController(P.default,null,k),this.coreComponents=k}var n=h.prototype;return n.createController=function(t,s,E){if(t){var f=s?new t(this,s):new t(this);return E&&E.push(f),f}return null},n.on=function(t,s,E){E===void 0&&(E=this),this._emitter.on(t,s,E)},n.once=function(t,s,E){E===void 0&&(E=this),this._emitter.once(t,s,E)},n.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},n.off=function(t,s,E,f){E===void 0&&(E=this),this._emitter.off(t,s,E,f)},n.listeners=function(t){return this._emitter.listeners(t)},n.emit=function(t,s,E){return this._emitter.emit(t,s,E)},n.trigger=function(t,s){if(this.config.debug)return this.emit(t,t,s);try{return this.emit(t,t,s)}catch(E){o.logger.error("An internal error happened while handling event "+t+'. Error message: "'+E.message+'". Here is a stacktrace:',E),this.trigger(m.Events.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:E})}return!1},n.listenerCount=function(t){return this._emitter.listenerCount(t)},n.destroy=function(){o.logger.log("destroy"),this.trigger(m.Events.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},n.attachMedia=function(t){o.logger.log("attachMedia"),this._media=t,this.trigger(m.Events.MEDIA_ATTACHING,{media:t})},n.detachMedia=function(){o.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(t){this.stopLoad();var s=this.media,E=this.url,f=this.url=b.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});o.logger.log("loadSource:"+f),s&&E&&E!==f&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(s)),this.trigger(m.Events.MANIFEST_LOADING,{url:t})},n.startLoad=function(t){t===void 0&&(t=-1),o.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(s){s.startLoad(t)})},n.stopLoad=function(){o.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},n.swapAudioCodec=function(){o.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){o.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},n.removeLevel=function(t,s){s===void 0&&(s=0),this.levelController.removeLevel(t,s)},i(h,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){o.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){o.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){o.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){o.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){o.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var s=!!t;s!==this.config.capLevelToPlayerSize&&(s?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=s)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(o.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,s=this.config.minAutoBitrate;if(!t)return 0;for(var E=t.length,f=0;f<E;f++)if(t[f].maxBitrate>s)return f;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,s=this.autoLevelCapping,E;return s===-1&&t&&t.length?E=t.length-1:E=s,E}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var s=this.audioTrackController;s&&(s.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var s=this.subtitleTrackController;s&&(s.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var s=this.subtitleTrackController;s&&(s.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.5"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return h.defaultConfig?h.defaultConfig:p.hlsDefaultConfig},set:function(t){h.defaultConfig=t}}]),h}();r.defaultConfig=void 0},"./src/is-supported.ts":function(K,C,g){g.r(C),g.d(C,"isSupported",function(){return L}),g.d(C,"changeTypeSupported",function(){return M});var b=g("./src/utils/mediasource-helper.ts");function O(){return self.SourceBuffer||self.WebKitSourceBuffer}function L(){var P=Object(b.getMediaSource)();if(!P)return!1;var x=O(),c=P&&typeof P.isTypeSupported=="function"&&P.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!x||x.prototype&&typeof x.prototype.appendBuffer=="function"&&typeof x.prototype.remove=="function";return!!c&&!!a}function M(){var P,x=O();return typeof(x==null||(P=x.prototype)===null||P===void 0?void 0:P.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return p}),g.d(C,"LoadError",function(){return m});var b=g("./src/polyfills/number.ts"),O=g("./src/errors.ts");function L(d,l){d.prototype=Object.create(l.prototype),d.prototype.constructor=d,a(d,l)}function M(d){var l=typeof Map=="function"?new Map:void 0;return M=function(r){if(r===null||!c(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(r))return l.get(r);l.set(r,h)}function h(){return P(r,arguments,u(this).constructor)}return h.prototype=Object.create(r.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),a(h,r)},M(d)}function P(d,l,i){return x()?P=Reflect.construct:P=function(h,n,e){var t=[null];t.push.apply(t,n);var s=Function.bind.apply(h,t),E=new s;return e&&a(E,e.prototype),E},P.apply(null,arguments)}function x(){if(typeof Reflect=="undefined"||!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 c(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function a(d,l){return a=Object.setPrototypeOf||function(r,h){return r.__proto__=h,r},a(d,l)}function u(d){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},u(d)}var o=Math.pow(2,17),p=function(){function d(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var l=d.prototype;return l.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},l.abort=function(){this.loader&&this.loader.abort()},l.load=function(r,h){var n=this,e=r.url;if(!e)return Promise.reject(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:r,networkDetails:null},"Fragment does not have a "+(e?"part list":"url")));this.abort();var t=this.config,s=t.fLoader,E=t.loader;return new Promise(function(f,v){n.loader&&n.loader.destroy();var D=n.loader=r.loader=s?new s(t):new E(t),S=y(r),A={timeout:t.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:t.fragLoadingMaxRetryTimeout,highWaterMark:o};r.stats=D.stats,D.load(S,A,{onSuccess:function(R,I,B,F){n.resetLoader(r,D),f({frag:r,part:null,payload:R.data,networkDetails:F})},onError:function(R,I,B){n.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:r,response:R,networkDetails:B}))},onAbort:function(R,I,B){n.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:r,networkDetails:B}))},onTimeout:function(R,I,B){n.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:r,networkDetails:B}))},onProgress:function(R,I,B,F){h&&h({frag:r,part:null,payload:B,networkDetails:F})}})})},l.loadPart=function(r,h,n){var e=this;this.abort();var t=this.config,s=t.fLoader,E=t.loader;return new Promise(function(f,v){e.loader&&e.loader.destroy();var D=e.loader=r.loader=s?new s(t):new E(t),S=y(r,h),A={timeout:t.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:t.fragLoadingMaxRetryTimeout,highWaterMark:o};h.stats=D.stats,D.load(S,A,{onSuccess:function(R,I,B,F){e.resetLoader(r,D),e.updateStatsFromPart(r,h);var _={frag:r,part:h,payload:R.data,networkDetails:F};n(_),f(_)},onError:function(R,I,B){e.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:r,part:h,response:R,networkDetails:B}))},onAbort:function(R,I,B){r.stats.aborted=h.stats.aborted,e.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:r,part:h,networkDetails:B}))},onTimeout:function(R,I,B){e.resetLoader(r,D),v(new m({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:r,part:h,networkDetails:B}))}})})},l.updateStatsFromPart=function(r,h){var n=r.stats,e=h.stats,t=e.total;if(n.loaded+=e.loaded,t){var s=Math.round(r.duration/h.duration),E=Math.min(Math.round(n.loaded/t),s),f=s-E,v=f*Math.round(n.loaded/E);n.total=n.loaded+v}else n.total=Math.max(n.loaded,n.total);var D=n.loading,S=e.loading;D.start?D.first+=S.first-S.start:(D.start=S.start,D.first=S.first),D.end=S.end},l.resetLoader=function(r,h){r.loader=null,this.loader===h&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),h.destroy()},d}();function y(d,l){l===void 0&&(l=null);var i=l||d,r={frag:d,part:l,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},h=i.byteRangeStartOffset,n=i.byteRangeEndOffset;return Object(b.isFiniteNumber)(h)&&Object(b.isFiniteNumber)(n)&&(r.rangeStart=h,r.rangeEnd=n),r}var m=function(d){L(l,d);function l(i){for(var r,h=arguments.length,n=new Array(h>1?h-1:0),e=1;e<h;e++)n[e-1]=arguments[e];return r=d.call.apply(d,[this].concat(n))||this,r.data=void 0,r.data=i,r}return l}(M(Error))},"./src/loader/fragment.ts":function(K,C,g){g.r(C),g.d(C,"ElementaryStreamTypes",function(){return o}),g.d(C,"BaseSegment",function(){return p}),g.d(C,"Fragment",function(){return y}),g.d(C,"Part",function(){return m});var b=g("./src/polyfills/number.ts"),O=g("./node_modules/url-toolkit/src/url-toolkit.js"),L=g("./src/utils/logger.ts"),M=g("./src/loader/level-key.ts"),P=g("./src/loader/load-stats.ts");function x(d,l){d.prototype=Object.create(l.prototype),d.prototype.constructor=d,c(d,l)}function c(d,l){return c=Object.setPrototypeOf||function(r,h){return r.__proto__=h,r},c(d,l)}function a(d,l){for(var i=0;i<l.length;i++){var r=l[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(d,r.key,r)}}function u(d,l,i){return l&&a(d.prototype,l),i&&a(d,i),d}var o;(function(d){d.AUDIO="audio",d.VIDEO="video",d.AUDIOVIDEO="audiovideo"})(o||(o={}));var p=function(){function d(i){var r;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(r={},r[o.AUDIO]=null,r[o.VIDEO]=null,r[o.AUDIOVIDEO]=null,r),this.baseurl=i}var l=d.prototype;return l.setByteRange=function(r,h){var n=r.split("@",2),e=[];n.length===1?e[0]=h?h.byteRangeEndOffset:0:e[0]=parseInt(n[1]),e[1]=parseInt(n[0])+e[0],this._byteRange=e},u(d,[{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=Object(O.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(r){this._url=r}}]),d}(),y=function(d){x(l,d);function l(r,h){var n;return n=d.call(this,h)||this,n._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new P.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=r,n}var i=l.prototype;return i.createInitializationVector=function(h){for(var n=new Uint8Array(16),e=12;e<16;e++)n[e]=h>>8*(15-e)&255;return n},i.setDecryptDataFromLevelKey=function(h,n){var e=h;return(h==null?void 0:h.method)==="AES-128"&&h.uri&&!h.iv&&(e=M.LevelKey.fromURI(h.uri),e.method=h.method,e.iv=this.createInitializationVector(n),e.keyFormat="identity"),e},i.setElementaryStreamInfo=function(h,n,e,t,s,E){E===void 0&&(E=!1);var f=this.elementaryStreams,v=f[h];if(!v){f[h]={startPTS:n,endPTS:e,startDTS:t,endDTS:s,partial:E};return}v.startPTS=Math.min(v.startPTS,n),v.endPTS=Math.max(v.endPTS,e),v.startDTS=Math.min(v.startDTS,t),v.endDTS=Math.max(v.endDTS,s)},i.clearElementaryStreamInfo=function(){var h=this.elementaryStreams;h[o.AUDIO]=null,h[o.VIDEO]=null,h[o.AUDIOVIDEO]=null},u(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var h=this.sn;typeof h!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&L.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),h=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,h)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(b.isFiniteNumber)(this.programDateTime))return null;var h=Object(b.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+h*1e3}},{key:"encrypted",get:function(){var h;return!!((h=this.decryptdata)!==null&&h!==void 0&&h.keyFormat&&this.decryptdata.uri)}}]),l}(p),m=function(d){x(l,d);function l(i,r,h,n,e){var t;t=d.call(this,h)||this,t.fragOffset=0,t.duration=0,t.gap=!1,t.independent=!1,t.relurl=void 0,t.fragment=void 0,t.index=void 0,t.stats=new P.LoadStats,t.duration=i.decimalFloatingPoint("DURATION"),t.gap=i.bool("GAP"),t.independent=i.bool("INDEPENDENT"),t.relurl=i.enumeratedString("URI"),t.fragment=r,t.index=n;var s=i.enumeratedString("BYTERANGE");return s&&t.setByteRange(s,e),e&&(t.fragOffset=e.fragOffset+e.duration),t}return u(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var r=this.elementaryStreams;return!!(r.audio||r.video||r.audiovideo)}}]),l}(p)},"./src/loader/key-loader.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return M});var b=g("./src/events.ts"),O=g("./src/errors.ts"),L=g("./src/utils/logger.ts"),M=function(){function P(c){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=c,this._registerListeners()}var x=P.prototype;return x._registerListeners=function(){this.hls.on(b.Events.KEY_LOADING,this.onKeyLoading,this)},x._unregisterListeners=function(){this.hls.off(b.Events.KEY_LOADING,this.onKeyLoading)},x.destroy=function(){this._unregisterListeners();for(var a in this.loaders){var u=this.loaders[a];u&&u.destroy()}this.loaders={}},x.onKeyLoading=function(a,u){var o=u.frag,p=o.type,y=this.loaders[p];if(!o.decryptdata){L.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var m=o.decryptdata.uri;if(m!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(y&&(L.logger.warn("abort previous key loader for type:"+p),y.abort()),!m){L.logger.warn("key uri is falsy");return}var l=d.loader,i=o.loader=this.loaders[p]=new l(d);this.decrypturl=m,this.decryptkey=null;var r={url:m,frag:o,responseType:"arraybuffer"},h={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};i.load(r,h,n)}else this.decryptkey&&(o.decryptdata.key=this.decryptkey,this.hls.trigger(b.Events.KEY_LOADED,{frag:o}))},x.loadsuccess=function(a,u,o){var p=o.frag;if(!p.decryptdata){L.logger.error("after key load, decryptdata unset");return}this.decryptkey=p.decryptdata.key=new Uint8Array(a.data),p.loader=null,delete this.loaders[p.type],this.hls.trigger(b.Events.KEY_LOADED,{frag:p})},x.loaderror=function(a,u){var o=u.frag,p=o.loader;p&&p.abort(),delete this.loaders[o.type],this.hls.trigger(b.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:o,response:a})},x.loadtimeout=function(a,u){var o=u.frag,p=o.loader;p&&p.abort(),delete this.loaders[o.type],this.hls.trigger(b.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:o})},P}()},"./src/loader/level-details.ts":function(K,C,g){g.r(C),g.d(C,"LevelDetails",function(){return P});var b=g("./src/polyfills/number.ts");function O(x,c){for(var a=0;a<c.length;a++){var u=c[a];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(x,u.key,u)}}function L(x,c,a){return c&&O(x.prototype,c),a&&O(x,a),x}var M=10,P=function(){function x(a){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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.fragments=[],this.url=a}var c=x.prototype;return c.reloaded=function(u){if(!u){this.advanced=!0,this.updated=!0;return}var o=this.lastPartSn-u.lastPartSn,p=this.lastPartIndex-u.lastPartIndex;this.updated=this.endSN!==u.endSN||!!p||!!o,this.advanced=this.endSN>u.endSN||o>0||o===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(u.misses*.6):this.misses=u.misses+1,this.availabilityDelay=u.availabilityDelay},L(x,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(b.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||M}},{key:"drift",get:function(){var u=this.driftEndTime-this.driftStartTime;if(u>0){var o=this.driftEnd-this.driftStart;return o*1e3/u}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var u;return(u=this.partList)!==null&&u!==void 0&&u.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var u;return(u=this.fragments)!==null&&u!==void 0&&u.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 u;return(u=this.partList)!==null&&u!==void 0&&u.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var u;return(u=this.partList)!==null&&u!==void 0&&u.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),x}()},"./src/loader/level-key.ts":function(K,C,g){g.r(C),g.d(C,"LevelKey",function(){return M});var b=g("./node_modules/url-toolkit/src/url-toolkit.js");function O(P,x){for(var c=0;c<x.length;c++){var a=x[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(P,a.key,a)}}function L(P,x,c){return x&&O(P.prototype,x),c&&O(P,c),P}var M=function(){P.fromURL=function(c,a){return new P(c,a)},P.fromURI=function(c){return new P(c)};function P(x,c){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,c?this._uri=Object(b.buildAbsoluteURL)(x,c,{alwaysNormalize:!0}):this._uri=x}return L(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(K,C,g){g.r(C),g.d(C,"LoadStats",function(){return b});var b=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}}},"./src/loader/m3u8-parser.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return l});var b=g("./src/polyfills/number.ts"),O=g("./node_modules/url-toolkit/src/url-toolkit.js"),L=g("./src/loader/fragment.ts"),M=g("./src/loader/level-details.ts"),P=g("./src/loader/level-key.ts"),x=g("./src/utils/attr-list.ts"),c=g("./src/utils/logger.ts"),a=g("./src/utils/codecs.ts"),u=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,o=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),m=/\.(mp4|m4s|m4v|m4a)$/i;function d(e){var t,s;return m.test((t=(s=O.parseURL(e))===null||s===void 0?void 0:s.path)!=null?t:"")}var l=function(){function e(){}return e.findGroup=function(s,E){for(var f=0;f<s.length;f++){var v=s[f];if(v.id===E)return v}},e.convertAVC1ToAVCOTI=function(s){var E=s.split(".");if(E.length>2){var f=E.shift()+".";return f+=parseInt(E.shift()).toString(16),f+=("000"+parseInt(E.shift()).toString(16)).substr(-4),f}return s},e.resolve=function(s,E){return O.buildAbsoluteURL(E,s,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(s,E){var f=[],v={},D=!1;u.lastIndex=0;for(var S;(S=u.exec(s))!=null;)if(S[1]){var A=new x.AttrList(S[1]),T={attrs:A,bitrate:A.decimalInteger("AVERAGE-BANDWIDTH")||A.decimalInteger("BANDWIDTH"),name:A.NAME,url:e.resolve(S[2],E)},R=A.decimalResolution("RESOLUTION");R&&(T.width=R.width,T.height=R.height),i((A.CODECS||"").split(/[ ,]+/).filter(function(B){return B}),T),T.videoCodec&&T.videoCodec.indexOf("avc1")!==-1&&(T.videoCodec=e.convertAVC1ToAVCOTI(T.videoCodec)),f.push(T)}else if(S[3]){var I=new x.AttrList(S[3]);I["DATA-ID"]&&(D=!0,v[I["DATA-ID"]]=I)}return{levels:f,sessionData:D?v:null}},e.parseMasterPlaylistMedia=function(s,E,f,v){v===void 0&&(v=[]);var D,S=[],A=0;for(o.lastIndex=0;(D=o.exec(s))!==null;){var T=new x.AttrList(D[1]);if(T.TYPE===f){var R={attrs:T,bitrate:0,id:A++,groupId:T["GROUP-ID"],instreamId:T["INSTREAM-ID"],name:T.NAME||T.LANGUAGE||"",type:f,default:T.bool("DEFAULT"),autoselect:T.bool("AUTOSELECT"),forced:T.bool("FORCED"),lang:T.LANGUAGE,url:T.URI?e.resolve(T.URI,E):""};if(v.length){var I=e.findGroup(v,R.groupId)||v[0];r(R,I,"audioCodec"),r(R,I,"textCodec")}S.push(R)}}return S},e.parseLevelPlaylist=function(s,E,f,v,D){var S=new M.LevelDetails(E),A=S.fragments,T=null,R=0,I=0,B=0,F=0,_=null,U=new L.Fragment(v,E),N,k,W,w=-1,H=!1;for(p.lastIndex=0,S.m3u8=s;(N=p.exec(s))!==null;){H&&(H=!1,U=new L.Fragment(v,E),U.start=B,U.sn=R,U.cc=F,U.level=f,T&&(U.initSegment=T,U.rawProgramDateTime=T.rawProgramDateTime));var Y=N[1];if(Y){U.duration=parseFloat(Y);var j=(" "+N[2]).slice(1);U.title=j||null,U.tagList.push(j?["INF",Y,j]:["INF",Y])}else if(N[3])Object(b.isFiniteNumber)(U.duration)&&(U.start=B,W&&(U.levelkey=W),U.sn=R,U.level=f,U.cc=F,U.urlId=D,A.push(U),U.relurl=(" "+N[3]).slice(1),n(U,_),_=U,B+=U.duration,R++,I=0,H=!0);else if(N[4]){var Q=(" "+N[4]).slice(1);_?U.setByteRange(Q,_):U.setByteRange(Q)}else if(N[5])U.rawProgramDateTime=(" "+N[5]).slice(1),U.tagList.push(["PROGRAM-DATE-TIME",U.rawProgramDateTime]),w===-1&&(w=A.length);else{if(N=N[0].match(y),!N){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(k=1;k<N.length&&typeof N[k]=="undefined";k++);var X=(" "+N[k]).slice(1),V=(" "+N[k+1]).slice(1),z=N[k+2]?(" "+N[k+2]).slice(1):"";switch(X){case"PLAYLIST-TYPE":S.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":R=S.startSN=parseInt(V);break;case"SKIP":{var $=new x.AttrList(V),Z=$.decimalInteger("SKIPPED-SEGMENTS");if(Object(b.isFiniteNumber)(Z)){S.skippedSegments=Z;for(var J=Z;J--;)A.unshift(null);R+=Z}var te=$.enumeratedString("RECENTLY-REMOVED-DATERANGES");te&&(S.recentlyRemovedDateranges=te.split(" "));break}case"TARGETDURATION":S.targetduration=parseFloat(V);break;case"VERSION":S.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":S.live=!1;break;case"#":(V||z)&&U.tagList.push(z?[V,z]:[V]);break;case"DIS":F++;case"GAP":U.tagList.push([X]);break;case"BITRATE":U.tagList.push([X,V]);break;case"DISCONTINUITY-SEQ":F=parseInt(V);break;case"KEY":{var q,re=new x.AttrList(V),se=re.enumeratedString("METHOD"),ie=re.URI,oe=re.hexadecimalInteger("IV"),ae=re.enumeratedString("KEYFORMATVERSIONS"),le=re.enumeratedString("KEYID"),ee=(q=re.enumeratedString("KEYFORMAT"))!=null?q:"identity",pe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(pe.indexOf(ee)>-1){c.logger.warn("Keyformat "+ee+" is not supported from the manifest");continue}else if(ee!=="identity")continue;se&&(W=P.LevelKey.fromURL(E,ie),ie&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(se)>=0&&(W.method=se,W.keyFormat=ee,le&&(W.keyID=le),ae&&(W.keyFormatVersions=ae),W.iv=oe));break}case"START":{var Te=new x.AttrList(V),me=Te.decimalFloatingPoint("TIME-OFFSET");Object(b.isFiniteNumber)(me)&&(S.startTimeOffset=me);break}case"MAP":{var fe=new x.AttrList(V);U.relurl=fe.URI,fe.BYTERANGE&&U.setByteRange(fe.BYTERANGE),U.level=f,U.sn="initSegment",W&&(U.levelkey=W),U.initSegment=null,T=U,H=!0;break}case"SERVER-CONTROL":{var de=new x.AttrList(V);S.canBlockReload=de.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=de.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&de.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=de.optionalFloat("PART-HOLD-BACK",0),S.holdBack=de.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ge=new x.AttrList(V);S.partTarget=ge.decimalFloatingPoint("PART-TARGET");break}case"PART":{var he=S.partList;he||(he=S.partList=[]);var ue=I>0?he[he.length-1]:void 0,ce=I++,xe=new L.Part(new x.AttrList(V),U,E,ce,ue);he.push(xe),U.duration+=xe.duration;break}case"PRELOAD-HINT":{var Le=new x.AttrList(V);S.preloadHint=Le;break}case"RENDITION-REPORT":{var ye=new x.AttrList(V);S.renditionReports=S.renditionReports||[],S.renditionReports.push(ye);break}default:c.logger.warn("line parsed but not handled: "+N);break}}}_&&!_.relurl?(A.pop(),B-=_.duration,S.partList&&(S.fragmentHint=_)):S.partList&&(n(U,_),U.cc=F,S.fragmentHint=U);var Se=A.length,Ee=A[0],ve=A[Se-1];if(B+=S.skippedSegments*S.targetduration,B>0&&Se&&ve){S.averagetargetduration=B/Se;var Ae=ve.sn;S.endSN=Ae!=="initSegment"?Ae:0,Ee&&(S.startCC=Ee.cc,Ee.initSegment||S.fragments.every(function(De){return De.relurl&&d(De.relurl)})&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),U=new L.Fragment(v,E),U.relurl=ve.relurl,U.level=f,U.sn="initSegment",Ee.initSegment=U,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(B+=S.fragmentHint.duration),S.totalduration=B,S.endCC=F,w>0&&h(A,w),S},e}();function i(e,t){["video","audio","text"].forEach(function(s){var E=e.filter(function(v){return Object(a.isCodecType)(v,s)});if(E.length){var f=E.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});t[s+"Codec"]=f.length>0?f[0]:E[0],e=e.filter(function(v){return E.indexOf(v)===-1})}}),t.unknownCodecs=e}function r(e,t,s){var E=t[s];E&&(e[s]=E)}function h(e,t){for(var s=e[t],E=t;E--;){var f=e[E];if(!f)return;f.programDateTime=s.programDateTime-f.duration*1e3,s=f}}function n(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t!=null&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(b.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(K,C,g){g.r(C);var b=g("./src/polyfills/number.ts"),O=g("./src/events.ts"),L=g("./src/errors.ts"),M=g("./src/utils/logger.ts"),P=g("./src/utils/mp4-tools.ts"),x=g("./src/loader/m3u8-parser.ts"),c=g("./src/types/loader.ts"),a=g("./src/utils/attr-list.ts");function u(y){var m=y.type;switch(m){case c.PlaylistContextType.AUDIO_TRACK:return c.PlaylistLevelType.AUDIO;case c.PlaylistContextType.SUBTITLE_TRACK:return c.PlaylistLevelType.SUBTITLE;default:return c.PlaylistLevelType.MAIN}}function o(y,m){var d=y.url;return(d===void 0||d.indexOf("data:")===0)&&(d=m.url),d}var p=function(){function y(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var m=y.prototype;return m.registerListeners=function(){var l=this.hls;l.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),l.on(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),l.on(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},m.unregisterListeners=function(){var l=this.hls;l.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),l.off(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),l.off(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},m.createInternalLoader=function(l){var i=this.hls.config,r=i.pLoader,h=i.loader,n=r||h,e=new n(i);return l.loader=e,this.loaders[l.type]=e,e},m.getInternalLoader=function(l){return this.loaders[l.type]},m.resetInternalLoader=function(l){this.loaders[l]&&delete this.loaders[l]},m.destroyInternalLoaders=function(){for(var l in this.loaders){var i=this.loaders[l];i&&i.destroy(),this.resetInternalLoader(l)}},m.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},m.onManifestLoading=function(l,i){var r=i.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:c.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},m.onLevelLoading=function(l,i){var r=i.id,h=i.level,n=i.url,e=i.deliveryDirectives;this.load({id:r,groupId:null,level:h,responseType:"text",type:c.PlaylistContextType.LEVEL,url:n,deliveryDirectives:e})},m.onAudioTrackLoading=function(l,i){var r=i.id,h=i.groupId,n=i.url,e=i.deliveryDirectives;this.load({id:r,groupId:h,level:null,responseType:"text",type:c.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:e})},m.onSubtitleTrackLoading=function(l,i){var r=i.id,h=i.groupId,n=i.url,e=i.deliveryDirectives;this.load({id:r,groupId:h,level:null,responseType:"text",type:c.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:e})},m.load=function(l){var i,r=this.hls.config,h=this.getInternalLoader(l);if(h){var n=h.context;if(n&&n.url===l.url){M.logger.trace("[playlist-loader]: playlist request ongoing");return}M.logger.log("[playlist-loader]: aborting previous loader for type: "+l.type),h.abort()}var e,t,s,E;switch(l.type){case c.PlaylistContextType.MANIFEST:e=r.manifestLoadingMaxRetry,t=r.manifestLoadingTimeOut,s=r.manifestLoadingRetryDelay,E=r.manifestLoadingMaxRetryTimeout;break;case c.PlaylistContextType.LEVEL:case c.PlaylistContextType.AUDIO_TRACK:case c.PlaylistContextType.SUBTITLE_TRACK:e=0,t=r.levelLoadingTimeOut;break;default:e=r.levelLoadingMaxRetry,t=r.levelLoadingTimeOut,s=r.levelLoadingRetryDelay,E=r.levelLoadingMaxRetryTimeout;break}if(h=this.createInternalLoader(l),(i=l.deliveryDirectives)!==null&&i!==void 0&&i.part){var f;if(l.type===c.PlaylistContextType.LEVEL&&l.level!==null?f=this.hls.levels[l.level].details:l.type===c.PlaylistContextType.AUDIO_TRACK&&l.id!==null?f=this.hls.audioTracks[l.id].details:l.type===c.PlaylistContextType.SUBTITLE_TRACK&&l.id!==null&&(f=this.hls.subtitleTracks[l.id].details),f){var v=f.partTarget,D=f.targetduration;v&&D&&(t=Math.min(Math.max(v*3,D*.8)*1e3,t))}}var S={timeout:t,maxRetry:e,retryDelay:s,maxRetryDelay:E,highWaterMark:0},A={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};h.load(l,S,A)},m.loadsuccess=function(l,i,r,h){if(h===void 0&&(h=null),r.isSidxRequest){this.handleSidxRequest(l,r),this.handlePlaylistLoaded(l,i,r,h);return}this.resetInternalLoader(r.type);var n=l.data;if(n.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(l,r,"no EXTM3U delimiter",h);return}i.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(l,i,r,h):this.handleMasterPlaylist(l,i,r,h)},m.loaderror=function(l,i,r){r===void 0&&(r=null),this.handleNetworkError(i,r,!1,l)},m.loadtimeout=function(l,i,r){r===void 0&&(r=null),this.handleNetworkError(i,r,!0)},m.handleMasterPlaylist=function(l,i,r,h){var n=this.hls,e=l.data,t=o(l,r),s=x.default.parseMasterPlaylist(e,t),E=s.levels,f=s.sessionData;if(!E.length){this.handleManifestParsingError(l,r,"no level found in manifest",h);return}var v=E.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),D=E.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),S=x.default.parseMasterPlaylistMedia(e,t,"AUDIO",v),A=x.default.parseMasterPlaylistMedia(e,t,"SUBTITLES",D),T=x.default.parseMasterPlaylistMedia(e,t,"CLOSED-CAPTIONS");if(S.length){var R=S.some(function(I){return!I.url});!R&&E[0].audioCodec&&!E[0].attrs.AUDIO&&(M.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new a.AttrList({}),bitrate:0,url:""}))}n.trigger(O.Events.MANIFEST_LOADED,{levels:E,audioTracks:S,subtitles:A,captions:T,url:t,stats:i,networkDetails:h,sessionData:f})},m.handleTrackOrLevelPlaylist=function(l,i,r,h){var n=this.hls,e=r.id,t=r.level,s=r.type,E=o(l,r),f=Object(b.isFiniteNumber)(e)?e:0,v=Object(b.isFiniteNumber)(t)?t:f,D=u(r),S=x.default.parseLevelPlaylist(l.data,E,v,D,f);if(!S.fragments.length){n.trigger(O.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:E,reason:"no fragments found in level",level:typeof r.level=="number"?r.level:void 0});return}if(s===c.PlaylistContextType.MANIFEST){var A={attrs:new a.AttrList({}),bitrate:0,details:S,name:"",url:E};n.trigger(O.Events.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:E,stats:i,networkDetails:h,sessionData:null})}if(i.parsing.end=performance.now(),S.needSidxRanges){var T,R=(T=S.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:R,isSidxRequest:!0,type:s,level:t,levelDetails:S,id:e,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}r.levelDetails=S,this.handlePlaylistLoaded(l,i,r,h)},m.handleSidxRequest=function(l,i){var r=Object(P.parseSegmentIndex)(new Uint8Array(l.data));if(!!r){var h=r.references,n=i.levelDetails;h.forEach(function(e,t){var s=e.info,E=n.fragments[t];E.byteRange.length===0&&E.setByteRange(String(1+s.end-s.start)+"@"+String(s.start)),E.initSegment&&E.initSegment.setByteRange(String(r.moovEndOffset)+"@0")})}},m.handleManifestParsingError=function(l,i,r,h){this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===c.PlaylistContextType.MANIFEST,url:l.url,reason:r,response:l,context:i,networkDetails:h})},m.handleNetworkError=function(l,i,r,h){r===void 0&&(r=!1),M.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+l.type+" level: "+l.level+" id: "+l.id+' group-id: "'+l.groupId+'"');var n=L.ErrorDetails.UNKNOWN,e=!1,t=this.getInternalLoader(l);switch(l.type){case c.PlaylistContextType.MANIFEST:n=r?L.ErrorDetails.MANIFEST_LOAD_TIMEOUT:L.ErrorDetails.MANIFEST_LOAD_ERROR,e=!0;break;case c.PlaylistContextType.LEVEL:n=r?L.ErrorDetails.LEVEL_LOAD_TIMEOUT:L.ErrorDetails.LEVEL_LOAD_ERROR,e=!1;break;case c.PlaylistContextType.AUDIO_TRACK:n=r?L.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,e=!1;break;case c.PlaylistContextType.SUBTITLE_TRACK:n=r?L.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:L.ErrorDetails.SUBTITLE_LOAD_ERROR,e=!1;break}t&&this.resetInternalLoader(l.type);var s={type:L.ErrorTypes.NETWORK_ERROR,details:n,fatal:e,url:l.url,loader:t,context:l,networkDetails:i};h&&(s.response=h),this.hls.trigger(O.Events.ERROR,s)},m.handlePlaylistLoaded=function(l,i,r,h){var n=r.type,e=r.level,t=r.id,s=r.groupId,E=r.loader,f=r.levelDetails,v=r.deliveryDirectives;if(!(f!=null&&f.targetduration)){this.handleManifestParsingError(l,r,"invalid target duration",h);return}if(!!E)switch(f.live&&(E.getCacheAge&&(f.ageHeader=E.getCacheAge()||0),(!E.getCacheAge||isNaN(f.ageHeader))&&(f.ageHeader=0)),n){case c.PlaylistContextType.MANIFEST:case c.PlaylistContextType.LEVEL:this.hls.trigger(O.Events.LEVEL_LOADED,{details:f,level:e||0,id:t||0,stats:i,networkDetails:h,deliveryDirectives:v});break;case c.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(O.Events.AUDIO_TRACK_LOADED,{details:f,id:t||0,groupId:s||"",stats:i,networkDetails:h,deliveryDirectives:v});break;case c.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADED,{details:f,id:t||0,groupId:s||"",stats:i,networkDetails:h,deliveryDirectives:v});break}},y}();C.default=p},"./src/polyfills/number.ts":function(K,C,g){g.r(C),g.d(C,"isFiniteNumber",function(){return b}),g.d(C,"MAX_SAFE_INTEGER",function(){return O});var b=Number.isFinite||function(L){return typeof L=="number"&&isFinite(L)},O=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,C,g){g.r(C);var b=function(){function O(){}return O.getSilentFrame=function(M,P){switch(M){case"mp4a.40.2":if(P===1)return new Uint8Array([0,200,0,128,35,128]);if(P===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(P===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(P===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(P===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(P===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(P===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(P===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(P===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}},O}();C.default=b},"./src/remux/mp4-generator.ts":function(K,C,g){g.r(C);var b=Math.pow(2,32)-1,O=function(){function L(){}return L.init=function(){L.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var P;for(P in L.types)L.types.hasOwnProperty(P)&&(L.types[P]=[P.charCodeAt(0),P.charCodeAt(1),P.charCodeAt(2),P.charCodeAt(3)]);var x=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]),c=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]);L.HDLR_TYPES={video:x,audio:c};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),u=new Uint8Array([0,0,0,0,0,0,0,0]);L.STTS=L.STSC=L.STCO=u,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),p=new Uint8Array([97,118,99,49]),y=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,o,y,o,p),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,a))},L.box=function(P){for(var x=8,c=arguments.length,a=new Array(c>1?c-1:0),u=1;u<c;u++)a[u-1]=arguments[u];for(var o=a.length,p=o;o--;)x+=a[o].byteLength;var y=new Uint8Array(x);for(y[0]=x>>24&255,y[1]=x>>16&255,y[2]=x>>8&255,y[3]=x&255,y.set(P,4),o=0,x=8;o<p;o++)y.set(a[o],x),x+=a[o].byteLength;return y},L.hdlr=function(P){return L.box(L.types.hdlr,L.HDLR_TYPES[P])},L.mdat=function(P){return L.box(L.types.mdat,P)},L.mdhd=function(P,x){x*=P;var c=Math.floor(x/(b+1)),a=Math.floor(x%(b+1));return L.box(L.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,c>>24,c>>16&255,c>>8&255,c&255,a>>24,a>>16&255,a>>8&255,a&255,85,196,0,0]))},L.mdia=function(P){return L.box(L.types.mdia,L.mdhd(P.timescale,P.duration),L.hdlr(P.type),L.minf(P))},L.mfhd=function(P){return L.box(L.types.mfhd,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255]))},L.minf=function(P){return P.type==="audio"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(P)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(P))},L.moof=function(P,x,c){return L.box(L.types.moof,L.mfhd(P),L.traf(c,x))},L.moov=function(P){for(var x=P.length,c=[];x--;)c[x]=L.trak(P[x]);return L.box.apply(null,[L.types.moov,L.mvhd(P[0].timescale,P[0].duration)].concat(c).concat(L.mvex(P)))},L.mvex=function(P){for(var x=P.length,c=[];x--;)c[x]=L.trex(P[x]);return L.box.apply(null,[L.types.mvex].concat(c))},L.mvhd=function(P,x){x*=P;var c=Math.floor(x/(b+1)),a=Math.floor(x%(b+1)),u=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,c>>24,c>>16&255,c>>8&255,c&255,a>>24,a>>16&255,a>>8&255,a&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 L.box(L.types.mvhd,u)},L.sdtp=function(P){var x=P.samples||[],c=new Uint8Array(4+x.length),a,u;for(a=0;a<x.length;a++)u=x[a].flags,c[a+4]=u.dependsOn<<4|u.isDependedOn<<2|u.hasRedundancy;return L.box(L.types.sdtp,c)},L.stbl=function(P){return L.box(L.types.stbl,L.stsd(P),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))},L.avc1=function(P){var x=[],c=[],a,u,o;for(a=0;a<P.sps.length;a++)u=P.sps[a],o=u.byteLength,x.push(o>>>8&255),x.push(o&255),x=x.concat(Array.prototype.slice.call(u));for(a=0;a<P.pps.length;a++)u=P.pps[a],o=u.byteLength,c.push(o>>>8&255),c.push(o&255),c=c.concat(Array.prototype.slice.call(u));var p=L.box(L.types.avcC,new Uint8Array([1,x[3],x[4],x[5],255,224|P.sps.length].concat(x).concat([P.pps.length]).concat(c))),y=P.width,m=P.height,d=P.pixelRatio[0],l=P.pixelRatio[1];return L.box(L.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,y>>8&255,y&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]),p,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,l>>24,l>>16&255,l>>8&255,l&255])))},L.esds=function(P){var x=P.config.length;return new Uint8Array([0,0,0,0,3,23+x,0,1,0,4,15+x,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([x]).concat(P.config).concat([6,1,2]))},L.mp4a=function(P){var x=P.samplerate;return L.box(L.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,P.channelCount,0,16,0,0,0,0,x>>8&255,x&255,0,0]),L.box(L.types.esds,L.esds(P)))},L.mp3=function(P){var x=P.samplerate;return L.box(L.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,P.channelCount,0,16,0,0,0,0,x>>8&255,x&255,0,0]))},L.stsd=function(P){return P.type==="audio"?!P.isAAC&&P.codec==="mp3"?L.box(L.types.stsd,L.STSD,L.mp3(P)):L.box(L.types.stsd,L.STSD,L.mp4a(P)):L.box(L.types.stsd,L.STSD,L.avc1(P))},L.tkhd=function(P){var x=P.id,c=P.duration*P.timescale,a=P.width,u=P.height,o=Math.floor(c/(b+1)),p=Math.floor(c%(b+1));return L.box(L.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,x>>24&255,x>>16&255,x>>8&255,x&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,p>>24,p>>16&255,p>>8&255,p&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,a>>8&255,a&255,0,0,u>>8&255,u&255,0,0]))},L.traf=function(P,x){var c=L.sdtp(P),a=P.id,u=Math.floor(x/(b+1)),o=Math.floor(x%(b+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255])),L.box(L.types.tfdt,new Uint8Array([1,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])),L.trun(P,c.length+16+20+8+16+8+8),c)},L.trak=function(P){return P.duration=P.duration||4294967295,L.box(L.types.trak,L.tkhd(P),L.mdia(P))},L.trex=function(P){var x=P.id;return L.box(L.types.trex,new Uint8Array([0,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},L.trun=function(P,x){var c=P.samples||[],a=c.length,u=12+16*a,o=new Uint8Array(u),p,y,m,d,l,i;for(x+=8+u,o.set([0,0,15,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255],0),p=0;p<a;p++)y=c[p],m=y.duration,d=y.size,l=y.flags,i=y.cts,o.set([m>>>24&255,m>>>16&255,m>>>8&255,m&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.paddingValue<<1|l.isNonSync,l.degradPrio&240<<8,l.degradPrio&15,i>>>24&255,i>>>16&255,i>>>8&255,i&255],12+16*p);return L.box(L.types.trun,o)},L.initSegment=function(P){L.types||L.init();var x=L.moov(P),c=new Uint8Array(L.FTYP.byteLength+x.byteLength);return c.set(L.FTYP),c.set(x,L.FTYP.byteLength),c},L}();O.types=void 0,O.HDLR_TYPES=void 0,O.STTS=void 0,O.STSC=void 0,O.STCO=void 0,O.STSZ=void 0,O.VMHD=void 0,O.SMHD=void 0,O.STSD=void 0,O.FTYP=void 0,O.DINF=void 0,C.default=O},"./src/remux/mp4-remuxer.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return i}),g.d(C,"normalizePts",function(){return r});var b=g("./src/polyfills/number.ts"),O=g("./src/remux/aac-helper.ts"),L=g("./src/remux/mp4-generator.ts"),M=g("./src/events.ts"),P=g("./src/errors.ts"),x=g("./src/utils/logger.ts"),c=g("./src/types/loader.ts"),a=g("./src/utils/timescale-conversion.ts");function u(){return u=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var E=arguments[s];for(var f in E)Object.prototype.hasOwnProperty.call(E,f)&&(t[f]=E[f])}return t},u.apply(this,arguments)}var o=10*1e3,p=1024,y=1152,m=null,d=null,l=!1,i=function(){function t(E,f,v,D){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=E,this.config=f,this.typeSupported=v,this.ISGenerated=!1,m===null){var S=navigator.userAgent||"",A=S.match(/Chrome\/(\d+)/i);m=A?parseInt(A[1]):0}if(d===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);d=T?parseInt(T[1]):0}l=!!m&&m<75||!!d&&d<600}var s=t.prototype;return s.destroy=function(){},s.resetTimeStamp=function(f){x.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},s.resetNextTimestamp=function(){x.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){x.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},s.getVideoStartPts=function(f){var v=!1,D=f.reduce(function(S,A){var T=A.pts-S;return T<-4294967296?(v=!0,r(S,A.pts)):T>0?S:A.pts},f[0].pts);return v&&x.logger.debug("PTS rollover detected"),D},s.remux=function(f,v,D,S,A,T,R,I){var B,F,_,U,N,k,W=A,w=A,H=f.pid>-1,Y=v.pid>-1,j=v.samples.length,Q=f.samples.length>0,X=j>1,V=(!H||Q)&&(!Y||X)||this.ISGenerated||R;if(V){this.ISGenerated||(_=this.generateIS(f,v,A));var z=this.isVideoContiguous,$=-1;if(X&&($=h(v.samples),!z&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,$>0){x.logger.warn("[mp4-remuxer]: Dropped "+$+" out of "+j+" video samples due to a missing keyframe");var Z=this.getVideoStartPts(v.samples);v.samples=v.samples.slice($),v.dropped+=$,w+=(v.samples[0].pts-Z)/(v.timescale||9e4)}else $===-1&&(x.logger.warn("[mp4-remuxer]: No keyframe found out of "+j+" video samples"),k=!1);if(this.ISGenerated){if(Q&&X){var J=this.getVideoStartPts(v.samples),te=r(f.samples[0].pts,J)-J,q=te/v.inputTimeScale;W+=Math.max(0,q),w+=Math.max(0,-q)}if(Q){if(f.samplerate||(x.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),_=this.generateIS(f,v,A)),F=this.remuxAudio(f,W,this.isAudioContiguous,T,Y||X||I===c.PlaylistLevelType.AUDIO?w:void 0),X){var re=F?F.endPTS-F.startPTS:0;v.inputTimeScale||(x.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),_=this.generateIS(f,v,A)),B=this.remuxVideo(v,w,z,re)}}else X&&(B=this.remuxVideo(v,w,z,0));B&&(B.firstKeyFrame=$,B.independent=$!==-1)}}return this.ISGenerated&&(D.samples.length&&(N=this.remuxID3(D,A)),S.samples.length&&(U=this.remuxText(S,A))),{audio:F,video:B,initSegment:_,independent:k,text:U,id3:N}},s.generateIS=function(f,v,D){var S=f.samples,A=v.samples,T=this.typeSupported,R={},I=!Object(b.isFiniteNumber)(this._initPTS),B="audio/mp4",F,_,U;if(I&&(F=_=1/0),f.config&&S.length&&(f.timescale=f.samplerate,f.isAAC||(T.mpeg?(B="audio/mpeg",f.codec=""):T.mp3&&(f.codec="mp3")),R.audio={id:"audio",container:B,codec:f.codec,initSegment:!f.isAAC&&T.mpeg?new Uint8Array(0):L.default.initSegment([f]),metadata:{channelCount:f.channelCount}},I&&(U=f.inputTimeScale,F=_=S[0].pts-Math.round(U*D))),v.sps&&v.pps&&A.length&&(v.timescale=v.inputTimeScale,R.video={id:"main",container:"video/mp4",codec:v.codec,initSegment:L.default.initSegment([v]),metadata:{width:v.width,height:v.height}},I)){U=v.inputTimeScale;var N=this.getVideoStartPts(A),k=Math.round(U*D);_=Math.min(_,r(A[0].dts,N)-k),F=Math.min(F,N-k)}if(Object.keys(R).length)return this.ISGenerated=!0,I&&(this._initPTS=F,this._initDTS=_),{tracks:R,initPTS:F,timescale:U}},s.remuxVideo=function(f,v,D,S){var A=f.inputTimeScale,T=f.samples,R=[],I=T.length,B=this._initPTS,F=this.nextAvcDts,_=8,U,N,k,W=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,H=0,Y=!1;if(!D||F===null){var j=v*A,Q=T[0].pts-r(T[0].dts,T[0].pts);F=j-Q}for(var X=0;X<I;X++){var V=T[X];if(V.pts=r(V.pts-B,F),V.dts=r(V.dts-B,F),V.dts>V.pts){var z=18e3;H=Math.max(Math.min(H,V.pts-V.dts),-1*z)}V.dts<T[X>0?X-1:X].dts&&(Y=!0)}Y&&T.sort(function(Ie,Ue){var tt=Ie.dts-Ue.dts,rt=Ie.pts-Ue.pts;return tt||rt}),N=T[0].dts,k=T[T.length-1].dts;var $=Math.round((k-N)/(I-1));if(H<0){if(H<$*-2){x.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(a.toMsFromMpegTsClock)(-$,!0)+" ms");for(var Z=H,J=0;J<I;J++)T[J].dts=Z=Math.max(Z,T[J].pts-$),T[J].pts=Math.max(Z,T[J].pts)}else{x.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(a.toMsFromMpegTsClock)(H,!0)+" ms to overcome this issue");for(var te=0;te<I;te++)T[te].dts=T[te].dts+H}N=T[0].dts}if(D){var q=N-F,re=q>$,se=q<-1;if(re||se){re?x.logger.warn("AVC: "+Object(a.toMsFromMpegTsClock)(q,!0)+" ms ("+q+"dts) hole between fragments detected, filling it"):x.logger.warn("AVC: "+Object(a.toMsFromMpegTsClock)(-q,!0)+" ms ("+q+"dts) overlapping between fragments detected"),N=F;var ie=T[0].pts-q;T[0].dts=N,T[0].pts=ie,x.logger.log("Video: First PTS/DTS adjusted: "+Object(a.toMsFromMpegTsClock)(ie,!0)+"/"+Object(a.toMsFromMpegTsClock)(N,!0)+", delta: "+Object(a.toMsFromMpegTsClock)(q,!0)+" ms")}}l&&(N=Math.max(0,N));for(var oe=0,ae=0,le=0;le<I;le++){for(var ee=T[le],pe=ee.units,Te=pe.length,me=0,fe=0;fe<Te;fe++)me+=pe[fe].data.length;ae+=me,oe+=Te,ee.length=me,ee.dts=Math.max(ee.dts,N),ee.pts=Math.max(ee.pts,ee.dts,0),W=Math.min(ee.pts,W),w=Math.max(ee.pts,w)}k=T[I-1].dts;var de=ae+4*oe+8,ge;try{ge=new Uint8Array(de)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:P.ErrorTypes.MUX_ERROR,details:P.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:de,reason:"fail allocating video mdat "+de});return}var he=new DataView(ge.buffer);he.setUint32(0,de),ge.set(L.default.types.mdat,4);for(var ue=0;ue<I;ue++){for(var ce=T[ue],xe=ce.units,Le=0,ye=0,Se=xe.length;ye<Se;ye++){var Ee=xe[ye],ve=Ee.data,Ae=Ee.data.byteLength;he.setUint32(_,Ae),_+=4,ge.set(ve,_),_+=Ae,Le+=4+Ae}if(ue<I-1)U=T[ue+1].dts-ce.dts;else{var De=this.config,Re=ce.dts-T[ue>0?ue-1:ue].dts;if(De.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qe=Math.floor(De.maxBufferHole*A),Pe=(S?W+S*A:this.nextAudioPts)-ce.pts;Pe>Qe?(U=Pe-Re,U<0&&(U=Re),x.logger.log("[mp4-remuxer]: It is approximately "+Pe/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=Re}else U=Re}var Ze=Math.round(ce.pts-ce.dts);R.push(new n(ce.key,U,Le,Ze))}if(R.length&&m&&m<70){var Be=R[0].flags;Be.dependsOn=2,Be.isNonSync=0}console.assert(U!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=F=k+U,this.isVideoContiguous=!0;var Je=L.default.moof(f.sequenceNumber++,N,u({},f,{samples:R})),qe="video",et={data1:Je,data2:ge,startPTS:W/A,endPTS:(w+U)/A,startDTS:N/A,endDTS:F/A,type:qe,hasAudio:!1,hasVideo:!0,nb:R.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(ge.length,"MDAT length must not be zero"),et},s.remuxAudio=function(f,v,D,S,A){var T=f.inputTimeScale,R=f.samplerate?f.samplerate:T,I=T/R,B=f.isAAC?p:y,F=B*I,_=this._initPTS,U=!f.isAAC&&this.typeSupported.mpeg,N=[],k=f.samples,W=U?0:8,w=this.nextAudioPts||-1,H=v*T;if(this.isAudioContiguous=D=D||k.length&&w>0&&(S&&Math.abs(H-w)<9e3||Math.abs(r(k[0].pts-_,H)-w)<20*F),k.forEach(function(ve){ve.pts=r(ve.pts-_,H)}),!D||w<0){if(k=k.filter(function(ve){return ve.pts>=0}),!k.length)return;A===0?w=0:S?w=Math.max(0,H):w=k[0].pts}if(f.isAAC)for(var Y=A!==void 0,j=this.config.maxAudioFramesDrift,Q=0,X=w;Q<k.length;Q++){var V=k[Q],z=V.pts,$=z-X,Z=Math.abs(1e3*$/T);if($<=-j*F&&Y)Q===0&&(x.logger.warn("Audio frame @ "+(z/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*$/T)+" ms."),this.nextAudioPts=w=X=z);else if($>=j*F&&Z<o&&Y){var J=Math.round($/F);X=z-J*F,X<0&&(J--,X+=F),Q===0&&(this.nextAudioPts=w=X),x.logger.warn("[mp4-remuxer]: Injecting "+J+" audio frame @ "+(X/T).toFixed(3)+"s due to "+Math.round(1e3*$/T)+" ms gap.");for(var te=0;te<J;te++){var q=Math.max(X,0),re=O.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);re||(x.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),re=V.unit.subarray()),k.splice(Q,0,{unit:re,pts:q}),X+=F,Q++}}V.pts=X,X+=F}for(var se=null,ie=null,oe,ae=0,le=k.length;le--;)ae+=k[le].unit.byteLength;for(var ee=0,pe=k.length;ee<pe;ee++){var Te=k[ee],me=Te.unit,fe=Te.pts;if(ie!==null){var de=N[ee-1];de.duration=Math.round((fe-ie)/I)}else if(D&&f.isAAC&&(fe=w),se=fe,ae>0){ae+=W;try{oe=new Uint8Array(ae)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:P.ErrorTypes.MUX_ERROR,details:P.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ae,reason:"fail allocating audio mdat "+ae});return}if(!U){var ge=new DataView(oe.buffer);ge.setUint32(0,ae),oe.set(L.default.types.mdat,4)}}else return;oe.set(me,W);var he=me.byteLength;W+=he,N.push(new n(!0,B,he,0)),ie=fe}var ue=N.length;if(!!ue){var ce=N[N.length-1];this.nextAudioPts=w=ie+I*ce.duration;var xe=U?new Uint8Array(0):L.default.moof(f.sequenceNumber++,se/I,u({},f,{samples:N}));f.samples=[];var Le=se/T,ye=w/T,Se="audio",Ee={data1:xe,data2:oe,startPTS:Le,endPTS:ye,startDTS:Le,endDTS:ye,type:Se,hasAudio:!0,hasVideo:!1,nb:ue};return this.isAudioContiguous=!0,console.assert(oe.length,"MDAT length must not be zero"),Ee}},s.remuxEmptyAudio=function(f,v,D,S){var A=f.inputTimeScale,T=f.samplerate?f.samplerate:A,R=A/T,I=this.nextAudioPts,B=(I!==null?I:S.startDTS*A)+this._initDTS,F=S.endDTS*A+this._initDTS,_=R*p,U=Math.ceil((F-B)/_),N=O.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(x.logger.warn("[mp4-remuxer]: remux empty Audio"),!N){x.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],W=0;W<U;W++){var w=B+W*_;k.push({unit:N,pts:w,dts:w})}return f.samples=k,this.remuxAudio(f,v,D,!1)},s.remuxID3=function(f,v){var D=f.samples.length;if(!!D){for(var S=f.inputTimeScale,A=this._initPTS,T=this._initDTS,R=0;R<D;R++){var I=f.samples[R];I.pts=r(I.pts-A,v*S)/S,I.dts=r(I.dts-T,v*S)/S}var B=f.samples;return f.samples=[],{samples:B}}},s.remuxText=function(f,v){var D=f.samples.length;if(!!D){for(var S=f.inputTimeScale,A=this._initPTS,T=0;T<D;T++){var R=f.samples[T];R.pts=r(R.pts-A,v*S)/S}f.samples.sort(function(B,F){return B.pts-F.pts});var I=f.samples;return f.samples=[],{samples:I}}},t}();function r(t,s){var E;if(s===null)return t;for(s<t?E=-8589934592:E=8589934592;Math.abs(t-s)>4294967296;)t+=E;return t}function h(t){for(var s=0;s<t.length;s++)if(t[s].key)return s;return-1}var n=function(s,E,f,v){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=E,this.size=f,this.cts=v,this.flags=new e(s)},e=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,C,g){g.r(C);var b=g("./src/polyfills/number.ts"),O=g("./src/utils/mp4-tools.ts"),L=g("./src/loader/fragment.ts"),M=g("./src/utils/logger.ts"),P=function(){function a(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var u=a.prototype;return u.destroy=function(){},u.resetTimeStamp=function(p){this.initPTS=p,this.lastEndDTS=null},u.resetNextTimestamp=function(){this.lastEndDTS=null},u.resetInitSegment=function(p,y,m){this.audioCodec=y,this.videoCodec=m,this.generateInitSegment(p),this.emitInitSegment=!0},u.generateInitSegment=function(p){var y=this.audioCodec,m=this.videoCodec;if(!p||!p.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(O.parseInitSegment)(p);y||(y=c(d.audio,L.ElementaryStreamTypes.AUDIO)),m||(m=c(d.video,L.ElementaryStreamTypes.VIDEO));var l={};d.audio&&d.video?l.audiovideo={container:"video/mp4",codec:y+","+m,initSegment:p,id:"main"}:d.audio?l.audio={container:"audio/mp4",codec:y,initSegment:p,id:"audio"}:d.video?l.video={container:"video/mp4",codec:m,initSegment:p,id:"main"}:M.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=l},u.remux=function(p,y,m,d,l){var i=this.initPTS,r=this.lastEndDTS,h={audio:void 0,video:void 0,text:d,id3:m,initSegment:void 0};Object(b.isFiniteNumber)(r)||(r=this.lastEndDTS=l||0);var n=y.samples;if(!n||!n.length)return h;var e={initPTS:void 0,timescale:1},t=this.initData;if((!t||!t.length)&&(this.generateInitSegment(n),t=this.initData),!t||!t.length)return M.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(e.tracks=this.initTracks,this.emitInitSegment=!1),Object(b.isFiniteNumber)(i)||(this.initPTS=e.initPTS=i=x(t,n,r));var s=Object(O.getDuration)(n,t),E=r,f=s+E;Object(O.offsetStartDTS)(t,n,i),s>0?this.lastEndDTS=f:(M.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!t.audio,D=!!t.video,S="";v&&(S+="audio"),D&&(S+="video");var A={data1:n,startPTS:E,startDTS:E,endPTS:f,endDTS:f,type:S,hasAudio:v,hasVideo:D,nb:1,dropped:0};return h.audio=A.type==="audio"?A:void 0,h.video=A.type!=="audio"?A:void 0,h.text=d,h.id3=m,h.initSegment=e,h},a}(),x=function(u,o,p){return Object(O.getStartDTS)(u,o)-p};function c(a,u){var o=a==null?void 0:a.codec;return o&&o.length>4?o:o==="hvc1"?"hvc1.1.c.L120.90":o==="av01"?"av01.0.04M.08":o==="avc1"||u===L.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}C.default=P},"./src/task-loop.ts":function(K,C,g){g.r(C),g.d(C,"default",function(){return b});var b=function(){function O(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var L=O.prototype;return L.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},L.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},L.onHandlerDestroyed=function(){},L.hasInterval=function(){return!!this._tickInterval},L.hasNextTick=function(){return!!this._tickTimer},L.setInterval=function(P){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,P),!0)},L.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},L.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},L.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},L.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},L.doTick=function(){},O}()},"./src/types/level.ts":function(K,C,g){g.r(C),g.d(C,"HlsSkip",function(){return L}),g.d(C,"getSkipValue",function(){return M}),g.d(C,"HlsUrlParameters",function(){return P}),g.d(C,"Level",function(){return x});function b(c,a){for(var u=0;u<a.length;u++){var o=a[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function O(c,a,u){return a&&b(c.prototype,a),u&&b(c,u),c}var L;(function(c){c.No="",c.Yes="YES",c.v2="v2"})(L||(L={}));function M(c,a){var u=c.canSkipUntil,o=c.canSkipDateRanges,p=c.endSN,y=a!==void 0?a-p:0;return u&&y<u?o?L.v2:L.Yes:L.No}var P=function(){function c(u,o,p){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=u,this.part=o,this.skip=p}var a=c.prototype;return a.addDirectives=function(o){var p=new self.URL(o);return this.msn!==void 0&&p.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&p.searchParams.set("_HLS_part",this.part.toString()),this.skip&&p.searchParams.set("_HLS_skip",this.skip),p.toString()},c}(),x=function(){function c(a){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[a.url],this.attrs=a.attrs,this.bitrate=a.bitrate,a.details&&(this.details=a.details),this.id=a.id||0,this.name=a.name,this.width=a.width||0,this.height=a.height||0,this.audioCodec=a.audioCodec,this.videoCodec=a.videoCodec,this.unknownCodecs=a.unknownCodecs,this.codecSet=[a.videoCodec,a.audioCodec].filter(function(u){return u}).join(",").replace(/\.[^.,]+/g,"")}return O(c,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(u){var o=u%this.url.length;this._urlId!==o&&(this.details=void 0,this._urlId=o)}}]),c}()},"./src/types/loader.ts":function(K,C,g){g.r(C),g.d(C,"PlaylistContextType",function(){return b}),g.d(C,"PlaylistLevelType",function(){return O});var b;(function(L){L.MANIFEST="manifest",L.LEVEL="level",L.AUDIO_TRACK="audioTrack",L.SUBTITLE_TRACK="subtitleTrack"})(b||(b={}));var O;(function(L){L.MAIN="main",L.AUDIO="audio",L.SUBTITLE="subtitle"})(O||(O={}))},"./src/types/transmuxer.ts":function(K,C,g){g.r(C),g.d(C,"ChunkMetadata",function(){return b});var b=function(M,P,x,c,a,u){c===void 0&&(c=0),a===void 0&&(a=-1),u===void 0&&(u=!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=O(),this.buffering={audio:O(),video:O(),audiovideo:O()},this.level=M,this.sn=P,this.id=x,this.size=c,this.part=a,this.partial=u};function O(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,C,g){g.r(C),g.d(C,"AttrList",function(){return L});var b=/^(\d+)x(\d+)$/,O=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function M(x){typeof x=="string"&&(x=M.parseAttrList(x));for(var c in x)x.hasOwnProperty(c)&&(this[c]=x[c])}var P=M.prototype;return P.decimalInteger=function(c){var a=parseInt(this[c],10);return a>Number.MAX_SAFE_INTEGER?1/0:a},P.hexadecimalInteger=function(c){if(this[c]){var a=(this[c]||"0x").slice(2);a=(a.length&1?"0":"")+a;for(var u=new Uint8Array(a.length/2),o=0;o<a.length/2;o++)u[o]=parseInt(a.slice(o*2,o*2+2),16);return u}else return null},P.hexadecimalIntegerAsNumber=function(c){var a=parseInt(this[c],16);return a>Number.MAX_SAFE_INTEGER?1/0:a},P.decimalFloatingPoint=function(c){return parseFloat(this[c])},P.optionalFloat=function(c,a){var u=this[c];return u?parseFloat(u):a},P.enumeratedString=function(c){return this[c]},P.bool=function(c){return this[c]==="YES"},P.decimalResolution=function(c){var a=b.exec(this[c]);if(a!==null)return{width:parseInt(a[1],10),height:parseInt(a[2],10)}},M.parseAttrList=function(c){var a,u={},o='"';for(O.lastIndex=0;(a=O.exec(c))!==null;){var p=a[2];p.indexOf(o)===0&&p.lastIndexOf(o)===p.length-1&&(p=p.slice(1,-1)),u[a[1]]=p}return u},M}()},"./src/utils/binary-search.ts":function(K,C,g){g.r(C);var b={search:function(L,M){for(var P=0,x=L.length-1,c=null,a=null;P<=x;){c=(P+x)/2|0,a=L[c];var u=M(a);if(u>0)P=c+1;else if(u<0)x=c-1;else return a}return null}};C.default=b},"./src/utils/buffer-helper.ts":function(K,C,g){g.r(C),g.d(C,"BufferHelper",function(){return L});var b=g("./src/utils/logger.ts"),O={length:0,start:function(){return 0},end:function(){return 0}},L=function(){function M(){}return M.isBuffered=function(x,c){try{if(x){for(var a=M.getBuffered(x),u=0;u<a.length;u++)if(c>=a.start(u)&&c<=a.end(u))return!0}}catch{}return!1},M.bufferInfo=function(x,c,a){try{if(x){var u=M.getBuffered(x),o=[],p;for(p=0;p<u.length;p++)o.push({start:u.start(p),end:u.end(p)});return this.bufferedInfo(o,c,a)}}catch{}return{len:0,start:c,end:c,nextStart:void 0}},M.bufferedInfo=function(x,c,a){c=Math.max(0,c),x.sort(function(e,t){var s=e.start-t.start;return s||t.end-e.end});var u=[];if(a)for(var o=0;o<x.length;o++){var p=u.length;if(p){var y=u[p-1].end;x[o].start-y<a?x[o].end>y&&(u[p-1].end=x[o].end):u.push(x[o])}else u.push(x[o])}else u=x;for(var m=0,d,l=c,i=c,r=0;r<u.length;r++){var h=u[r].start,n=u[r].end;if(c+a>=h&&c<n)l=h,i=n,m=i-c;else if(c+a<h){d=h;break}}return{len:m,start:l||0,end:i||0,nextStart:d}},M.getBuffered=function(x){try{return x.buffered}catch(c){return b.logger.log("failed to get media.buffered",c),O}},M}()},"./src/utils/codecs.ts":function(K,C,g){g.r(C),g.d(C,"isCodecType",function(){return O}),g.d(C,"isCodecSupportedInMp4",function(){return L});var b={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function O(M,P){var x=b[P];return!!x&&x[M.slice(0,4)]===!0}function L(M,P){return MediaSource.isTypeSupported((P||"video")+'/mp4;codecs="'+M+'"')}},"./src/utils/discontinuities.ts":function(K,C,g){g.r(C),g.d(C,"findFirstFragWithCC",function(){return M}),g.d(C,"shouldAlignOnDiscontinuities",function(){return P}),g.d(C,"findDiscontinuousReferenceFrag",function(){return x}),g.d(C,"adjustSlidingStart",function(){return a}),g.d(C,"alignStream",function(){return u}),g.d(C,"alignPDT",function(){return p}),g.d(C,"alignFragmentByPDTDelta",function(){return y}),g.d(C,"alignMediaPlaylistByPDT",function(){return m});var b=g("./src/polyfills/number.ts"),O=g("./src/utils/logger.ts"),L=g("./src/controller/level-helper.ts");function M(d,l){for(var i=null,r=0,h=d.length;r<h;r++){var n=d[r];if(n&&n.cc===l){i=n;break}}return i}function P(d,l,i){return!!(l.details&&(i.endCC>i.startCC||d&&d.cc<i.startCC))}function x(d,l){var i=d.fragments,r=l.fragments;if(!r.length||!i.length){O.logger.log("No fragments to align");return}var h=M(i,r[0].cc);if(!h||h&&!h.startPTS){O.logger.log("No frag in previous level to align on");return}return h}function c(d,l){if(d){var i=d.start+l;d.start=d.startPTS=i,d.endPTS=i+d.duration}}function a(d,l){for(var i=l.fragments,r=0,h=i.length;r<h;r++)c(i[r],d);l.fragmentHint&&c(l.fragmentHint,d),l.alignedSliding=!0}function u(d,l,i){!l||(o(d,i,l),!i.alignedSliding&&l.details&&p(i,l.details),!i.alignedSliding&&l.details&&!i.skippedSegments&&Object(L.adjustSliding)(l.details,i))}function o(d,l,i){if(P(d,i,l)){var r=x(i.details,l);r&&Object(b.isFiniteNumber)(r.start)&&(O.logger.log("Adjusting PTS using last level due to CC increase within current level "+l.url),a(r.start,l))}}function p(d,l){if(!(!l.fragments.length||!d.hasProgramDateTime||!l.hasProgramDateTime)){var i=l.fragments[0].programDateTime,r=d.fragments[0].programDateTime,h=(r-i)/1e3+l.fragments[0].start;h&&Object(b.isFiniteNumber)(h)&&(O.logger.log("Adjusting PTS using programDateTime delta "+(r-i)+"ms, sliding:"+h.toFixed(3)+" "+d.url+" "),a(h,d))}}function y(d,l){var i=d.programDateTime;if(!!i){var r=(i-l)/1e3;d.start=d.startPTS=r,d.endPTS=r+d.duration}}function m(d,l){if(!(!l.fragments.length||!d.hasProgramDateTime||!l.hasProgramDateTime)){var i=l.fragments[0].programDateTime,r=l.fragments[0].start,h=i-r*1e3;d.fragments.forEach(function(n){y(n,h)}),d.fragmentHint&&y(d.fragmentHint,h),d.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,C,g){g.r(C);var b=g("./src/utils/ewma.ts"),O=function(){function L(P,x,c){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=c,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new b.default(P),this.fast_=new b.default(x)}var M=L.prototype;return M.update=function(x,c){var a=this.slow_,u=this.fast_;this.slow_.halfLife!==x&&(this.slow_=new b.default(x,a.getEstimate(),a.getTotalWeight())),this.fast_.halfLife!==c&&(this.fast_=new b.default(c,u.getEstimate(),u.getTotalWeight()))},M.sample=function(x,c){x=Math.max(x,this.minDelayMs_);var a=8*c,u=x/1e3,o=a/u;this.fast_.sample(u,o),this.slow_.sample(u,o)},M.canEstimate=function(){var x=this.fast_;return x&&x.getTotalWeight()>=this.minWeight_},M.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},M.destroy=function(){},L}();C.default=O},"./src/utils/ewma.ts":function(K,C,g){g.r(C);var b=function(){function O(M,P,x){P===void 0&&(P=0),x===void 0&&(x=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=M,this.alpha_=M?Math.exp(Math.log(.5)/M):0,this.estimate_=P,this.totalWeight_=x}var L=O.prototype;return L.sample=function(P,x){var c=Math.pow(this.alpha_,P);this.estimate_=x*(1-c)+c*this.estimate_,this.totalWeight_+=P},L.getTotalWeight=function(){return this.totalWeight_},L.getEstimate=function(){if(this.alpha_){var P=1-Math.pow(this.alpha_,this.totalWeight_);if(P)return this.estimate_/P}return this.estimate_},O}();C.default=b},"./src/utils/fetch-loader.ts":function(K,C,g){g.r(C),g.d(C,"fetchSupported",function(){return y});var b=g("./src/polyfills/number.ts"),O=g("./src/loader/load-stats.ts"),L=g("./src/demux/chunk-cache.ts");function M(r,h){r.prototype=Object.create(h.prototype),r.prototype.constructor=r,u(r,h)}function P(r){var h=typeof Map=="function"?new Map:void 0;return P=function(e){if(e===null||!a(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof h!="undefined"){if(h.has(e))return h.get(e);h.set(e,t)}function t(){return x(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),u(t,e)},P(r)}function x(r,h,n){return c()?x=Reflect.construct:x=function(t,s,E){var f=[null];f.push.apply(f,s);var v=Function.bind.apply(t,f),D=new v;return E&&u(D,E.prototype),D},x.apply(null,arguments)}function c(){if(typeof Reflect=="undefined"||!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 a(r){return Function.toString.call(r).indexOf("[native code]")!==-1}function u(r,h){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(r,h)}function o(r){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},o(r)}function p(){return p=Object.assign||function(r){for(var h=1;h<arguments.length;h++){var n=arguments[h];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},p.apply(this,arguments)}function y(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var m=function(){function r(n){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=n.fetchSetup||l,this.controller=new self.AbortController,this.stats=new O.LoadStats}var h=r.prototype;return h.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},h.abortInternal=function(){var e=this.response;(!e||!e.ok)&&(this.stats.aborted=!0,this.controller.abort())},h.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},h.load=function(e,t,s){var E=this,f=this.stats;if(f.loading.start)throw new Error("Loader can only be used once.");f.loading.start=self.performance.now();var v=d(e,this.controller.signal),D=s.onProgress,S=e.responseType==="arraybuffer",A=S?"byteLength":"length";this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,v),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){E.abortInternal(),s.onTimeout(f,e,E.response)},t.timeout),self.fetch(this.request).then(function(T){if(E.response=E.loader=T,!T.ok){var R=T.status,I=T.statusText;throw new i(I||"fetch, bad network response",R,T)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(T.headers.get("Content-Length")||"0"),D&&Object(b.isFiniteNumber)(t.highWaterMark)?E.loadProgressively(T,f,e,t.highWaterMark,D):S?T.arrayBuffer():T.text()}).then(function(T){var R=E.response;self.clearTimeout(E.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=T[A];var I={url:R.url,data:T};D&&!Object(b.isFiniteNumber)(t.highWaterMark)&&D(f,e,T,R),s.onSuccess(I,f,e,R)}).catch(function(T){if(self.clearTimeout(E.requestTimeout),!f.aborted){var R=T.code||0;s.onError({code:R,text:T.message},e,T.details)}})},h.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},h.loadProgressively=function(e,t,s,E,f){E===void 0&&(E=0);var v=new L.default,D=e.body.getReader(),S=function A(){return D.read().then(function(T){if(T.done)return v.dataLength&&f(t,s,v.flush(),e),Promise.resolve(new ArrayBuffer(0));var R=T.value,I=R.length;return t.loaded+=I,I<E||v.dataLength?(v.push(R),v.dataLength>=E&&f(t,s,v.flush(),e)):f(t,s,R,e),A()}).catch(function(){return Promise.reject()})};return S()},r}();function d(r,h){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:h,headers:new self.Headers(p({},r.headers))};return r.rangeEnd&&n.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),n}function l(r,h){return new self.Request(r.url,h)}var i=function(r){M(h,r);function h(n,e,t){var s;return s=r.call(this,n)||this,s.code=void 0,s.details=void 0,s.code=e,s.details=t,s}return h}(P(Error));C.default=m},"./src/utils/logger.ts":function(K,C,g){g.r(C),g.d(C,"enableLogs",function(){return x}),g.d(C,"logger",function(){return c});var b=function(){},O={trace:b,debug:b,log:b,warn:b,info:b,error:b},L=O;function M(a){var u=self.console[a];return u?u.bind(self.console,"["+a+"] >"):b}function P(a){for(var u=arguments.length,o=new Array(u>1?u-1:0),p=1;p<u;p++)o[p-1]=arguments[p];o.forEach(function(y){L[y]=a[y]?a[y].bind(a):M(y)})}function x(a){if(self.console&&a===!0||typeof a=="object"){P(a,"debug","log","info","warn","error");try{L.log()}catch{L=O}}else L=O}var c=L},"./src/utils/mediakeys-helper.ts":function(K,C,g){g.r(C),g.d(C,"KeySystems",function(){return b}),g.d(C,"requestMediaKeySystemAccess",function(){return O});var b;(function(L){L.WIDEVINE="com.widevine.alpha",L.PLAYREADY="com.microsoft.playready"})(b||(b={}));var O=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,C,g){g.r(C),g.d(C,"getMediaSource",function(){return b});function b(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,C,g){g.r(C),g.d(C,"bin2str",function(){return P}),g.d(C,"readUint16",function(){return x}),g.d(C,"readUint32",function(){return c}),g.d(C,"writeUint32",function(){return a}),g.d(C,"findBox",function(){return u}),g.d(C,"parseSegmentIndex",function(){return o}),g.d(C,"parseInitSegment",function(){return p}),g.d(C,"getStartDTS",function(){return y}),g.d(C,"getDuration",function(){return m}),g.d(C,"computeRawDurationFromSamples",function(){return d}),g.d(C,"offsetStartDTS",function(){return l}),g.d(C,"segmentValidRange",function(){return i}),g.d(C,"appendUint8Array",function(){return r});var b=g("./src/utils/typed-array.ts"),O=g("./src/loader/fragment.ts"),L=Math.pow(2,32)-1,M=[].push;function P(h){return String.fromCharCode.apply(null,h)}function x(h,n){"data"in h&&(n+=h.start,h=h.data);var e=h[n]<<8|h[n+1];return e<0?65536+e:e}function c(h,n){"data"in h&&(n+=h.start,h=h.data);var e=h[n]<<24|h[n+1]<<16|h[n+2]<<8|h[n+3];return e<0?4294967296+e:e}function a(h,n,e){"data"in h&&(n+=h.start,h=h.data),h[n]=e>>24,h[n+1]=e>>16&255,h[n+2]=e>>8&255,h[n+3]=e&255}function u(h,n){var e=[];if(!n.length)return e;var t,s,E;"data"in h?(t=h.data,s=h.start,E=h.end):(t=h,s=0,E=t.byteLength);for(var f=s;f<E;){var v=c(t,f),D=P(t.subarray(f+4,f+8)),S=v>1?f+v:E;if(D===n[0])if(n.length===1)e.push({data:t,start:f+8,end:S});else{var A=u({data:t,start:f+8,end:S},n.slice(1));A.length&&M.apply(e,A)}f=S}return e}function o(h){var n=u(h,["moov"]),e=n[0],t=e?e.end:null,s=u(h,["sidx"]);if(!s||!s[0])return null;var E=[],f=s[0],v=f.data[0],D=v===0?8:16,S=c(f,D);D+=4;var A=0,T=0;v===0?D+=8:D+=16,D+=2;var R=f.end+T,I=x(f,D);D+=2;for(var B=0;B<I;B++){var F=D,_=c(f,F);F+=4;var U=_&2147483647,N=(_&2147483648)>>>31;if(N===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var k=c(f,F);F+=4,E.push({referenceSize:U,subsegmentDuration:k,info:{duration:k/S,start:R,end:R+U-1}}),R+=U,F+=4,D=F}return{earliestPresentationTime:A,timescale:S,version:v,referencesCount:I,references:E,moovEndOffset:t}}function p(h){for(var n=[],e=u(h,["moov","trak"]),t=0;t<e.length;t++){var s=e[t],E=u(s,["tkhd"])[0];if(E){var f=E.data[E.start],v=f===0?12:20,D=c(E,v),S=u(s,["mdia","mdhd"])[0];if(S){f=S.data[S.start],v=f===0?12:20;var A=c(S,v),T=u(s,["mdia","hdlr"])[0];if(T){var R=P(T.data.subarray(T.start+8,T.start+12)),I={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[R];if(I){var B=u(s,["mdia","minf","stbl","stsd"])[0],F=void 0;B&&(F=P(B.data.subarray(B.start+12,B.start+16))),n[D]={timescale:A,type:I},n[I]={timescale:A,id:D,codec:F}}}}}}var _=u(h,["moov","mvex","trex"]);return _.forEach(function(U){var N=c(U,4),k=n[N];k&&(k.default={duration:c(U,12),flags:c(U,20)})}),n}function y(h,n){return u(n,["moof","traf"]).reduce(function(e,t){var s=u(t,["tfdt"])[0],E=s.data[s.start],f=u(t,["tfhd"]).reduce(function(v,D){var S=c(D,4),A=h[S];if(A){var T=c(s,4);E===1&&(T*=Math.pow(2,32),T+=c(s,8));var R=A.timescale||9e4,I=T/R;if(isFinite(I)&&(v===null||I<v))return I}return v},null);return f!==null&&isFinite(f)&&(e===null||f<e)?f:e},null)||0}function m(h,n){for(var e=0,t=0,s=0,E=u(h,["moof","traf"]),f=0;f<E.length;f++){var v=E[f],D=u(v,["tfhd"])[0],S=c(D,4),A=n[S];if(!!A){var T=A.default,R=c(D,0)|(T==null?void 0:T.flags),I=T==null?void 0:T.duration;R&8&&(R&2?I=c(D,12):I=c(D,8));for(var B=A.timescale||9e4,F=u(v,["trun"]),_=0;_<F.length;_++){if(e=d(F[_]),!e&&I){var U=c(F[_],4);e=I*U}A.type===O.ElementaryStreamTypes.VIDEO?t+=e/B:A.type===O.ElementaryStreamTypes.AUDIO&&(s+=e/B)}}}if(t===0&&s===0){var N=o(h);if(N!=null&&N.references)return N.references.reduce(function(k,W){return k+W.info.duration||0},0)}return t||s}function d(h){var n=c(h,0),e=8;n&1&&(e+=4),n&4&&(e+=4);for(var t=0,s=c(h,4),E=0;E<s;E++){if(n&256){var f=c(h,e);t+=f,e+=4}n&512&&(e+=4),n&1024&&(e+=4),n&2048&&(e+=4)}return t}function l(h,n,e){u(n,["moof","traf"]).forEach(function(t){u(t,["tfhd"]).forEach(function(s){var E=c(s,4),f=h[E];if(!!f){var v=f.timescale||9e4;u(t,["tfdt"]).forEach(function(D){var S=D.data[D.start],A=c(D,4);if(S===0)a(D,4,A-e*v);else{A*=Math.pow(2,32),A+=c(D,8),A-=e*v,A=Math.max(A,0);var T=Math.floor(A/(L+1)),R=Math.floor(A%(L+1));a(D,4,T),a(D,8,R)}})}})})}function i(h){var n={valid:null,remainder:null},e=u(h,["moof"]);if(e){if(e.length<2)return n.remainder=h,n}else return n;var t=e[e.length-1];return n.valid=Object(b.sliceUint8)(h,0,t.start-8),n.remainder=Object(b.sliceUint8)(h,t.start-8),n}function r(h,n){var e=new Uint8Array(h.length+n.length);return e.set(h),e.set(n,h.length),e}},"./src/utils/texttrack-utils.ts":function(K,C,g){g.r(C),g.d(C,"sendAddTrackEvent",function(){return O}),g.d(C,"addCueToTrack",function(){return L}),g.d(C,"clearCurrentCues",function(){return M}),g.d(C,"removeCuesInRange",function(){return P}),g.d(C,"getCuesInRange",function(){return c});var b=g("./src/utils/logger.ts");function O(a,u){var o;try{o=new Event("addtrack")}catch{o=document.createEvent("Event"),o.initEvent("addtrack",!1,!1)}o.track=a,u.dispatchEvent(o)}function L(a,u){var o=a.mode;if(o==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(u.id))try{if(a.addCue(u),!a.cues.getCueById(u.id))throw new Error("addCue is failed for: "+u)}catch(y){b.logger.debug("[texttrack-utils]: "+y);var p=new self.TextTrackCue(u.startTime,u.endTime,u.text);p.id=u.id,a.addCue(p)}o==="disabled"&&(a.mode=o)}function M(a){var u=a.mode;if(u==="disabled"&&(a.mode="hidden"),a.cues)for(var o=a.cues.length;o--;)a.removeCue(a.cues[o]);u==="disabled"&&(a.mode=u)}function P(a,u,o){var p=a.mode;if(p==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0)for(var y=c(a.cues,u,o),m=0;m<y.length;m++)a.removeCue(y[m]);p==="disabled"&&(a.mode=p)}function x(a,u){if(u<a[0].startTime)return 0;var o=a.length-1;if(u>a[o].endTime)return-1;for(var p=0,y=o;p<=y;){var m=Math.floor((y+p)/2);if(u<a[m].startTime)y=m-1;else if(u>a[m].startTime&&p<o)p=m+1;else return m}return a[p].startTime-u<u-a[y].startTime?p:y}function c(a,u,o){var p=[],y=x(a,u);if(y>-1)for(var m=y,d=a.length;m<d;m++){var l=a[m];if(l.startTime>=u&&l.endTime<=o)p.push(l);else if(l.startTime>o)return p}return p}},"./src/utils/time-ranges.ts":function(K,C,g){g.r(C);var b={toString:function(L){for(var M="",P=L.length,x=0;x<P;x++)M+="["+L.start(x).toFixed(3)+","+L.end(x).toFixed(3)+"]";return M}};C.default=b},"./src/utils/timescale-conversion.ts":function(K,C,g){g.r(C),g.d(C,"toTimescaleFromBase",function(){return O}),g.d(C,"toTimescaleFromScale",function(){return L}),g.d(C,"toMsFromMpegTsClock",function(){return M}),g.d(C,"toMpegTsClockFromTimescale",function(){return P});var b=9e4;function O(x,c,a,u){a===void 0&&(a=1),u===void 0&&(u=!1);var o=x*c*a;return u?Math.round(o):o}function L(x,c,a,u){return a===void 0&&(a=1),u===void 0&&(u=!1),O(x,c,1/a,u)}function M(x,c){return c===void 0&&(c=!1),O(x,1e3,1/b,c)}function P(x,c){return c===void 0&&(c=1),O(x,b,1/c)}},"./src/utils/typed-array.ts":function(K,C,g){g.r(C),g.d(C,"sliceUint8",function(){return b});function b(O,L,M){return Uint8Array.prototype.slice?O.slice(L,M):new Uint8Array(Array.prototype.slice.call(O,L,M))}},"./src/utils/xhr-loader.ts":function(K,C,g){g.r(C);var b=g("./src/utils/logger.ts"),O=g("./src/loader/load-stats.ts"),L=/^age:\s*[\d.]+\s*$/m,M=function(){function P(c){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=c?c.xhrSetup:null,this.stats=new O.LoadStats,this.retryDelay=0}var x=P.prototype;return x.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},x.abortInternal=function(){var a=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),a&&(a.onreadystatechange=null,a.onprogress=null,a.readyState!==4&&(this.stats.aborted=!0,a.abort()))},x.abort=function(){var a;this.abortInternal(),(a=this.callbacks)!==null&&a!==void 0&&a.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},x.load=function(a,u,o){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=a,this.config=u,this.callbacks=o,this.retryDelay=u.retryDelay,this.loadInternal()},x.loadInternal=function(){var a=this.config,u=this.context;if(!!a){var o=this.loader=new self.XMLHttpRequest,p=this.stats;p.loading.first=0,p.loaded=0;var y=this.xhrSetup;try{if(y)try{y(o,u.url)}catch{o.open("GET",u.url,!0),y(o,u.url)}o.readyState||o.open("GET",u.url,!0);var m=this.context.headers;if(m)for(var d in m)o.setRequestHeader(d,m[d])}catch(l){this.callbacks.onError({code:o.status,text:l.message},u,o);return}u.rangeEnd&&o.setRequestHeader("Range","bytes="+u.rangeStart+"-"+(u.rangeEnd-1)),o.onreadystatechange=this.readystatechange.bind(this),o.onprogress=this.loadprogress.bind(this),o.responseType=u.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout),o.send()}},x.readystatechange=function(){var a=this.context,u=this.loader,o=this.stats;if(!(!a||!u)){var p=u.readyState,y=this.config;if(!o.aborted&&p>=2)if(self.clearTimeout(this.requestTimeout),o.loading.first===0&&(o.loading.first=Math.max(self.performance.now(),o.loading.start)),p===4){u.onreadystatechange=null,u.onprogress=null;var m=u.status;if(m>=200&&m<300){o.loading.end=Math.max(self.performance.now(),o.loading.first);var d,l;if(a.responseType==="arraybuffer"?(d=u.response,l=d.byteLength):(d=u.responseText,l=d.length),o.loaded=o.total=l,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(o,a,d,u),!this.callbacks)return;var r={url:u.responseURL,data:d};this.callbacks.onSuccess(r,o,a,u)}else o.retry>=y.maxRetry||m>=400&&m<499?(b.logger.error(m+" while loading "+a.url),this.callbacks.onError({code:m,text:u.statusText},a,u)):(b.logger.warn(m+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,y.maxRetryDelay),o.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout)}},x.loadtimeout=function(){b.logger.warn("timeout while loading "+this.context.url);var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))},x.loadprogress=function(a){var u=this.stats;u.loaded=a.loaded,a.lengthComputable&&(u.total=a.total)},x.getCacheAge=function(){var a=null;if(this.loader&&L.test(this.loader.getAllResponseHeaders())){var u=this.loader.getResponseHeader("age");a=u?parseFloat(u):null}return a},P}();C.default=M}}).default})})(Me);var Oe=Ne(Me.exports),ke=function(){var G=this,ne=G.$createElement,K=G._self._c||ne;return K("div",{staticClass:"video-player"},[K("transition",{attrs:{name:"fade"}},[!!G.thumb&&G.state.playback==="idle"?K("img",{staticClass:"thumb",attrs:{src:G.thumb.src,srcset:G.thumb.srcset,sizes:"auto"}}):G._e()]),K("transition",{attrs:{name:"fade"}},[G.state.playback==="idle"||G.state.playback==="ended"||G.state.playback==="paused"?K("div",{staticClass:"overlay",on:{click:G.togglePlayback}},[K("button",{staticClass:"overlay__inner"},[K("svg",{attrs:{width:"10",height:"13",viewBox:"0 0 10 13",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"}},[K("path",{attrs:{d:"M0 0.388916L10 6.50003L0 12.6111V0.388916Z"}})])])]):G._e()]),K("video",{ref:"video",staticClass:"player-video",attrs:{loop:!1,preload:"auto"},domProps:{muted:G.state.muted},on:{play:G.onPlay,pause:G.onPause,ended:G.onEnded,click:G.togglePlayback}})],1)},Ke=[],nt="";function Ce(G,ne,K,C,g,b,O,L){var M=typeof G=="function"?G.options:G;ne&&(M.render=ne,M.staticRenderFns=K,M._compiled=!0),C&&(M.functional=!0),b&&(M._scopeId="data-v-"+b);var P;if(O?(P=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!a&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(a=__VUE_SSR_CONTEXT__),g&&g.call(this,a),a&&a._registeredComponents&&a._registeredComponents.add(O)},M._ssrRegister=P):g&&(P=L?function(){g.call(this,(M.functional?this.parent:this).$root.$options.shadowRoot)}:g),P)if(M.functional){M._injectStyles=P;var x=M.render;M.render=function(u,o){return P.call(o),x(u,o)}}else{var c=M.beforeCreate;M.beforeCreate=c?[].concat(c,P):[P]}return{exports:G,options:M}}const We={name:"VideoPlayer",props:{src:{type:String,required:!0},thumb:{type:Object,default:()=>({})}},data(){return{state:{loaded:!1,playback:"idle",muted:!1},hls:null}},mounted(){this.load()},beforeUnmount(){this.destroy()},methods:{load(){Oe.isSupported()?(this.hls=new Oe,this.hls.loadSource(this.src),this.hls.attachMedia(this.$refs.video),this.hls.on(Oe.Events.MEDIA_ATTACHED,this.onLoad)):(this.$refs.video.src=this.src,this.$refs.video.load(),this.state.loaded=!0)},destroy(){this.hls.detachMedia(),this.hls.destroy()},play(){const G=this.$refs.video.play();G!==null&&G.catch(()=>{this.pause()})},pause(){this.$refs.video.pause()},togglePlayback(){this.state.playback==="playing"?this.pause():this.play()},onLoad(){this.state.loaded=!0},onPlay(){this.state.playback="playing"},onPause(){this.state.playback="paused"},onEnded(){this.state.playback="ended"}}},be={};var we=Ce(We,ke,Ke,!1,Ge,"d38eb820",null,null);function Ge(G){for(let ne in be)this[ne]=be[ne]}var je=function(){return we.exports}(),He=function(){var G=this,ne=G.$createElement,K=G._self._c||ne;return K("k-block-figure",{attrs:{"is-empty":!G.video.url,"empty-icon":"video","empty-text":"Select a video \u2026"},on:{open:G.open,update:G.update}},[G.src?K("VideoPlayer",{attrs:{src:G.src,thumb:G.thumb}}):G._e()],1)},Ve=[];const Xe={name:"VideoBlock",components:{VideoPlayer:je},data(){return{mux:null}},computed:{video(){return this.content.video[0]||{}},id(){var G;return(G=this.mux)==null?void 0:G.playback_ids[0].id},src(){return this.id?`https://stream.mux.com/${this.id}.m3u8`:""},thumb(){if(!this.id)return"";const G=`https://image.mux.com/${this.id}/thumbnail.jpg`;return{src:G,srcset:[300,600,900,1200,1600].map(K=>`${G}?width=${K} ${K}w`).join(", ")}}},watch:{"video.link":{handler(G){G&&this.$api.get(G).then(ne=>{this.mux=JSON.parse(ne.content.mux)})},immediate:!0}}},Fe={};var Ye=Ce(Xe,He,Ve,!1,ze,null,null,null);function ze(G){for(let ne in Fe)this[ne]=Fe[ne]}var $e=function(){return Ye.exports}();window.panel.plugin("robinscholz/kirby-mux",{blocks:{"mux-video":$e}})})();