23 lines
372 KiB
JavaScript
23 lines
372 KiB
JavaScript
import{q as we,c as Z,A as be,x as je,u as G,i as ue,d as xe,y as pe,z as me,a as K,e as z,t as J,r as ye,B as ae,n as Se,s as Xe,v as mt,o as yt,w as Q,T as at,F as Ce,G as Fe,h as Y,p as Ve,g as He,D as Et,a5 as It,aP as Ct,aQ as Tt,I as fe,S as Je,aR as ut,C as wt,b as xt,N as ee,a4 as st,W as St,E as bt,a9 as Ot,aS as Pt,U as Ft,ax as De,R as Ge,ay as dt,a8 as ct,aT as Mt,aU as Nt,aV as Bt,ap as Ut,aW as Gt,an as jt,ao as Kt,V as Vt,ai as Ht,ad as Wt,aB as Yt,at as qt,as as zt,aF as Xt,X as $t,Y as Qt,aa as Zt,aO as Jt,a0 as er,_ as tr}from"./index-4dcc0234.js";/* empty css *//* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-tooltip-4ed993c7.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{_ as rr}from"./index.vue_vue_type_script_setup_true_lang-9285296e.js";import{q as ir,r as nr,s as ar,t as sr,u as or,v as lr,w as ur,x as dr,y as cr}from"./sys-8ead7f22.js";var hr=Object.defineProperty,fr=Object.defineProperties,gr=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable,ft=(N,w,h)=>w in N?hr(N,w,{enumerable:!0,configurable:!0,writable:!0,value:h}):N[w]=h,ot=(N,w)=>{for(var h in w||(w={}))vr.call(w,h)&&ft(N,h,w[h]);if(ht)for(var h of ht(w))pr.call(w,h)&&ft(N,h,w[h]);return N},lt=(N,w)=>fr(N,gr(w));function gt(N,w,h,R){var T,A=!1,k=0;function I(){T&&clearTimeout(T)}function D(){for(var o=arguments.length,L=new Array(o),m=0;m<o;m++)L[m]=arguments[m];var f=this,S=Date.now()-k;function E(){k=Date.now(),h.apply(f,L)}function c(){T=void 0}A||(R&&!T&&E(),I(),R===void 0&&S>N?E():w!==!0&&(T=setTimeout(R?c:E,R===void 0?N-S:N)))}return typeof w!="boolean"&&(R=h,h=w,w=void 0),D.cancel=function(){I(),A=!0},D}function vt(N,w,h){return h===void 0?gt(N,w,!1):gt(N,h,w!==!1)}function mr(N){return N&&N.__esModule&&Object.prototype.hasOwnProperty.call(N,"default")?N.default:N}var Lt={exports:{}};typeof window<"u"&&(Lt.exports=function(N){var w={};function h(R){if(w[R])return w[R].exports;var T=w[R]={i:R,l:!1,exports:{}};return N[R].call(T.exports,T,T.exports,h),T.l=!0,T.exports}return h.m=N,h.c=w,h.d=function(R,T,A){h.o(R,T)||Object.defineProperty(R,T,{enumerable:!0,get:A})},h.r=function(R){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},h.t=function(R,T){if(1&T&&(R=h(R)),8&T||4&T&&typeof R=="object"&&R&&R.__esModule)return R;var A=Object.create(null);if(h.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:R}),2&T&&typeof R!="string")for(var k in R)h.d(A,k,function(I){return R[I]}.bind(null,k));return A},h.n=function(R){var T=R&&R.__esModule?function(){return R.default}:function(){return R};return h.d(T,"a",T),T},h.o=function(R,T){return Object.prototype.hasOwnProperty.call(R,T)},h.p="/dist/",h(h.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(N,w,h){var R=Object.prototype.hasOwnProperty,T="~";function A(){}function k(L,m,f){this.fn=L,this.context=m,this.once=f||!1}function I(L,m,f,S,E){if(typeof f!="function")throw new TypeError("The listener must be a function");var c=new k(f,S||L,E),e=T?T+m:m;return L._events[e]?L._events[e].fn?L._events[e]=[L._events[e],c]:L._events[e].push(c):(L._events[e]=c,L._eventsCount++),L}function D(L,m){--L._eventsCount==0?L._events=new A:delete L._events[m]}function o(){this._events=new A,this._eventsCount=0}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(T=!1)),o.prototype.eventNames=function(){var L,m,f=[];if(this._eventsCount===0)return f;for(m in L=this._events)R.call(L,m)&&f.push(T?m.slice(1):m);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(L)):f},o.prototype.listeners=function(L){var m=T?T+L:L,f=this._events[m];if(!f)return[];if(f.fn)return[f.fn];for(var S=0,E=f.length,c=new Array(E);S<E;S++)c[S]=f[S].fn;return c},o.prototype.listenerCount=function(L){var m=T?T+L:L,f=this._events[m];return f?f.fn?1:f.length:0},o.prototype.emit=function(L,m,f,S,E,c){var e=T?T+L:L;if(!this._events[e])return!1;var a,t,s=this._events[e],l=arguments.length;if(s.fn){switch(s.once&&this.removeListener(L,s.fn,void 0,!0),l){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,m),!0;case 3:return s.fn.call(s.context,m,f),!0;case 4:return s.fn.call(s.context,m,f,S),!0;case 5:return s.fn.call(s.context,m,f,S,E),!0;case 6:return s.fn.call(s.context,m,f,S,E,c),!0}for(t=1,a=new Array(l-1);t<l;t++)a[t-1]=arguments[t];s.fn.apply(s.context,a)}else{var n,d=s.length;for(t=0;t<d;t++)switch(s[t].once&&this.removeListener(L,s[t].fn,void 0,!0),l){case 1:s[t].fn.call(s[t].context);break;case 2:s[t].fn.call(s[t].context,m);break;case 3:s[t].fn.call(s[t].context,m,f);break;case 4:s[t].fn.call(s[t].context,m,f,S);break;default:if(!a)for(n=1,a=new Array(l-1);n<l;n++)a[n-1]=arguments[n];s[t].fn.apply(s[t].context,a)}}return!0},o.prototype.on=function(L,m,f){return I(this,L,m,f,!1)},o.prototype.once=function(L,m,f){return I(this,L,m,f,!0)},o.prototype.removeListener=function(L,m,f,S){var E=T?T+L:L;if(!this._events[E])return this;if(!m)return D(this,E),this;var c=this._events[E];if(c.fn)c.fn!==m||S&&!c.once||f&&c.context!==f||D(this,E);else{for(var e=0,a=[],t=c.length;e<t;e++)(c[e].fn!==m||S&&!c[e].once||f&&c[e].context!==f)&&a.push(c[e]);a.length?this._events[E]=a.length===1?a[0]:a:D(this,E)}return this},o.prototype.removeAllListeners=function(L){var m;return L?(m=T?T+L:L,this._events[m]&&D(this,m)):(this._events=new A,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=T,o.EventEmitter=o,N.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":function(N,w,h){var R,T,A,k,I;R=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,T=/^([^\/?#]*)([^]*)$/,A=/(?:\/|^)\.(?=\/)/g,k=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,I={buildAbsoluteURL:function(D,o,L){if(L=L||{},D=D.trim(),!(o=o.trim())){if(!L.alwaysNormalize)return D;var m=I.parseURL(D);if(!m)throw new Error("Error trying to parse base URL.");return m.path=I.normalizePath(m.path),I.buildURLFromParts(m)}var f=I.parseURL(o);if(!f)throw new Error("Error trying to parse relative URL.");if(f.scheme)return L.alwaysNormalize?(f.path=I.normalizePath(f.path),I.buildURLFromParts(f)):o;var S=I.parseURL(D);if(!S)throw new Error("Error trying to parse base URL.");if(!S.netLoc&&S.path&&S.path[0]!=="/"){var E=T.exec(S.path);S.netLoc=E[1],S.path=E[2]}S.netLoc&&!S.path&&(S.path="/");var c={scheme:S.scheme,netLoc:f.netLoc,path:null,params:f.params,query:f.query,fragment:f.fragment};if(!f.netLoc&&(c.netLoc=S.netLoc,f.path[0]!=="/"))if(f.path){var e=S.path,a=e.substring(0,e.lastIndexOf("/")+1)+f.path;c.path=I.normalizePath(a)}else c.path=S.path,f.params||(c.params=S.params,f.query||(c.query=S.query));return c.path===null&&(c.path=L.alwaysNormalize?I.normalizePath(f.path):f.path),I.buildURLFromParts(c)},parseURL:function(D){var o=R.exec(D);return o?{scheme:o[1]||"",netLoc:o[2]||"",path:o[3]||"",params:o[4]||"",query:o[5]||"",fragment:o[6]||""}:null},normalizePath:function(D){for(D=D.split("").reverse().join("").replace(A,"");D.length!==(D=D.replace(k,"")).length;);return D.split("").reverse().join("")},buildURLFromParts:function(D){return D.scheme+D.netLoc+D.path+D.params+D.query+D.fragment}},N.exports=I},"./node_modules/webworkify-webpack/index.js":function(N,w,h){function R(o){var L={};function m(S){if(L[S])return L[S].exports;var E=L[S]={i:S,l:!1,exports:{}};return o[S].call(E.exports,E,E.exports,m),E.l=!0,E.exports}m.m=o,m.c=L,m.i=function(S){return S},m.d=function(S,E,c){m.o(S,E)||Object.defineProperty(S,E,{configurable:!1,enumerable:!0,get:c})},m.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},m.n=function(S){var E=S&&S.__esModule?function(){return S.default}:function(){return S};return m.d(E,"a",E),E},m.o=function(S,E){return Object.prototype.hasOwnProperty.call(S,E)},m.p="/",m.oe=function(S){throw console.error(S),S};var f=m(m.s=ENTRY_MODULE);return f.default||f}var T="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function k(o){return(o+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function I(o,L,m){var f={};f[m]=[];var S=L.toString(),E=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!E)return f;for(var c,e=E[1],a=new RegExp("(\\\\n|\\W)"+k(e)+A,"g");c=a.exec(S);)c[3]!=="dll-reference"&&f[m].push(c[3]);for(a=new RegExp("\\("+k(e)+'\\("(dll-reference\\s('+T+'))"\\)\\)'+A,"g");c=a.exec(S);)o[c[2]]||(f[m].push(c[1]),o[c[2]]=h(c[1]).m),f[c[2]]=f[c[2]]||[],f[c[2]].push(c[4]);for(var t,s=Object.keys(f),l=0;l<s.length;l++)for(var n=0;n<f[s[l]].length;n++)t=f[s[l]][n],isNaN(1*t)||(f[s[l]][n]=1*f[s[l]][n]);return f}function D(o){return Object.keys(o).reduce(function(L,m){return L||o[m].length>0},!1)}N.exports=function(o,L){L=L||{};var m={main:h.m},f=L.all?{main:Object.keys(m.main)}:function(a,t){for(var s={main:[t]},l={main:[]},n={main:{}};D(s);)for(var d=Object.keys(s),p=0;p<d.length;p++){var g=d[p],v=s[g].pop();if(n[g]=n[g]||{},!n[g][v]&&a[g][v]){n[g][v]=!0,l[g]=l[g]||[],l[g].push(v);for(var r=I(a,a[g][v],g),i=Object.keys(r),u=0;u<i.length;u++)s[i[u]]=s[i[u]]||[],s[i[u]]=s[i[u]].concat(r[i[u]])}}return l}(m,o),S="";Object.keys(f).filter(function(a){return a!=="main"}).forEach(function(a){for(var t=0;f[a][t];)t++;f[a].push(t),m[a][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+f[a].map(function(s){return JSON.stringify(s)+": "+m[a][s].toString()}).join(",")+`});
|
||
`}),S=S+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(o))+")({"+f.main.map(function(a){return JSON.stringify(a)+": "+m.main[a].toString()}).join(",")+"}))(self);";var E=new window.Blob([S],{type:"text/javascript"});if(L.bare)return E;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(E),e=new window.Worker(c);return e.objectURL=c,e}},"./src/config.ts":function(N,w,h){h.r(w),h.d(w,"hlsDefaultConfig",function(){return d}),h.d(w,"mergeConfig",function(){return p}),h.d(w,"enableStreamingMode",function(){return g});var R=h("./src/controller/abr-controller.ts"),T=h("./src/controller/audio-stream-controller.ts"),A=h("./src/controller/audio-track-controller.ts"),k=h("./src/controller/subtitle-stream-controller.ts"),I=h("./src/controller/subtitle-track-controller.ts"),D=h("./src/controller/buffer-controller.ts"),o=h("./src/controller/timeline-controller.ts"),L=h("./src/controller/cap-level-controller.ts"),m=h("./src/controller/fps-controller.ts"),f=h("./src/controller/eme-controller.ts"),S=h("./src/utils/xhr-loader.ts"),E=h("./src/utils/fetch-loader.ts"),c=h("./src/utils/cues.ts"),e=h("./src/utils/mediakeys-helper.ts"),a=h("./src/utils/logger.ts");function t(){return(t=Object.assign||function(v){for(var r=1;r<arguments.length;r++){var i=arguments[r];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(v[u]=i[u])}return v}).apply(this,arguments)}function s(v,r){var i=Object.keys(v);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(v);r&&(u=u.filter(function(y){return Object.getOwnPropertyDescriptor(v,y).enumerable})),i.push.apply(i,u)}return i}function l(v){for(var r=1;r<arguments.length;r++){var i=arguments[r]!=null?arguments[r]:{};r%2?s(Object(i),!0).forEach(function(u){n(v,u,i[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach(function(u){Object.defineProperty(v,u,Object.getOwnPropertyDescriptor(i,u))})}return v}function n(v,r,i){return r in v?Object.defineProperty(v,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):v[r]=i,v}var d=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,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:S.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:D.default,capLevelController:L.default,fpsController:m.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:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0},{cueHandler:c.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:k.SubtitleStreamController,subtitleTrackController:I.default,timelineController:o.TimelineController,audioStreamController:T.default,audioTrackController:A.default,emeController:f.default});function p(v,r){if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(r.liveMaxLatencyDurationCount!==void 0&&(r.liveSyncDurationCount===void 0||r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(r.liveMaxLatencyDuration!==void 0&&(r.liveSyncDuration===void 0||r.liveMaxLatencyDuration<=r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return t({},v,r)}function g(v){var r=v.loader;r!==E.default&&r!==S.default?(a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),v.progressive=!1):Object(E.fetchSupported)()&&(v.loader=E.default,v.progressive=!0,v.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":function(N,w,h){h.r(w);var R=h("./src/polyfills/number.ts"),T=h("./src/utils/ewma-bandwidth-estimator.ts"),A=h("./src/events.ts"),k=h("./src/utils/buffer-helper.ts"),I=h("./src/errors.ts"),D=h("./src/types/loader.ts"),o=h("./src/utils/logger.ts");function L(f,S){for(var E=0;E<S.length;E++){var c=S[E];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(f,c.key,c)}}var m=function(){function f(e){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=e;var a=e.config;this.bwEstimator=new T.default(a.abrEwmaSlowVoD,a.abrEwmaFastVoD,a.abrEwmaDefaultEstimate),this.registerListeners()}var S,E,c=f.prototype;return c.registerListeners=function(){var e=this.hls;e.on(A.Events.FRAG_LOADING,this.onFragLoading,this),e.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(A.Events.ERROR,this.onError,this)},c.unregisterListeners=function(){var e=this.hls;e.off(A.Events.FRAG_LOADING,this.onFragLoading,this),e.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(A.Events.ERROR,this.onError,this)},c.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},c.onFragLoading=function(e,a){var t,s=a.frag;s.type===D.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=s,this.partCurrent=(t=a.part)!=null?t:null,this.timer=self.setInterval(this.onCheck,100)))},c.onLevelLoaded=function(e,a){var t=this.hls.config;a.details.live?this.bwEstimator.update(t.abrEwmaSlowLive,t.abrEwmaFastLive):this.bwEstimator.update(t.abrEwmaSlowVoD,t.abrEwmaFastVoD)},c._abandonRulesCheck=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.autoLevelEnabled,l=t.config,n=t.media;if(e&&n){var d=a?a.stats:e.stats,p=a?a.duration:e.duration;if(d.aborted)return o.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(s&&!n.paused&&n.playbackRate&&n.readyState){var g=performance.now()-d.loading.start,v=Math.abs(n.playbackRate);if(!(g<=500*p/v)){var r=t.levels,i=t.minAutoLevel,u=r[e.level],y=d.total||Math.max(d.loaded,Math.round(p*u.maxBitrate/8)),b=Math.max(1,d.bwEstimate?d.bwEstimate/8:1e3*d.loaded/g),_=(y-d.loaded)/b,x=n.currentTime,C=(k.BufferHelper.bufferInfo(n,x,l.maxBufferHole).end-x)/v;if(!(C>=2*p/v||_<=C)){var O,P=Number.POSITIVE_INFINITY;for(O=e.level-1;O>i&&!((P=p*r[O].maxBitrate/(6.4*b))<C);O--);if(!(P>=_)){var F=this.bwEstimator.getEstimate();o.logger.warn("Fragment "+e.sn+(a?" part "+a.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+O+`
|
||
Current BW estimate: `+(Object(R.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
|
||
Estimated load time for current fragment: `+_.toFixed(3)+` s
|
||
Estimated load time for the next fragment: `+P.toFixed(3)+` s
|
||
Time to underbuffer: `+C.toFixed(3)+" s"),t.nextLoadLevel=O,this.bwEstimator.sample(g,d.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),t.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:a,stats:d})}}}}}},c.onFragLoaded=function(e,a){var t=a.frag,s=a.part;if(t.type===D.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(t.sn)){var l=s?s.stats:t.stats,n=s?s.duration:t.duration;if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var d=this.hls.levels[t.level],p=(d.loaded?d.loaded.bytes:0)+l.loaded,g=(d.loaded?d.loaded.duration:0)+n;d.loaded={bytes:p,duration:g},d.realBitrate=Math.round(8*p/g)}if(t.bitrateTest){var v={stats:l,frag:t,part:s,id:t.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,v),t.bitrateTest=!1}}},c.onFragBuffered=function(e,a){var t=a.frag,s=a.part,l=s?s.stats:t.stats;if(!l.aborted&&t.type===D.PlaylistLevelType.MAIN&&t.sn!=="initSegment"){var n=l.parsing.end-l.loading.start;this.bwEstimator.sample(n,l.loaded),l.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},c.onError=function(e,a){switch(a.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},c.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},c.getNextABRAutoLevel=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.maxAutoLevel,l=t.config,n=t.minAutoLevel,d=t.media,p=a?a.duration:e?e.duration:0,g=d?d.currentTime:0,v=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():l.abrEwmaDefaultEstimate,i=(k.BufferHelper.bufferInfo(d,g,l.maxBufferHole).end-g)/v,u=this.findBestLevel(r,n,s,i,l.abrBandWidthFactor,l.abrBandWidthUpFactor);if(u>=0)return u;o.logger.trace((i?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=p?Math.min(p,l.maxStarvationDelay):l.maxStarvationDelay,b=l.abrBandWidthFactor,_=l.abrBandWidthUpFactor;if(!i){var x=this.bitrateTestDelay;x&&(y=(p?Math.min(p,l.maxLoadingDelay):l.maxLoadingDelay)-x,o.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),b=_=1)}return u=this.findBestLevel(r,n,s,i+y,b,_),Math.max(u,0)},c.findBestLevel=function(e,a,t,s,l,n){for(var d,p=this.fragCurrent,g=this.partCurrent,v=this.lastLoadedFragLevel,r=this.hls.levels,i=r[v],u=!(i==null||(d=i.details)===null||d===void 0||!d.live),y=i==null?void 0:i.codecSet,b=g?g.duration:p?p.duration:0,_=t;_>=a;_--){var x=r[_];if(x&&(!y||x.codecSet===y)){var C=x.details,O=(g?C==null?void 0:C.partTarget:C==null?void 0:C.averagetargetduration)||b,P=void 0;P=_<=v?l*e:n*e;var F=r[_].maxBitrate,M=F*O/P;if(o.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+_+"/"+Math.round(P)+"/"+F+"/"+O+"/"+s+"/"+M),P>F&&(!M||u&&!this.bitrateTestDelay||M<s))return _}}return-1},S=f,(E=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,a=this.bwEstimator;if(!(e===-1||a&&a.canEstimate()))return e;var t=this.getNextABRAutoLevel();return e!==-1&&(t=Math.min(e,t)),t},set:function(e){this._nextAutoLevel=e}}])&&L(S.prototype,E),f}();w.default=m},"./src/controller/audio-stream-controller.ts":function(N,w,h){h.r(w);var R=h("./src/polyfills/number.ts"),T=h("./src/controller/base-stream-controller.ts"),A=h("./src/events.ts"),k=h("./src/utils/buffer-helper.ts"),I=h("./src/controller/fragment-tracker.ts"),D=h("./src/types/level.ts"),o=h("./src/types/loader.ts"),L=h("./src/loader/fragment.ts"),m=h("./src/demux/chunk-cache.ts"),f=h("./src/demux/transmuxer-interface.ts"),S=h("./src/types/transmuxer.ts"),E=h("./src/controller/fragment-finders.ts"),c=h("./src/utils/discontinuities.ts"),e=h("./src/errors.ts"),a=h("./src/utils/logger.ts");function t(){return(t=Object.assign||function(n){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var g in p)Object.prototype.hasOwnProperty.call(p,g)&&(n[g]=p[g])}return n}).apply(this,arguments)}function s(n,d){return(s=Object.setPrototypeOf||function(p,g){return p.__proto__=g,p})(n,d)}var l=function(n){var d,p;function g(r,i){var u;return(u=n.call(this,r,i,"[audio-stream-controller]")||this).videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u._registerListeners(),u}p=n,(d=g).prototype=Object.create(p.prototype),d.prototype.constructor=d,s(d,p);var v=g.prototype;return v.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},v._registerListeners=function(){var r=this.hls;r.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(A.Events.ERROR,this.onError,this),r.on(A.Events.BUFFER_RESET,this.onBufferReset,this),r.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var r=this.hls;r.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(A.Events.ERROR,this.onError,this),r.off(A.Events.BUFFER_RESET,this.onBufferReset,this),r.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),r.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onInitPtsFound=function(r,i){var u=i.frag,y=i.id,b=i.initPTS;if(y==="main"){var _=u.cc;this.initPTS[u.cc]=b,this.log("InitPTS for cc: "+_+" found from main: "+b),this.videoTrackCC=_,this.state===T.State.WAITING_INIT_PTS&&this.tick()}},v.startLoad=function(r){if(!this.levels)return this.startPosition=r,void(this.state=T.State.STOPPED);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,i>0&&r===-1?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),this.state=T.State.IDLE):(this.loadedmetadata=!1,this.state=T.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},v.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_TRACK:var r,i=this.levels,u=this.trackId,y=i==null||(r=i[u])===null||r===void 0?void 0:r.details;if(y){if(this.waitForCdnTuneIn(y))break;this.state=T.State.WAITING_INIT_PTS}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,_=performance.now(),x=this.retryDate;(!x||_>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=T.State.IDLE);break;case T.State.WAITING_INIT_PTS:var C=this.waitingData;if(C){var O=C.frag,P=C.part,F=C.cache,M=C.complete;if(this.initPTS[O.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=T.State.FRAG_LOADING;var B={frag:O,part:P,payload:F.flush(),networkDetails:null};this._handleFragmentLoadProgress(B),M&&n.prototype._handleFragmentLoadComplete.call(this,B)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+O.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var U=this.getLoadPosition(),j=k.BufferHelper.bufferInfo(this.mediaBuffer,U,this.config.maxBufferHole);Object(E.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,O)<0&&(a.logger.log("Waiting fragment cc ("+O.cc+") @ "+O.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=T.State.IDLE}this.onTickEnd()},v.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=T.State.IDLE)},v.onTickEnd=function(){var r=this.media;if(r&&r.readyState){var i=(this.mediaBuffer?this.mediaBuffer:r).buffered;!this.loadedmetadata&&i.length&&(this.loadedmetadata=!0),this.lastCurrentTime=r.currentTime}},v.doTickIdle=function(){var r,i,u=this.hls,y=this.levels,b=this.media,_=this.trackId,x=u.config;if(y&&y[_]&&(b||!this.startFragRequested&&x.startFragPrefetch)){var C=y[_].details;if(!C||C.live&&this.levelLastLoaded!==_||this.waitForCdnTuneIn(C))this.state=T.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,L.ElementaryStreamTypes.AUDIO,o.PlaylistLevelType.AUDIO));var O=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,o.PlaylistLevelType.AUDIO);if(O!==null){var P=O.len,F=this.getMaxBufferLength(),M=this.audioSwitch;if(!(P>=F)||M){if(!M&&this._streamEnded(O,C))return u.trigger(A.Events.BUFFER_EOS,{type:"audio"}),void(this.state=T.State.ENDED);var B=C.fragments[0].start,U=O.end;if(M){var j=this.getLoadPosition();U=j,C.PTSKnown&&j<B&&(O.end>B||O.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=B+.05)}var V=this.getNextFragment(U,C);V?((r=V.decryptdata)===null||r===void 0?void 0:r.keyFormat)!=="identity"||(i=V.decryptdata)!==null&&i!==void 0&&i.key?this.loadFragment(V,C,U):this.loadKey(V,C):this.bufferFlushed=!0}}}}},v.getMaxBufferLength=function(){var r=n.prototype.getMaxBufferLength.call(this),i=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,o.PlaylistLevelType.MAIN);return i===null?r:Math.max(r,i.len)},v.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},v.onAudioTracksUpdated=function(r,i){var u=i.audioTracks;this.resetTransmuxer(),this.levels=u.map(function(y){return new D.Level(y)})},v.onAudioTrackSwitching=function(r,i){var u=!!i.url;this.trackId=i.id;var y=this.fragCurrent;y!=null&&y.loader&&y.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),u?this.setInterval(100):this.resetTransmuxer(),u?(this.audioSwitch=!0,this.state=T.State.IDLE):this.state=T.State.STOPPED,this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},v.onLevelLoaded=function(r,i){this.mainDetails=i.details},v.onAudioTrackLoaded=function(r,i){var u,y=this.levels,b=i.details,_=i.id;if(y){this.log("Track "+_+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var x=y[_],C=0;if(b.live||(u=x.details)!==null&&u!==void 0&&u.live){var O=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!O)return;!x.details&&b.hasProgramDateTime&&O.hasProgramDateTime?(Object(c.alignPDT)(b,O),C=b.fragments[0].start):C=this.alignPlaylists(b,x.details)}x.details=b,this.levelLastLoaded=_,this.startFragRequested||!this.mainDetails&&b.live||this.setStartPosition(x.details,C),this.state!==T.State.WAITING_TRACK||this.waitForCdnTuneIn(b)||(this.state=T.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+_)},v._handleFragmentLoadProgress=function(r){var i,u=r.frag,y=r.part,b=r.payload,_=this.config,x=this.trackId,C=this.levels;if(C){var O=C[x];console.assert(O,"Audio track is defined on fragment load progress");var P=O.details;console.assert(P,"Audio track details are defined on fragment load progress");var F=_.defaultAudioCodec||O.audioCodec||"mp4a.40.2",M=this.transmuxer;M||(M=this.transmuxer=new f.default(this.hls,o.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[u.cc],U=(i=u.initSegment)===null||i===void 0?void 0:i.data;if(B!==void 0){var j=y?y.index:-1,V=j!==-1,W=new S.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,b.byteLength,j,V);M.push(b,U,F,"",u,y,P.totalduration,!1,W,B)}else a.logger.log("Unknown video PTS for cc "+u.cc+", waiting for video PTS before demuxing audio frag "+u.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+x),(this.waitingData=this.waitingData||{frag:u,part:y,cache:new m.default,complete:!1}).cache.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=T.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered")},v._handleFragmentLoadComplete=function(r){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,r)},v.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},v.onBufferCreated=function(r,i){var u=i.tracks.audio;u&&(this.mediaBuffer=u.buffer),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer)},v.onFragBuffered=function(r,i){var u=i.frag,y=i.part;u.type===o.PlaylistLevelType.AUDIO&&(this.fragContextChanged(u)?this.warn("Fragment "+u.sn+(y?" p: "+y.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(u.sn!=="initSegment"&&(this.fragPrevious=u,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(u,y)))},v.onError=function(r,i){switch(i.details){case e.ErrorDetails.FRAG_LOAD_ERROR:case e.ErrorDetails.FRAG_LOAD_TIMEOUT:case e.ErrorDetails.KEY_LOAD_ERROR:case e.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(o.PlaylistLevelType.AUDIO,i);break;case e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case e.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==T.State.ERROR&&this.state!==T.State.STOPPED&&(this.state=i.fatal?T.State.ERROR:T.State.IDLE,this.warn(i.details+" while loading frag, switching to "+this.state+" state"));break;case e.ErrorDetails.BUFFER_FULL_ERROR:if(i.parent==="audio"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)){var u=!0,y=this.getFwdBufferInfo(this.mediaBuffer,o.PlaylistLevelType.AUDIO);y&&y.len>.5&&(u=!this.reduceMaxBufferLength(y.len)),u&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},v.onBufferFlushed=function(r,i){i.type===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},v._handleTransmuxComplete=function(r){var i,u="audio",y=this.hls,b=r.remuxResult,_=r.chunkMeta,x=this.getCurrentContext(_);if(!x)return this.warn("The loading context changed while buffering fragment "+_.sn+" of level "+_.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(_.level);var C=x.frag,O=x.part,P=b.audio,F=b.text,M=b.id3,B=b.initSegment;if(!this.fragContextChanged(C)){if(this.state=T.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),B!=null&&B.tracks&&(this._bufferInitSegment(B.tracks,C,_),y.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:u,tracks:B.tracks})),P){var U=P.startPTS,j=P.endPTS,V=P.startDTS,W=P.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:U,endPTS:j,startDTS:V,endDTS:W}),C.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,U,j,V,W),this.bufferFragmentData(P,C,O,_)}if(M!=null&&(i=M.samples)!==null&&i!==void 0&&i.length){var X=t({frag:C,id:u},M);y.trigger(A.Events.FRAG_PARSING_METADATA,X)}if(F){var q=t({frag:C,id:u},F);y.trigger(A.Events.FRAG_PARSING_USERDATA,q)}}},v._bufferInitSegment=function(r,i,u){if(this.state===T.State.PARSING){r.video&&delete r.video;var y=r.audio;if(y){y.levelCodec=y.codec,y.id="audio",this.log("Init audio buffer, container:"+y.container+", codecs[parsed]=["+y.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,r);var b=y.initSegment;if(b!=null&&b.byteLength){var _={type:"audio",frag:i,part:null,chunkMeta:u,parent:i.type,data:b};this.hls.trigger(A.Events.BUFFER_APPENDING,_)}this.tick()}}},v.loadFragment=function(r,i,u){var y=this.fragmentTracker.getState(r);this.fragCurrent=r,(this.audioSwitch||y===I.FragmentState.NOT_LOADED||y===I.FragmentState.PARTIAL)&&(r.sn==="initSegment"?this._loadInitSegment(r):i.live&&!Object(R.isFiniteNumber)(this.initPTS[r.cc])?(this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId),this.state=T.State.WAITING_INIT_PTS):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,r,i,u)))},v.completeAudioSwitch=function(){var r=this.hls,i=this.media,u=this.trackId;i&&(this.log("Switching audio track : flushing all audio"),n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,r.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:u})},g}(T.default);w.default=l},"./src/controller/audio-track-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/controller/base-playlist-controller.ts"),k=h("./src/types/loader.ts");function I(L,m){for(var f=0;f<m.length;f++){var S=m[f];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(L,S.key,S)}}function D(L,m){return(D=Object.setPrototypeOf||function(f,S){return f.__proto__=S,f})(L,m)}var o=function(L){var m,f;function S(a){var t;return(t=L.call(this,a,"[audio-track-controller]")||this).tracks=[],t.groupId=null,t.tracksInGroup=[],t.trackId=-1,t.trackName="",t.selectDefaultTrack=!0,t.registerListeners(),t}f=L,(m=S).prototype=Object.create(f.prototype),m.prototype.constructor=m,D(m,f);var E,c,e=S.prototype;return e.registerListeners=function(){var a=this.hls;a.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(R.Events.ERROR,this.onError,this)},e.unregisterListeners=function(){var a=this.hls;a.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(R.Events.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,L.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},e.onManifestParsed=function(a,t){this.tracks=t.audioTracks||[]},e.onAudioTrackLoaded=function(a,t){var s=t.id,l=t.details,n=this.tracksInGroup[s];if(n){var d=n.details;n.details=t.details,this.log("audioTrack "+s+" loaded ["+l.startSN+"-"+l.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,t,d))}else this.warn("Invalid audio track id "+s)},e.onLevelLoading=function(a,t){this.switchLevel(t.level)},e.onLevelSwitching=function(a,t){this.switchLevel(t.level)},e.switchLevel=function(a){var t=this.hls.levels[a];if(t!=null&&t.audioGroupIds){var s=t.audioGroupIds[t.urlId];if(this.groupId!==s){this.groupId=s;var l=this.tracks.filter(function(d){return!s||d.groupId===s});this.selectDefaultTrack&&!l.some(function(d){return d.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var n={audioTracks:l};this.log("Updating audio tracks, "+l.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},e.onError=function(a,t){L.prototype.onError.call(this,a,t),!t.fatal&&t.context&&t.context.type===k.PlaylistContextType.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.retryLoadingOrFail(t)},e.setAudioTrack=function(a){var t=this.tracksInGroup;if(a<0||a>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var s=t[this.trackId];this.log("Now switching to audio-track index "+a);var l=t[a],n=l.id,d=l.groupId,p=d===void 0?"":d,g=l.name,v=l.type,r=l.url;if(this.trackId=a,this.trackName=g,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:p,name:g,type:v,url:r}),!l.details||l.details.live){var i=this.switchParams(l.url,s==null?void 0:s.details);this.loadPlaylist(i)}}},e.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,s=this.findTrackId(t)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},e.findTrackId=function(a){for(var t=this.tracksInGroup,s=0;s<t.length;s++){var l=t[s];if((!this.selectDefaultTrack||l.default)&&(!a||a===l.name))return l.id}return-1},e.loadPlaylist=function(a){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var s=t.id,l=t.groupId,n=t.url;if(a)try{n=a.addDirectives(n)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:l,deliveryDirectives:a||null})}},E=S,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}])&&I(E.prototype,c),S}(A.default);w.default=o},"./src/controller/base-playlist-controller.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return D});var R=h("./src/polyfills/number.ts"),T=h("./src/types/level.ts"),A=h("./src/controller/level-helper.ts"),k=h("./src/utils/logger.ts"),I=h("./src/errors.ts"),D=function(){function o(m,f){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=k.logger.log.bind(k.logger,f+":"),this.warn=k.logger.warn.bind(k.logger,f+":"),this.hls=m}var L=o.prototype;return L.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},L.onError=function(m,f){f.fatal&&f.type===I.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},L.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},L.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},L.stopLoad=function(){this.canLoad=!1,this.clearTimer()},L.switchParams=function(m,f){var S=f==null?void 0:f.renditionReports;if(S)for(var E=0;E<S.length;E++){var c=S[E],e=""+c.URI;if(e===m.substr(-e.length)){var a=parseInt(c["LAST-MSN"]),t=parseInt(c["LAST-PART"]);if(f&&this.hls.config.lowLatencyMode){var s=Math.min(f.age-f.partTarget,f.targetduration);t!==void 0&&s>f.partTarget&&(t+=1)}if(Object(R.isFiniteNumber)(a))return new T.HlsUrlParameters(a,Object(R.isFiniteNumber)(t)?t:void 0,T.HlsSkip.No)}}},L.loadPlaylist=function(m){},L.shouldLoadTrack=function(m){return this.canLoad&&m&&!!m.url&&(!m.details||m.details.live)},L.playlistLoaded=function(m,f,S){var E=this,c=f.details,e=f.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(c.advancedDateTime=Date.now()-a,c.live||S!=null&&S.live){if(c.reloaded(S),S&&this.log("live playlist "+m+" "+(c.advanced?"REFRESHED "+c.lastPartSn+"-"+c.lastPartIndex:"MISSED")),S&&c.fragments.length>0&&Object(A.mergeDetails)(S,c),!this.canLoad||!c.live)return;var t,s=void 0,l=void 0;if(c.canBlockReload&&c.endSN&&c.advanced){var n=this.hls.config.lowLatencyMode,d=c.lastPartSn,p=c.endSN,g=c.lastPartIndex,v=d===p;g!==-1?(s=v?p+1:d,l=v?n?0:g:g+1):s=p+1;var r=c.age,i=r+c.ageHeader,u=Math.min(i-c.partTarget,1.5*c.targetduration);if(u>0){if(S&&u>S.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+S.tuneInGoal+" to: "+u+" with playlist age: "+c.age),u=0;else{var y=Math.floor(u/c.targetduration);s+=y,l!==void 0&&(l+=Math.round(u%c.targetduration/c.partTarget)),this.log("CDN Tune-in age: "+c.ageHeader+"s last advanced "+r.toFixed(2)+"s goal: "+u+" skip sn "+y+" to part "+l)}c.tuneInGoal=u}if(t=this.getDeliveryDirectives(c,f.deliveryDirectives,s,l),n||!v)return void this.loadPlaylist(t)}else t=this.getDeliveryDirectives(c,f.deliveryDirectives,s,l);var b=Object(A.computeReloadInterval)(c,e);s!==void 0&&c.canBlockReload&&(b-=c.partTarget||1),this.log("reload live playlist "+m+" in "+Math.round(b)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(t)},b)}else this.clearTimer()},L.getDeliveryDirectives=function(m,f,S,E){var c=Object(T.getSkipValue)(m,S);return f!=null&&f.skip&&m.deltaUpdateFailed&&(S=f.msn,E=f.part,c=T.HlsSkip.No),new T.HlsUrlParameters(S,E,c)},L.retryLoadingOrFail=function(m){var f,S=this,E=this.hls.config,c=this.retryCount<E.levelLoadingMaxRetry;if(c)if(this.retryCount++,m.details.indexOf("LoadTimeOut")>-1&&(f=m.context)!==null&&f!==void 0&&f.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+m.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*E.levelLoadingRetryDelay,E.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+m.details+'"')}else this.warn('cannot recover from error "'+m.details+'"'),this.clearTimer(),m.fatal=!0;return c},o}()},"./src/controller/base-stream-controller.ts":function(N,w,h){h.r(w),h.d(w,"State",function(){return n}),h.d(w,"default",function(){return d});var R=h("./src/polyfills/number.ts"),T=h("./src/task-loop.ts"),A=h("./src/controller/fragment-tracker.ts"),k=h("./src/utils/buffer-helper.ts"),I=h("./src/utils/logger.ts"),D=h("./src/events.ts"),o=h("./src/errors.ts"),L=h("./src/types/transmuxer.ts"),m=h("./src/utils/mp4-tools.ts"),f=h("./src/utils/discontinuities.ts"),S=h("./src/controller/fragment-finders.ts"),E=h("./src/controller/level-helper.ts"),c=h("./src/loader/fragment-loader.ts"),e=h("./src/crypt/decrypter.ts"),a=h("./src/utils/time-ranges.ts"),t=h("./src/types/loader.ts");function s(p,g){for(var v=0;v<g.length;v++){var r=g[v];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(p,r.key,r)}}function l(p,g){return(l=Object.setPrototypeOf||function(v,r){return v.__proto__=r,v})(p,g)}var n={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"},d=function(p){var g,v;function r(b,_,x){var C;return(C=p.call(this)||this).hls=void 0,C.fragPrevious=null,C.fragCurrent=null,C.fragmentTracker=void 0,C.transmuxer=null,C._state=n.STOPPED,C.media=void 0,C.mediaBuffer=void 0,C.config=void 0,C.bitrateTest=!1,C.lastCurrentTime=0,C.nextLoadPosition=0,C.startPosition=0,C.loadedmetadata=!1,C.fragLoadError=0,C.retryDate=0,C.levels=null,C.fragmentLoader=void 0,C.levelLastLoaded=null,C.startFragRequested=!1,C.decrypter=void 0,C.initPTS=[],C.onvseeking=null,C.onvended=null,C.logPrefix="",C.log=void 0,C.warn=void 0,C.logPrefix=x,C.log=I.logger.log.bind(I.logger,x+":"),C.warn=I.logger.warn.bind(I.logger,x+":"),C.hls=b,C.fragmentLoader=new c.default(b.config),C.fragmentTracker=_,C.config=b.config,C.decrypter=new e.default(b,b.config),b.on(D.Events.KEY_LOADED,C.onKeyLoaded,function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(C)),C}v=p,(g=r).prototype=Object.create(v.prototype),g.prototype.constructor=g,l(g,v);var i,u,y=r.prototype;return y.doTick=function(){this.onTickEnd()},y.onTickEnd=function(){},y.startLoad=function(b){},y.stopLoad=function(){this.fragmentLoader.abort();var b=this.fragCurrent;b&&this.fragmentTracker.removeFragment(b),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=n.STOPPED},y._streamEnded=function(b,_){var x=this.fragCurrent,C=this.fragmentTracker;if(!_.live&&x&&x.sn===_.endSN&&!b.nextStart){var O=C.getState(x);return O===A.FragmentState.PARTIAL||O===A.FragmentState.OK}return!1},y.onMediaAttached=function(b,_){var x=this.media=this.mediaBuffer=_.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var C=this.config;this.levels&&C.autoStartLoad&&this.state===n.STOPPED&&this.startLoad(C.startPosition)},y.onMediaDetaching=function(){var b=this.media;b!=null&&b.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),b&&(b.removeEventListener("seeking",this.onvseeking),b.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},y.onMediaSeeking=function(){var b=this.config,_=this.fragCurrent,x=this.media,C=this.mediaBuffer,O=this.state,P=x?x.currentTime:0,F=k.BufferHelper.bufferInfo(C||x,P,b.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(P)?P.toFixed(3):P)+", state: "+O),O===n.ENDED)this.resetLoadingState();else if(_&&!F.len){var M=b.maxFragLookUpTolerance,B=_.start-M,U=P>_.start+_.duration+M;(P<B||U)&&(U&&_.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),_.loader.abort()),this.resetLoadingState())}x&&(this.lastCurrentTime=P),this.loadedmetadata||F.len||(this.nextLoadPosition=this.startPosition=P),this.tickImmediate()},y.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},y.onKeyLoaded=function(b,_){if(this.state===n.KEY_LOADING&&_.frag===this.fragCurrent&&this.levels){this.state=n.IDLE;var x=this.levels[_.frag.level].details;x&&this.loadFragment(_.frag,x,_.frag.start)}},y.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},y.onHandlerDestroyed=function(){this.state=n.STOPPED,this.hls.off(D.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,p.prototype.onHandlerDestroyed.call(this)},y.loadKey=function(b,_){this.log("Loading key for "+b.sn+" of ["+_.startSN+"-"+_.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level),this.state=n.KEY_LOADING,this.fragCurrent=b,this.hls.trigger(D.Events.KEY_LOADING,{frag:b})},y.loadFragment=function(b,_,x){this._loadFragForPlayback(b,_,x)},y._loadFragForPlayback=function(b,_,x){var C=this;this._doFragLoad(b,_,x,function(O){if(C.fragContextChanged(b))return C.warn("Fragment "+b.sn+(O.part?" p: "+O.part.index:"")+" of level "+b.level+" was dropped during download."),void C.fragmentTracker.removeFragment(b);b.stats.chunkCount++,C._handleFragmentLoadProgress(O)}).then(function(O){if(O){C.fragLoadError=0;var P=C.state;if(!C.fragContextChanged(b))return"payload"in O&&(C.log("Loaded fragment "+b.sn+" of level "+b.level),C.hls.trigger(D.Events.FRAG_LOADED,O),C.state===n.BACKTRACKING)?(C.fragmentTracker.backtrack(b,O),void C.resetFragmentLoading(b)):void C._handleFragmentLoadComplete(O);(P===n.FRAG_LOADING||P===n.BACKTRACKING||!C.fragCurrent&&P===n.PARSING)&&(C.fragmentTracker.removeFragment(b),C.state=n.IDLE)}}).catch(function(O){C.warn(O),C.resetFragmentLoading(b)})},y.flushMainBuffer=function(b,_,x){if(x===void 0&&(x=null),b-_){var C={startOffset:b,endOffset:_,type:x};this.fragLoadError=0,this.hls.trigger(D.Events.BUFFER_FLUSHING,C)}},y._loadInitSegment=function(b){var _=this;this._doFragLoad(b).then(function(x){if(!x||_.fragContextChanged(b)||!_.levels)throw new Error("init load aborted");return x}).then(function(x){var C=_.hls,O=x.payload,P=b.decryptdata;if(O&&O.byteLength>0&&P&&P.key&&P.iv&&P.method==="AES-128"){var F=self.performance.now();return _.decrypter.webCryptoDecrypt(new Uint8Array(O),P.key.buffer,P.iv.buffer).then(function(M){var B=self.performance.now();return C.trigger(D.Events.FRAG_DECRYPTED,{frag:b,payload:M,stats:{tstart:F,tdecrypt:B}}),x.payload=M,x})}return x}).then(function(x){var C=_.fragCurrent,O=_.hls,P=_.levels;if(!P)throw new Error("init load aborted, missing levels");var F=P[b.level].details;console.assert(F,"Level details are defined when init segment is loaded");var M=b.stats;_.state=n.IDLE,_.fragLoadError=0,b.data=new Uint8Array(x.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),x.frag===C&&O.trigger(D.Events.FRAG_BUFFERED,{stats:M,frag:C,part:null,id:b.type}),_.tick()}).catch(function(x){_.warn(x),_.resetFragmentLoading(b)})},y.fragContextChanged=function(b){var _=this.fragCurrent;return!b||!_||b.level!==_.level||b.sn!==_.sn||b.urlId!==_.urlId},y.fragBufferedComplete=function(b,_){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(_?" part: "+_.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+a.default.toString(k.BufferHelper.getBuffered(x))),this.state=n.IDLE,this.tick()},y._handleFragmentLoadComplete=function(b){var _=this.transmuxer;if(_){var x=b.frag,C=b.part,O=b.partsLoaded,P=!O||O.length===0||O.some(function(M){return!M}),F=new L.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,C?C.index:-1,!P);_.flush(F)}},y._handleFragmentLoadProgress=function(b){},y._doFragLoad=function(b,_,x,C){var O=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(b.start,x||0),this.config.lowLatencyMode&&_){var P=_.partList;if(P&&C){x>b.end&&_.fragmentHint&&(b=_.fragmentHint);var F=this.getNextPart(P,b,x);if(F>-1){var M=P[F];return this.log("Loading part sn: "+b.sn+" p: "+M.index+" cc: "+b.cc+" of playlist ["+_.startSN+"-"+_.endSN+"] parts [0-"+F+"-"+(P.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=n.FRAG_LOADING,this.hls.trigger(D.Events.FRAG_LOADING,{frag:b,part:P[F],targetBufferTime:x}),this.doFragPartsLoad(b,P,F,C).catch(function(B){return O.handleFragLoadError(B)})}if(!b.url||this.loadedEndOfParts(P,x))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(_?"of ["+_.startSN+"-"+_.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),Object(R.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=n.FRAG_LOADING,this.hls.trigger(D.Events.FRAG_LOADING,{frag:b,targetBufferTime:x}),this.fragmentLoader.load(b,C).catch(function(B){return O.handleFragLoadError(B)})},y.doFragPartsLoad=function(b,_,x,C){var O=this;return new Promise(function(P,F){var M=[];(function B(U){var j=_[U];O.fragmentLoader.loadPart(b,j,C).then(function(V){M[j.index]=V;var W=V.part;O.hls.trigger(D.Events.FRAG_LOADED,V);var X=_[U+1];if(!X||X.fragment!==b)return P({frag:b,part:W,partsLoaded:M});B(U+1)}).catch(F)})(x)})},y.handleFragLoadError=function(b){var _=b.data;return _&&_.details===o.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(_.frag,_.part):this.hls.trigger(D.Events.ERROR,_),null},y._handleTransmuxerFlush=function(b){var _=this.getCurrentContext(b);if(_&&this.state===n.PARSING){var x=_.frag,C=_.part,O=_.level,P=self.performance.now();x.stats.parsing.end=P,C&&(C.stats.parsing.end=P),this.updateLevelTiming(x,C,O,b.partial)}else this.fragCurrent||(this.state=n.IDLE)},y.getCurrentContext=function(b){var _=this.levels,x=b.level,C=b.sn,O=b.part;if(!_||!_[x])return this.warn("Levels object was unset while buffering fragment "+C+" of level "+x+". The current chunk will not be buffered."),null;var P=_[x],F=O>-1?Object(E.getPartWith)(P,C,O):null,M=F?F.fragment:Object(E.getFragmentWithSN)(P,C,this.fragCurrent);return M?{frag:M,part:F,level:P}:null},y.bufferFragmentData=function(b,_,x,C){if(b&&this.state===n.PARSING){var O=b.data1,P=b.data2,F=O;if(O&&P&&(F=Object(m.appendUint8Array)(O,P)),F&&F.length){var M={type:b.type,frag:_,part:x,chunkMeta:C,parent:_.type,data:F};this.hls.trigger(D.Events.BUFFER_APPENDING,M),b.dropped&&b.independent&&!x&&this.flushBufferGap(_)}}},y.flushBufferGap=function(b){var _=this.media;if(_)if(k.BufferHelper.isBuffered(_,_.currentTime)){var x=_.currentTime,C=k.BufferHelper.bufferInfo(_,x,0),O=b.duration,P=Math.min(2*this.config.maxFragLookUpTolerance,.25*O),F=Math.max(Math.min(b.start-P,C.end-P),x+P);b.start-F>P&&this.flushMainBuffer(F,b.start)}else this.flushMainBuffer(0,b.start)},y.getFwdBufferInfo=function(b,_){var x=this.config,C=this.getLoadPosition();if(!Object(R.isFiniteNumber)(C))return null;var O=k.BufferHelper.bufferInfo(b,C,x.maxBufferHole);if(O.len===0&&O.nextStart!==void 0){var P=this.fragmentTracker.getBufferedFrag(C,_);if(P&&O.nextStart<P.end)return k.BufferHelper.bufferInfo(b,C,Math.max(O.nextStart,x.maxBufferHole))}return O},y.getMaxBufferLength=function(b){var _,x=this.config;return _=b?Math.max(8*x.maxBufferSize/b,x.maxBufferLength):x.maxBufferLength,Math.min(_,x.maxMaxBufferLength)},y.reduceMaxBufferLength=function(b){var _=this.config,x=b||_.maxBufferLength;return _.maxMaxBufferLength>=x&&(_.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+_.maxMaxBufferLength+"s"),!0)},y.getNextFragment=function(b,_){var x,C,O=_.fragments,P=O.length;if(!P)return null;var F,M=this.config,B=O[0].start;if(_.live){var U=M.initialLiveManifestSize;if(P<U)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+U+")"),null;_.PTSKnown||this.startFragRequested||this.startPosition!==-1||(F=this.getInitialLiveFragment(_,O),this.startPosition=F?this.hls.liveSyncPosition||F.start:b)}else b<=B&&(F=O[0]);if(!F){var j=M.lowLatencyMode?_.partEnd:_.fragmentEnd;F=this.getFragmentAtPosition(b,j,_)}return(x=F)===null||x===void 0||!x.initSegment||(C=F)!==null&&C!==void 0&&C.initSegment.data||this.bitrateTest||(F=F.initSegment),F},y.getNextPart=function(b,_,x){for(var C=-1,O=!1,P=!0,F=0,M=b.length;F<M;F++){var B=b[F];if(P=P&&!B.independent,C>-1&&x<B.start)break;var U=B.loaded;!U&&(O||B.independent||P)&&B.fragment===_&&(C=F),O=U}return C},y.loadedEndOfParts=function(b,_){var x=b[b.length-1];return x&&_>x.start&&x.loaded},y.getInitialLiveFragment=function(b,_){var x=this.fragPrevious,C=null;if(x){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),C=Object(S.findFragmentByPDT)(_,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!C){var O=x.sn+1;if(O>=b.startSN&&O<=b.endSN){var P=_[O-b.startSN];x.cc===P.cc&&(C=P,this.log("Live playlist, switching playlist, load frag with next SN: "+C.sn))}C||(C=Object(S.findFragWithCC)(_,x.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+C.sn)}}else{var F=this.hls.liveSyncPosition;F!==null&&(C=this.getFragmentAtPosition(F,this.bitrateTest?b.fragmentEnd:b.edge,b))}return C},y.getFragmentAtPosition=function(b,_,x){var C,O=this.config,P=this.fragPrevious,F=x.fragments,M=x.endSN,B=x.fragmentHint,U=O.maxFragLookUpTolerance,j=!!(O.lowLatencyMode&&x.partList&&B);if(j&&B&&!this.bitrateTest&&(F=F.concat(B),M=B.sn),b<_){var V=b>_-U?0:U;C=Object(S.findFragmentByPTS)(P,F,b,V)}else C=F[F.length-1];if(C){var W=C.sn-x.startSN,X=P&&C.level===P.level,q=F[W+1];if(this.fragmentTracker.getState(C)===A.FragmentState.BACKTRACKED){C=null;for(var $=W;F[$]&&this.fragmentTracker.getState(F[$])===A.FragmentState.BACKTRACKED;)C=P?F[$--]:F[--$];C||(C=q)}else P&&C.sn===P.sn&&!j&&X&&(C.sn<M&&this.fragmentTracker.getState(q)!==A.FragmentState.OK?(this.log("SN "+C.sn+" just loaded, load next one: "+q.sn),C=q):C=null)}return C},y.synchronizeToLiveEdge=function(b){var _=this.config,x=this.media;if(x){var C=this.hls.liveSyncPosition,O=x.currentTime,P=b.fragments[0].start,F=b.edge,M=O>=P-_.maxFragLookUpTolerance&&O<=F;if(C!==null&&x.duration>C&&(O<C||!M)){var B=_.liveMaxLatencyDuration!==void 0?_.liveMaxLatencyDuration:_.liveMaxLatencyDurationCount*b.targetduration;(!M&&x.readyState<4||O<F-B)&&(this.loadedmetadata||(this.nextLoadPosition=C),x.readyState&&(this.warn("Playback: "+O.toFixed(3)+" is located too far from the end of live sliding playlist: "+F+", reset currentTime to : "+C.toFixed(3)),x.currentTime=C))}}},y.alignPlaylists=function(b,_){var x=this.levels,C=this.levelLastLoaded,O=this.fragPrevious,P=C!==null?x[C]:null,F=b.fragments.length;if(!F)return this.warn("No fragments in live playlist"),0;var M=b.fragments[0].start,B=!_,U=b.alignedSliding&&Object(R.isFiniteNumber)(M);if(B||!U&&!M){Object(f.alignStream)(O,P,b);var j=b.fragments[0].start;return this.log("Live playlist sliding: "+j.toFixed(2)+" start-sn: "+(_?_.startSN:"na")+"->"+b.startSN+" prev-sn: "+(O?O.sn:"na")+" fragments: "+F),j}return M},y.waitForCdnTuneIn=function(b){return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,3*b.partTarget)},y.setStartPosition=function(b,_){var x=this.startPosition;if(x<_&&(x=-1),x===-1||this.lastCurrentTime===-1){var C=b.startTimeOffset;Object(R.isFiniteNumber)(C)?(x=_+C,C<0&&(x+=b.totalduration),x=Math.min(Math.max(_,x),_+b.totalduration),this.log("Start time offset "+C+" found in playlist, adjust startPosition to "+x),this.startPosition=x):b.live?x=this.hls.liveSyncPosition||_:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},y.getLoadPosition=function(){var b=this.media,_=0;return this.loadedmetadata&&b?_=b.currentTime:this.nextLoadPosition&&(_=this.nextLoadPosition),_},y.handleFragLoadAborted=function(b,_){this.transmuxer&&b.sn!=="initSegment"&&b.stats.aborted&&(this.warn("Fragment "+b.sn+(_?" part"+_.index:"")+" of level "+b.level+" was aborted"),this.resetFragmentLoading(b))},y.resetFragmentLoading=function(b){this.fragCurrent&&this.fragContextChanged(b)||(this.state=n.IDLE)},y.onFragmentOrKeyLoadError=function(b,_){if(!_.fatal){var x=_.frag;if(x&&x.type===b){var C=this.fragCurrent;console.assert(C&&x.sn===C.sn&&x.level===C.level&&x.urlId===C.urlId,"Frag load error must match current frag to retry");var O=this.config;if(this.fragLoadError+1<=O.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(x.level))return;var P=Math.min(Math.pow(2,this.fragLoadError)*O.fragLoadingRetryDelay,O.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+b+" "+x.level+" failed to load, retrying in "+P+"ms"),this.retryDate=self.performance.now()+P,this.fragLoadError++,this.state=n.FRAG_LOADING_WAITING_RETRY}else _.levelRetry?(b===t.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=n.IDLE):(I.logger.error(_.details+" reaches max retry, redispatch as fatal ..."),_.fatal=!0,this.hls.stopLoad(),this.state=n.ERROR)}}},y.afterBufferFlushed=function(b,_,x){if(b){var C=k.BufferHelper.getBuffered(b);this.fragmentTracker.detectEvictedFragments(_,C,x),this.state===n.ENDED&&this.resetLoadingState()}},y.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=n.IDLE},y.resetLiveStartWhenNotLoaded=function(b){if(!this.loadedmetadata){this.startFragRequested=!1;var _=this.levels?this.levels[b].details:null;if(_!=null&&_.live)return this.startPosition=-1,this.setStartPosition(_,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},y.updateLevelTiming=function(b,_,x,C){var O=this,P=x.details;console.assert(!!P,"level.details must be defined"),Object.keys(b.elementaryStreams).reduce(function(F,M){var B=b.elementaryStreams[M];if(B){var U=B.endPTS-B.startPTS;if(U<=0)return O.warn("Could not parse fragment "+b.sn+" "+M+" duration reliably ("+U+") resetting transmuxer to fallback to playlist timing"),O.resetTransmuxer(),F||!1;var j=C?0:Object(E.updateFragPTSDTS)(P,b,B.startPTS,B.endPTS,B.startDTS,B.endDTS);return O.hls.trigger(D.Events.LEVEL_PTS_UPDATED,{details:P,level:x,drift:j,type:M,frag:b,start:B.startPTS,end:B.endPTS}),!0}return F},!1)?(this.state=n.PARSED,this.hls.trigger(D.Events.FRAG_PARSED,{frag:b,part:_})):this.resetLoadingState()},y.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=r,(u=[{key:"state",get:function(){return this._state},set:function(b){var _=this._state;_!==b&&(this._state=b,this.log(_+"->"+b))}}])&&s(i.prototype,u),r}(T.default)},"./src/controller/buffer-controller.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return S});var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts"),k=h("./src/errors.ts"),I=h("./src/utils/buffer-helper.ts"),D=h("./src/utils/mediasource-helper.ts"),o=h("./src/loader/fragment.ts"),L=h("./src/controller/buffer-operation-queue.ts"),m=Object(D.getMediaSource)(),f=/([ha]vc.)(?:\.[^.,]+)+/,S=function(){function E(e){var a=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 t=a.hls,s=a.media,l=a.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),s&&(a.updateMediaElementDuration(),t.trigger(T.Events.MEDIA_ATTACHED,{media:s})),l&&l.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var c=E.prototype;return c.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},c.destroy=function(){this.unregisterListeners(),this.details=null},c.registerListeners=function(){var e=this.hls;e.on(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(T.Events.BUFFER_RESET,this.onBufferReset,this),e.on(T.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(T.Events.BUFFER_EOS,this.onBufferEos,this),e.on(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(T.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(T.Events.FRAG_PARSED,this.onFragParsed,this),e.on(T.Events.FRAG_CHANGED,this.onFragChanged,this)},c.unregisterListeners=function(){var e=this.hls;e.off(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(T.Events.BUFFER_RESET,this.onBufferReset,this),e.off(T.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(T.Events.BUFFER_EOS,this.onBufferEos,this),e.off(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(T.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(T.Events.FRAG_PARSED,this.onFragParsed,this),e.off(T.Events.FRAG_CHANGED,this.onFragChanged,this)},c._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},c.onManifestParsed=function(e,a){var t=2;(a.audio&&!a.video||!a.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},c.onMediaAttaching=function(e,a){var t=this.media=a.media;if(t&&m){var s=this.mediaSource=new m;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(s),this._objectUrl=t.src}},c.onMediaDetaching=function(){var e=this.media,a=this.mediaSource,t=this._objectUrl;if(a){if(A.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(s){A.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(t&&self.URL.revokeObjectURL(t),e.src===t?(e.removeAttribute("src"),e.load()):A.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(T.Events.MEDIA_DETACHED,void 0)},c.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(a){var t=e.sourceBuffer[a];try{t&&(e.removeBufferListeners(a),e.mediaSource&&e.mediaSource.removeSourceBuffer(t),e.sourceBuffer[a]=void 0)}catch(s){A.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",s)}}),this._initSourceBuffer()},c.onBufferCodecs=function(e,a){var t=this,s=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(l){if(s){var n=t.tracks[l];if(n&&typeof n.buffer.changeType=="function"){var d=a[l],p=d.codec,g=d.levelCodec,v=d.container;if((n.levelCodec||n.codec).replace(f,"$1")!==(g||p).replace(f,"$1")){var r=v+";codecs="+(g||p);t.appendChangeType(l,r)}}}else t.pendingTracks[l]=a[l]}),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},c.appendChangeType=function(e,a){var t=this,s=this.operationQueue,l={execute:function(){var n=t.sourceBuffer[e];n&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+a),n.changeType(a)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(n){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",n)}};s.append(l,e)},c.onBufferAppending=function(e,a){var t=this,s=this.hls,l=this.operationQueue,n=this.tracks,d=a.data,p=a.type,g=a.frag,v=a.part,r=a.chunkMeta,i=r.buffering[p],u=self.performance.now();i.start=u;var y=g.stats.buffering,b=v?v.stats.buffering:null;y.start===0&&(y.start=u),b&&b.start===0&&(b.start=u);var _=n.audio,x=p==="audio"&&r.id===1&&(_==null?void 0:_.container)==="audio/mpeg",C={execute:function(){if(i.executeStart=self.performance.now(),x){var O=t.sourceBuffer[p];if(O){var P=g.start-O.timestampOffset;Math.abs(P)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+P+") sn: "+g.sn+")"),O.timestampOffset=g.start)}}t.appendExecutor(d,p)},onStart:function(){},onComplete:function(){var O=self.performance.now();i.executeEnd=i.end=O,y.first===0&&(y.first=O),b&&b.first===0&&(b.first=O);var P=t.sourceBuffer,F={};for(var M in P)F[M]=I.BufferHelper.getBuffered(P[M]);t.appendError=0,t.hls.trigger(T.Events.BUFFER_APPENDED,{type:p,frag:g,part:v,chunkMeta:r,parent:g.type,timeRanges:F})},onError:function(O){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",O);var P={type:k.ErrorTypes.MEDIA_ERROR,parent:g.type,details:k.ErrorDetails.BUFFER_APPEND_ERROR,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=k.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,P.details=k.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>s.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),P.fatal=!0)),s.trigger(T.Events.ERROR,P)}};l.append(C,p)},c.onBufferFlushing=function(e,a){var t=this,s=this.operationQueue,l=function(n){return{execute:t.removeExecutor.bind(t,n,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){t.hls.trigger(T.Events.BUFFER_FLUSHED,{type:n})},onError:function(d){A.logger.warn("[buffer-controller]: Failed to remove from "+n+" SourceBuffer",d)}}};a.type?s.append(l(a.type),a.type):this.getSourceBufferTypes().forEach(function(n){s.append(l(n),n)})},c.onFragParsed=function(e,a){var t=this,s=a.frag,l=a.part,n=[],d=l?l.elementaryStreams:s.elementaryStreams;d[o.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(d[o.ElementaryStreamTypes.AUDIO]&&n.push("audio"),d[o.ElementaryStreamTypes.VIDEO]&&n.push("video")),n.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(function(){var p=self.performance.now();s.stats.buffering.end=p,l&&(l.stats.buffering.end=p);var g=l?l.stats:s.stats;t.hls.trigger(T.Events.FRAG_BUFFERED,{frag:s,part:l,stats:g,id:s.type})},n)},c.onFragChanged=function(e,a){this.flushBackBuffer()},c.onBufferEos=function(e,a){var t=this;this.getSourceBufferTypes().reduce(function(s,l){var n=t.sourceBuffer[l];return a.type&&a.type!==l||n&&!n.ended&&(n.ended=!0,A.logger.log("[buffer-controller]: "+l+" sourceBuffer now EOS")),s&&!(n&&!n.ended)},!0)&&this.blockBuffers(function(){var s=t.mediaSource;s&&s.readyState==="open"&&s.endOfStream()})},c.onLevelUpdated=function(e,a){var t=a.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},c.flushBackBuffer=function(){var e=this.hls,a=this.details,t=this.media,s=this.sourceBuffer;if(t&&a!==null){var l=this.getSourceBufferTypes();if(l.length){var n=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(R.isFiniteNumber)(n)&&!(n<0)){var d=t.currentTime,p=a.levelTargetDuration,g=Math.max(n,p),v=Math.floor(d/p)*p-g;l.forEach(function(r){var i=s[r];if(i){var u=I.BufferHelper.getBuffered(i);u.length>0&&v>u.start(0)&&(e.trigger(T.Events.BACK_BUFFER_REACHED,{bufferEnd:v}),a.live&&e.trigger(T.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v}),e.trigger(T.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:r}))}})}}}},c.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,a=this.hls,t=this.media,s=this.mediaSource,l=e.fragments[0].start+e.totalduration,n=t.duration,d=Object(R.isFiniteNumber)(s.duration)?s.duration:0;e.live&&a.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(l>d&&l>n||!Object(R.isFiniteNumber)(n))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),s.duration=l)}},c.updateSeekableRange=function(e){var a=this.mediaSource,t=e.fragments;if(t.length&&e.live&&a!=null&&a.setLiveSeekableRange){var s=Math.max(0,t[0].start),l=Math.max(s,s+e.totalduration);a.setLiveSeekableRange(s,l)}},c.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,a=this.operationQueue,t=this.pendingTracks,s=Object.keys(t).length;if(s&&!e||s===2){this.createSourceBuffers(t),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0)return void this.hls.trigger(T.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});l.forEach(function(n){a.executeNext(n)})}},c.createSourceBuffers=function(e){var a=this.sourceBuffer,t=this.mediaSource;if(!t)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var l in e)if(!a[l]){var n=e[l];if(!n)throw Error("source buffer exists for track "+l+", however track does not");var d=n.levelCodec||n.codec,p=n.container+";codecs="+d;A.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var g=a[l]=t.addSourceBuffer(p),v=l;this.addBufferListener(v,"updatestart",this._onSBUpdateStart),this.addBufferListener(v,"updateend",this._onSBUpdateEnd),this.addBufferListener(v,"error",this._onSBUpdateError),this.tracks[l]={buffer:g,codec:d,container:n.container,levelCodec:n.levelCodec,id:n.id},s++}catch(r){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+r.message),this.hls.trigger(T.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:r,mimeType:p})}}s&&this.hls.trigger(T.Events.BUFFER_CREATED,{tracks:this.tracks})},c._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},c._onSBUpdateEnd=function(e){var a=this.operationQueue;a.current(e).onComplete(),a.shiftAndExecuteNext(e)},c._onSBUpdateError=function(e,a){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(T.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(a)},c.removeExecutor=function(e,a,t){var s=this.media,l=this.mediaSource,n=this.operationQueue,d=this.sourceBuffer[e];if(!s||!l||!d)return A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(e);var p=Object(R.isFiniteNumber)(s.duration)?s.duration:1/0,g=Object(R.isFiniteNumber)(l.duration)?l.duration:1/0,v=Math.max(0,a),r=Math.min(t,p,g);r>v?(A.logger.log("[buffer-controller]: Removing ["+v+","+r+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(v,r)):n.shiftAndExecuteNext(e)},c.appendExecutor=function(e,a){var t=this.operationQueue,s=this.sourceBuffer[a];if(!s)return A.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),void t.shiftAndExecuteNext(a);s.ended=!1,console.assert(!s.updating,a+" sourceBuffer must not be updating"),s.appendBuffer(e)},c.blockBuffers=function(e,a){var t=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length)return A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(e);var s=this.operationQueue,l=a.map(function(n){return s.appendBlocker(n)});Promise.all(l).then(function(){e(),a.forEach(function(n){var d=t.sourceBuffer[n];d&&d.updating||s.shiftAndExecuteNext(n)})})},c.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},c.addBufferListener=function(e,a,t){var s=this.sourceBuffer[e];if(s){var l=t.bind(this,e);this.listeners[e].push({event:a,listener:l}),s.addEventListener(a,l)}},c.removeBufferListeners=function(e){var a=this.sourceBuffer[e];a&&this.listeners[e].forEach(function(t){a.removeEventListener(t.event,t.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return T});var R=h("./src/utils/logger.ts"),T=function(){function A(I){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=I}var k=A.prototype;return k.append=function(I,D){var o=this.queues[D];o.push(I),o.length===1&&this.buffers[D]&&this.executeNext(D)},k.insertAbort=function(I,D){this.queues[D].unshift(I),this.executeNext(D)},k.appendBlocker=function(I){var D,o=new Promise(function(m){D=m}),L={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,I),o},k.executeNext=function(I){var D=this.buffers,o=this.queues,L=D[I],m=o[I];if(m.length){var f=m[0];try{f.execute()}catch(S){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),f.onError(S),L&&L.updating||(m.shift(),this.executeNext(I))}}},k.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},k.current=function(I){return this.queues[I][0]},A}()},"./src/controller/cap-level-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts");function T(k,I){for(var D=0;D<I.length;D++){var o=I[D];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(k,o.key,o)}}var A=function(){function k(m){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=m,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var I,D,o,L=k.prototype;return L.setStreamController=function(m){this.streamController=m},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var m=this.hls;m.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var m=this.hls;m.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(m,f){k.isLevelAllowed(f.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(f.droppedLevel)},L.onMediaAttaching=function(m,f){this.media=f.media instanceof HTMLVideoElement?f.media:null},L.onManifestParsed=function(m,f){var S=this.hls;this.restrictedLevels=[],this.firstLevel=f.firstLevel,S.config.capLevelToPlayerSize&&f.video&&this.startCapping()},L.onBufferCodecs=function(m,f){this.hls.config.capLevelToPlayerSize&&f.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var f=this.hls;f.autoLevelCapping=this.getMaxLevel(m.length-1),f.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=f.autoLevelCapping}}},L.getMaxLevel=function(m){var f=this,S=this.hls.levels;if(!S.length)return-1;var E=S.filter(function(c,e){return k.isLevelAllowed(e,f.restrictedLevels)&&e<=m});return this.clientRect=null,k.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},L.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())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,f={width:0,height:0};if(m){var S=m.getBoundingClientRect();f.width=S.width,f.height=S.height,f.width||f.height||(f.width=S.right-S.left||m.width||0,f.height=S.bottom-S.top||m.height||0)}return this.clientRect=f,f},k.isLevelAllowed=function(m,f){return f===void 0&&(f=[]),f.indexOf(m)===-1},k.getMaxLevelByMediaSize=function(m,f,S){if(!m||!m.length)return-1;for(var E,c,e=m.length-1,a=0;a<m.length;a+=1){var t=m[a];if((t.width>=f||t.height>=S)&&(E=t,!(c=m[a+1])||E.width!==c.width||E.height!==c.height)){e=a;break}}return e},I=k,o=[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}],(D=[{key:"mediaWidth",get:function(){return this.getDimensions().width*k.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*k.contentScaleFactor}}])&&T(I.prototype,D),o&&T(I,o),k}();w.default=A},"./src/controller/eme-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/utils/logger.ts"),k=h("./src/utils/mediakeys-helper.ts");function I(o,L){for(var m=0;m<L.length;m++){var f=L[m];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(o,f.key,f)}}var D=function(){function o(S){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=S,this._config=S.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var L,m,f=o.prototype;return f.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},f._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},f._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},f.getLicenseServerUrl=function(S){switch(S){case k.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+S+'"')},f._attemptKeySystemAccess=function(S,E,c){var e=this,a=function(s,l,n,d){switch(s){case k.KeySystems.WIDEVINE:return function(p,g,v){var r={audioCapabilities:[],videoCapabilities:[]};return p.forEach(function(i){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:v.audioRobustness||""})}),g.forEach(function(i){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:v.videoRobustness||""})}),[r]}(l,n,d);default:throw new Error("Unknown key-system: "+s)}}(S,E,c,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var t=this.requestMediaKeySystemAccess(S,a);this.mediaKeysPromise=t.then(function(s){return e._onMediaKeySystemAccessObtained(S,s)}),t.catch(function(s){A.logger.error('Failed to obtain key-system "'+S+'" access:',s)})},f._onMediaKeySystemAccessObtained=function(S,E){var c=this;A.logger.log('Access for key-system "'+S+'" obtained');var e={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:E,mediaKeySystemDomain:S};this._mediaKeysList.push(e);var a=Promise.resolve().then(function(){return E.createMediaKeys()}).then(function(t){return e.mediaKeys=t,A.logger.log('Media-keys created for key-system "'+S+'"'),c._onMediaKeysCreated(),t});return a.catch(function(t){A.logger.error("Failed to create media-keys:",t)}),a},f._onMediaKeysCreated=function(){var S=this;this._mediaKeysList.forEach(function(E){E.mediaKeysSession||(E.mediaKeysSession=E.mediaKeys.createSession(),S._onNewMediaKeySession(E.mediaKeysSession))})},f._onNewMediaKeySession=function(S){var E=this;A.logger.log("New key-system session "+S.sessionId),S.addEventListener("message",function(c){E._onKeySessionMessage(S,c.message)},!1)},f._onKeySessionMessage=function(S,E){A.logger.log("Got EME message event, creating license request"),this._requestLicense(E,function(c){A.logger.log("Received license data (length: "+(c&&c.byteLength)+"), updating key-session"),S.update(c)})},f.onMediaEncrypted=function(S){var E=this;if(A.logger.log('Media is encrypted using "'+S.initDataType+'" init data type'),!this.mediaKeysPromise)return A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var c=function(e){E._media&&(E._attemptSetMediaKeys(e),E._generateRequestWithPreferredKeySession(S.initDataType,S.initData))};this.mediaKeysPromise.then(c).catch(c)},f._attemptSetMediaKeys=function(S){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var E=this._mediaKeysList[0];if(!E||!E.mediaKeys)return A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(E.mediaKeys),this._hasSetMediaKeys=!0}},f._generateRequestWithPreferredKeySession=function(S,E){var c=this,e=this._mediaKeysList[0];if(!e)return A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(e.mediaKeysSessionInitialized)A.logger.warn("Key-Session already initialized but requested again");else{var a=e.mediaKeysSession;if(!a)return A.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!E)return A.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});A.logger.log('Generating key-session request for "'+S+'" init data type'),e.mediaKeysSessionInitialized=!0,a.generateRequest(S,E).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(t){A.logger.error("Error generating key-session request:",t),c.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})}},f._createLicenseXhr=function(S,E,c){var e=new XMLHttpRequest;e.responseType="arraybuffer",e.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,e,S,E,c);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,e,S),a=void 0}catch(t){A.logger.error(t)}try{e.readyState||e.open("POST",S,!0),a&&a.call(this.hls,e,S)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return e},f._onLicenseRequestReadyStageChange=function(S,E,c,e){switch(S.readyState){case 4:if(S.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var a=S.response,t=this._licenseResponseCallback;if(t)try{a=t.call(this.hls,S,E)}catch(l){A.logger.error(l)}e(a)}else{if(A.logger.error("License Request XHR failed ("+E+"). Status: "+S.status+" ("+S.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var s=3-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+s+" attempts left"),this._requestLicense(c,e)}}},f._generateLicenseRequestChallenge=function(S,E){switch(S.mediaKeySystemDomain){case k.KeySystems.WIDEVINE:return E}throw new Error("unsupported key-system: "+S.mediaKeySystemDomain)},f._requestLicense=function(S,E){A.logger.log("Requesting content license for key-system");var c=this._mediaKeysList[0];if(!c)return A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var e=this.getLicenseServerUrl(c.mediaKeySystemDomain),a=this._createLicenseXhr(e,S,E);A.logger.log("Sending license request to URL: "+e);var t=this._generateLicenseRequestChallenge(c,S);a.send(t)}catch(s){A.logger.error("Failure requesting DRM license: "+s),this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},f.onMediaAttached=function(S,E){if(this._emeEnabled){var c=E.media;this._media=c,c.addEventListener("encrypted",this._onMediaEncrypted)}},f.onMediaDetached=function(){var S=this._media,E=this._mediaKeysList;S&&(S.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(E.map(function(c){if(c.mediaKeysSession)return c.mediaKeysSession.close().catch(function(){})})).then(function(){return S.setMediaKeys(null)}).catch(function(){}))},f.onManifestParsed=function(S,E){if(this._emeEnabled){var c=E.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),e=E.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(k.KeySystems.WIDEVINE,c,e)}},L=o,(m=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&I(L.prototype,m),o}();w.default=D},"./src/controller/fps-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts"),T=h("./src/utils/logger.ts"),A=function(){function k(D){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=D,this.registerListeners()}var I=k.prototype;return I.setStreamController=function(D){this.streamController=D},I.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(D,o){var L=this.hls.config;if(L.capLevelOnFPSDrop){var m=o.media instanceof self.HTMLVideoElement?o.media:null;this.media=m,m&&typeof m.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(D,o,L){var m=performance.now();if(o){if(this.lastTime){var f=m-this.lastTime,S=L-this.lastDroppedFrames,E=o-this.lastDecodedFrames,c=1e3*S/f,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:S,currentDecoded:E,totalDroppedFrames:L}),c>0&&S>e.config.fpsDroppedMonitoringThreshold*E){var a=e.currentLevel;T.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=a)&&(a-=1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:e.currentLevel}),e.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=m,this.lastDroppedFrames=L,this.lastDecodedFrames=o}},I.checkFPSInterval=function(){var D=this.media;if(D)if(this.isVideoPlaybackQualityAvailable){var o=D.getVideoPlaybackQuality();this.checkFPS(D,o.totalVideoFrames,o.droppedVideoFrames)}else this.checkFPS(D,D.webkitDecodedFrameCount,D.webkitDroppedFrameCount)},k}();w.default=A},"./src/controller/fragment-finders.ts":function(N,w,h){h.r(w),h.d(w,"findFragmentByPDT",function(){return A}),h.d(w,"findFragmentByPTS",function(){return k}),h.d(w,"fragmentWithinToleranceTest",function(){return I}),h.d(w,"pdtWithinToleranceTest",function(){return D}),h.d(w,"findFragWithCC",function(){return o});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/binary-search.ts");function A(L,m,f){if(m===null||!Array.isArray(L)||!L.length||!Object(R.isFiniteNumber)(m)||m<(L[0].programDateTime||0)||m>=(L[L.length-1].endProgramDateTime||0))return null;f=f||0;for(var S=0;S<L.length;++S){var E=L[S];if(D(m,f,E))return E}return null}function k(L,m,f,S){f===void 0&&(f=0),S===void 0&&(S=0);var E=null;if(L?E=m[L.sn-m[0].sn+1]||null:f===0&&m[0].start===0&&(E=m[0]),E&&I(f,S,E)===0)return E;var c=T.default.search(m,I.bind(null,f,S));return c||E}function I(L,m,f){L===void 0&&(L=0),m===void 0&&(m=0);var S=Math.min(m,f.duration+(f.deltaPTS?f.deltaPTS:0));return f.start+f.duration-S<=L?1:f.start-S>L&&f.start?-1:0}function D(L,m,f){var S=1e3*Math.min(m,f.duration+(f.deltaPTS?f.deltaPTS:0));return(f.endProgramDateTime||0)-S>L}function o(L,m){return T.default.search(L,function(f){return f.cc<m?1:f.cc>m?-1:0})}},"./src/controller/fragment-tracker.ts":function(N,w,h){h.r(w),h.d(w,"FragmentState",function(){return R}),h.d(w,"FragmentTracker",function(){return I});var R,T,A=h("./src/events.ts"),k=h("./src/types/loader.ts");(T=R||(R={})).NOT_LOADED="NOT_LOADED",T.BACKTRACKED="BACKTRACKED",T.APPENDING="APPENDING",T.PARTIAL="PARTIAL",T.OK="OK";var I=function(){function L(f){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=f,this._registerListeners()}var m=L.prototype;return m._registerListeners=function(){var f=this.hls;f.on(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),f.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var f=this.hls;f.off(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),f.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(f,S){if(S===k.PlaylistLevelType.MAIN){var E=this.activeFragment,c=this.activeParts;if(!E)return null;if(c)for(var e=c.length;e--;){var a=c[e],t=a?a.end:E.appendedPTS;if(a.start<=f&&t!==void 0&&f<=t)return e>9&&(this.activeParts=c.slice(e-9)),a}else if(E.start<=f&&E.appendedPTS!==void 0&&f<=E.appendedPTS)return E}return this.getBufferedFrag(f,S)},m.getBufferedFrag=function(f,S){for(var E=this.fragments,c=Object.keys(E),e=c.length;e--;){var a=E[c[e]];if((a==null?void 0:a.body.type)===S&&a.buffered){var t=a.body;if(t.start<=f&&f<=t.end)return t}}return null},m.detectEvictedFragments=function(f,S,E){var c=this;Object.keys(this.fragments).forEach(function(e){var a=c.fragments[e];if(a)if(a.buffered){var t=a.range[f];t&&t.time.some(function(s){var l=!c.isTimeBuffered(s.startPTS,s.endPTS,S);return l&&c.removeFragment(a.body),l})}else a.body.type===E&&c.removeFragment(a.body)})},m.detectPartialFragments=function(f){var S=this,E=this.timeRanges,c=f.frag,e=f.part;if(E&&c.sn!=="initSegment"){var a=o(c),t=this.fragments[a];t&&(Object.keys(E).forEach(function(s){var l=c.elementaryStreams[s];if(l){var n=E[s],d=e!==null||l.partial===!0;t.range[s]=S.getBufferedTimes(c,e,d,n)}}),t.backtrack=t.loaded=null,Object.keys(t.range).length?t.buffered=!0:this.removeFragment(t.body))}},m.fragBuffered=function(f){var S=o(f),E=this.fragments[S];E&&(E.backtrack=E.loaded=null,E.buffered=!0)},m.getBufferedTimes=function(f,S,E,c){for(var e={time:[],partial:E},a=S?S.start:f.start,t=S?S.end:f.end,s=f.minEndPTS||t,l=f.maxStartPTS||a,n=0;n<c.length;n++){var d=c.start(n)-this.bufferPadding,p=c.end(n)+this.bufferPadding;if(l>=d&&s<=p){e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});break}if(a<p&&t>d)e.partial=!0,e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});else if(t<=d)break}return e},m.getPartialFragment=function(f){var S,E,c,e=null,a=0,t=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(function(l){var n=s[l];n&&D(n)&&(E=n.body.start-t,c=n.body.end+t,f>=E&&f<=c&&(S=Math.min(f-E,c-f),a<=S&&(e=n.body,a=S)))}),e},m.getState=function(f){var S=o(f),E=this.fragments[S];return E?E.buffered?D(E)?R.PARTIAL:R.OK:E.backtrack?R.BACKTRACKED:R.APPENDING:R.NOT_LOADED},m.backtrack=function(f,S){var E=o(f),c=this.fragments[E];if(!c||c.backtrack)return null;var e=c.backtrack=S||c.loaded;return c.loaded=null,e},m.getBacktrackData=function(f){var S=o(f),E=this.fragments[S];if(E){var c,e=E.backtrack;if(e!=null&&(c=e.payload)!==null&&c!==void 0&&c.byteLength)return e;this.removeFragment(f)}return null},m.isTimeBuffered=function(f,S,E){for(var c,e,a=0;a<E.length;a++){if(c=E.start(a)-this.bufferPadding,e=E.end(a)+this.bufferPadding,f>=c&&S<=e)return!0;if(S<=c)return!1}return!1},m.onFragLoaded=function(f,S){var E=S.frag,c=S.part;if(E.sn!=="initSegment"&&!E.bitrateTest&&!c){var e=o(E);this.fragments[e]={body:E,loaded:S,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(f,S){var E=this,c=S.frag,e=S.part,a=S.timeRanges;if(c.type===k.PlaylistLevelType.MAIN)if(this.activeFragment=c,e){var t=this.activeParts;t||(this.activeParts=t=[]),t.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(s){var l=a[s];if(E.detectEvictedFragments(s,l),!e)for(var n=0;n<l.length;n++)c.appendedPTS=Math.max(l.end(n),c.appendedPTS||0)})},m.onFragBuffered=function(f,S){this.detectPartialFragments(S)},m.hasFragment=function(f){var S=o(f);return!!this.fragments[S]},m.removeFragmentsInRange=function(f,S,E){var c=this;Object.keys(this.fragments).forEach(function(e){var a=c.fragments[e];if(a&&a.buffered){var t=a.body;t.type===E&&t.start<S&&t.end>f&&c.removeFragment(t)}})},m.removeFragment=function(f){var S=o(f);f.stats.loaded=0,f.clearElementaryStreamInfo(),delete this.fragments[S]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function D(L){var m,f;return L.buffered&&(((m=L.range.video)===null||m===void 0?void 0:m.partial)||((f=L.range.audio)===null||f===void 0?void 0:f.partial))}function o(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(N,w,h){h.r(w),h.d(w,"STALL_MINIMUM_DURATION_MS",function(){return I}),h.d(w,"MAX_START_GAP_JUMP",function(){return D}),h.d(w,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return o}),h.d(w,"SKIP_BUFFER_RANGE_START",function(){return L}),h.d(w,"default",function(){return m});var R=h("./src/utils/buffer-helper.ts"),T=h("./src/errors.ts"),A=h("./src/events.ts"),k=h("./src/utils/logger.ts"),I=250,D=2,o=.1,L=.05,m=function(){function f(E,c,e,a){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=E,this.media=c,this.fragmentTracker=e,this.hls=a}var S=f.prototype;return S.destroy=function(){this.hls=this.fragmentTracker=this.media=null},S.poll=function(E){var c=this.config,e=this.media,a=this.stalled,t=e.currentTime,s=e.seeking,l=this.seeking&&!s,n=!this.seeking&&s;if(this.seeking=s,t===E){if((n||l)&&(this.stalled=null),!e.paused&&!e.ended&&e.playbackRate!==0&&R.BufferHelper.getBuffered(e).length){var d=R.BufferHelper.bufferInfo(e,t,0),p=d.len>0,g=d.nextStart||0;if(p||g){if(s){var v=d.len>D,r=!g||g-t>D&&!this.fragmentTracker.getPartialFragment(t);if(v||r)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var i,u=Math.max(g,d.start||0)-t,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=!(y==null||(i=y.details)===null||i===void 0)&&i.live?2*y.details.targetduration:D;if(u>0&&u<=b)return void this._trySkipBufferHole(null)}var _=self.performance.now();if(a!==null){var x=_-a;!s&&x>=I&&this._reportStall(d.len);var C=R.BufferHelper.bufferInfo(e,t,c.maxBufferHole);this._tryFixBufferStall(C,x)}else this.stalled=_}}}else if(this.moved=!0,a!==null){if(this.stallReported){var O=self.performance.now()-a;k.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},S._tryFixBufferStall=function(E,c){var e=this.config,a=this.fragmentTracker,t=this.media.currentTime,s=a.getPartialFragment(t);s&&this._trySkipBufferHole(s)||E.len>e.maxBufferHole&&c>1e3*e.highBufferWatchdogPeriod&&(k.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},S._reportStall=function(E){var c=this.hls,e=this.media;this.stallReported||(this.stallReported=!0,k.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+E+")"),c.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E}))},S._trySkipBufferHole=function(E){for(var c=this.config,e=this.hls,a=this.media,t=a.currentTime,s=0,l=R.BufferHelper.getBuffered(a),n=0;n<l.length;n++){var d=l.start(n);if(t+c.maxBufferHole>=s&&t<d){var p=Math.max(d+L,a.currentTime+o);return k.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+p),this.moved=!0,this.stalled=null,a.currentTime=p,E&&e.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+t+" to "+p,frag:E}),p}s=l.end(n)}return 0},S._tryNudgeBuffer=function(){var E=this.config,c=this.hls,e=this.media,a=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<E.nudgeMaxRetry){var s=a+t*E.nudgeOffset;k.logger.warn("Nudging 'currentTime' from "+a+" to "+s),e.currentTime=s,c.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else k.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+E.nudgeMaxRetry+" nudges"),c.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},f}()},"./src/controller/id3-track-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts"),T=h("./src/utils/texttrack-utils.ts"),A=h("./src/demux/id3.ts"),k=function(){function I(o){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=o,this._registerListeners()}var D=I.prototype;return D.destroy=function(){this._unregisterListeners()},D._registerListeners=function(){var o=this.hls;o.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),o.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D._unregisterListeners=function(){var o=this.hls;o.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),o.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D.onMediaAttached=function(o,L){this.media=L.media},D.onMediaDetaching=function(){this.id3Track&&(Object(T.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},D.getID3Track=function(o){if(this.media){for(var L=0;L<o.length;L++){var m=o[L];if(m.kind==="metadata"&&m.label==="id3")return Object(T.sendAddTrackEvent)(m,this.media),m}return this.media.addTextTrack("metadata","id3")}},D.onFragParsingMetadata=function(o,L){if(this.media){var m=L.frag,f=L.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var S=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,E=0;E<f.length;E++){var c=A.getID3Frames(f[E].data);if(c){var e=f[E].pts,a=E<f.length-1?f[E+1].pts:m.end;a-e<=0&&(a=e+.25);for(var t=0;t<c.length;t++){var s=c[t];if(!A.isTimeStampFrame(s)){var l=new S(e,a,"");l.value=s,this.id3Track.addCue(l)}}}}}},D.onBufferFlushing=function(o,L){var m=L.startOffset,f=L.endOffset,S=L.type;if(!S||S==="audio"){var E=this.id3Track;E&&Object(T.removeCuesInRange)(E,m,f)}},I}();w.default=k},"./src/controller/latency-controller.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return I});var R=h("./src/errors.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts");function k(D,o){for(var L=0;L<o.length;L++){var m=o[L];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(D,m.key,m)}}var I=function(){function D(f){var S=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 S.timeupdate()},this.hls=f,this.config=f.config,this.registerListeners()}var o,L,m=D.prototype;return m.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},m.registerListeners=function(){this.hls.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(T.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(T.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){this.hls.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(T.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(T.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(T.Events.ERROR,this.onError)},m.onMediaAttached=function(f,S){this.media=S.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},m.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},m.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},m.onLevelUpdated=function(f,S){var E=S.details;this.levelDetails=E,E.advanced&&this.timeupdate(),!E.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},m.onError=function(f,S){S.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},m.timeupdate=function(){var f=this.media,S=this.levelDetails;if(f&&S){this.currentTime=f.currentTime;var E=this.computeLatency();if(E!==null){this._latency=E;var c=this.config,e=c.lowLatencyMode,a=c.maxLiveSyncPlaybackRate;if(e&&a!==1){var t=this.targetLatency;if(t!==null){var s=E-t,l=s<Math.min(this.maxLatency,t+S.targetduration);if(S.live&&l&&s>.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,a)),d=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;f.playbackRate=Math.min(n,Math.max(1,d))}else f.playbackRate!==1&&f.playbackRate!==0&&(f.playbackRate=1)}}}}},m.estimateLiveEdge=function(){var f=this.levelDetails;return f===null?null:f.edge+f.age},m.computeLatency=function(){var f=this.estimateLiveEdge();return f===null?null:f-this.currentTime},o=D,(L=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var f=this.config,S=this.levelDetails;return f.liveMaxLatencyDuration!==void 0?f.liveMaxLatencyDuration:S?f.liveMaxLatencyDurationCount*S.targetduration:0}},{key:"targetLatency",get:function(){var f=this.levelDetails;if(f===null)return null;var S=f.holdBack,E=f.partHoldBack,c=f.targetduration,e=this.config,a=e.liveSyncDuration,t=e.liveSyncDurationCount,s=e.lowLatencyMode,l=this.hls.userConfig,n=s&&E||S;(l.liveSyncDuration||l.liveSyncDurationCount||n===0)&&(n=a!==void 0?a:t*c);var d=c;return n+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var f=this.estimateLiveEdge(),S=this.targetLatency,E=this.levelDetails;if(f===null||S===null||E===null)return null;var c=E.edge,e=f-S-this.edgeStalled,a=c-E.totalduration,t=c-(this.config.lowLatencyMode&&E.partTarget||E.targetduration);return Math.min(Math.max(a,e),t)}},{key:"drift",get:function(){var f=this.levelDetails;return f===null?1:f.drift}},{key:"edgeStalled",get:function(){var f=this.levelDetails;if(f===null)return 0;var S=3*(this.config.lowLatencyMode&&f.partTarget||f.targetduration);return Math.max(f.age-S,0)}},{key:"forwardBufferLength",get:function(){var f=this.media,S=this.levelDetails;if(!f||!S)return 0;var E=f.buffered.length;return E?f.buffered.end(E-1):S.edge-this.currentTime}}])&&k(o.prototype,L),D}()},"./src/controller/level-controller.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return E});var R=h("./src/types/level.ts"),T=h("./src/events.ts"),A=h("./src/errors.ts"),k=h("./src/utils/codecs.ts"),I=h("./src/controller/level-helper.ts"),D=h("./src/controller/base-playlist-controller.ts"),o=h("./src/types/loader.ts");function L(){return(L=Object.assign||function(c){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(c[t]=a[t])}return c}).apply(this,arguments)}function m(c,e){for(var a=0;a<e.length;a++){var t=e[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(c,t.key,t)}}function f(c,e){return(f=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(c,e)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),E=function(c){var e,a;function t(d){var p;return(p=c.call(this,d,"[level-controller]")||this)._levels=[],p._firstLevel=-1,p._startLevel=void 0,p.currentLevelIndex=-1,p.manualLevelIndex=-1,p.onParsedComplete=void 0,p._registerListeners(),p}a=c,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,f(e,a);var s,l,n=t.prototype;return n._registerListeners=function(){var d=this.hls;d.on(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(T.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(T.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(T.Events.ERROR,this.onError,this)},n._unregisterListeners=function(){var d=this.hls;d.off(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(T.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(T.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(T.Events.ERROR,this.onError,this)},n.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,c.prototype.destroy.call(this)},n.startLoad=function(){this._levels.forEach(function(d){d.loadError=0}),c.prototype.startLoad.call(this)},n.onManifestLoaded=function(d,p){var g,v,r=[],i=[],u=[],y={},b=!1,_=!1,x=!1;if(p.levels.forEach(function(F){var M=F.attrs;b=b||!(!F.width||!F.height),_=_||!!F.videoCodec,x=x||!!F.audioCodec,S&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var B=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;(v=y[B])?v.url.push(F.url):(v=new R.Level(F),y[B]=v,r.push(v)),M&&(M.AUDIO&&Object(I.addGroupId)(v,"audio",M.AUDIO),M.SUBTITLES&&Object(I.addGroupId)(v,"text",M.SUBTITLES))}),(b||_)&&x&&(r=r.filter(function(F){var M=F.videoCodec,B=F.width,U=F.height;return!!M||!(!B||!U)})),r=r.filter(function(F){var M=F.audioCodec,B=F.videoCodec;return(!M||Object(k.isCodecSupportedInMp4)(M,"audio"))&&(!B||Object(k.isCodecSupportedInMp4)(B,"video"))}),p.audioTracks&&(i=p.audioTracks.filter(function(F){return!F.audioCodec||Object(k.isCodecSupportedInMp4)(F.audioCodec,"audio")}),Object(I.assignTrackIdsByGroup)(i)),p.subtitles&&(u=p.subtitles,Object(I.assignTrackIdsByGroup)(u)),r.length>0){g=r[0].bitrate,r.sort(function(F,M){return F.bitrate-M.bitrate}),this._levels=r;for(var C=0;C<r.length;C++)if(r[C].bitrate===g){this._firstLevel=C,this.log("manifest loaded, "+r.length+" level(s) found, first bitrate: "+g);break}var O=x&&!_,P={levels:r,audioTracks:i,subtitleTracks:u,firstLevel:this._firstLevel,stats:p.stats,audio:x,video:_,altAudio:!O&&i.some(function(F){return!!F.url})};this.hls.trigger(T.Events.MANIFEST_PARSED,P),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(T.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},n.onError=function(d,p){if(c.prototype.onError.call(this,d,p),!p.fatal){var g=p.context,v=this._levels[this.currentLevelIndex];if(g&&(g.type===o.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&g.groupId===v.audioGroupIds[v.urlId]||g.type===o.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&g.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var r,i=!1,u=!0;switch(p.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var y=this._levels[p.frag.level];y?(y.fragmentError++,y.fragmentError>this.hls.config.fragLoadingMaxRetry&&(r=p.frag.level)):r=p.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:g&&(g.deliveryDirectives&&(u=!1),r=g.level),i=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:r=p.level,i=!0}r!==void 0&&this.recoverLevel(p,r,i,u)}}},n.recoverLevel=function(d,p,g,v){var r=d.details,i=this._levels[p];if(i.loadError++,g){if(!this.retryLoadingOrFail(d))return void(this.currentLevelIndex=-1);d.levelRetry=!0}if(v){var u=i.url.length;if(u>1&&i.loadError<u)d.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var y=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==y&&this._levels[y].loadError===0&&(this.warn(r+": switch to "+y),d.levelRetry=!0,this.hls.nextAutoLevel=y)}}},n.redundantFailover=function(d){var p=this._levels[d],g=p.url.length;if(g>1){var v=(p.urlId+1)%g;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(r){r.urlId=v}),this.level=d}},n.onFragLoaded=function(d,p){var g=p.frag;if(g!==void 0&&g.type===o.PlaylistLevelType.MAIN){var v=this._levels[g.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},n.onLevelLoaded=function(d,p){var g,v,r=p.level,i=p.details,u=this._levels[r];if(!u)return this.warn("Invalid level index "+r),void((v=p.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(i.deltaUpdateFailed=!0));r===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0,this.retryCount=0),this.playlistLoaded(r,p,u.details)):(g=p.deliveryDirectives)!==null&&g!==void 0&&g.skip&&(i.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(d,p){var g=this.hls.levels[this.currentLevelIndex];if(g&&g.audioGroupIds){for(var v=-1,r=this.hls.audioTracks[p.id].groupId,i=0;i<g.audioGroupIds.length;i++)if(g.audioGroupIds[i]===r){v=i;break}v!==g.urlId&&(g.urlId=v,this.startLoad())}},n.loadPlaylist=function(d){var p=this.currentLevelIndex,g=this._levels[p];if(this.canLoad&&g&&g.url.length>0){var v=g.urlId,r=g.url[v];if(d)try{r=d.addDirectives(r)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("Attempt loading level index "+p+(d?" at sn "+d.msn+" part "+d.part:"")+" with URL-id "+v+" "+r),this.clearTimer(),this.hls.trigger(T.Events.LEVEL_LOADING,{url:r,level:p,id:v,deliveryDirectives:d||null})}},n.removeLevel=function(d,p){var g=function(r,i){return i!==p},v=this._levels.filter(function(r,i){return i!==d||r.url.length>1&&p!==void 0&&(r.url=r.url.filter(g),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(g)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(g)),r.urlId=0,!0)}).map(function(r,i){var u=r.details;return u!=null&&u.fragments&&u.fragments.forEach(function(y){y.level=i}),r});this._levels=v,this.hls.trigger(T.Events.LEVELS_UPDATED,{levels:v})},s=t,(l=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(d){var p,g=this._levels;if(g.length!==0&&(this.currentLevelIndex!==d||(p=g[d])===null||p===void 0||!p.details)){if(d<0||d>=g.length){var v=d<0;if(this.hls.trigger(T.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:d,fatal:v,reason:"invalid level idx"}),v)return;d=Math.min(d,g.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=g[r],u=g[d];this.log("switching to level "+d+" from "+r),this.currentLevelIndex=d;var y=L({},u,{level:d,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete y._urlId,this.hls.trigger(T.Events.LEVEL_SWITCHING,y);var b=u.details;if(!b||b.live){var _=this.switchParams(u.uri,i==null?void 0:i.details);this.loadPlaylist(_)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(d){this.manualLevelIndex=d,this._startLevel===void 0&&(this._startLevel=d),d!==-1&&(this.level=d)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(d){this._firstLevel=d}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var d=this.hls.config.startLevel;return d!==void 0?d:this._firstLevel}return this._startLevel},set:function(d){this._startLevel=d}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(d){this.level=d,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=d)}}])&&m(s.prototype,l),t}(D.default)},"./src/controller/level-helper.ts":function(N,w,h){h.r(w),h.d(w,"addGroupId",function(){return A}),h.d(w,"assignTrackIdsByGroup",function(){return k}),h.d(w,"updatePTS",function(){return I}),h.d(w,"updateFragPTSDTS",function(){return o}),h.d(w,"mergeDetails",function(){return L}),h.d(w,"mapPartIntersection",function(){return m}),h.d(w,"mapFragmentIntersection",function(){return f}),h.d(w,"adjustSliding",function(){return S}),h.d(w,"addSliding",function(){return E}),h.d(w,"computeReloadInterval",function(){return c}),h.d(w,"getFragmentWithSN",function(){return e}),h.d(w,"getPartWith",function(){return a});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/logger.ts");function A(t,s,l){switch(s){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(l);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(l)}}function k(t){var s={};t.forEach(function(l){var n=l.groupId||"";l.id=s[n]=s[n]||0,s[n]++})}function I(t,s,l){D(t[s],t[l])}function D(t,s){var l=s.startPTS;if(Object(R.isFiniteNumber)(l)){var n,d=0;s.sn>t.sn?(d=l-t.start,n=t):(d=t.start-l,n=s),n.duration!==d&&(n.duration=d)}else s.sn>t.sn?t.cc===s.cc&&t.minEndPTS?s.start=t.start+(t.minEndPTS-t.start):s.start=t.start+t.duration:s.start=Math.max(t.start-s.duration,0)}function o(t,s,l,n,d,p){n-l<=0&&(T.logger.warn("Fragment should have a positive duration",s),n=l+s.duration,p=d+s.duration);var g=l,v=n,r=s.startPTS,i=s.endPTS;if(Object(R.isFiniteNumber)(r)){var u=Math.abs(r-l);Object(R.isFiniteNumber)(s.deltaPTS)?s.deltaPTS=Math.max(u,s.deltaPTS):s.deltaPTS=u,g=Math.max(l,r),l=Math.min(l,r),d=Math.min(d,s.startDTS),v=Math.min(n,i),n=Math.max(n,i),p=Math.max(p,s.endDTS)}s.duration=n-l;var y=l-s.start;s.appendedPTS=n,s.start=s.startPTS=l,s.maxStartPTS=g,s.startDTS=d,s.endPTS=n,s.minEndPTS=v,s.endDTS=p;var b,_=s.sn;if(!t||_<t.startSN||_>t.endSN)return 0;var x=_-t.startSN,C=t.fragments;for(C[x]=s,b=x;b>0;b--)D(C[b],C[b-1]);for(b=x;b<C.length-1;b++)D(C[b],C[b+1]);return t.fragmentHint&&D(C[C.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,y}function L(t,s){for(var l=null,n=t.fragments,d=n.length-1;d>=0;d--){var p=n[d].initSegment;if(p){l=p;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var g,v=0;if(f(t,s,function(_,x){var C;_.relurl&&(v=_.cc-x.cc),Object(R.isFiniteNumber)(_.startPTS)&&Object(R.isFiniteNumber)(_.endPTS)&&(x.start=x.startPTS=_.startPTS,x.startDTS=_.startDTS,x.appendedPTS=_.appendedPTS,x.maxStartPTS=_.maxStartPTS,x.endPTS=_.endPTS,x.endDTS=_.endDTS,x.minEndPTS=_.minEndPTS,x.duration=_.endPTS-_.startPTS,x.duration&&(g=x),s.PTSKnown=s.alignedSliding=!0),x.elementaryStreams=_.elementaryStreams,x.loader=_.loader,x.stats=_.stats,x.urlId=_.urlId,_.initSegment?(x.initSegment=_.initSegment,l=_.initSegment):x.initSegment&&x.initSegment.relurl!=((C=l)===null||C===void 0?void 0:C.relurl)||(x.initSegment=l)}),s.skippedSegments&&(s.deltaUpdateFailed=s.fragments.some(function(_){return!_}),s.deltaUpdateFailed)){T.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var r=s.skippedSegments;r--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}var i=s.fragments;if(v){T.logger.warn("discontinuity sliding from playlist, take drift into account");for(var u=0;u<i.length;u++)i[u].cc+=v}s.skippedSegments&&(s.startCC=s.fragments[0].cc),m(t.partList,s.partList,function(_,x){x.elementaryStreams=_.elementaryStreams,x.stats=_.stats}),g?o(s,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):S(t,s),i.length&&(s.totalduration=s.edge-i[0].start),s.driftStartTime=t.driftStartTime,s.driftStart=t.driftStart;var y=s.advancedDateTime;if(s.advanced&&y){var b=s.edge;s.driftStart||(s.driftStartTime=y,s.driftStart=b),s.driftEndTime=y,s.driftEnd=b}else s.driftEndTime=t.driftEndTime,s.driftEnd=t.driftEnd,s.advancedDateTime=t.advancedDateTime}function m(t,s,l){if(t&&s)for(var n=0,d=0,p=t.length;d<=p;d++){var g=t[d],v=s[d+n];g&&v&&g.index===v.index&&g.fragment.sn===v.fragment.sn?l(g,v):n--}}function f(t,s,l){for(var n=s.skippedSegments,d=Math.max(t.startSN,s.startSN)-s.startSN,p=(t.fragmentHint?1:0)+(n?s.endSN:Math.min(t.endSN,s.endSN))-s.startSN,g=s.startSN-t.startSN,v=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,r=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,i=d;i<=p;i++){var u=r[g+i],y=v[i];n&&!y&&i<n&&(y=s.fragments[i]=u),u&&y&&l(u,y)}}function S(t,s){var l=s.startSN+s.skippedSegments-t.startSN,n=t.fragments;l<0||l>=n.length||E(s,n[l].start)}function E(t,s){if(s){for(var l=t.fragments,n=t.skippedSegments;n<l.length;n++)l[n].start+=s;t.fragmentHint&&(t.fragmentHint.start+=s)}}function c(t,s){var l,n=1e3*t.levelTargetDuration,d=n/2,p=t.age,g=p>0&&p<3*n,v=s.loading.end-s.loading.start,r=t.availabilityDelay;if(t.updated===!1)if(g){var i=333*t.misses;l=Math.max(Math.min(d,2*v),i),t.availabilityDelay=(t.availabilityDelay||0)+l}else l=d;else g?(r=Math.min(r||n/2,p),t.availabilityDelay=r,l=r+n-p):l=n-v;return Math.round(l)}function e(t,s,l){if(!t||!t.details)return null;var n=t.details,d=n.fragments[s-n.startSN];return d||((d=n.fragmentHint)&&d.sn===s?d:s<n.startSN&&l&&l.sn===s?l:null)}function a(t,s,l){if(!t||!t.details)return null;var n=t.details.partList;if(n)for(var d=n.length;d--;){var p=n[d];if(p.index===l&&p.fragment.sn===s)return p}return null}},"./src/controller/stream-controller.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return t});var R=h("./src/polyfills/number.ts"),T=h("./src/controller/base-stream-controller.ts"),A=h("./src/is-supported.ts"),k=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),D=h("./src/controller/fragment-tracker.ts"),o=h("./src/types/loader.ts"),L=h("./src/loader/fragment.ts"),m=h("./src/demux/transmuxer-interface.ts"),f=h("./src/types/transmuxer.ts"),S=h("./src/controller/gap-controller.ts"),E=h("./src/errors.ts"),c=h("./src/utils/logger.ts");function e(s,l){for(var n=0;n<l.length;n++){var d=l[n];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(s,d.key,d)}}function a(s,l){return(a=Object.setPrototypeOf||function(n,d){return n.__proto__=d,n})(s,l)}var t=function(s){var l,n;function d(r,i){var u;return(u=s.call(this,r,i,"[stream-controller]")||this).audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.stalled=!1,u.couldBacktrack=!1,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}n=s,(l=d).prototype=Object.create(n.prototype),l.prototype.constructor=l,a(l,n);var p,g,v=d.prototype;return v._registerListeners=function(){var r=this.hls;r.on(k.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(k.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(k.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(k.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(k.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(k.Events.ERROR,this.onError,this),r.on(k.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(k.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(k.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(k.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(k.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(k.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var r=this.hls;r.off(k.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(k.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(k.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(k.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(k.Events.ERROR,this.onError,this),r.off(k.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(k.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(k.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(k.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(k.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(k.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},v.startLoad=function(r){if(this.levels){var i=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var y=u.startLevel;y===-1&&(u.config.testBandwidth?(y=0,this.bitrateTest=!0):y=u.nextAutoLevel),this.level=u.nextLoadLevel=y,this.loadedmetadata=!1}i>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),r=i),this.state=T.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=T.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_LEVEL:var r,i=this.levels,u=this.level,y=i==null||(r=i[u])===null||r===void 0?void 0:r.details;if(y&&(!y.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(y))break;this.state=T.State.IDLE;break}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,_=self.performance.now(),x=this.retryDate;(!x||_>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=T.State.IDLE)}this.onTickEnd()},v.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var r,i,u=this.hls,y=this.levelLastLoaded,b=this.levels,_=this.media,x=u.config,C=u.nextLoadLevel;if(y!==null&&(_||!this.startFragRequested&&x.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&b&&b[C]){var O=b[C];this.level=u.nextLoadLevel=C;var P=O.details;if(!P||this.state===T.State.WAITING_LEVEL||P.live&&this.levelLastLoaded!==C)this.state=T.State.WAITING_LEVEL;else{var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:_,o.PlaylistLevelType.MAIN);if(F!==null&&!(F.len>=this.getMaxBufferLength(O.maxBitrate))){if(this._streamEnded(F,P)){var M={};return this.altAudio&&(M.type="video"),this.hls.trigger(k.Events.BUFFER_EOS,M),void(this.state=T.State.ENDED)}var B=F.end,U=this.getNextFragment(B,P);if(this.couldBacktrack&&!this.fragPrevious&&U&&U.sn!=="initSegment"){var j=U.sn-P.startSN;j>1&&(U=P.fragments[j-1],this.fragmentTracker.removeFragment(U))}if(U&&this.fragmentTracker.getState(U)===D.FragmentState.OK&&this.nextLoadPosition>B){var V=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(_,V,o.PlaylistLevelType.MAIN),U=this.getNextFragment(this.nextLoadPosition,P)}U&&(!U.initSegment||U.initSegment.data||this.bitrateTest||(U=U.initSegment),((r=U.decryptdata)===null||r===void 0?void 0:r.keyFormat)!=="identity"||(i=U.decryptdata)!==null&&i!==void 0&&i.key?this.loadFragment(U,P,B):this.loadKey(U,P))}}}},v.loadFragment=function(r,i,u){var y,b=this.fragmentTracker.getState(r);if(this.fragCurrent=r,b===D.FragmentState.BACKTRACKED){var _=this.fragmentTracker.getBacktrackData(r);if(_)return this._handleFragmentLoadProgress(_),void this._handleFragmentLoadComplete(_);b=D.FragmentState.NOT_LOADED}b===D.FragmentState.NOT_LOADED||b===D.FragmentState.PARTIAL?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(r.bitrateTest=!0,this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,r,i,u)):b===D.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((y=this.media)===null||y===void 0?void 0:y.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(r){var i=this.fragmentTracker.getAppendedFrag(r,o.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},v.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,o.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var r=this.levels,i=this.media;if(i!=null&&i.readyState){var u,y=this.getAppendedFrag(i.currentTime);if(y&&y.start>1&&this.flushMainBuffer(0,y.start-1),!i.paused&&r){var b=r[this.hls.nextLoadLevel],_=this.fragLastKbps;u=_&&this.fragCurrent?this.fragCurrent.duration*b.maxBitrate/(1e3*_)+1:0}else u=0;var x=this.getBufferedFrag(i.currentTime+u);if(x){var C=this.followingBufferedFrag(x);if(C){this.abortCurrentFrag();var O=C.maxStartPTS?C.maxStartPTS:C.start,P=C.duration,F=Math.max(x.end,O+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var r=this.fragCurrent;this.fragCurrent=null,r!=null&&r.loader&&r.loader.abort(),this.state===T.State.KEY_LOADING&&(this.state=T.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(r,i){s.prototype.flushMainBuffer.call(this,r,i,this.altAudio?"video":null)},v.onMediaAttached=function(r,i){s.prototype.onMediaAttached.call(this,r,i);var u=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new S.default(this.config,u,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var r=this.media;r&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var r=this.media,i=r?r.currentTime:null;Object(R.isFiniteNumber)(i)&&this.log("Media seeked to "+i.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(k.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(r,i){var u,y=!1,b=!1;i.levels.forEach(function(_){(u=_.audioCodec)&&(u.indexOf("mp4a.40.2")!==-1&&(y=!0),u.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=y&&b&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},v.onLevelLoading=function(r,i){var u=this.levels;if(u&&this.state===T.State.IDLE){var y=u[i.level];(!y.details||y.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(y.details))&&(this.state=T.State.WAITING_LEVEL)}},v.onLevelLoaded=function(r,i){var u,y=this.levels,b=i.level,_=i.details,x=_.totalduration;if(y){this.log("Level "+b+" loaded ["+_.startSN+","+_.endSN+"], cc ["+_.startCC+", "+_.endCC+"] duration:"+x);var C=this.fragCurrent;!C||this.state!==T.State.FRAG_LOADING&&this.state!==T.State.FRAG_LOADING_WAITING_RETRY||C.level!==i.level&&C.loader&&(this.state=T.State.IDLE,C.loader.abort());var O=y[b],P=0;if(_.live||(u=O.details)!==null&&u!==void 0&&u.live){if(_.fragments[0]||(_.deltaUpdateFailed=!0),_.deltaUpdateFailed)return;P=this.alignPlaylists(_,O.details)}if(O.details=_,this.levelLastLoaded=b,this.hls.trigger(k.Events.LEVEL_UPDATED,{details:_,level:b}),this.state===T.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(_))return;this.state=T.State.IDLE}this.startFragRequested?_.live&&this.synchronizeToLiveEdge(_):this.setStartPosition(_,P),this.tick()}else this.warn("Levels were reset while loading level "+b)},v._handleFragmentLoadProgress=function(r){var i,u=r.frag,y=r.part,b=r.payload,_=this.levels;if(_){var x=_[u.level],C=x.details;if(C){var O=x.videoCodec,P=C.PTSKnown||!C.live,F=(i=u.initSegment)===null||i===void 0?void 0:i.data,M=this._getAudioCodec(x),B=this.transmuxer=this.transmuxer||new m.default(this.hls,o.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=y?y.index:-1,j=U!==-1,V=new f.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,b.byteLength,U,j),W=this.initPTS[u.cc];B.push(b,F,M,O,u,y,C.totalduration,P,V,W)}else this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered")},v.onAudioTrackSwitching=function(r,i){var u=this.altAudio,y=!!i.url,b=i.id;if(!y){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var _=this.fragCurrent;_!=null&&_.loader&&(this.log("Switching to main audio track, cancel main fragment load"),_.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var x=this.hls;u&&x.trigger(k.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),x.trigger(k.Events.AUDIO_TRACK_SWITCHED,{id:b})}},v.onAudioTrackSwitched=function(r,i){var u=i.id,y=!!this.hls.audioTracks[u].url;if(y){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=y,this.tick()},v.onBufferCreated=function(r,i){var u,y,b=i.tracks,_=!1;for(var x in b){var C=b[x];if(C.id==="main"){if(y=x,u=C,x==="video"){var O=b[x];O&&(this.videoBuffer=O.buffer)}}else _=!0}_&&u?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(r,i){var u=i.frag,y=i.part;if(!u||u.type===o.PlaylistLevelType.MAIN){if(this.fragContextChanged(u))return this.warn("Fragment "+u.sn+(y?" p: "+y.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===T.State.PARSED&&(this.state=T.State.IDLE));var b=y?y.stats:u.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,y)}},v.onError=function(r,i){switch(i.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(o.PlaylistLevelType.MAIN,i);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==T.State.ERROR&&(i.fatal?(this.warn(""+i.details),this.state=T.State.ERROR):i.levelRetry||this.state!==T.State.WAITING_LEVEL||(this.state=T.State.IDLE));break;case E.ErrorDetails.BUFFER_FULL_ERROR:if(i.parent==="main"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)){var u=!0,y=this.getFwdBufferInfo(this.media,o.PlaylistLevelType.MAIN);y&&y.len>.5&&(u=!this.reduceMaxBufferLength(y.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},v.checkBuffer=function(){var r=this.media,i=this.gapController;if(r&&i&&r.readyState){var u=I.BufferHelper.getBuffered(r);!this.loadedmetadata&&u.length?(this.loadedmetadata=!0,this.seekToStartPos()):i.poll(this.lastCurrentTime),this.lastCurrentTime=r.currentTime}},v.onFragLoadEmergencyAborted=function(){this.state=T.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(r,i){var u=i.type;if(u!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var y=(u===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(y,u,o.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(r,i){this.levels=i.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var r=this.media,i=r.currentTime,u=this.startPosition;if(u>=0&&i<u){if(r.seeking)return void c.logger.log("could not seek to "+u+", already seeking at "+i);var y=I.BufferHelper.getBuffered(r),b=(y.length?y.start(0):0)-u;b>0&&b<this.config.maxBufferHole&&(c.logger.log("adjusting start position by "+b+" to match buffer start"),u+=b,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+i),r.currentTime=u}},v._getAudioCodec=function(r){var i=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=i.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),i},v._loadBitrateTestFrag=function(r){var i=this;this._doFragLoad(r).then(function(u){var y=i.hls;if(u&&!y.nextLoadLevel&&!i.fragContextChanged(r)){i.fragLoadError=0,i.state=T.State.IDLE,i.startFragRequested=!1,i.bitrateTest=!1;var b=r.stats;b.parsing.start=b.parsing.end=b.buffering.start=b.buffering.end=self.performance.now(),y.trigger(k.Events.FRAG_LOADED,u)}})},v._handleTransmuxComplete=function(r){var i,u="main",y=this.hls,b=r.remuxResult,_=r.chunkMeta,x=this.getCurrentContext(_);if(!x)return this.warn("The loading context changed while buffering fragment "+_.sn+" of level "+_.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(_.level);var C=x.frag,O=x.part,P=x.level,F=b.video,M=b.text,B=b.id3,U=b.initSegment,j=this.altAudio?void 0:b.audio;if(!this.fragContextChanged(C)){if(this.state=T.State.PARSING,U){U.tracks&&(this._bufferInitSegment(P,U.tracks,C,_),y.trigger(k.Events.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:u,tracks:U.tracks}));var V=U.initPTS,W=U.timescale;Object(R.isFiniteNumber)(V)&&(this.initPTS[C.cc]=V,y.trigger(k.Events.INIT_PTS_FOUND,{frag:C,id:u,initPTS:V,timescale:W}))}if(F&&b.independent!==!1){if(P.details){var X=F.startPTS,q=F.endPTS,$=F.startDTS,ie=F.endDTS;if(O)O.elementaryStreams[F.type]={startPTS:X,endPTS:q,startDTS:$,endDTS:ie};else if(F.firstKeyFrame&&F.independent&&(this.couldBacktrack=!0),F.dropped&&F.independent){if(this.getLoadPosition()+this.config.maxBufferHole<X)return void this.backtrack(C);C.setElementaryStreamInfo(F.type,C.start,q,C.start,ie,!0)}C.setElementaryStreamInfo(F.type,X,q,$,ie),this.bufferFragmentData(F,C,O,_)}}else if(b.independent===!1)return void this.backtrack(C);if(j){var se=j.startPTS,le=j.endPTS,re=j.startDTS,de=j.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:le,startDTS:re,endDTS:de}),C.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,se,le,re,de),this.bufferFragmentData(j,C,O,_)}if(B!=null&&(i=B.samples)!==null&&i!==void 0&&i.length){var te={frag:C,id:u,samples:B.samples};y.trigger(k.Events.FRAG_PARSING_METADATA,te)}if(M){var ne={frag:C,id:u,samples:M.samples};y.trigger(k.Events.FRAG_PARSING_USERDATA,ne)}}},v._bufferInitSegment=function(r,i,u,y){var b=this;if(this.state===T.State.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var _=i.audio,x=i.video,C=i.audiovideo;if(_){var O=r.audioCodec,P=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(O&&(O=O.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),_.metadata.channelCount!==1&&P.indexOf("firefox")===-1&&(O="mp4a.40.5")),P.indexOf("android")!==-1&&_.container!=="audio/mpeg"&&(O="mp4a.40.2",this.log("Android: force audio codec to "+O)),r.audioCodec&&r.audioCodec!==O&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+O+'"'),_.levelCodec=O,_.id="main",this.log("Init audio buffer, container:"+_.container+", codecs[selected/level/parsed]=["+(O||"")+"/"+(r.audioCodec||"")+"/"+_.codec+"]")}x&&(x.levelCodec=r.videoCodec,x.id="main",this.log("Init video buffer, container:"+x.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+x.codec+"]")),C&&this.log("Init audiovideo buffer, container:"+C.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+C.codec+"]"),this.hls.trigger(k.Events.BUFFER_CODECS,i),Object.keys(i).forEach(function(F){var M=i[F].initSegment;M!=null&&M.byteLength&&b.hls.trigger(k.Events.BUFFER_APPENDING,{type:F,data:M,frag:u,part:null,chunkMeta:y,parent:u.type})}),this.tick()}},v.backtrack=function(r){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(r);var i=this.fragmentTracker.backtrack(r);this.fragPrevious=null,this.nextLoadPosition=r.start,i?this.resetFragmentLoading(r):this.state=T.State.BACKTRACKING},v.checkFragmentChanged=function(){var r=this.media,i=null;if(r&&r.readyState>1&&r.seeking===!1){var u=r.currentTime;if(I.BufferHelper.isBuffered(r,u)?i=this.getAppendedFrag(u):I.BufferHelper.isBuffered(r,u+.1)&&(i=this.getAppendedFrag(u+.1)),i){var y=this.fragPlaying,b=i.level;y&&i.sn===y.sn&&y.level===b&&i.urlId===y.urlId||(this.hls.trigger(k.Events.FRAG_CHANGED,{frag:i}),y&&y.level===b||this.hls.trigger(k.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=i)}}},p=d,(g=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentLevel",get:function(){var r=this.media;if(r){var i=this.getAppendedFrag(r.currentTime);if(i)return i.level}return-1}},{key:"nextBufferedFrag",get:function(){var r=this.media;if(r){var i=this.getAppendedFrag(r.currentTime);return this.followingBufferedFrag(i)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&e(p.prototype,g),d}(T.default)},"./src/controller/subtitle-stream-controller.ts":function(N,w,h){h.r(w),h.d(w,"SubtitleStreamController",function(){return c});var R=h("./src/events.ts"),T=h("./src/utils/logger.ts"),A=h("./src/utils/buffer-helper.ts"),k=h("./src/controller/fragment-finders.ts"),I=h("./src/utils/discontinuities.ts"),D=h("./src/controller/level-helper.ts"),o=h("./src/controller/fragment-tracker.ts"),L=h("./src/controller/base-stream-controller.ts"),m=h("./src/types/loader.ts"),f=h("./src/types/level.ts");function S(e,a){for(var t=0;t<a.length;t++){var s=a[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function E(e,a){return(E=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t})(e,a)}var c=function(e){var a,t;function s(p,g){var v;return(v=e.call(this,p,g,"[subtitle-stream-controller]")||this).levels=[],v.currentTrackId=-1,v.tracksBuffered=[],v.mainDetails=null,v._registerListeners(),v}t=e,(a=s).prototype=Object.create(t.prototype),a.prototype.constructor=a,E(a,t);var l,n,d=s.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var p=this.hls;p.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(R.Events.ERROR,this.onError,this),p.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},d._unregisterListeners=function(){var p=this.hls;p.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(R.Events.ERROR,this.onError,this),p.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},d.startLoad=function(){this.stopLoad(),this.state=L.State.IDLE,this.setInterval(500),this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},d.onLevelLoaded=function(p,g){this.mainDetails=g.details},d.onSubtitleFragProcessed=function(p,g){var v=g.frag,r=g.success;if(this.fragPrevious=v,this.state=L.State.IDLE,r){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var u,y=v.start,b=0;b<i.length;b++)if(y>=i[b].start&&y<=i[b].end){u=i[b];break}var _=v.start+v.duration;u?u.end=_:(u={start:y,end:_},i.push(u)),this.fragmentTracker.fragBuffered(v)}}},d.onBufferFlushing=function(p,g){var v=g.startOffset,r=g.endOffset;if(v===0&&r!==Number.POSITIVE_INFINITY){var i=this.currentTrackId,u=this.levels;if(!u.length||!u[i]||!u[i].details)return;var y=r-u[i].details.targetduration;if(y<=0)return;g.endOffsetSubtitles=Math.max(0,y),this.tracksBuffered.forEach(function(b){for(var _=0;_<b.length;)if(b[_].end<=y)b.shift();else{if(!(b[_].start<y))break;b[_].start=y,_++}}),this.fragmentTracker.removeFragmentsInRange(v,y,m.PlaylistLevelType.SUBTITLE)}},d.onError=function(p,g){var v,r=g.frag;r&&r.type===m.PlaylistLevelType.SUBTITLE&&((v=this.fragCurrent)!==null&&v!==void 0&&v.loader&&this.fragCurrent.loader.abort(),this.state=L.State.IDLE)},d.onSubtitleTracksUpdated=function(p,g){var v=this,r=g.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(i){return new f.Level(i)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(i){v.tracksBuffered[i.id]=[]}),this.mediaBuffer=null},d.onSubtitleTrackSwitch=function(p,g){if(this.currentTrackId=g.id,this.levels.length&&this.currentTrackId!==-1){var v=this.levels[this.currentTrackId];v!=null&&v.details?(this.mediaBuffer=this.mediaBufferTimeRanges,this.setInterval(500)):this.mediaBuffer=null}else this.clearInterval()},d.onSubtitleTrackLoaded=function(p,g){var v,r=g.details,i=g.id,u=this.currentTrackId,y=this.levels;if(y.length){var b=y[u];if(!(i>=y.length||i!==u)&&b){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||(v=b.details)!==null&&v!==void 0&&v.live){var _=this.mainDetails;if(r.deltaUpdateFailed||!_)return;var x=_.fragments[0];b.details?this.alignPlaylists(r,b.details)===0&&x&&Object(D.addSliding)(r,x.start):r.hasProgramDateTime&&_.hasProgramDateTime?Object(I.alignPDT)(r,_):x&&Object(D.addSliding)(r,x.start)}b.details=r,this.levelLastLoaded=i,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE&&(Object(k.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0))}}},d._handleFragmentLoadComplete=function(p){var g=p.frag,v=p.payload,r=g.decryptdata,i=this.hls;if(!this.fragContextChanged(g)&&v&&v.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){var u=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(v),r.key.buffer,r.iv.buffer).then(function(y){var b=performance.now();i.trigger(R.Events.FRAG_DECRYPTED,{frag:g,payload:y,stats:{tstart:u,tdecrypt:b}})})}},d.doTick=function(){if(this.media){if(this.state===L.State.IDLE){var p,g=this.currentTrackId,v=this.levels;if(!v.length||!v[g]||!v[g].details)return;var r=v[g].details,i=r.targetduration,u=this.config,y=this.media,b=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,y.currentTime-i,u.maxBufferHole),_=b.end;if(b.len>this.getMaxBufferLength()+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var x,C=r.fragments,O=C.length,P=r.edge,F=this.fragPrevious;if(_<P){var M=u.maxFragLookUpTolerance;F&&r.hasProgramDateTime&&(x=Object(k.findFragmentByPDT)(C,F.endProgramDateTime,M)),x||!(x=Object(k.findFragmentByPTS)(F,C,_,M))&&F&&F.start<C[0].start&&(x=C[0])}else x=C[O-1];(p=x)!==null&&p!==void 0&&p.encrypted?(T.logger.log("Loading key for "+x.sn),this.state=L.State.KEY_LOADING,this.hls.trigger(R.Events.KEY_LOADING,{frag:x})):x&&this.fragmentTracker.getState(x)===o.FragmentState.NOT_LOADED&&this.loadFragment(x,r,_)}}else this.state=L.State.IDLE},d.loadFragment=function(p,g,v){this.fragCurrent=p,e.prototype.loadFragment.call(this,p,g,v)},l=s,(n=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&S(l.prototype,n),s}(L.default)},"./src/controller/subtitle-track-controller.ts":function(N,w,h){h.r(w);var R=h("./src/events.ts"),T=h("./src/utils/texttrack-utils.ts"),A=h("./src/controller/base-playlist-controller.ts"),k=h("./src/types/loader.ts");function I(m,f){for(var S=0;S<f.length;S++){var E=f[S];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(m,E.key,E)}}function D(m,f){return(D=Object.setPrototypeOf||function(S,E){return S.__proto__=E,S})(m,f)}var o=function(m){var f,S;function E(t){var s;return(s=m.call(this,t,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s.subtitleDisplay=!0,s.registerListeners(),s}S=m,(f=E).prototype=Object.create(S.prototype),f.prototype.constructor=f,D(f,S);var c,e,a=E.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,m.prototype.destroy.call(this)},a.registerListeners=function(){var t=this.hls;t.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var t=this.hls;t.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.Events.ERROR,this.onError,this)},a.onMediaAttached=function(t,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},a.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),L(this.media.textTracks).forEach(function(t){Object(T.clearCurrentCues)(t)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(t,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(t,s){var l=s.id,n=s.details,d=this.trackId,p=this.tracksInGroup[d];if(p){var g=p.details;p.details=s.details,this.log("subtitle track "+l+" loaded ["+n.startSN+"-"+n.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,g))}else this.warn("Invalid subtitle track id "+l)},a.onLevelLoading=function(t,s){this.switchLevel(s.level)},a.onLevelSwitching=function(t,s){this.switchLevel(s.level)},a.switchLevel=function(t){var s=this.hls.levels[t];if(s!=null&&s.textGroupIds){var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,d=this.tracks.filter(function(v){return!l||v.groupId===l});this.tracksInGroup=d;var p=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=l;var g={subtitleTracks:d};this.log("Updating subtitle tracks, "+d.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,g),p!==-1&&this.setSubtitleTrack(p,n)}}},a.findTrackId=function(t){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var n=s[l];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},a.onError=function(t,s){m.prototype.onError.call(this,t,s),!s.fatal&&s.context&&s.context.type===k.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(t){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,n=s.groupId,d=s.url;if(t)try{d=t.addDirectives(d)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:d,id:l,groupId:n,deliveryDirectives:t||null})}},a.toggleTrackModes=function(t){var s=this,l=this.media,n=this.subtitleDisplay,d=this.trackId;if(l){var p=L(l.textTracks),g=p.filter(function(i){return i.groupId===s.groupId});if(t===-1)[].slice.call(p).forEach(function(i){i.mode="disabled"});else{var v=g[d];v&&(v.mode="disabled")}var r=g[t];r&&(r.mode=n?"showing":"hidden")}},a.setSubtitleTrack=function(t,s){var l,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(l=n[t])!==null&&l!==void 0&&l.details)||t<-1||t>=n.length)){this.clearTimer();var d=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,d){var p=d.id,g=d.groupId,v=g===void 0?"":g,r=d.name,i=d.type,u=d.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:v,name:r,type:i,url:u});var y=this.switchParams(d.url,s==null?void 0:s.details);this.loadPlaylist(y)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,s=L(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")t=l;else if(s[l].mode==="showing"){t=l;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},c=E,(e=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,s)}}])&&I(c.prototype,e),E}(A.default);function L(m){for(var f=[],S=0;S<m.length;S++){var E=m[S];E.kind==="subtitles"&&E.label&&f.push(m[S])}return f}w.default=o},"./src/controller/timeline-controller.ts":function(N,w,h){h.r(w),h.d(w,"TimelineController",function(){return f});var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/utils/cea-608-parser.ts"),k=h("./src/utils/output-filter.ts"),I=h("./src/utils/webvtt-parser.ts"),D=h("./src/utils/texttrack-utils.ts"),o=h("./src/utils/imsc1-ttml-parser.ts"),L=h("./src/types/loader.ts"),m=h("./src/utils/logger.ts"),f=function(){function E(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var a=new k.default(this,"textTrack1"),t=new k.default(this,"textTrack2"),s=new k.default(this,"textTrack3"),l=new k.default(this,"textTrack4");this.cea608Parser1=new A.default(1,a,t),this.cea608Parser2=new A.default(3,s,l)}e.on(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(T.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(T.Events.FRAG_LOADING,this.onFragLoading,this),e.on(T.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(T.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(T.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(T.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var c=E.prototype;return c.destroy=function(){var e=this.hls;e.off(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(T.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(T.Events.FRAG_LOADING,this.onFragLoading,this),e.off(T.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(T.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(T.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(T.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},c.addCues=function(e,a,t,s,l){for(var n,d,p,g,v=!1,r=l.length;r--;){var i=l[r],u=(n=i[0],d=i[1],p=a,g=t,Math.min(d,g)-Math.max(n,p));if(u>=0&&(i[0]=Math.min(i[0],a),i[1]=Math.max(i[1],t),v=!0,u/(t-a)>.5))return}if(v||l.push([a,t]),this.config.renderTextTracksNatively){var y=this.captionsTracks[e];this.Cues.newCue(y,a,t,s)}else{var b=this.Cues.newCue(null,a,t,s);this.hls.trigger(T.Events.CUES_PARSED,{type:"captions",cues:b,track:e})}},c.onInitPtsFound=function(e,a){var t=this,s=a.frag,l=a.id,n=a.initPTS,d=a.timescale,p=this.unparsedVttFrags;l==="main"&&(this.initPTS[s.cc]=n,this.timescale[s.cc]=d),p.length&&(this.unparsedVttFrags=[],p.forEach(function(g){t.onFragLoaded(T.Events.FRAG_LOADED,g)}))},c.getExistingTrack=function(e){var a=this.media;if(a)for(var t=0;t<a.textTracks.length;t++){var s=a.textTracks[t];if(s[e])return s}return null},c.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},c.createNativeTrack=function(e){if(!this.captionsTracks[e]){var a=this.captionsProperties,t=this.captionsTracks,s=this.media,l=a[e],n=l.label,d=l.languageCode,p=this.getExistingTrack(e);if(p)t[e]=p,Object(D.clearCurrentCues)(t[e]),Object(D.sendAddTrackEvent)(t[e],s);else{var g=this.createTextTrack("captions",n,d);g&&(g[e]=!0,t[e]=g)}}},c.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var a=this.captionsProperties[e];if(a){var t={_id:e,label:a.label,kind:"captions",default:!!a.media&&!!a.media.default,closedCaptions:a.media};this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]})}}},c.createTextTrack=function(e,a,t){var s=this.media;if(s)return s.addTextTrack(e,a,t)},c.onMediaAttaching=function(e,a){this.media=a.media,this._cleanTracks()},c.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(a){Object(D.clearCurrentCues)(e[a]),delete e[a]}),this.nonNativeCaptionsTracks={}},c.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},c._cleanTracks=function(){var e=this.media;if(e){var a=e.textTracks;if(a)for(var t=0;t<a.length;t++)Object(D.clearCurrentCues)(a[t])}},c.onSubtitleTracksUpdated=function(e,a){var t=this;this.textTracks=[];var s=a.subtitleTracks||[],l=s.some(function(g){return g.textCodec===o.IMSC1_CODEC});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){var n=this.tracks&&s&&this.tracks.length===s.length;if(this.tracks=s||[],this.config.renderTextTracksNatively){var d=this.media?this.media.textTracks:[];this.tracks.forEach(function(g,v){var r;if(v<d.length){for(var i=null,u=0;u<d.length;u++)if(S(d[u],g)){i=d[u];break}i&&(r=i)}r?Object(D.clearCurrentCues)(r):(r=t.createTextTrack("subtitles",g.name,g.lang))&&(r.mode="disabled"),r&&(r.groupId=g.groupId,t.textTracks.push(r))})}else if(!n&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(g){return{label:g.name,kind:g.type.toLowerCase(),default:g.default,subtitleTrack:g}});this.hls.trigger(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},c.onManifestLoaded=function(e,a){var t=this;this.config.enableCEA708Captions&&a.captions&&a.captions.forEach(function(s){var l=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(l){var n="textTrack"+l[1],d=t.captionsProperties[n];d&&(d.label=s.name,s.lang&&(d.languageCode=s.lang),d.media=s)}})},c.onFragLoading=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2,l=this.lastSn;if(this.enabled&&t&&s&&a.frag.type===L.PlaylistLevelType.MAIN){var n=a.frag.sn;n!==l+1&&(t.reset(),s.reset()),this.lastSn=n}},c.onFragLoaded=function(e,a){var t=a.frag,s=a.payload,l=this.initPTS,n=this.unparsedVttFrags;if(t.type===L.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(R.isFiniteNumber)(l[t.cc]))return n.push(a),void(l.length&&this.hls.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")}));var d=t.decryptdata;if(d==null||d.key==null||d.method!=="AES-128"){var p=this.tracks[t.level],g=this.vttCCs;g[t.cc]||(g[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),p&&p.textCodec===o.IMSC1_CODEC?this._parseIMSC1(t,s):this._parseVTTs(t,s,g)}}else this.hls.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},c._parseIMSC1=function(e,a){var t=this,s=this.hls;Object(o.parseIMSC1)(a,this.initPTS[e.cc],this.timescale[e.cc],function(l){t._appendCues(l,e.level),s.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){m.logger.log("Failed to parse IMSC1: "+l),s.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},c._parseVTTs=function(e,a,t){var s=this,l=this.hls;Object(I.parseWebVTT)(a,this.initPTS[e.cc],this.timescale[e.cc],t,e.cc,e.start,function(n){s._appendCues(n,e.level),l.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(n){s._fallbackToIMSC1(e,a),m.logger.log("Failed to parse VTT cue: "+n),l.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})},c._fallbackToIMSC1=function(e,a){var t=this,s=this.tracks[e.level];s.textCodec||Object(o.parseIMSC1)(a,this.initPTS[e.cc],this.timescale[e.cc],function(){s.textCodec=o.IMSC1_CODEC,t._parseIMSC1(e,a)},function(){s.textCodec="wvtt"})},c._appendCues=function(e,a){var t=this.hls;if(this.config.renderTextTracksNatively){var s=this.textTracks[a];if(s.mode==="disabled")return;e.forEach(function(n){return Object(D.addCueToTrack)(s,n)})}else{var l=this.tracks[a].default?"default":"subtitles"+a;t.trigger(T.Events.CUES_PARSED,{type:"subtitles",cues:e,track:l})}},c.onFragDecrypted=function(e,a){var t=a.frag;if(t.type===L.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc]))return void this.unparsedVttFrags.push(a);this.onFragLoaded(T.Events.FRAG_LOADED,a)}},c.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},c.onFragParsingUserdata=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2;if(this.enabled&&t&&s)for(var l=0;l<a.samples.length;l++){var n=a.samples[l].bytes;if(n){var d=this.extractCea608Data(n);t.addData(a.samples[l].pts,d[0]),s.addData(a.samples[l].pts,d[1])}}},c.onBufferFlushing=function(e,a){var t=a.startOffset,s=a.endOffset,l=a.endOffsetSubtitles,n=a.type,d=this.media;if(d&&!(d.currentTime<s)){if(!n||n==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(v){return Object(D.removeCuesInRange)(p[v],t,s)})}if(this.config.renderTextTracksNatively&&t===0&&l!==void 0){var g=this.textTracks;Object.keys(g).forEach(function(v){return Object(D.removeCuesInRange)(g[v],t,l)})}}},c.extractCea608Data=function(e){for(var a=31&e[0],t=2,s=[[],[]],l=0;l<a;l++){var n=e[t++],d=127&e[t++],p=127&e[t++],g=3&n;d===0&&p===0||4&n&&(g!==0&&g!==1||(s[g].push(d),s[g].push(p)))}return s},E}();function S(E,c){return E&&E.label===c.name&&!(E.textTrack1||E.textTrack2)}},"./src/crypt/aes-crypto.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return R});var R=function(){function T(A,k){this.subtle=void 0,this.aesIV=void 0,this.subtle=A,this.aesIV=k}return T.prototype.decrypt=function(A,k){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},k,A)},T}()},"./src/crypt/aes-decryptor.ts":function(N,w,h){h.r(w),h.d(w,"removePadding",function(){return T}),h.d(w,"default",function(){return A});var R=h("./src/utils/typed-array.ts");function T(k){var I=k.byteLength,D=I&&new DataView(k.buffer).getUint8(I-1);return D?Object(R.sliceUint8)(k,0,I-D):k}var A=function(){function k(){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 I=k.prototype;return I.uint8ArrayToUint32Array_=function(D){for(var o=new DataView(D),L=new Uint32Array(4),m=0;m<4;m++)L[m]=o.getUint32(4*m);return L},I.initTable=function(){var D=this.sBox,o=this.invSBox,L=this.subMix,m=L[0],f=L[1],S=L[2],E=L[3],c=this.invSubMix,e=c[0],a=c[1],t=c[2],s=c[3],l=new Uint32Array(256),n=0,d=0,p=0;for(p=0;p<256;p++)l[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=d^d<<1^d<<2^d<<3^d<<4;g=g>>>8^255&g^99,D[n]=g,o[g]=n;var v=l[n],r=l[v],i=l[r],u=257*l[g]^16843008*g;m[n]=u<<24|u>>>8,f[n]=u<<16|u>>>16,S[n]=u<<8|u>>>24,E[n]=u,u=16843009*i^65537*r^257*v^16843008*n,e[g]=u<<24|u>>>8,a[g]=u<<16|u>>>16,t[g]=u<<8|u>>>24,s[g]=u,n?(n=v^l[l[l[i^v]]],d^=l[l[d]]):n=d=1}},I.expandKey=function(D){for(var o=this.uint8ArrayToUint32Array_(D),L=!0,m=0;m<o.length&&L;)L=o[m]===this.key[m],m++;if(!L){this.key=o;var f=this.keySize=o.length;if(f!==4&&f!==6&&f!==8)throw new Error("Invalid aes key size="+f);var S,E,c,e,a=this.ksRows=4*(f+6+1),t=this.keySchedule=new Uint32Array(a),s=this.invKeySchedule=new Uint32Array(a),l=this.sBox,n=this.rcon,d=this.invSubMix,p=d[0],g=d[1],v=d[2],r=d[3];for(S=0;S<a;S++)S<f?c=t[S]=o[S]:(e=c,S%f==0?(e=l[(e=e<<8|e>>>24)>>>24]<<24|l[e>>>16&255]<<16|l[e>>>8&255]<<8|l[255&e],e^=n[S/f|0]<<24):f>6&&S%f==4&&(e=l[e>>>24]<<24|l[e>>>16&255]<<16|l[e>>>8&255]<<8|l[255&e]),t[S]=c=(t[S-f]^e)>>>0);for(E=0;E<a;E++)S=a-E,e=3&E?t[S]:t[S-4],s[E]=E<4||S<=4?e:p[l[e>>>24]]^g[l[e>>>16&255]]^v[l[e>>>8&255]]^r[l[255&e]],s[E]=s[E]>>>0}},I.networkToHostOrderSwap=function(D){return D<<24|(65280&D)<<8|(16711680&D)>>8|D>>>24},I.decrypt=function(D,o,L){for(var m,f,S,E,c,e,a,t,s,l,n,d,p,g,v=this.keySize+6,r=this.invKeySchedule,i=this.invSBox,u=this.invSubMix,y=u[0],b=u[1],_=u[2],x=u[3],C=this.uint8ArrayToUint32Array_(L),O=C[0],P=C[1],F=C[2],M=C[3],B=new Int32Array(D),U=new Int32Array(B.length),j=this.networkToHostOrderSwap;o<B.length;){for(s=j(B[o]),l=j(B[o+1]),n=j(B[o+2]),d=j(B[o+3]),c=s^r[0],e=d^r[1],a=n^r[2],t=l^r[3],p=4,g=1;g<v;g++)m=y[c>>>24]^b[e>>16&255]^_[a>>8&255]^x[255&t]^r[p],f=y[e>>>24]^b[a>>16&255]^_[t>>8&255]^x[255&c]^r[p+1],S=y[a>>>24]^b[t>>16&255]^_[c>>8&255]^x[255&e]^r[p+2],E=y[t>>>24]^b[c>>16&255]^_[e>>8&255]^x[255&a]^r[p+3],c=m,e=f,a=S,t=E,p+=4;m=i[c>>>24]<<24^i[e>>16&255]<<16^i[a>>8&255]<<8^i[255&t]^r[p],f=i[e>>>24]<<24^i[a>>16&255]<<16^i[t>>8&255]<<8^i[255&c]^r[p+1],S=i[a>>>24]<<24^i[t>>16&255]<<16^i[c>>8&255]<<8^i[255&e]^r[p+2],E=i[t>>>24]<<24^i[c>>16&255]<<16^i[e>>8&255]<<8^i[255&a]^r[p+3],U[o]=j(m^O),U[o+1]=j(E^P),U[o+2]=j(S^F),U[o+3]=j(f^M),O=s,P=l,F=n,M=d,o+=4}return U.buffer},k}()},"./src/crypt/decrypter.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return o});var R=h("./src/crypt/aes-crypto.ts"),T=h("./src/crypt/fast-aes-key.ts"),A=h("./src/crypt/aes-decryptor.ts"),k=h("./src/utils/logger.ts"),I=h("./src/utils/mp4-tools.ts"),D=h("./src/utils/typed-array.ts"),o=function(){function L(f,S,E){var c=(E===void 0?{}:E).removePKCS7Padding,e=c===void 0||c;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=f,this.config=S,this.removePKCS7Padding=e,e)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var m=L.prototype;return m.destroy=function(){this.observer=null},m.isSync=function(){return this.config.enableSoftwareAES},m.flush=function(){var f=this.currentResult;if(f){var S=new Uint8Array(f);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(S):S}this.reset()},m.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},m.decrypt=function(f,S,E,c){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(f),S,E);var e=this.flush();e&&c(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(f),S,E).then(c)},m.softwareDecrypt=function(f,S,E){var c=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(f=Object(I.appendUint8Array)(a,f),this.remainderData=null);var t=this.getValidChunk(f);if(!t.length)return null;c&&(E=c);var s=this.softwareDecrypter;s||(s=this.softwareDecrypter=new A.default),s.expandKey(S);var l=e;return this.currentResult=s.decrypt(t.buffer,0,E),this.currentIV=Object(D.sliceUint8)(t,-16).buffer,l||null},m.webCryptoDecrypt=function(f,S,E){var c=this,e=this.subtle;return this.key===S&&this.fastAesKey||(this.key=S,this.fastAesKey=new T.default(e,S)),this.fastAesKey.expandKey().then(function(a){return e?new R.default(e,E).decrypt(f.buffer,a):Promise.reject(new Error("web crypto not initialized"))}).catch(function(a){return c.onWebCryptoError(a,f,S,E)})},m.onWebCryptoError=function(f,S,E,c){return k.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",f),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,E,c)},m.getValidChunk=function(f){var S=f,E=f.length-f.length%16;return E!==f.length&&(S=Object(D.sliceUint8)(f,0,E),this.remainderData=Object(D.sliceUint8)(f,E)),S},m.logOnce=function(f){this.logEnabled&&(k.logger.log("[decrypter.ts]: "+f),this.logEnabled=!1)},L}()},"./src/crypt/fast-aes-key.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return R});var R=function(){function T(A,k){this.subtle=void 0,this.key=void 0,this.subtle=A,this.key=k}return T.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},T}()},"./src/demux/aacdemuxer.ts":function(N,w,h){h.r(w);var R=h("./src/demux/base-audio-demuxer.ts"),T=h("./src/demux/adts.ts"),A=h("./src/utils/logger.ts"),k=h("./src/demux/id3.ts");function I(o,L){return(I=Object.setPrototypeOf||function(m,f){return m.__proto__=f,m})(o,L)}var D=function(o){var L,m;function f(E,c){var e;return(e=o.call(this)||this).observer=void 0,e.config=void 0,e.observer=E,e.config=c,e}m=o,(L=f).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var S=f.prototype;return S.resetInitSegment=function(E,c,e){o.prototype.resetInitSegment.call(this,E,c,e),this._audioTrack={container:"audio/adts",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},f.probe=function(E){if(!E)return!1;for(var c=(k.getID3Data(E,0)||[]).length,e=E.length;c<e;c++)if(T.probe(E,c))return A.logger.log("ADTS sync word found !"),!0;return!1},S.canParse=function(E,c){return T.canParse(E,c)},S.appendFrame=function(E,c,e){T.initTrackConfig(E,this.observer,c,e,E.manifestCodec);var a=T.appendFrame(E,c,e,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},f}(R.default);D.minProbeByteLength=9,w.default=D},"./src/demux/adts.ts":function(N,w,h){h.r(w),h.d(w,"getAudioConfig",function(){return k}),h.d(w,"isHeaderPattern",function(){return I}),h.d(w,"getHeaderLength",function(){return D}),h.d(w,"getFullFrameLength",function(){return o}),h.d(w,"canGetFrameLength",function(){return L}),h.d(w,"isHeader",function(){return m}),h.d(w,"canParse",function(){return f}),h.d(w,"probe",function(){return S}),h.d(w,"initTrackConfig",function(){return E}),h.d(w,"getFrameDuration",function(){return c}),h.d(w,"parseFrameHeader",function(){return e}),h.d(w,"appendFrame",function(){return a});var R=h("./src/utils/logger.ts"),T=h("./src/errors.ts"),A=h("./src/events.ts");function k(t,s,l,n){var d,p,g,v,r=navigator.userAgent.toLowerCase(),i=n,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];d=1+((192&s[l+2])>>>6);var y=(60&s[l+2])>>>2;if(!(y>u.length-1))return g=(1&s[l+2])<<2,g|=(192&s[l+3])>>>6,R.logger.log("manifest codec:"+n+", ADTS type:"+d+", samplingIndex:"+y),/firefox/i.test(r)?y>=6?(d=5,v=new Array(4),p=y-3):(d=2,v=new Array(2),p=y):r.indexOf("android")!==-1?(d=2,v=new Array(2),p=y):(d=5,v=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&y>=6?p=y-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(y>=6&&g===1||/vivaldi/i.test(r))||!n&&g===1)&&(d=2,v=new Array(2)),p=y)),v[0]=d<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=g<<3,d===5&&(v[1]|=(14&p)>>1,v[2]=(1&p)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:u[y],channelCount:g,codec:"mp4a.40."+d,manifestCodec:i};t.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+y})}function I(t,s){return t[s]===255&&(246&t[s+1])==240}function D(t,s){return 1&t[s+1]?7:9}function o(t,s){return(3&t[s+3])<<11|t[s+4]<<3|(224&t[s+5])>>>5}function L(t,s){return s+5<t.length}function m(t,s){return s+1<t.length&&I(t,s)}function f(t,s){return L(t,s)&&I(t,s)&&o(t,s)<=t.length-s}function S(t,s){if(m(t,s)){var l=D(t,s);if(s+l>=t.length)return!1;var n=o(t,s);if(n<=l)return!1;var d=s+n;return d===t.length||m(t,d)}return!1}function E(t,s,l,n,d){if(!t.samplerate){var p=k(s,l,n,d);if(!p)return;t.config=p.config,t.samplerate=p.samplerate,t.channelCount=p.channelCount,t.codec=p.codec,t.manifestCodec=p.manifestCodec,R.logger.log("parsed codec:"+t.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function c(t){return 9216e4/t}function e(t,s,l,n,d){var p=D(t,s),g=o(t,s);if((g-=p)>0)return{headerLength:p,frameLength:g,stamp:l+n*d}}function a(t,s,l,n,d){var p=e(s,l,n,d,c(t.samplerate));if(p){var g,v=p.frameLength,r=p.headerLength,i=p.stamp,u=r+v,y=Math.max(0,l+u-s.length);y?(g=new Uint8Array(u-r)).set(s.subarray(l+r,s.length),0):g=s.subarray(l+r,l+u);var b={unit:g,pts:i};return y||t.samples.push(b),{sample:b,length:u,missing:y}}}},"./src/demux/base-audio-demuxer.ts":function(N,w,h){h.r(w),h.d(w,"initPTSFn",function(){return o});var R=h("./src/polyfills/number.ts"),T=h("./src/demux/id3.ts"),A=h("./src/demux/dummy-demuxed-track.ts"),k=h("./src/utils/mp4-tools.ts"),I=h("./src/utils/typed-array.ts"),D=function(){function L(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var m=L.prototype;return m.resetInitSegment=function(f,S,E){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},m.resetTimeStamp=function(){},m.resetContiguity=function(){},m.canParse=function(f,S){return!1},m.appendFrame=function(f,S,E){},m.demux=function(f,S){this.cachedData&&(f=Object(k.appendUint8Array)(this.cachedData,f),this.cachedData=null);var E,c,e=T.getID3Data(f,0),a=e?e.length:0,t=this._audioTrack,s=this._id3Track,l=e?T.getTimeStamp(e):void 0,n=f.length;for(this.frameIndex!==0&&this.initPTS!==null||(this.initPTS=o(l,S)),e&&e.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:e}),c=this.initPTS;a<n;){if(this.canParse(f,a)){var d=this.appendFrame(t,f,a);d?(this.frameIndex++,c=d.sample.pts,E=a+=d.length):a=n}else T.canParse(f,a)?(e=T.getID3Data(f,a),s.samples.push({pts:c,dts:c,data:e}),E=a+=e.length):a++;if(a===n&&E!==n){var p=Object(I.sliceUint8)(f,E);this.cachedData?this.cachedData=Object(k.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:t,avcTrack:Object(A.dummyTrack)(),id3Track:s,textTrack:Object(A.dummyTrack)()}},m.demuxSampleAes=function(f,S,E){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},m.flush=function(f){var S=this.cachedData;return S&&(this.cachedData=null,this.demux(S,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(A.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(A.dummyTrack)()}},m.destroy=function(){},L}(),o=function(L,m){return Object(R.isFiniteNumber)(L)?90*L:9e4*m};w.default=D},"./src/demux/chunk-cache.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return R});var R=function(){function T(){this.chunks=[],this.dataLength=0}var A=T.prototype;return A.push=function(k){this.chunks.push(k),this.dataLength+=k.length},A.flush=function(){var k,I=this.chunks,D=this.dataLength;return I.length?(k=I.length===1?I[0]:function(o,L){for(var m=new Uint8Array(L),f=0,S=0;S<o.length;S++){var E=o[S];m.set(E,f),f+=E.length}return m}(I,D),this.reset(),k):new Uint8Array(0)},A.reset=function(){this.chunks.length=0,this.dataLength=0},T}()},"./src/demux/dummy-demuxed-track.ts":function(N,w,h){function R(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}h.r(w),h.d(w,"dummyTrack",function(){return R})},"./src/demux/exp-golomb.ts":function(N,w,h){h.r(w);var R=h("./src/utils/logger.ts"),T=function(){function A(I){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=I,this.bytesAvailable=I.byteLength,this.word=0,this.bitsAvailable=0}var k=A.prototype;return k.loadWord=function(){var I=this.data,D=this.bytesAvailable,o=I.byteLength-D,L=new Uint8Array(4),m=Math.min(4,D);if(m===0)throw new Error("no bytes available");L.set(I.subarray(o,o+m)),this.word=new DataView(L.buffer).getUint32(0),this.bitsAvailable=8*m,this.bytesAvailable-=m},k.skipBits=function(I){var D;this.bitsAvailable>I?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,I-=(D=I>>3)>>3,this.bytesAvailable-=D,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},k.readBits=function(I){var D=Math.min(this.bitsAvailable,I),o=this.word>>>32-D;return I>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=D,this.bitsAvailable>0?this.word<<=D:this.bytesAvailable>0&&this.loadWord(),(D=I-D)>0&&this.bitsAvailable?o<<D|this.readBits(D):o},k.skipLZ=function(){var I;for(I=0;I<this.bitsAvailable;++I)if(this.word&2147483648>>>I)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},k.skipUEG=function(){this.skipBits(1+this.skipLZ())},k.skipEG=function(){this.skipBits(1+this.skipLZ())},k.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},k.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>1)},k.readBoolean=function(){return this.readBits(1)===1},k.readUByte=function(){return this.readBits(8)},k.readUShort=function(){return this.readBits(16)},k.readUInt=function(){return this.readBits(32)},k.skipScalingList=function(I){for(var D=8,o=8,L=0;L<I;L++)o!==0&&(o=(D+this.readEG()+256)%256),D=o===0?D:o},k.readSPS=function(){var I,D,o,L=0,m=0,f=0,S=0,E=this.readUByte.bind(this),c=this.readBits.bind(this),e=this.readUEG.bind(this),a=this.readBoolean.bind(this),t=this.skipBits.bind(this),s=this.skipEG.bind(this),l=this.skipUEG.bind(this),n=this.skipScalingList.bind(this);E();var d=E();if(c(5),t(3),E(),l(),d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128){var p=e();if(p===3&&t(1),l(),l(),t(1),a())for(D=p!==3?8:12,o=0;o<D;o++)a()&&n(o<6?16:64)}l();var g=e();if(g===0)e();else if(g===1)for(t(1),s(),s(),I=e(),o=0;o<I;o++)s();l(),t(1);var v=e(),r=e(),i=c(1);i===0&&t(1),t(1),a()&&(L=e(),m=e(),f=e(),S=e());var u=[1,1];if(a()&&a())switch(E()){case 1:u=[1,1];break;case 2:u=[12,11];break;case 3:u=[10,11];break;case 4:u=[16,11];break;case 5:u=[40,33];break;case 6:u=[24,11];break;case 7:u=[20,11];break;case 8:u=[32,11];break;case 9:u=[80,33];break;case 10:u=[18,11];break;case 11:u=[15,11];break;case 12:u=[64,33];break;case 13:u=[160,99];break;case 14:u=[4,3];break;case 15:u=[3,2];break;case 16:u=[2,1];break;case 255:u=[E()<<8|E(),E()<<8|E()]}return{width:Math.ceil(16*(v+1)-2*L-2*m),height:(2-i)*(r+1)*16-(i?2:4)*(f+S),pixelRatio:u}},k.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();w.default=T},"./src/demux/id3.ts":function(N,w,h){h.r(w),h.d(w,"isHeader",function(){return T}),h.d(w,"isFooter",function(){return A}),h.d(w,"getID3Data",function(){return k}),h.d(w,"canParse",function(){return D}),h.d(w,"getTimeStamp",function(){return o}),h.d(w,"isTimeStampFrame",function(){return L}),h.d(w,"getID3Frames",function(){return f}),h.d(w,"decodeFrame",function(){return S}),h.d(w,"utf8ArrayToStr",function(){return t}),h.d(w,"testables",function(){return s});var R,T=function(l,n){return n+10<=l.length&&l[n]===73&&l[n+1]===68&&l[n+2]===51&&l[n+3]<255&&l[n+4]<255&&l[n+6]<128&&l[n+7]<128&&l[n+8]<128&&l[n+9]<128},A=function(l,n){return n+10<=l.length&&l[n]===51&&l[n+1]===68&&l[n+2]===73&&l[n+3]<255&&l[n+4]<255&&l[n+6]<128&&l[n+7]<128&&l[n+8]<128&&l[n+9]<128},k=function(l,n){for(var d=n,p=0;T(l,n);)p+=10,p+=I(l,n+6),A(l,n+10)&&(p+=10),n+=p;if(p>0)return l.subarray(d,d+p)},I=function(l,n){var d=0;return d=(127&l[n])<<21,d|=(127&l[n+1])<<14,d|=(127&l[n+2])<<7,d|=127&l[n+3]},D=function(l,n){return T(l,n)&&I(l,n+6)+10<=l.length-n},o=function(l){for(var n=f(l),d=0;d<n.length;d++){var p=n[d];if(L(p))return a(p)}},L=function(l){return l&&l.key==="PRIV"&&l.info==="com.apple.streaming.transportStreamTimestamp"},m=function(l){var n=String.fromCharCode(l[0],l[1],l[2],l[3]),d=I(l,4);return{type:n,size:d,data:l.subarray(10,10+d)}},f=function(l){for(var n=0,d=[];T(l,n);){for(var p=I(l,n+6),g=(n+=10)+p;n+8<g;){var v=m(l.subarray(n)),r=S(v);r&&d.push(r),n+=v.size+10}A(l,n)&&(n+=10)}return d},S=function(l){return l.type==="PRIV"?E(l):l.type[0]==="W"?e(l):c(l)},E=function(l){if(!(l.size<2)){var n=t(l.data,!0),d=new Uint8Array(l.data.subarray(n.length+1));return{key:l.type,info:n,data:d.buffer}}},c=function(l){if(!(l.size<2)){if(l.type==="TXXX"){var n=1,d=t(l.data.subarray(n),!0);n+=d.length+1;var p=t(l.data.subarray(n));return{key:l.type,info:d,data:p}}var g=t(l.data.subarray(1));return{key:l.type,data:g}}},e=function(l){if(l.type==="WXXX"){if(l.size<2)return;var n=1,d=t(l.data.subarray(n),!0);n+=d.length+1;var p=t(l.data.subarray(n));return{key:l.type,info:d,data:p}}var g=t(l.data);return{key:l.type,data:g}},a=function(l){if(l.data.byteLength===8){var n=new Uint8Array(l.data),d=1&n[3],p=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return p/=45,d&&(p+=4772185884e-2),Math.round(p)}},t=function(l,n){n===void 0&&(n=!1);var d=(R||self.TextDecoder===void 0||(R=new self.TextDecoder("utf-8")),R);if(d){var p=d.decode(l);if(n){var g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}for(var v,r,i,u=l.length,y="",b=0;b<u;){if((v=l[b++])===0&&n)return y;if(v!==0&&v!==3)switch(v>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:y+=String.fromCharCode(v);break;case 12:case 13:r=l[b++],y+=String.fromCharCode((31&v)<<6|63&r);break;case 14:r=l[b++],i=l[b++],y+=String.fromCharCode((15&v)<<12|(63&r)<<6|(63&i)<<0)}}return y},s={decodeTextFrame:c}},"./src/demux/mp3demuxer.ts":function(N,w,h){h.r(w);var R=h("./src/demux/base-audio-demuxer.ts"),T=h("./src/demux/id3.ts"),A=h("./src/utils/logger.ts"),k=h("./src/demux/mpegaudio.ts");function I(o,L){return(I=Object.setPrototypeOf||function(m,f){return m.__proto__=f,m})(o,L)}var D=function(o){var L,m;function f(){return o.apply(this,arguments)||this}m=o,(L=f).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var S=f.prototype;return S.resetInitSegment=function(E,c,e){o.prototype.resetInitSegment.call(this,E,c,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},f.probe=function(E){if(!E)return!1;for(var c=(T.getID3Data(E,0)||[]).length,e=E.length;c<e;c++)if(k.probe(E,c))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},S.canParse=function(E,c){return k.canParse(E,c)},S.appendFrame=function(E,c,e){if(this.initPTS!==null)return k.appendFrame(E,c,e,this.initPTS,this.frameIndex)},f}(R.default);D.minProbeByteLength=4,w.default=D},"./src/demux/mp4demuxer.ts":function(N,w,h){h.r(w);var R=h("./src/utils/mp4-tools.ts"),T=h("./src/demux/dummy-demuxed-track.ts"),A=function(){function k(D,o){this.remainderData=null,this.config=void 0,this.config=o}var I=k.prototype;return I.resetTimeStamp=function(){},I.resetInitSegment=function(){},I.resetContiguity=function(){},k.probe=function(D){return Object(R.findBox)({data:D,start:0,end:Math.min(D.length,16384)},["moof"]).length>0},I.demux=function(D){var o=D,L=Object(T.dummyTrack)();if(this.config.progressive){this.remainderData&&(o=Object(R.appendUint8Array)(this.remainderData,D));var m=Object(R.segmentValidRange)(o);this.remainderData=m.remainder,L.samples=m.valid||new Uint8Array}else L.samples=o;return{audioTrack:Object(T.dummyTrack)(),avcTrack:L,id3Track:Object(T.dummyTrack)(),textTrack:Object(T.dummyTrack)()}},I.flush=function(){var D=Object(T.dummyTrack)();return D.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(T.dummyTrack)(),avcTrack:D,id3Track:Object(T.dummyTrack)(),textTrack:Object(T.dummyTrack)()}},I.demuxSampleAes=function(D,o,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},k}();A.minProbeByteLength=1024,w.default=A},"./src/demux/mpegaudio.ts":function(N,w,h){h.r(w),h.d(w,"appendFrame",function(){return D}),h.d(w,"parseHeader",function(){return o}),h.d(w,"isHeaderPattern",function(){return L}),h.d(w,"isHeader",function(){return m}),h.d(w,"canParse",function(){return f}),h.d(w,"probe",function(){return S});var R=null,T=[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],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],k=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I=[0,1,1,4];function D(E,c,e,a,t){if(!(e+24>c.length)){var s=o(c,e);if(s&&e+s.frameLength<=c.length){var l=a+t*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:c.subarray(e,e+s.frameLength),pts:l,dts:l};return E.config=[],E.channelCount=s.channelCount,E.samplerate=s.sampleRate,E.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}}function o(E,c){var e=E[c+1]>>3&3,a=E[c+1]>>1&3,t=E[c+2]>>4&15,s=E[c+2]>>2&3;if(e!==1&&t!==0&&t!==15&&s!==3){var l=E[c+2]>>1&1,n=E[c+3]>>6,d=1e3*T[14*(e===3?3-a:a===3?3:4)+t-1],p=A[3*(e===3?0:e===2?1:2)+s],g=n===3?1:2,v=k[e][a],r=I[a],i=8*v*r,u=Math.floor(v*d/p+l)*r;if(R===null){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);R=y?parseInt(y[1]):0}return R&&R<=87&&a===2&&d>=224e3&&n===0&&(E[c+3]=128|E[c+3]),{sampleRate:p,channelCount:g,frameLength:u,samplesPerFrame:i}}}function L(E,c){return E[c]===255&&(224&E[c+1])==224&&(6&E[c+1])!=0}function m(E,c){return c+1<E.length&&L(E,c)}function f(E,c){return L(E,c)&&4<=E.length-c}function S(E,c){if(c+1<E.length&&L(E,c)){var e=o(E,c),a=4;e!=null&&e.frameLength&&(a=e.frameLength);var t=c+a;return t===E.length||m(E,t)}return!1}},"./src/demux/sample-aes.ts":function(N,w,h){h.r(w);var R=h("./src/crypt/decrypter.ts"),T=h("./src/demux/tsdemuxer.ts"),A=function(){function k(D,o,L){this.keyData=void 0,this.decrypter=void 0,this.keyData=L,this.decrypter=new R.default(D,o,{removePKCS7Padding:!1})}var I=k.prototype;return I.decryptBuffer=function(D,o){this.decrypter.decrypt(D,this.keyData.key.buffer,this.keyData.iv.buffer,o)},I.decryptAacSample=function(D,o,L,m){var f=D[o].unit,S=f.subarray(16,f.length-f.length%16),E=S.buffer.slice(S.byteOffset,S.byteOffset+S.length),c=this;this.decryptBuffer(E,function(e){var a=new Uint8Array(e);f.set(a,16),m||c.decryptAacSamples(D,o+1,L)})},I.decryptAacSamples=function(D,o,L){for(;;o++){if(o>=D.length)return void L();if(!(D[o].unit.length<32)){var m=this.decrypter.isSync();if(this.decryptAacSample(D,o,L,m),!m)return}}},I.getAvcEncryptedData=function(D){for(var o=16*Math.floor((D.length-48)/160)+16,L=new Int8Array(o),m=0,f=32;f<=D.length-16;f+=160,m+=16)L.set(D.subarray(f,f+16),m);return L},I.getAvcDecryptedUnit=function(D,o){for(var L=new Uint8Array(o),m=0,f=32;f<=D.length-16;f+=160,m+=16)D.set(L.subarray(m,m+16),f);return D},I.decryptAvcSample=function(D,o,L,m,f,S){var E=Object(T.discardEPB)(f.data),c=this.getAvcEncryptedData(E),e=this;this.decryptBuffer(c.buffer,function(a){f.data=e.getAvcDecryptedUnit(E,a),S||e.decryptAvcSamples(D,o,L+1,m)})},I.decryptAvcSamples=function(D,o,L,m){if(D instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;o++,L=0){if(o>=D.length)return void m();for(var f=D[o].units;!(L>=f.length);L++){var S=f[L];if(!(S.data.length<=48||S.type!==1&&S.type!==5)){var E=this.decrypter.isSync();if(this.decryptAvcSample(D,o,L,m,S,E),!E)return}}}},k}();w.default=A},"./src/demux/transmuxer-interface.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return m});var R=h("./node_modules/webworkify-webpack/index.js"),T=h("./src/events.ts"),A=h("./src/demux/transmuxer.ts"),k=h("./src/utils/logger.ts"),I=h("./src/errors.ts"),D=h("./src/utils/mediasource-helper.ts"),o=h("./node_modules/eventemitter3/index.js"),L=Object(D.getMediaSource)()||{isTypeSupported:function(){return!1}},m=function(){function f(E,c,e,a){var t=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=E,this.id=c,this.onTransmuxComplete=e,this.onFlush=a;var s=E.config,l=function(g,v){(v=v||{}).frag=t.frag,v.id=t.id,E.trigger(g,v)};this.observer=new o.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,l),this.observer.on(T.Events.ERROR,l);var n={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(s.enableWorker&&typeof Worker<"u"){var p;k.logger.log("demuxing in webworker");try{p=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(g){E.trigger(T.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},p.postMessage({cmd:"init",typeSupported:n,vendor:d,id:c,config:JSON.stringify(s)})}catch(g){k.logger.warn("Error in worker:",g),k.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new A.default(this.observer,n,s,d,c),this.worker=null}}else this.transmuxer=new A.default(this.observer,n,s,d,c)}var S=f.prototype;return S.destroy=function(){var E=this.worker;if(E)E.removeEventListener("message",this.onwmsg),E.terminate(),this.worker=null;else{var c=this.transmuxer;c&&(c.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.observer=null},S.push=function(E,c,e,a,t,s,l,n,d,p){var g=this;d.transmuxing.start=self.performance.now();var v=this.transmuxer,r=this.worker,i=s?s.start:t.start,u=t.decryptdata,y=this.frag,b=!(y&&t.cc===y.cc),_=!(y&&d.level===y.level),x=y?d.sn-y.sn:-1,C=this.part?d.part-this.part.index:1,O=!_&&(x===1||x===0&&C===1),P=self.performance.now();(_||x||t.stats.parsing.start===0)&&(t.stats.parsing.start=P),!s||!C&&O||(s.stats.parsing.start=P);var F=new A.TransmuxState(b,O,n,_,i);if(!O||b){k.logger.log("[transmuxer-interface, "+t.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
|
||
discontinuity: `+b+`
|
||
trackSwitch: `+_+`
|
||
contiguous: `+O+`
|
||
accurateTimeOffset: `+n+`
|
||
timeOffset: `+i);var M=new A.TransmuxConfig(e,a,c,l,p);this.configureTransmuxer(M)}if(this.frag=t,this.part=s,r)r.postMessage({cmd:"demux",data:E,decryptdata:u,chunkMeta:d,state:F},E instanceof ArrayBuffer?[E]:[]);else if(v){var B=v.push(E,u,d,F);Object(A.isPromise)(B)?B.then(function(U){g.handleTransmuxComplete(U)}):this.handleTransmuxComplete(B)}},S.flush=function(E){var c=this;E.transmuxing.start=self.performance.now();var e=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:E});else if(e){var t=e.flush(E);Object(A.isPromise)(t)?t.then(function(s){c.handleFlushResult(s,E)}):this.handleFlushResult(t,E)}},S.handleFlushResult=function(E,c){var e=this;E.forEach(function(a){e.handleTransmuxComplete(a)}),this.onFlush(c)},S.onWorkerMessage=function(E){var c=E.data,e=this.hls;switch(c.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(c.data);break;case"flush":this.onFlush(c.data);break;default:c.data=c.data||{},c.data.frag=this.frag,c.data.id=this.id,e.trigger(c.event,c.data)}},S.configureTransmuxer=function(E){var c=this.worker,e=this.transmuxer;c?c.postMessage({cmd:"configure",config:E}):e&&e.configure(E)},S.handleTransmuxComplete=function(E){E.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(E)},f}()},"./src/demux/transmuxer-worker.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return I});var R=h("./src/demux/transmuxer.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts"),k=h("./node_modules/eventemitter3/index.js");function I(m){var f=new k.EventEmitter,S=function(E,c){m.postMessage({event:E,data:c})};f.on(T.Events.FRAG_DECRYPTED,S),f.on(T.Events.ERROR,S),m.addEventListener("message",function(E){var c=E.data;switch(c.cmd){case"init":var e=JSON.parse(c.config);m.transmuxer=new R.default(f,c.typeSupported,e,c.vendor,c.id),Object(A.enableLogs)(e.debug),S("init",null);break;case"configure":m.transmuxer.configure(c.config);break;case"demux":var a=m.transmuxer.push(c.data,c.decryptdata,c.chunkMeta,c.state);Object(R.isPromise)(a)?a.then(function(l){D(m,l)}):D(m,a);break;case"flush":var t=c.chunkMeta,s=m.transmuxer.flush(t);Object(R.isPromise)(s)?s.then(function(l){L(m,l,t)}):L(m,s,t)}})}function D(m,f){if((S=f.remuxResult).audio||S.video||S.text||S.id3||S.initSegment){var S,E=[],c=f.remuxResult,e=c.audio,a=c.video;e&&o(E,e),a&&o(E,a),m.postMessage({event:"transmuxComplete",data:f},E)}}function o(m,f){f.data1&&m.push(f.data1.buffer),f.data2&&m.push(f.data2.buffer)}function L(m,f,S){f.forEach(function(E){D(m,E)}),m.postMessage({event:"flush",data:S})}},"./src/demux/transmuxer.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return t}),h.d(w,"isPromise",function(){return l}),h.d(w,"TransmuxConfig",function(){return n}),h.d(w,"TransmuxState",function(){return d});var R,T=h("./src/events.ts"),A=h("./src/errors.ts"),k=h("./src/crypt/decrypter.ts"),I=h("./src/demux/aacdemuxer.ts"),D=h("./src/demux/mp4demuxer.ts"),o=h("./src/demux/tsdemuxer.ts"),L=h("./src/demux/mp3demuxer.ts"),m=h("./src/remux/mp4-remuxer.ts"),f=h("./src/remux/passthrough-remuxer.ts"),S=h("./src/demux/chunk-cache.ts"),E=h("./src/utils/mp4-tools.ts"),c=h("./src/utils/logger.ts");try{R=self.performance.now.bind(self.performance)}catch{c.logger.debug("Unable to use Performance API on this environment"),R=self.Date.now}var e=[{demux:o.default,remux:m.default},{demux:D.default,remux:f.default},{demux:I.default,remux:m.default},{demux:L.default,remux:m.default}],a=1024;e.forEach(function(p){var g=p.demux;a=Math.max(a,g.minProbeByteLength)});var t=function(){function p(v,r,i,u,y){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 S.default,this.observer=v,this.typeSupported=r,this.config=i,this.vendor=u,this.id=y}var g=p.prototype;return g.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},g.push=function(v,r,i,u){var y=this,b=i.transmuxing;b.executeStart=R();var _=new Uint8Array(v),x=this.cache,C=this.config,O=this.currentTransmuxState,P=this.transmuxConfig;u&&(this.currentTransmuxState=u);var F=function(ce,H){var oe=null;return ce.byteLength>0&&H!=null&&H.key!=null&&H.iv!==null&&H.method!=null&&(oe=H),oe}(_,r);if(F&&F.method==="AES-128"){var M=this.getDecrypter();if(!C.enableSoftwareAES)return this.decryptionPromise=M.webCryptoDecrypt(_,F.key.buffer,F.iv.buffer).then(function(ce){var H=y.push(ce,null,i);return y.decryptionPromise=null,H}),this.decryptionPromise;var B=M.softwareDecrypt(_,F.key.buffer,F.iv.buffer);if(!B)return b.executeEnd=R(),s(i);_=new Uint8Array(B)}var U=u||O,j=U.contiguous,V=U.discontinuity,W=U.trackSwitch,X=U.accurateTimeOffset,q=U.timeOffset,$=P.audioCodec,ie=P.videoCodec,se=P.defaultInitPts,le=P.duration,re=P.initSegmentData;if((V||W)&&this.resetInitSegment(re,$,ie,le),V&&this.resetInitialTimestamp(se),j||this.resetContiguity(),this.needsProbing(_,V,W)){if(x.dataLength){var de=x.flush();_=Object(E.appendUint8Array)(de,_)}this.configureTransmuxer(_,P)}var te=this.transmux(_,F,q,X,i),ne=this.currentTransmuxState;return ne.contiguous=!0,ne.discontinuity=!1,ne.trackSwitch=!1,b.executeEnd=R(),te},g.flush=function(v){var r=this,i=v.transmuxing;i.executeStart=R();var u=this.decrypter,y=this.cache,b=this.currentTransmuxState,_=this.decryptionPromise;if(_)return _.then(function(){return r.flush(v)});var x=[],C=b.timeOffset;if(u){var O=u.flush();O&&x.push(this.push(O,null,v))}var P=y.dataLength;y.reset();var F=this.demuxer,M=this.remuxer;if(!F||!M)return P>=a&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),i.executeEnd=R(),[s(v)];var B=F.flush(C);return l(B)?B.then(function(U){return r.flushRemux(x,U,v),x}):(this.flushRemux(x,B,v),x)},g.flushRemux=function(v,r,i){var u=r.audioTrack,y=r.avcTrack,b=r.id3Track,_=r.textTrack,x=this.currentTransmuxState,C=x.accurateTimeOffset,O=x.timeOffset;c.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var P=this.remuxer.remux(u,y,b,_,O,C,!0,this.id);v.push({remuxResult:P,chunkMeta:i}),i.transmuxing.executeEnd=R()},g.resetInitialTimestamp=function(v){var r=this.demuxer,i=this.remuxer;r&&i&&(r.resetTimeStamp(v),i.resetTimeStamp(v))},g.resetContiguity=function(){var v=this.demuxer,r=this.remuxer;v&&r&&(v.resetContiguity(),r.resetNextTimestamp())},g.resetInitSegment=function(v,r,i,u){var y=this.demuxer,b=this.remuxer;y&&b&&(y.resetInitSegment(r,i,u),b.resetInitSegment(v,r,i))},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(v,r,i,u,y){return r&&r.method==="SAMPLE-AES"?this.transmuxSampleAes(v,r,i,u,y):this.transmuxUnencrypted(v,i,u,y)},g.transmuxUnencrypted=function(v,r,i,u){var y=this.demuxer.demux(v,r,!1,!this.config.progressive),b=y.audioTrack,_=y.avcTrack,x=y.id3Track,C=y.textTrack;return{remuxResult:this.remuxer.remux(b,_,x,C,r,i,!1,this.id),chunkMeta:u}},g.transmuxSampleAes=function(v,r,i,u,y){var b=this;return this.demuxer.demuxSampleAes(v,r,i).then(function(_){return{remuxResult:b.remuxer.remux(_.audioTrack,_.avcTrack,_.id3Track,_.textTrack,i,u,!1,b.id),chunkMeta:y}})},g.configureTransmuxer=function(v,r){for(var i,u=this.config,y=this.observer,b=this.typeSupported,_=this.vendor,x=r.audioCodec,C=r.defaultInitPts,O=r.duration,P=r.initSegmentData,F=r.videoCodec,M=0,B=e.length;M<B;M++)if(e[M].demux.probe(v)){i=e[M];break}i||(c.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),i={demux:D.default,remux:f.default});var U=this.demuxer,j=this.remuxer,V=i.remux,W=i.demux;j&&j instanceof V||(this.remuxer=new V(y,u,b,_)),U&&U instanceof W||(this.demuxer=new W(y,u,b),this.probe=W.probe),this.resetInitSegment(P,x,F,O),this.resetInitialTimestamp(C)},g.needsProbing=function(v,r,i){return!this.demuxer||!this.remuxer||r||i},g.getDecrypter=function(){var v=this.decrypter;return v||(v=this.decrypter=new k.default(this.observer,this.config)),v},p}(),s=function(p){return{remuxResult:{},chunkMeta:p}};function l(p){return"then"in p&&p.then instanceof Function}var n=function(p,g,v,r,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=p,this.videoCodec=g,this.initSegmentData=v,this.duration=r,this.defaultInitPts=i},d=function(p,g,v,r,i){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=p,this.contiguous=g,this.accurateTimeOffset=v,this.trackSwitch=r,this.timeOffset=i}},"./src/demux/tsdemuxer.ts":function(N,w,h){h.r(w),h.d(w,"discardEPB",function(){return l});var R=h("./src/demux/adts.ts"),T=h("./src/demux/mpegaudio.ts"),A=h("./src/demux/exp-golomb.ts"),k=h("./src/demux/id3.ts"),I=h("./src/demux/sample-aes.ts"),D=h("./src/events.ts"),o=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/logger.ts"),m=h("./src/errors.ts"),f={video:1,audio:2,id3:3,text:4},S=function(){function n(p,g,v){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=p,this.config=g,this.typeSupported=v}n.probe=function(p){var g=n.syncOffset(p);return!(g<0||(g&&L.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),0))},n.syncOffset=function(p){for(var g=Math.min(1e3,p.length-564),v=0;v<g;){if(p[v]===71&&p[v+188]===71&&p[v+376]===71)return v;v++}return-1},n.createTrack=function(p,g){return{container:p==="video"||p==="audio"?"video/mp2t":void 0,type:p,id:f[p],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:p==="audio"?g:void 0}};var d=n.prototype;return d.resetInitSegment=function(p,g,v){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video",v),this._audioTrack=n.createTrack("audio",v),this._id3Track=n.createTrack("id3",v),this._txtTrack=n.createTrack("text",v),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=p,this.videoCodec=g,this._duration=v},d.resetTimeStamp=function(){},d.resetContiguity=function(){var p=this._audioTrack,g=this._avcTrack,v=this._id3Track;p&&(p.pesData=null),g&&(g.pesData=null),v&&(v.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},d.demux=function(p,g,v,r){var i;v===void 0&&(v=!1),r===void 0&&(r=!1),v||(this.sampleAes=null);var u=this._avcTrack,y=this._audioTrack,b=this._id3Track,_=u.pid,x=u.pesData,C=y.pid,O=b.pid,P=y.pesData,F=b.pesData,M=!1,B=this.pmtParsed,U=this._pmtId,j=p.length;if(this.remainderData&&(j=(p=Object(o.appendUint8Array)(this.remainderData,p)).length,this.remainderData=null),j<188&&!r)return this.remainderData=p,{audioTrack:y,avcTrack:u,id3Track:b,textTrack:this._txtTrack};var V=Math.max(0,n.syncOffset(p));(j-=(j+V)%188)<p.byteLength&&!r&&(this.remainderData=new Uint8Array(p.buffer,j,p.buffer.byteLength-j));for(var W=V;W<j;W+=188)if(p[W]===71){var X=!!(64&p[W+1]),q=((31&p[W+1])<<8)+p[W+2],$=void 0;if((48&p[W+3])>>4>1){if(($=W+5+p[W+4])===W+188)continue}else $=W+4;switch(q){case _:X&&(x&&(i=a(x))&&this.parseAVCPES(i,!1),x={data:[],size:0}),x&&(x.data.push(p.subarray($,W+188)),x.size+=W+188-$);break;case C:X&&(P&&(i=a(P))&&(y.isAAC?this.parseAACPES(i):this.parseMPEGPES(i)),P={data:[],size:0}),P&&(P.data.push(p.subarray($,W+188)),P.size+=W+188-$);break;case O:X&&(F&&(i=a(F))&&this.parseID3PES(i),F={data:[],size:0}),F&&(F.data.push(p.subarray($,W+188)),F.size+=W+188-$);break;case 0:X&&($+=p[$]+1),U=this._pmtId=c(p,$);break;case U:X&&($+=p[$]+1);var ie=e(p,$,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,v);(_=ie.avc)>0&&(u.pid=_),(C=ie.audio)>0&&(y.pid=C,y.isAAC=ie.isAAC),(O=ie.id3)>0&&(b.pid=O),M&&!B&&(L.logger.log("reparse from beginning"),M=!1,W=V-188),B=this.pmtParsed=!0;break;case 17:case 8191:break;default:M=!0}}else this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});u.pesData=x,y.pesData=P,b.pesData=F;var se={audioTrack:y,avcTrack:u,id3Track:b,textTrack:this._txtTrack};return r&&this.extractRemainingSamples(se),se},d.flush=function(){var p,g=this.remainderData;return this.remainderData=null,p=g?this.demux(g,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},d.extractRemainingSamples=function(p){var g,v=p.audioTrack,r=p.avcTrack,i=p.id3Track,u=r.pesData,y=v.pesData,b=i.pesData;u&&(g=a(u))?(this.parseAVCPES(g,!0),r.pesData=null):r.pesData=u,y&&(g=a(y))?(v.isAAC?this.parseAACPES(g):this.parseMPEGPES(g),v.pesData=null):(y!=null&&y.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),v.pesData=y),b&&(g=a(b))?(this.parseID3PES(g),i.pesData=null):i.pesData=b},d.demuxSampleAes=function(p,g,v){var r=this.demux(p,v,!0,!this.config.progressive),i=this.sampleAes=new I.default(this.observer,this.config,g);return this.decrypt(r,i)},d.decrypt=function(p,g){return new Promise(function(v){var r=p.audioTrack,i=p.avcTrack;r.samples&&r.isAAC?g.decryptAacSamples(r.samples,0,function(){i.samples?g.decryptAvcSamples(i.samples,0,0,function(){v(p)}):v(p)}):i.samples&&g.decryptAvcSamples(i.samples,0,0,function(){v(p)})})},d.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},d.parseAVCPES=function(p,g){var v,r=this,i=this._avcTrack,u=this.parseAVCNALu(p.data),y=this.avcSample,b=!1;p.data=null,y&&u.length&&!i.audFound&&(t(y,i),y=this.avcSample=E(!1,p.pts,p.dts,"")),u.forEach(function(_){switch(_.type){case 1:v=!0,y||(y=r.avcSample=E(!0,p.pts,p.dts,"")),y.frame=!0;var x=_.data;if(b&&x.length>4){var C=new A.default(x).readSliceType();C!==2&&C!==4&&C!==7&&C!==9||(y.key=!0)}break;case 5:v=!0,y||(y=r.avcSample=E(!0,p.pts,p.dts,"")),y.key=!0,y.frame=!0;break;case 6:v=!0;var O=new A.default(l(_.data));O.readUByte();for(var P=0,F=0,M=!1,B=0;!M&&O.bytesAvailable>1;){P=0;do P+=B=O.readUByte();while(B===255);F=0;do F+=B=O.readUByte();while(B===255);if(P===4&&O.bytesAvailable!==0){if(M=!0,O.readUByte()===181&&O.readUShort()===49&&O.readUInt()===1195456820&&O.readUByte()===3){for(var U=O.readUByte(),j=31&U,V=[U,O.readUByte()],W=0;W<j;W++)V.push(O.readUByte()),V.push(O.readUByte()),V.push(O.readUByte());s(r._txtTrack.samples,{type:3,pts:p.pts,bytes:V})}}else if(P===5&&O.bytesAvailable!==0){if(M=!0,F>16){for(var X=[],q=0;q<16;q++)X.push(O.readUByte().toString(16)),q!==3&&q!==5&&q!==7&&q!==9||X.push("-");for(var $=F-16,ie=new Uint8Array($),se=0;se<$;se++)ie[se]=O.readUByte();s(r._txtTrack.samples,{pts:p.pts,payloadType:P,uuid:X.join(""),userData:Object(k.utf8ArrayToStr)(ie),userDataBytes:ie})}}else if(F<O.bytesAvailable)for(var le=0;le<F;le++)O.readUByte()}break;case 7:if(v=!0,b=!0,!i.sps){var re=new A.default(_.data).readSPS();i.width=re.width,i.height=re.height,i.pixelRatio=re.pixelRatio,i.sps=[_.data],i.duration=r._duration;for(var de=_.data.subarray(1,4),te="avc1.",ne=0;ne<3;ne++){var ce=de[ne].toString(16);ce.length<2&&(ce="0"+ce),te+=ce}i.codec=te}break;case 8:v=!0,i.pps||(i.pps=[_.data]);break;case 9:v=!1,i.audFound=!0,y&&t(y,i),y=r.avcSample=E(!1,p.pts,p.dts,"");break;case 12:v=!1;break;default:v=!1,y&&(y.debug+="unknown NAL "+_.type+" ")}y&&v&&y.units.push(_)}),g&&y&&(t(y,i),this.avcSample=null)},d.getLastNalUnit=function(){var p,g,v=this.avcSample;if(!v||v.units.length===0){var r=this._avcTrack.samples;v=r[r.length-1]}if((p=v)!==null&&p!==void 0&&p.units){var i=v.units;g=i[i.length-1]}return g},d.parseAVCNALu=function(p){var g,v,r=p.byteLength,i=this._avcTrack,u=i.naluState||0,y=u,b=[],_=0,x=-1,C=0;for(u===-1&&(x=0,C=31&p[0],u=0,_=1);_<r;)if(g=p[_++],u)if(u!==1)if(g)if(g===1){if(x>=0){var O={data:p.subarray(x,_-u-1),type:C};b.push(O)}else{var P=this.getLastNalUnit();if(P&&(y&&_<=4-y&&P.state&&(P.data=P.data.subarray(0,P.data.byteLength-y)),(v=_-u-1)>0)){var F=new Uint8Array(P.data.byteLength+v);F.set(P.data,0),F.set(p.subarray(0,v),P.data.byteLength),P.data=F}}_<r?(x=_,C=31&p[_],u=0):u=-1}else u=0;else u=3;else u=g?0:2;else u=g?0:1;if(x>=0&&u>=0){var M={data:p.subarray(x,r),type:C,state:u};b.push(M)}if(b.length===0){var B=this.getLastNalUnit();if(B){var U=new Uint8Array(B.data.byteLength+p.byteLength);U.set(B.data,0),U.set(p,B.data.byteLength),B.data=U}}return i.naluState=u,b},d.parseAACPES=function(p){var g,v,r,i,u,y=0,b=this._audioTrack,_=this.aacOverFlow,x=p.data;if(_){this.aacOverFlow=null;var C=_.sample.unit.byteLength,O=Math.min(_.missing,C),P=C-O;_.sample.unit.set(x.subarray(0,O),P),b.samples.push(_.sample),y=_.missing}for(g=y,v=x.length;g<v-1&&!R.isHeader(x,g);g++);if(g===y||(g<v-1?(r="AAC PES did not start with ADTS header,offset:"+g,i=!1):(r="no ADTS header found in AAC PES",i=!0),L.logger.warn("parsing error:"+r),this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:i,reason:r}),!i)){if(R.initTrackConfig(b,this.observer,x,g,this.audioCodec),p.pts!==void 0)u=p.pts;else{if(!_)return void L.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var F=R.getFrameDuration(b.samplerate);u=_.sample.pts+F}for(var M=0;g<v;){if(R.isHeader(x,g)){if(g+5<v){var B=R.appendFrame(b,x,g,u,M);if(B){if(!B.missing){g+=B.length,M++;continue}this.aacOverFlow=B}}break}g++}}},d.parseMPEGPES=function(p){var g=p.data,v=g.length,r=0,i=0,u=p.pts;if(u!==void 0)for(;i<v;)if(T.isHeader(g,i)){var y=T.appendFrame(this._audioTrack,g,i,u,r);if(!y)break;i+=y.length,r++}else i++;else L.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},d.parseID3PES=function(p){p.pts!==void 0?this._id3Track.samples.push(p):L.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},n}();function E(n,d,p,g){return{key:n,frame:!1,pts:d,dts:p,units:[],debug:g,length:0}}function c(n,d){return(31&n[d+10])<<8|n[d+11]}function e(n,d,p,g){var v={audio:-1,avc:-1,id3:-1,isAAC:!0},r=d+3+((15&n[d+1])<<8|n[d+2])-4;for(d+=12+((15&n[d+10])<<8|n[d+11]);d<r;){var i=(31&n[d+1])<<8|n[d+2];switch(n[d]){case 207:if(!g){L.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:v.audio===-1&&(v.audio=i);break;case 21:v.id3===-1&&(v.id3=i);break;case 219:if(!g){L.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:v.avc===-1&&(v.avc=i);break;case 3:case 4:p?v.audio===-1&&(v.audio=i,v.isAAC=!1):L.logger.log("MPEG audio found, not supported in this browser");break;case 36:L.logger.warn("Unsupported HEVC stream type found")}d+=5+((15&n[d+3])<<8|n[d+4])}return v}function a(n){var d,p,g,v,r,i=0,u=n.data;if(!n||n.size===0)return null;for(;u[0].length<19&&u.length>1;){var y=new Uint8Array(u[0].length+u[1].length);y.set(u[0]),y.set(u[1],u[0].length),u[0]=y,u.splice(1,1)}if(((d=u[0])[0]<<16)+(d[1]<<8)+d[2]===1){if((p=(d[4]<<8)+d[5])&&p>n.size-6)return null;var b=d[7];192&b&&(v=536870912*(14&d[9])+4194304*(255&d[10])+16384*(254&d[11])+128*(255&d[12])+(254&d[13])/2,64&b?v-(r=536870912*(14&d[14])+4194304*(255&d[15])+16384*(254&d[16])+128*(255&d[17])+(254&d[18])/2)>54e5&&(L.logger.warn(Math.round((v-r)/9e4)+"s delta between PTS and DTS, align them"),v=r):r=v);var _=(g=d[8])+9;if(n.size<=_)return null;n.size-=_;for(var x=new Uint8Array(n.size),C=0,O=u.length;C<O;C++){var P=(d=u[C]).byteLength;if(_){if(_>P){_-=P;continue}d=d.subarray(_),P-=_,_=0}x.set(d,i),i+=P}return p&&(p-=g+3),{data:x,pts:v,dts:r,len:p}}return null}function t(n,d){if(n.units.length&&n.frame){if(n.pts===void 0){var p=d.samples,g=p.length;if(!g)return void d.dropped++;var v=p[g-1];n.pts=v.pts,n.dts=v.dts}d.samples.push(n)}n.debug.length&&L.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function s(n,d){var p=n.length;if(p>0){if(d.pts>=n[p-1].pts)n.push(d);else for(var g=p-1;g>=0;g--)if(d.pts<n[g].pts){n.splice(g,0,d);break}}else n.push(d)}function l(n){for(var d=n.byteLength,p=[],g=1;g<d-2;)n[g]===0&&n[g+1]===0&&n[g+2]===3?(p.push(g+2),g+=2):g++;if(p.length===0)return n;var v=d-p.length,r=new Uint8Array(v),i=0;for(g=0;g<v;i++,g++)i===p[0]&&(i++,p.shift()),r[g]=n[i];return r}S.minProbeByteLength=188,w.default=S},"./src/errors.ts":function(N,w,h){var R,T,A,k;h.r(w),h.d(w,"ErrorTypes",function(){return R}),h.d(w,"ErrorDetails",function(){return A}),(T=R||(R={})).NETWORK_ERROR="networkError",T.MEDIA_ERROR="mediaError",T.KEY_SYSTEM_ERROR="keySystemError",T.MUX_ERROR="muxError",T.OTHER_ERROR="otherError",(k=A||(A={})).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",k.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",k.KEY_SYSTEM_NO_SESSION="keySystemNoSession",k.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",k.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",k.MANIFEST_LOAD_ERROR="manifestLoadError",k.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",k.MANIFEST_PARSING_ERROR="manifestParsingError",k.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",k.LEVEL_EMPTY_ERROR="levelEmptyError",k.LEVEL_LOAD_ERROR="levelLoadError",k.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",k.LEVEL_SWITCH_ERROR="levelSwitchError",k.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",k.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",k.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",k.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",k.FRAG_LOAD_ERROR="fragLoadError",k.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",k.FRAG_DECRYPT_ERROR="fragDecryptError",k.FRAG_PARSING_ERROR="fragParsingError",k.REMUX_ALLOC_ERROR="remuxAllocError",k.KEY_LOAD_ERROR="keyLoadError",k.KEY_LOAD_TIMEOUT="keyLoadTimeOut",k.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",k.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",k.BUFFER_APPEND_ERROR="bufferAppendError",k.BUFFER_APPENDING_ERROR="bufferAppendingError",k.BUFFER_STALLED_ERROR="bufferStalledError",k.BUFFER_FULL_ERROR="bufferFullError",k.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",k.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",k.INTERNAL_EXCEPTION="internalException",k.INTERNAL_ABORTED="aborted",k.UNKNOWN="unknown"},"./src/events.ts":function(N,w,h){var R,T;h.r(w),h.d(w,"Events",function(){return R}),(T=R||(R={})).MEDIA_ATTACHING="hlsMediaAttaching",T.MEDIA_ATTACHED="hlsMediaAttached",T.MEDIA_DETACHING="hlsMediaDetaching",T.MEDIA_DETACHED="hlsMediaDetached",T.BUFFER_RESET="hlsBufferReset",T.BUFFER_CODECS="hlsBufferCodecs",T.BUFFER_CREATED="hlsBufferCreated",T.BUFFER_APPENDING="hlsBufferAppending",T.BUFFER_APPENDED="hlsBufferAppended",T.BUFFER_EOS="hlsBufferEos",T.BUFFER_FLUSHING="hlsBufferFlushing",T.BUFFER_FLUSHED="hlsBufferFlushed",T.MANIFEST_LOADING="hlsManifestLoading",T.MANIFEST_LOADED="hlsManifestLoaded",T.MANIFEST_PARSED="hlsManifestParsed",T.LEVEL_SWITCHING="hlsLevelSwitching",T.LEVEL_SWITCHED="hlsLevelSwitched",T.LEVEL_LOADING="hlsLevelLoading",T.LEVEL_LOADED="hlsLevelLoaded",T.LEVEL_UPDATED="hlsLevelUpdated",T.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",T.LEVELS_UPDATED="hlsLevelsUpdated",T.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",T.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",T.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",T.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",T.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",T.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",T.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",T.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",T.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",T.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",T.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",T.CUES_PARSED="hlsCuesParsed",T.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",T.INIT_PTS_FOUND="hlsInitPtsFound",T.FRAG_LOADING="hlsFragLoading",T.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",T.FRAG_LOADED="hlsFragLoaded",T.FRAG_DECRYPTED="hlsFragDecrypted",T.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",T.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",T.FRAG_PARSING_METADATA="hlsFragParsingMetadata",T.FRAG_PARSED="hlsFragParsed",T.FRAG_BUFFERED="hlsFragBuffered",T.FRAG_CHANGED="hlsFragChanged",T.FPS_DROP="hlsFpsDrop",T.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",T.ERROR="hlsError",T.DESTROYING="hlsDestroying",T.KEY_LOADING="hlsKeyLoading",T.KEY_LOADED="hlsKeyLoaded",T.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",T.BACK_BUFFER_REACHED="hlsBackBufferReached"},"./src/hls.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return t});var R=h("./node_modules/url-toolkit/src/url-toolkit.js"),T=h("./src/loader/playlist-loader.ts"),A=h("./src/loader/key-loader.ts"),k=h("./src/controller/id3-track-controller.ts"),I=h("./src/controller/latency-controller.ts"),D=h("./src/controller/level-controller.ts"),o=h("./src/controller/fragment-tracker.ts"),L=h("./src/controller/stream-controller.ts"),m=h("./src/is-supported.ts"),f=h("./src/utils/logger.ts"),S=h("./src/config.ts"),E=h("./node_modules/eventemitter3/index.js"),c=h("./src/events.ts"),e=h("./src/errors.ts");function a(s,l){for(var n=0;n<l.length;n++){var d=l[n];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(s,d.key,d)}}var t=function(){function s(g){g===void 0&&(g={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.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._media=null,this.url=null;var v=this.config=Object(S.mergeConfig)(s.DefaultConfig,g);this.userConfig=g,Object(f.enableLogs)(v.debug),this._autoLevelCapping=-1,v.progressive&&Object(S.enableStreamingMode)(v);var r=v.abrController,i=v.bufferController,u=v.capLevelController,y=v.fpsController,b=this.abrController=new r(this),_=this.bufferController=new i(this),x=this.capLevelController=new u(this),C=new y(this),O=new T.default(this),P=new A.default(this),F=new k.default(this),M=this.levelController=new D.default(this),B=new o.FragmentTracker(this),U=this.streamController=new L.default(this,B);x.setStreamController(U),C.setStreamController(U);var j=[M,U];this.networkControllers=j;var V=[O,P,b,_,x,C,F,B];this.audioTrackController=this.createController(v.audioTrackController,null,j),this.createController(v.audioStreamController,B,j),this.subtitleTrackController=this.createController(v.subtitleTrackController,null,j),this.createController(v.subtitleStreamController,B,j),this.createController(v.timelineController,null,V),this.emeController=this.createController(v.emeController,null,V),this.latencyController=this.createController(I.default,null,V),this.coreComponents=V}s.isSupported=function(){return Object(m.isSupported)()};var l,n,d,p=s.prototype;return p.createController=function(g,v,r){if(g){var i=v?new g(this,v):new g(this);return r&&r.push(i),i}return null},p.on=function(g,v,r){r===void 0&&(r=this),this._emitter.on(g,v,r)},p.once=function(g,v,r){r===void 0&&(r=this),this._emitter.once(g,v,r)},p.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},p.off=function(g,v,r,i){r===void 0&&(r=this),this._emitter.off(g,v,r,i)},p.listeners=function(g){return this._emitter.listeners(g)},p.emit=function(g,v,r){return this._emitter.emit(g,v,r)},p.trigger=function(g,v){if(this.config.debug)return this.emit(g,g,v);try{return this.emit(g,g,v)}catch(r){f.logger.error("An internal error happened while handling event "+g+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(c.Events.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:r})}return!1},p.listenerCount=function(g){return this._emitter.listenerCount(g)},p.destroy=function(){f.logger.log("destroy"),this.trigger(c.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},p.attachMedia=function(g){f.logger.log("attachMedia"),this._media=g,this.trigger(c.Events.MEDIA_ATTACHING,{media:g})},p.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(c.Events.MEDIA_DETACHING,void 0),this._media=null},p.loadSource=function(g){this.stopLoad();var v=this.media,r=this.url,i=this.url=R.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});f.logger.log("loadSource:"+i),v&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(v)),this.trigger(c.Events.MANIFEST_LOADING,{url:g})},p.startLoad=function(g){g===void 0&&(g=-1),f.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(v){v.startLoad(g)})},p.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},p.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},p.recoverMediaError=function(){f.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},p.removeLevel=function(g,v){v===void 0&&(v=0),this.levelController.removeLevel(g,v)},l=s,d=[{key:"version",get:function(){return"1.0.10"}},{key:"Events",get:function(){return c.Events}},{key:"ErrorTypes",get:function(){return e.ErrorTypes}},{key:"ErrorDetails",get:function(){return e.ErrorDetails}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:S.hlsDefaultConfig},set:function(g){s.defaultConfig=g}}],(n=[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){f.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){f.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){f.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){f.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){f.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var v=!!g;v!==this.config.capLevelToPlayerSize&&(v?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=v)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(f.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,v=this.config.minAutoBitrate;if(!g)return 0;for(var r=g.length,i=0;i<r;i++)if(g[i].maxBitrate>v)return i;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,v=this.autoLevelCapping;return v===-1&&g&&g.length?g.length-1:v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var v=this.audioTrackController;v&&(v.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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}}])&&a(l.prototype,n),d&&a(l,d),s}();t.defaultConfig=void 0},"./src/is-supported.ts":function(N,w,h){h.r(w),h.d(w,"isSupported",function(){return A}),h.d(w,"changeTypeSupported",function(){return k});var R=h("./src/utils/mediasource-helper.ts");function T(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var I=Object(R.getMediaSource)();if(!I)return!1;var D=T(),o=I&&typeof I.isTypeSupported=="function"&&I.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!D||D.prototype&&typeof D.prototype.appendBuffer=="function"&&typeof D.prototype.remove=="function";return!!o&&!!L}function k(){var I,D=T();return typeof(D==null||(I=D.prototype)===null||I===void 0?void 0:I.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return m}),h.d(w,"LoadError",function(){return S});var R=h("./src/polyfills/number.ts"),T=h("./src/errors.ts");function A(E){var c=typeof Map=="function"?new Map:void 0;return(A=function(e){if(e===null||(a=e,Function.toString.call(a).indexOf("[native code]")===-1))return e;var a;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(c!==void 0){if(c.has(e))return c.get(e);c.set(e,t)}function t(){return k(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),D(t,e)})(E)}function k(E,c,e){return(k=I()?Reflect.construct:function(a,t,s){var l=[null];l.push.apply(l,t);var n=new(Function.bind.apply(a,l));return s&&D(n,s.prototype),n}).apply(null,arguments)}function I(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function D(E,c){return(D=Object.setPrototypeOf||function(e,a){return e.__proto__=a,e})(E,c)}function o(E){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)})(E)}var L=Math.pow(2,17),m=function(){function E(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var c=E.prototype;return c.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},c.abort=function(){this.loader&&this.loader.abort()},c.load=function(e,a){var t=this,s=e.url;if(!s)return Promise.reject(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")));this.abort();var l=this.config,n=l.fLoader,d=l.loader;return new Promise(function(p,g){t.loader&&t.loader.destroy();var v=t.loader=e.loader=n?new n(l):new d(l),r=f(e),i={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:L};e.stats=v.stats,v.load(r,i,{onSuccess:function(u,y,b,_){t.resetLoader(e,v),p({frag:e,part:null,payload:u.data,networkDetails:_})},onError:function(u,y,b){t.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:u,networkDetails:b}))},onAbort:function(u,y,b){t.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:b}))},onTimeout:function(u,y,b){t.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:b}))},onProgress:function(u,y,b,_){a&&a({frag:e,part:null,payload:b,networkDetails:_})}})})},c.loadPart=function(e,a,t){var s=this;this.abort();var l=this.config,n=l.fLoader,d=l.loader;return new Promise(function(p,g){s.loader&&s.loader.destroy();var v=s.loader=e.loader=n?new n(l):new d(l),r=f(e,a),i={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:L};a.stats=v.stats,v.load(r,i,{onSuccess:function(u,y,b,_){s.resetLoader(e,v),s.updateStatsFromPart(e,a);var x={frag:e,part:a,payload:u.data,networkDetails:_};t(x),p(x)},onError:function(u,y,b){s.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:a,response:u,networkDetails:b}))},onAbort:function(u,y,b){e.stats.aborted=a.stats.aborted,s.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:a,networkDetails:b}))},onTimeout:function(u,y,b){s.resetLoader(e,v),g(new S({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:a,networkDetails:b}))}})})},c.updateStatsFromPart=function(e,a){var t=e.stats,s=a.stats,l=s.total;if(t.loaded+=s.loaded,l){var n=Math.round(e.duration/a.duration),d=Math.min(Math.round(t.loaded/l),n),p=(n-d)*Math.round(t.loaded/d);t.total=t.loaded+p}else t.total=Math.max(t.loaded,t.total);var g=t.loading,v=s.loading;g.start?g.first+=v.first-v.start:(g.start=v.start,g.first=v.first),g.end=v.end},c.resetLoader=function(e,a){e.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},E}();function f(E,c){c===void 0&&(c=null);var e=c||E,a={frag:E,part:c,responseType:"arraybuffer",url:e.url,rangeStart:0,rangeEnd:0},t=e.byteRangeStartOffset,s=e.byteRangeEndOffset;return Object(R.isFiniteNumber)(t)&&Object(R.isFiniteNumber)(s)&&(a.rangeStart=t,a.rangeEnd=s),a}var S=function(E){var c,e;function a(t){for(var s,l=arguments.length,n=new Array(l>1?l-1:0),d=1;d<l;d++)n[d-1]=arguments[d];return(s=E.call.apply(E,[this].concat(n))||this).data=void 0,s.data=t,s}return e=E,(c=a).prototype=Object.create(e.prototype),c.prototype.constructor=c,D(c,e),a}(A(Error))},"./src/loader/fragment.ts":function(N,w,h){h.r(w),h.d(w,"ElementaryStreamTypes",function(){return R}),h.d(w,"BaseSegment",function(){return E}),h.d(w,"Fragment",function(){return c}),h.d(w,"Part",function(){return e});var R,T,A=h("./src/polyfills/number.ts"),k=h("./node_modules/url-toolkit/src/url-toolkit.js"),I=h("./src/utils/logger.ts"),D=h("./src/loader/level-key.ts"),o=h("./src/loader/load-stats.ts");function L(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,m(a,t)}function m(a,t){return(m=Object.setPrototypeOf||function(s,l){return s.__proto__=l,s})(a,t)}function f(a,t){for(var s=0;s<t.length;s++){var l=t[s];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(a,l.key,l)}}function S(a,t,s){return t&&f(a.prototype,t),s&&f(a,s),a}(T=R||(R={})).AUDIO="audio",T.VIDEO="video",T.AUDIOVIDEO="audiovideo";var E=function(){function a(t){var s;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((s={})[R.AUDIO]=null,s[R.VIDEO]=null,s[R.AUDIOVIDEO]=null,s),this.baseurl=t}return a.prototype.setByteRange=function(t,s){var l=t.split("@",2),n=[];l.length===1?n[0]=s?s.byteRangeEndOffset:0:n[0]=parseInt(l[1]),n[1]=parseInt(l[0])+n[0],this._byteRange=n},S(a,[{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(k.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),a}(),c=function(a){function t(l,n){var d;return(d=a.call(this,n)||this)._decryptdata=null,d.rawProgramDateTime=null,d.programDateTime=null,d.tagList=[],d.duration=0,d.sn=0,d.levelkey=void 0,d.type=void 0,d.loader=null,d.level=-1,d.cc=0,d.startPTS=void 0,d.endPTS=void 0,d.appendedPTS=void 0,d.startDTS=void 0,d.endDTS=void 0,d.start=0,d.deltaPTS=void 0,d.maxStartPTS=void 0,d.minEndPTS=void 0,d.stats=new o.LoadStats,d.urlId=0,d.data=void 0,d.bitrateTest=!1,d.title=null,d.initSegment=null,d.type=l,d}L(t,a);var s=t.prototype;return s.createInitializationVector=function(l){for(var n=new Uint8Array(16),d=12;d<16;d++)n[d]=l>>8*(15-d)&255;return n},s.setDecryptDataFromLevelKey=function(l,n){var d=l;return(l==null?void 0:l.method)==="AES-128"&&l.uri&&!l.iv&&((d=D.LevelKey.fromURI(l.uri)).method=l.method,d.iv=this.createInitializationVector(n),d.keyFormat="identity"),d},s.setElementaryStreamInfo=function(l,n,d,p,g,v){v===void 0&&(v=!1);var r=this.elementaryStreams,i=r[l];i?(i.startPTS=Math.min(i.startPTS,n),i.endPTS=Math.max(i.endPTS,d),i.startDTS=Math.min(i.startDTS,p),i.endDTS=Math.max(i.endDTS,g)):r[l]={startPTS:n,endPTS:d,startDTS:p,endDTS:g,partial:v}},s.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[R.AUDIO]=null,l[R.VIDEO]=null,l[R.AUDIOVIDEO]=null},S(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var l=this.sn;typeof l!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),l=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,l)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(A.isFiniteNumber)(this.programDateTime))return null;var l=Object(A.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*l}},{key:"encrypted",get:function(){var l;return!((l=this.decryptdata)===null||l===void 0||!l.keyFormat||!this.decryptdata.uri)}}]),t}(E),e=function(a){function t(s,l,n,d,p){var g;(g=a.call(this,n)||this).fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new o.LoadStats,g.duration=s.decimalFloatingPoint("DURATION"),g.gap=s.bool("GAP"),g.independent=s.bool("INDEPENDENT"),g.relurl=s.enumeratedString("URI"),g.fragment=l,g.index=d;var v=s.enumeratedString("BYTERANGE");return v&&g.setByteRange(v,p),p&&(g.fragOffset=p.fragOffset+p.duration),g}return L(t,a),S(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),t}(E)},"./src/loader/key-loader.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return k});var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/utils/logger.ts"),k=function(){function I(o){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=o,this._registerListeners()}var D=I.prototype;return D._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},D._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},D.destroy=function(){for(var o in this._unregisterListeners(),this.loaders){var L=this.loaders[o];L&&L.destroy()}this.loaders={}},D.onKeyLoading=function(o,L){var m=L.frag,f=m.type,S=this.loaders[f];if(m.decryptdata){var E=m.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var c=this.hls.config;if(S&&(A.logger.warn("abort previous key loader for type:"+f),S.abort()),!E)return void A.logger.warn("key uri is falsy");var e=c.loader,a=m.loader=this.loaders[f]=new e(c);this.decrypturl=E,this.decryptkey=null;var t={url:E,frag:m,responseType:"arraybuffer"},s={timeout:c.fragLoadingTimeOut,maxRetry:0,retryDelay:c.fragLoadingRetryDelay,maxRetryDelay:c.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(t,s,l)}else this.decryptkey&&(m.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:m}))}else A.logger.warn("Missing decryption data on fragment in onKeyLoading")},D.loadsuccess=function(o,L,m){var f=m.frag;f.decryptdata?(this.decryptkey=f.decryptdata.key=new Uint8Array(o.data),f.loader=null,delete this.loaders[f.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:f})):A.logger.error("after key load, decryptdata unset")},D.loaderror=function(o,L){var m=L.frag,f=m.loader;f&&f.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:m,response:o})},D.loadtimeout=function(o,L){var m=L.frag,f=m.loader;f&&f.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:m})},I}()},"./src/loader/level-details.ts":function(N,w,h){h.r(w),h.d(w,"LevelDetails",function(){return A});var R=h("./src/polyfills/number.ts");function T(k,I){for(var D=0;D<I.length;D++){var o=I[D];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(k,o.key,o)}}var A=function(){function k(o){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=o}var I,D;return k.prototype.reloaded=function(o){if(!o)return this.advanced=!0,void(this.updated=!0);var L=this.lastPartSn-o.lastPartSn,m=this.lastPartIndex-o.lastPartIndex;this.updated=this.endSN!==o.endSN||!!m||!!L,this.advanced=this.endSN>o.endSN||L>0||L===0&&m>0,this.updated||this.advanced?this.misses=Math.floor(.6*o.misses):this.misses=o.misses+1,this.availabilityDelay=o.availabilityDelay},I=k,(D=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var o=this.driftEndTime-this.driftStartTime;return o>0?1e3*(this.driftEnd-this.driftStart)/o:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var o;return(o=this.fragments)!==null&&o!==void 0&&o.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 o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&T(I.prototype,D),k}()},"./src/loader/level-key.ts":function(N,w,h){h.r(w),h.d(w,"LevelKey",function(){return A});var R=h("./node_modules/url-toolkit/src/url-toolkit.js");function T(k,I){for(var D=0;D<I.length;D++){var o=I[D];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(k,o.key,o)}}var A=function(){function k(o,L){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=L?Object(R.buildAbsoluteURL)(o,L,{alwaysNormalize:!0}):o}var I,D;return k.fromURL=function(o,L){return new k(o,L)},k.fromURI=function(o){return new k(o)},I=k,(D=[{key:"uri",get:function(){return this._uri}}])&&T(I.prototype,D),k}()},"./src/loader/load-stats.ts":function(N,w,h){h.r(w),h.d(w,"LoadStats",function(){return R});var R=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(N,w,h){h.r(w),h.d(w,"default",function(){return e});var R=h("./src/polyfills/number.ts"),T=h("./node_modules/url-toolkit/src/url-toolkit.js"),A=h("./src/loader/fragment.ts"),k=h("./src/loader/level-details.ts"),I=h("./src/loader/level-key.ts"),D=h("./src/utils/attr-list.ts"),o=h("./src/utils/logger.ts"),L=h("./src/utils/codecs.ts"),m=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,S=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),E=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("|")),c=/\.(mp4|m4s|m4v|m4a)$/i,e=function(){function l(){}return l.findGroup=function(n,d){for(var p=0;p<n.length;p++){var g=n[p];if(g.id===d)return g}},l.convertAVC1ToAVCOTI=function(n){var d=n.split(".");if(d.length>2){var p=d.shift()+".";return p+=parseInt(d.shift()).toString(16),p+=("000"+parseInt(d.shift()).toString(16)).substr(-4)}return n},l.resolve=function(n,d){return T.buildAbsoluteURL(d,n,{alwaysNormalize:!0})},l.parseMasterPlaylist=function(n,d){var p,g=[],v={},r=!1;for(m.lastIndex=0;(p=m.exec(n))!=null;)if(p[1]){var i=new D.AttrList(p[1]),u={attrs:i,bitrate:i.decimalInteger("AVERAGE-BANDWIDTH")||i.decimalInteger("BANDWIDTH"),name:i.NAME,url:l.resolve(p[2],d)},y=i.decimalResolution("RESOLUTION");y&&(u.width=y.width,u.height=y.height),a((i.CODECS||"").split(/[ ,]+/).filter(function(_){return _}),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=l.convertAVC1ToAVCOTI(u.videoCodec)),g.push(u)}else if(p[3]){var b=new D.AttrList(p[3]);b["DATA-ID"]&&(r=!0,v[b["DATA-ID"]]=b)}return{levels:g,sessionData:r?v:null}},l.parseMasterPlaylistMedia=function(n,d,p,g){var v;g===void 0&&(g=[]);var r=[],i=0;for(f.lastIndex=0;(v=f.exec(n))!==null;){var u=new D.AttrList(v[1]);if(u.TYPE===p){var y={attrs:u,bitrate:0,id:i++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:p,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?l.resolve(u.URI,d):""};if(g.length){var b=l.findGroup(g,y.groupId)||g[0];t(y,b,"audioCodec"),t(y,b,"textCodec")}r.push(y)}}return r},l.parseLevelPlaylist=function(n,d,p,g,v){var r,i,u,y=new k.LevelDetails(d),b=y.fragments,_=null,x=0,C=0,O=0,P=0,F=null,M=new A.Fragment(g,d),B=-1,U=!1;for(S.lastIndex=0,y.m3u8=n;(r=S.exec(n))!==null;){U&&(U=!1,(M=new A.Fragment(g,d)).start=O,M.sn=x,M.cc=P,M.level=p,_&&(M.initSegment=_,M.rawProgramDateTime=_.rawProgramDateTime));var j=r[1];if(j){M.duration=parseFloat(j);var V=(" "+r[2]).slice(1);M.title=V||null,M.tagList.push(V?["INF",j,V]:["INF",j])}else if(r[3])Object(R.isFiniteNumber)(M.duration)&&(M.start=O,u&&(M.levelkey=u),M.sn=x,M.level=p,M.cc=P,M.urlId=v,b.push(M),M.relurl=(" "+r[3]).slice(1),s(M,F),F=M,O+=M.duration,x++,C=0,U=!0);else if(r[4]){var W=(" "+r[4]).slice(1);F?M.setByteRange(W,F):M.setByteRange(W)}else if(r[5])M.rawProgramDateTime=(" "+r[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),B===-1&&(B=b.length);else{if(!(r=r[0].match(E))){o.logger.warn("No matches on slow regex match for level playlist!");continue}for(i=1;i<r.length&&r[i]===void 0;i++);var X=(" "+r[i]).slice(1),q=(" "+r[i+1]).slice(1),$=r[i+2]?(" "+r[i+2]).slice(1):"";switch(X){case"PLAYLIST-TYPE":y.type=q.toUpperCase();break;case"MEDIA-SEQUENCE":x=y.startSN=parseInt(q);break;case"SKIP":var ie=new D.AttrList(q),se=ie.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(se)){y.skippedSegments=se;for(var le=se;le--;)b.unshift(null);x+=se}var re=ie.enumeratedString("RECENTLY-REMOVED-DATERANGES");re&&(y.recentlyRemovedDateranges=re.split(" "));break;case"TARGETDURATION":y.targetduration=parseFloat(q);break;case"VERSION":y.version=parseInt(q);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(q||$)&&M.tagList.push($?[q,$]:[q]);break;case"DIS":P++;case"GAP":M.tagList.push([X]);break;case"BITRATE":M.tagList.push([X,q]);break;case"DISCONTINUITY-SEQ":P=parseInt(q);break;case"KEY":var de,te=new D.AttrList(q),ne=te.enumeratedString("METHOD"),ce=te.URI,H=te.hexadecimalInteger("IV"),oe=te.enumeratedString("KEYFORMATVERSIONS"),he=te.enumeratedString("KEYID"),Te=(de=te.enumeratedString("KEYFORMAT"))!=null?de:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(Te)>-1){o.logger.warn("Keyformat "+Te+" is not supported from the manifest");continue}if(Te!=="identity")continue;ne&&(u=I.LevelKey.fromURL(d,ce),ce&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ne)>=0&&(u.method=ne,u.keyFormat=Te,he&&(u.keyID=he),oe&&(u.keyFormatVersions=oe),u.iv=H));break;case"START":var Ae=new D.AttrList(q).decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(Ae)&&(y.startTimeOffset=Ae);break;case"MAP":var ve=new D.AttrList(q);M.relurl=ve.URI,ve.BYTERANGE&&M.setByteRange(ve.BYTERANGE),M.level=p,M.sn="initSegment",u&&(M.levelkey=u),M.initSegment=null,_=M,U=!0;break;case"SERVER-CONTROL":var ge=new D.AttrList(q);y.canBlockReload=ge.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=ge.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&ge.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=ge.optionalFloat("PART-HOLD-BACK",0),y.holdBack=ge.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var We=new D.AttrList(q);y.partTarget=We.decimalFloatingPoint("PART-TARGET");break;case"PART":var ke=y.partList;ke||(ke=y.partList=[]);var Oe=C>0?ke[ke.length-1]:void 0,Ye=C++,Me=new A.Part(new D.AttrList(q),M,d,Ye,Oe);ke.push(Me),M.duration+=Me.duration;break;case"PRELOAD-HINT":var Re=new D.AttrList(q);y.preloadHint=Re;break;case"RENDITION-REPORT":var Qe=new D.AttrList(q);y.renditionReports=y.renditionReports||[],y.renditionReports.push(Qe);break;default:o.logger.warn("line parsed but not handled: "+r)}}}F&&!F.relurl?(b.pop(),O-=F.duration,y.partList&&(y.fragmentHint=F)):y.partList&&(s(M,F),M.cc=P,y.fragmentHint=M);var qe=b.length,Ie=b[0],Ze=b[qe-1];if((O+=y.skippedSegments*y.targetduration)>0&&qe&&Ze){y.averagetargetduration=O/qe;var ze=Ze.sn;y.endSN=ze!=="initSegment"?ze:0,Ie&&(y.startCC=Ie.cc,Ie.initSegment||y.fragments.every(function(Ne){return Ne.relurl&&(Pe=Ne.relurl,c.test((Be=(_e=T.parseURL(Pe))===null||_e===void 0?void 0:_e.path)!=null?Be:""));var Pe,Be,_e})&&(o.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new A.Fragment(g,d)).relurl=Ze.relurl,M.level=p,M.sn="initSegment",Ie.initSegment=M,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(O+=y.fragmentHint.duration),y.totalduration=O,y.endCC=P,B>0&&function(Ne,Pe){for(var Be=Ne[Pe],_e=Pe;_e--;){var Ue=Ne[_e];if(!Ue)return;Ue.programDateTime=Be.programDateTime-1e3*Ue.duration,Be=Ue}}(b,B),y},l}();function a(l,n){["video","audio","text"].forEach(function(d){var p=l.filter(function(v){return Object(L.isCodecType)(v,d)});if(p.length){var g=p.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[d+"Codec"]=g.length>0?g[0]:p[0],l=l.filter(function(v){return p.indexOf(v)===-1})}}),n.unknownCodecs=l}function t(l,n,d){var p=n[d];p&&(l[d]=p)}function s(l,n){l.rawProgramDateTime?l.programDateTime=Date.parse(l.rawProgramDateTime):n!=null&&n.programDateTime&&(l.programDateTime=n.endProgramDateTime),Object(R.isFiniteNumber)(l.programDateTime)||(l.programDateTime=null,l.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,w,h){h.r(w);var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/errors.ts"),k=h("./src/utils/logger.ts"),I=h("./src/utils/mp4-tools.ts"),D=h("./src/loader/m3u8-parser.ts"),o=h("./src/types/loader.ts"),L=h("./src/utils/attr-list.ts");function m(S,E){var c=S.url;return c!==void 0&&c.indexOf("data:")!==0||(c=E.url),c}var f=function(){function S(c){this.hls=void 0,this.loaders=Object.create(null),this.hls=c,this.registerListeners()}var E=S.prototype;return E.registerListeners=function(){var c=this.hls;c.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(T.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.on(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var c=this.hls;c.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(T.Events.LEVEL_LOADING,this.onLevelLoading,this),c.off(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.off(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(c){var e=this.hls.config,a=e.pLoader,t=e.loader,s=new(a||t)(e);return c.loader=s,this.loaders[c.type]=s,s},E.getInternalLoader=function(c){return this.loaders[c.type]},E.resetInternalLoader=function(c){this.loaders[c]&&delete this.loaders[c]},E.destroyInternalLoaders=function(){for(var c in this.loaders){var e=this.loaders[c];e&&e.destroy(),this.resetInternalLoader(c)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(c,e){var a=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:o.PlaylistContextType.MANIFEST,url:a,deliveryDirectives:null})},E.onLevelLoading=function(c,e){var a=e.id,t=e.level,s=e.url,l=e.deliveryDirectives;this.load({id:a,groupId:null,level:t,responseType:"text",type:o.PlaylistContextType.LEVEL,url:s,deliveryDirectives:l})},E.onAudioTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,l=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:o.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:l})},E.onSubtitleTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,l=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:o.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:l})},E.load=function(c){var e,a,t,s,l,n,d=this.hls.config,p=this.getInternalLoader(c);if(p){var g=p.context;if(g&&g.url===c.url)return void k.logger.trace("[playlist-loader]: playlist request ongoing");k.logger.log("[playlist-loader]: aborting previous loader for type: "+c.type),p.abort()}switch(c.type){case o.PlaylistContextType.MANIFEST:a=d.manifestLoadingMaxRetry,t=d.manifestLoadingTimeOut,s=d.manifestLoadingRetryDelay,l=d.manifestLoadingMaxRetryTimeout;break;case o.PlaylistContextType.LEVEL:case o.PlaylistContextType.AUDIO_TRACK:case o.PlaylistContextType.SUBTITLE_TRACK:a=0,t=d.levelLoadingTimeOut;break;default:a=d.levelLoadingMaxRetry,t=d.levelLoadingTimeOut,s=d.levelLoadingRetryDelay,l=d.levelLoadingMaxRetryTimeout}if(p=this.createInternalLoader(c),(e=c.deliveryDirectives)!==null&&e!==void 0&&e.part&&(c.type===o.PlaylistContextType.LEVEL&&c.level!==null?n=this.hls.levels[c.level].details:c.type===o.PlaylistContextType.AUDIO_TRACK&&c.id!==null?n=this.hls.audioTracks[c.id].details:c.type===o.PlaylistContextType.SUBTITLE_TRACK&&c.id!==null&&(n=this.hls.subtitleTracks[c.id].details),n)){var v=n.partTarget,r=n.targetduration;v&&r&&(t=Math.min(1e3*Math.max(3*v,.8*r),t))}var i={timeout:t,maxRetry:a,retryDelay:s,maxRetryDelay:l,highWaterMark:0},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};p.load(c,i,u)},E.loadsuccess=function(c,e,a,t){if(t===void 0&&(t=null),a.isSidxRequest)return this.handleSidxRequest(c,a),void this.handlePlaylistLoaded(c,e,a,t);this.resetInternalLoader(a.type);var s=c.data;s.indexOf("#EXTM3U")===0?(e.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(c,e,a,t):this.handleMasterPlaylist(c,e,a,t)):this.handleManifestParsingError(c,a,"no EXTM3U delimiter",t)},E.loaderror=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!1,c)},E.loadtimeout=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!0)},E.handleMasterPlaylist=function(c,e,a,t){var s=this.hls,l=c.data,n=m(c,a),d=D.default.parseMasterPlaylist(l,n),p=d.levels,g=d.sessionData;if(p.length){var v=p.map(function(b){return{id:b.attrs.AUDIO,audioCodec:b.audioCodec}}),r=p.map(function(b){return{id:b.attrs.SUBTITLES,textCodec:b.textCodec}}),i=D.default.parseMasterPlaylistMedia(l,n,"AUDIO",v),u=D.default.parseMasterPlaylistMedia(l,n,"SUBTITLES",r),y=D.default.parseMasterPlaylistMedia(l,n,"CLOSED-CAPTIONS");i.length&&(i.some(function(b){return!b.url})||!p[0].audioCodec||p[0].attrs.AUDIO||(k.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),i.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L.AttrList({}),bitrate:0,url:""}))),s.trigger(T.Events.MANIFEST_LOADED,{levels:p,audioTracks:i,subtitles:u,captions:y,url:n,stats:e,networkDetails:t,sessionData:g})}else this.handleManifestParsingError(c,a,"no level found in manifest",t)},E.handleTrackOrLevelPlaylist=function(c,e,a,t){var s=this.hls,l=a.id,n=a.level,d=a.type,p=m(c,a),g=Object(R.isFiniteNumber)(l)?l:0,v=Object(R.isFiniteNumber)(n)?n:g,r=function(_){switch(_.type){case o.PlaylistContextType.AUDIO_TRACK:return o.PlaylistLevelType.AUDIO;case o.PlaylistContextType.SUBTITLE_TRACK:return o.PlaylistLevelType.SUBTITLE;default:return o.PlaylistLevelType.MAIN}}(a),i=D.default.parseLevelPlaylist(c.data,p,v,r,g);if(i.fragments.length){if(d===o.PlaylistContextType.MANIFEST){var u={attrs:new L.AttrList({}),bitrate:0,details:i,name:"",url:p};s.trigger(T.Events.MANIFEST_LOADED,{levels:[u],audioTracks:[],url:p,stats:e,networkDetails:t,sessionData:null})}if(e.parsing.end=performance.now(),i.needSidxRanges){var y,b=(y=i.fragments[0].initSegment)===null||y===void 0?void 0:y.url;this.load({url:b,isSidxRequest:!0,type:d,level:n,levelDetails:i,id:l,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else a.levelDetails=i,this.handlePlaylistLoaded(c,e,a,t)}else s.trigger(T.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof a.level=="number"?a.level:void 0})},E.handleSidxRequest=function(c,e){var a=Object(I.parseSegmentIndex)(new Uint8Array(c.data));if(a){var t=a.references,s=e.levelDetails;t.forEach(function(l,n){var d=l.info,p=s.fragments[n];p.byteRange.length===0&&p.setByteRange(String(1+d.end-d.start)+"@"+String(d.start)),p.initSegment&&p.initSegment.setByteRange(String(a.moovEndOffset)+"@0")})}},E.handleManifestParsingError=function(c,e,a,t){this.hls.trigger(T.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===o.PlaylistContextType.MANIFEST,url:c.url,reason:a,response:c,context:e,networkDetails:t})},E.handleNetworkError=function(c,e,a,t){a===void 0&&(a=!1),k.logger.warn("[playlist-loader]: A network "+(a?"timeout":"error")+" occurred while loading "+c.type+" level: "+c.level+" id: "+c.id+' group-id: "'+c.groupId+'"');var s=A.ErrorDetails.UNKNOWN,l=!1,n=this.getInternalLoader(c);switch(c.type){case o.PlaylistContextType.MANIFEST:s=a?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case o.PlaylistContextType.LEVEL:s=a?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case o.PlaylistContextType.AUDIO_TRACK:s=a?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case o.PlaylistContextType.SUBTITLE_TRACK:s=a?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}n&&this.resetInternalLoader(c.type);var d={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:l,url:c.url,loader:n,context:c,networkDetails:e};t&&(d.response=t),this.hls.trigger(T.Events.ERROR,d)},E.handlePlaylistLoaded=function(c,e,a,t){var s=a.type,l=a.level,n=a.id,d=a.groupId,p=a.loader,g=a.levelDetails,v=a.deliveryDirectives;if(g!=null&&g.targetduration){if(p)switch(g.live&&(p.getCacheAge&&(g.ageHeader=p.getCacheAge()||0),p.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),s){case o.PlaylistContextType.MANIFEST:case o.PlaylistContextType.LEVEL:this.hls.trigger(T.Events.LEVEL_LOADED,{details:g,level:l||0,id:n||0,stats:e,networkDetails:t,deliveryDirectives:v});break;case o.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(T.Events.AUDIO_TRACK_LOADED,{details:g,id:n||0,groupId:d||"",stats:e,networkDetails:t,deliveryDirectives:v});break;case o.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(T.Events.SUBTITLE_TRACK_LOADED,{details:g,id:n||0,groupId:d||"",stats:e,networkDetails:t,deliveryDirectives:v})}}else this.handleManifestParsingError(c,a,"invalid target duration",t)},S}();w.default=f},"./src/polyfills/number.ts":function(N,w,h){h.r(w),h.d(w,"isFiniteNumber",function(){return R}),h.d(w,"MAX_SAFE_INTEGER",function(){return T});var R=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},T=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(N,w,h){h.r(w);var R=function(){function T(){}return T.getSilentFrame=function(A,k){switch(A){case"mp4a.40.2":if(k===1)return new Uint8Array([0,200,0,128,35,128]);if(k===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(k===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(k===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(k===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(k===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(k===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(k===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(k===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])}},T}();w.default=R},"./src/remux/mp4-generator.ts":function(N,w,h){h.r(w);var R=Math.pow(2,32)-1,T=function(){function A(){}return A.init=function(){var k;for(k in A.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:[]},A.types)A.types.hasOwnProperty(k)&&(A.types[k]=[k.charCodeAt(0),k.charCodeAt(1),k.charCodeAt(2),k.charCodeAt(3)]);var I=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]),D=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);A.HDLR_TYPES={video:I,audio:D};var o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=L,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var m=new Uint8Array([105,115,111,109]),f=new Uint8Array([97,118,99,49]),S=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,m,S,m,f),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,o))},A.box=function(k){for(var I=8,D=arguments.length,o=new Array(D>1?D-1:0),L=1;L<D;L++)o[L-1]=arguments[L];for(var m=o.length,f=m;m--;)I+=o[m].byteLength;var S=new Uint8Array(I);for(S[0]=I>>24&255,S[1]=I>>16&255,S[2]=I>>8&255,S[3]=255&I,S.set(k,4),m=0,I=8;m<f;m++)S.set(o[m],I),I+=o[m].byteLength;return S},A.hdlr=function(k){return A.box(A.types.hdlr,A.HDLR_TYPES[k])},A.mdat=function(k){return A.box(A.types.mdat,k)},A.mdhd=function(k,I){I*=k;var D=Math.floor(I/(R+1)),o=Math.floor(I%(R+1));return A.box(A.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,k>>24&255,k>>16&255,k>>8&255,255&k,D>>24,D>>16&255,D>>8&255,255&D,o>>24,o>>16&255,o>>8&255,255&o,85,196,0,0]))},A.mdia=function(k){return A.box(A.types.mdia,A.mdhd(k.timescale,k.duration),A.hdlr(k.type),A.minf(k))},A.mfhd=function(k){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,k>>24,k>>16&255,k>>8&255,255&k]))},A.minf=function(k){return k.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(k)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(k))},A.moof=function(k,I,D){return A.box(A.types.moof,A.mfhd(k),A.traf(D,I))},A.moov=function(k){for(var I=k.length,D=[];I--;)D[I]=A.trak(k[I]);return A.box.apply(null,[A.types.moov,A.mvhd(k[0].timescale,k[0].duration)].concat(D).concat(A.mvex(k)))},A.mvex=function(k){for(var I=k.length,D=[];I--;)D[I]=A.trex(k[I]);return A.box.apply(null,[A.types.mvex].concat(D))},A.mvhd=function(k,I){I*=k;var D=Math.floor(I/(R+1)),o=Math.floor(I%(R+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,k>>24&255,k>>16&255,k>>8&255,255&k,D>>24,D>>16&255,D>>8&255,255&D,o>>24,o>>16&255,o>>8&255,255&o,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 A.box(A.types.mvhd,L)},A.sdtp=function(k){var I,D,o=k.samples||[],L=new Uint8Array(4+o.length);for(I=0;I<o.length;I++)D=o[I].flags,L[I+4]=D.dependsOn<<4|D.isDependedOn<<2|D.hasRedundancy;return A.box(A.types.sdtp,L)},A.stbl=function(k){return A.box(A.types.stbl,A.stsd(k),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))},A.avc1=function(k){var I,D,o,L=[],m=[];for(I=0;I<k.sps.length;I++)o=(D=k.sps[I]).byteLength,L.push(o>>>8&255),L.push(255&o),L=L.concat(Array.prototype.slice.call(D));for(I=0;I<k.pps.length;I++)o=(D=k.pps[I]).byteLength,m.push(o>>>8&255),m.push(255&o),m=m.concat(Array.prototype.slice.call(D));var f=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|k.sps.length].concat(L).concat([k.pps.length]).concat(m))),S=k.width,E=k.height,c=k.pixelRatio[0],e=k.pixelRatio[1];return A.box(A.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,S>>8&255,255&S,E>>8&255,255&E,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),f,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,e>>24,e>>16&255,e>>8&255,255&e])))},A.esds=function(k){var I=k.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(k.config).concat([6,1,2]))},A.mp4a=function(k){var I=k.samplerate;return A.box(A.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,k.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]),A.box(A.types.esds,A.esds(k)))},A.mp3=function(k){var I=k.samplerate;return A.box(A.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,k.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]))},A.stsd=function(k){return k.type==="audio"?k.isAAC||k.codec!=="mp3"?A.box(A.types.stsd,A.STSD,A.mp4a(k)):A.box(A.types.stsd,A.STSD,A.mp3(k)):A.box(A.types.stsd,A.STSD,A.avc1(k))},A.tkhd=function(k){var I=k.id,D=k.duration*k.timescale,o=k.width,L=k.height,m=Math.floor(D/(R+1)),f=Math.floor(D%(R+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,255&I,0,0,0,0,m>>24,m>>16&255,m>>8&255,255&m,f>>24,f>>16&255,f>>8&255,255&f,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,o>>8&255,255&o,0,0,L>>8&255,255&L,0,0]))},A.traf=function(k,I){var D=A.sdtp(k),o=k.id,L=Math.floor(I/(R+1)),m=Math.floor(I%(R+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,255&L,m>>24,m>>16&255,m>>8&255,255&m])),A.trun(k,D.length+16+20+8+16+8+8),D)},A.trak=function(k){return k.duration=k.duration||4294967295,A.box(A.types.trak,A.tkhd(k),A.mdia(k))},A.trex=function(k){var I=k.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(k,I){var D,o,L,m,f,S,E=k.samples||[],c=E.length,e=12+16*c,a=new Uint8Array(e);for(I+=8+e,a.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,I>>>24&255,I>>>16&255,I>>>8&255,255&I],0),D=0;D<c;D++)L=(o=E[D]).duration,m=o.size,f=o.flags,S=o.cts,a.set([L>>>24&255,L>>>16&255,L>>>8&255,255&L,m>>>24&255,m>>>16&255,m>>>8&255,255&m,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,61440&f.degradPrio,15&f.degradPrio,S>>>24&255,S>>>16&255,S>>>8&255,255&S],12+16*D);return A.box(A.types.trun,a)},A.initSegment=function(k){A.types||A.init();var I=A.moov(k),D=new Uint8Array(A.FTYP.byteLength+I.byteLength);return D.set(A.FTYP),D.set(I,A.FTYP.byteLength),D},A}();T.types=void 0,T.HDLR_TYPES=void 0,T.STTS=void 0,T.STSC=void 0,T.STCO=void 0,T.STSZ=void 0,T.VMHD=void 0,T.SMHD=void 0,T.STSD=void 0,T.FTYP=void 0,T.DINF=void 0,w.default=T},"./src/remux/mp4-remuxer.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return c}),h.d(w,"normalizePts",function(){return e});var R=h("./src/polyfills/number.ts"),T=h("./src/remux/aac-helper.ts"),A=h("./src/remux/mp4-generator.ts"),k=h("./src/events.ts"),I=h("./src/errors.ts"),D=h("./src/utils/logger.ts"),o=h("./src/types/loader.ts"),L=h("./src/utils/timescale-conversion.ts");function m(){return(m=Object.assign||function(s){for(var l=1;l<arguments.length;l++){var n=arguments[l];for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&(s[d]=n[d])}return s}).apply(this,arguments)}var f=null,S=null,E=!1,c=function(){function s(n,d,p,g){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=n,this.config=d,this.typeSupported=p,this.ISGenerated=!1,f===null){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);f=v?parseInt(v[1]):0}if(S===null){var r=navigator.userAgent.match(/Safari\/(\d+)/i);S=r?parseInt(r[1]):0}E=!!f&&f<75||!!S&&S<600}var l=s.prototype;return l.destroy=function(){},l.resetTimeStamp=function(n){D.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=n},l.resetNextTimestamp=function(){D.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},l.resetInitSegment=function(){D.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},l.getVideoStartPts=function(n){var d=!1,p=n.reduce(function(g,v){var r=v.pts-g;return r<-4294967296?(d=!0,e(g,v.pts)):r>0?g:v.pts},n[0].pts);return d&&D.logger.debug("PTS rollover detected"),p},l.remux=function(n,d,p,g,v,r,i,u){var y,b,_,x,C,O,P=v,F=v,M=n.pid>-1,B=d.pid>-1,U=d.samples.length,j=n.samples.length>0,V=U>1;if((!M||j)&&(!B||V)||this.ISGenerated||i){this.ISGenerated||(_=this.generateIS(n,d,v));var W=this.isVideoContiguous,X=-1;if(V&&(X=function(le){for(var re=0;re<le.length;re++)if(le[re].key)return re;return-1}(d.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(O=!0,X>0){D.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+U+" video samples due to a missing keyframe");var q=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(X),d.dropped+=X,F+=(d.samples[0].pts-q)/(d.timescale||9e4)}else X===-1&&(D.logger.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),O=!1);if(this.ISGenerated){if(j&&V){var $=this.getVideoStartPts(d.samples),ie=(e(n.samples[0].pts,$)-$)/d.inputTimeScale;P+=Math.max(0,ie),F+=Math.max(0,-ie)}if(j){if(n.samplerate||(D.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),_=this.generateIS(n,d,v)),b=this.remuxAudio(n,P,this.isAudioContiguous,r,B||V||u===o.PlaylistLevelType.AUDIO?F:void 0),V){var se=b?b.endPTS-b.startPTS:0;d.inputTimeScale||(D.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),_=this.generateIS(n,d,v)),y=this.remuxVideo(d,F,W,se)}}else V&&(y=this.remuxVideo(d,F,W,0));y&&(y.firstKeyFrame=X,y.independent=X!==-1)}}return this.ISGenerated&&(p.samples.length&&(C=this.remuxID3(p,v)),g.samples.length&&(x=this.remuxText(g,v))),{audio:b,video:y,initSegment:_,independent:O,text:x,id3:C}},l.generateIS=function(n,d,p){var g,v,r,i=n.samples,u=d.samples,y=this.typeSupported,b={},_=!Object(R.isFiniteNumber)(this._initPTS),x="audio/mp4";if(_&&(g=v=1/0),n.config&&i.length&&(n.timescale=n.samplerate,n.isAAC||(y.mpeg?(x="audio/mpeg",n.codec=""):y.mp3&&(n.codec="mp3")),b.audio={id:"audio",container:x,codec:n.codec,initSegment:!n.isAAC&&y.mpeg?new Uint8Array(0):A.default.initSegment([n]),metadata:{channelCount:n.channelCount}},_&&(r=n.inputTimeScale,g=v=i[0].pts-Math.round(r*p))),d.sps&&d.pps&&u.length&&(d.timescale=d.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:A.default.initSegment([d]),metadata:{width:d.width,height:d.height}},_)){r=d.inputTimeScale;var C=this.getVideoStartPts(u),O=Math.round(r*p);v=Math.min(v,e(u[0].dts,C)-O),g=Math.min(g,C-O)}if(Object.keys(b).length)return this.ISGenerated=!0,_&&(this._initPTS=g,this._initDTS=v),{tracks:b,initPTS:g,timescale:r}},l.remuxVideo=function(n,d,p,g){var v,r,i,u=n.inputTimeScale,y=n.samples,b=[],_=y.length,x=this._initPTS,C=this.nextAvcDts,O=8,P=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,M=0,B=!1;p&&C!==null||(C=d*u-(y[0].pts-e(y[0].dts,y[0].pts)));for(var U=0;U<_;U++){var j=y[U];j.pts=e(j.pts-x,C),j.dts=e(j.dts-x,C),j.dts>j.pts&&(M=Math.max(Math.min(M,j.pts-j.dts),-18e3)),j.dts<y[U>0?U-1:U].dts&&(B=!0)}B&&y.sort(function(_e,Ue){var Dt=_e.dts-Ue.dts,Rt=_e.pts-Ue.pts;return Dt||Rt}),r=y[0].dts,i=y[y.length-1].dts;var V=Math.round((i-r)/(_-1));if(M<0){if(M<-2*V){D.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(L.toMsFromMpegTsClock)(-V,!0)+" ms");for(var W=M,X=0;X<_;X++)y[X].dts=W=Math.max(W,y[X].pts-V),y[X].pts=Math.max(W,y[X].pts)}else{D.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(L.toMsFromMpegTsClock)(M,!0)+" ms to overcome this issue");for(var q=0;q<_;q++)y[q].dts=y[q].dts+M}r=y[0].dts}if(p){var $=r-C,ie=$>V;if(ie||$<-1){ie?D.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)($,!0)+" ms ("+$+"dts) hole between fragments detected, filling it"):D.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(-$,!0)+" ms ("+$+"dts) overlapping between fragments detected"),r=C;var se=y[0].pts-$;y[0].dts=r,y[0].pts=se,D.logger.log("Video: First PTS/DTS adjusted: "+Object(L.toMsFromMpegTsClock)(se,!0)+"/"+Object(L.toMsFromMpegTsClock)(r,!0)+", delta: "+Object(L.toMsFromMpegTsClock)($,!0)+" ms")}}E&&(r=Math.max(0,r));for(var le=0,re=0,de=0;de<_;de++){for(var te=y[de],ne=te.units,ce=ne.length,H=0,oe=0;oe<ce;oe++)H+=ne[oe].data.length;re+=H,le+=ce,te.length=H,te.dts=Math.max(te.dts,r),te.pts=Math.max(te.pts,te.dts,0),P=Math.min(te.pts,P),F=Math.max(te.pts,F)}i=y[_-1].dts;var he,Te=re+4*le+8;try{he=new Uint8Array(Te)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Te,reason:"fail allocating video mdat "+Te})}var Ae=new DataView(he.buffer);Ae.setUint32(0,Te),he.set(A.default.types.mdat,4);for(var ve=0;ve<_;ve++){for(var ge=y[ve],We=ge.units,ke=0,Oe=0,Ye=We.length;Oe<Ye;Oe++){var Me=We[Oe],Re=Me.data,Qe=Me.data.byteLength;Ae.setUint32(O,Qe),O+=4,he.set(Re,O),O+=Qe,ke+=4+Qe}if(ve<_-1)v=y[ve+1].dts-ge.dts;else{var qe=this.config,Ie=ge.dts-y[ve>0?ve-1:ve].dts;if(qe.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ze=Math.floor(qe.maxBufferHole*u),ze=(g?P+g*u:this.nextAudioPts)-ge.pts;ze>Ze?((v=ze-Ie)<0&&(v=Ie),D.logger.log("[mp4-remuxer]: It is approximately "+ze/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=Ie}else v=Ie}var Ne=Math.round(ge.pts-ge.dts);b.push(new a(ge.key,v,ke,Ne))}if(b.length&&f&&f<70){var Pe=b[0].flags;Pe.dependsOn=2,Pe.isNonSync=0}console.assert(v!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=C=i+v,this.isVideoContiguous=!0;var Be={data1:A.default.moof(n.sequenceNumber++,r,m({},n,{samples:b})),data2:he,startPTS:P/u,endPTS:(F+v)/u,startDTS:r/u,endDTS:C/u,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(he.length,"MDAT length must not be zero"),Be},l.remuxAudio=function(n,d,p,g,v){var r=n.inputTimeScale,i=r/(n.samplerate?n.samplerate:r),u=n.isAAC?1024:1152,y=u*i,b=this._initPTS,_=!n.isAAC&&this.typeSupported.mpeg,x=[],C=n.samples,O=_?0:8,P=this.nextAudioPts||-1,F=d*r;if(this.isAudioContiguous=p=p||C.length&&P>0&&(g&&Math.abs(F-P)<9e3||Math.abs(e(C[0].pts-b,F)-P)<20*y),C.forEach(function(Re){Re.pts=e(Re.pts-b,F)}),!p||P<0){if(!(C=C.filter(function(Re){return Re.pts>=0})).length)return;P=v===0?0:g?Math.max(0,F):C[0].pts}if(n.isAAC)for(var M=v!==void 0,B=this.config.maxAudioFramesDrift,U=0,j=P;U<C.length;U++){var V=C[U],W=V.pts,X=W-j,q=Math.abs(1e3*X/r);if(X<=-B*y&&M)U===0&&(D.logger.warn("Audio frame @ "+(W/r).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/r)+" ms."),this.nextAudioPts=P=j=W);else if(X>=B*y&&q<1e4&&M){var $=Math.round(X/y);(j=W-$*y)<0&&($--,j+=y),U===0&&(this.nextAudioPts=P=j),D.logger.warn("[mp4-remuxer]: Injecting "+$+" audio frame @ "+(j/r).toFixed(3)+"s due to "+Math.round(1e3*X/r)+" ms gap.");for(var ie=0;ie<$;ie++){var se=Math.max(j,0),le=T.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);le||(D.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),le=V.unit.subarray()),C.splice(U,0,{unit:le,pts:se}),j+=y,U++}}V.pts=j,j+=y}for(var re,de=null,te=null,ne=0,ce=C.length;ce--;)ne+=C[ce].unit.byteLength;for(var H=0,oe=C.length;H<oe;H++){var he=C[H],Te=he.unit,Ae=he.pts;if(te!==null)x[H-1].duration=Math.round((Ae-te)/i);else{if(p&&n.isAAC&&(Ae=P),de=Ae,!(ne>0))return;ne+=O;try{re=new Uint8Array(ne)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ne,reason:"fail allocating audio mdat "+ne})}_||(new DataView(re.buffer).setUint32(0,ne),re.set(A.default.types.mdat,4))}re.set(Te,O);var ve=Te.byteLength;O+=ve,x.push(new a(!0,u,ve,0)),te=Ae}var ge=x.length;if(ge){var We=x[x.length-1];this.nextAudioPts=P=te+i*We.duration;var ke=_?new Uint8Array(0):A.default.moof(n.sequenceNumber++,de/i,m({},n,{samples:x}));n.samples=[];var Oe=de/r,Ye=P/r,Me={data1:ke,data2:re,startPTS:Oe,endPTS:Ye,startDTS:Oe,endDTS:Ye,type:"audio",hasAudio:!0,hasVideo:!1,nb:ge};return this.isAudioContiguous=!0,console.assert(re.length,"MDAT length must not be zero"),Me}},l.remuxEmptyAudio=function(n,d,p,g){var v=n.inputTimeScale,r=v/(n.samplerate?n.samplerate:v),i=this.nextAudioPts,u=(i!==null?i:g.startDTS*v)+this._initDTS,y=g.endDTS*v+this._initDTS,b=1024*r,_=Math.ceil((y-u)/b),x=T.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(D.logger.warn("[mp4-remuxer]: remux empty Audio"),x){for(var C=[],O=0;O<_;O++){var P=u+O*b;C.push({unit:x,pts:P,dts:P})}return n.samples=C,this.remuxAudio(n,d,p,!1)}D.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},l.remuxID3=function(n,d){var p=n.samples.length;if(p){for(var g=n.inputTimeScale,v=this._initPTS,r=this._initDTS,i=0;i<p;i++){var u=n.samples[i];u.pts=e(u.pts-v,d*g)/g,u.dts=e(u.dts-r,d*g)/g}var y=n.samples;return n.samples=[],{samples:y}}},l.remuxText=function(n,d){var p=n.samples.length;if(p){for(var g=n.inputTimeScale,v=this._initPTS,r=0;r<p;r++){var i=n.samples[r];i.pts=e(i.pts-v,d*g)/g}n.samples.sort(function(y,b){return y.pts-b.pts});var u=n.samples;return n.samples=[],{samples:u}}},s}();function e(s,l){var n;if(l===null)return s;for(n=l<s?-8589934592:8589934592;Math.abs(s-l)>4294967296;)s+=n;return s}var a=function(s,l,n,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=l,this.size=n,this.cts=d,this.flags=new t(s)},t=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(N,w,h){h.r(w);var R=h("./src/polyfills/number.ts"),T=h("./src/utils/mp4-tools.ts"),A=h("./src/loader/fragment.ts"),k=h("./src/utils/logger.ts"),I=function(){function L(){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 m=L.prototype;return m.destroy=function(){},m.resetTimeStamp=function(f){this.initPTS=f,this.lastEndDTS=null},m.resetNextTimestamp=function(){this.lastEndDTS=null},m.resetInitSegment=function(f,S,E){this.audioCodec=S,this.videoCodec=E,this.generateInitSegment(f),this.emitInitSegment=!0},m.generateInitSegment=function(f){var S=this.audioCodec,E=this.videoCodec;if(!f||!f.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var c=this.initData=Object(T.parseInitSegment)(f);S||(S=o(c.audio,A.ElementaryStreamTypes.AUDIO)),E||(E=o(c.video,A.ElementaryStreamTypes.VIDEO));var e={};c.audio&&c.video?e.audiovideo={container:"video/mp4",codec:S+","+E,initSegment:f,id:"main"}:c.audio?e.audio={container:"audio/mp4",codec:S,initSegment:f,id:"audio"}:c.video?e.video={container:"video/mp4",codec:E,initSegment:f,id:"main"}:k.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},m.remux=function(f,S,E,c,e){var a=this.initPTS,t=this.lastEndDTS,s={audio:void 0,video:void 0,text:c,id3:E,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var l=S.samples;if(!l||!l.length)return s;var n={initPTS:void 0,timescale:1},d=this.initData;if(d&&d.length||(this.generateInitSegment(l),d=this.initData),!d||!d.length)return k.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(R.isFiniteNumber)(a)||(this.initPTS=n.initPTS=a=D(d,l,t));var p=Object(T.getDuration)(l,d),g=t,v=p+g;Object(T.offsetStartDTS)(d,l,a),p>0?this.lastEndDTS=v:(k.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var r=!!d.audio,i=!!d.video,u="";r&&(u+="audio"),i&&(u+="video");var y={data1:l,startPTS:g,startDTS:g,endPTS:v,endDTS:v,type:u,hasAudio:r,hasVideo:i,nb:1,dropped:0};return s.audio=y.type==="audio"?y:void 0,s.video=y.type!=="audio"?y:void 0,s.text=c,s.id3=E,s.initSegment=n,s},L}(),D=function(L,m,f){return Object(T.getStartDTS)(L,m)-f};function o(L,m){var f=L==null?void 0:L.codec;return f&&f.length>4?f:f==="hvc1"?"hvc1.1.c.L120.90":f==="av01"?"av01.0.04M.08":f==="avc1"||m===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}w.default=I},"./src/task-loop.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return R});var R=function(){function T(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=T.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(k){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,k),!0)},A.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},A.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},T}()},"./src/types/level.ts":function(N,w,h){function R(o,L){for(var m=0;m<L.length;m++){var f=L[m];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(o,f.key,f)}}var T,A;function k(o,L){var m=o.canSkipUntil,f=o.canSkipDateRanges,S=o.endSN;return m&&(L!==void 0?L-S:0)<m?f?T.v2:T.Yes:T.No}h.r(w),h.d(w,"HlsSkip",function(){return T}),h.d(w,"getSkipValue",function(){return k}),h.d(w,"HlsUrlParameters",function(){return I}),h.d(w,"Level",function(){return D}),(A=T||(T={})).No="",A.Yes="YES",A.v2="v2";var I=function(){function o(L,m,f){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=L,this.part=m,this.skip=f}return o.prototype.addDirectives=function(L){var m=new self.URL(L);return this.msn!==void 0&&m.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&m.searchParams.set("_HLS_part",this.part.toString()),this.skip&&m.searchParams.set("_HLS_skip",this.skip),m.toString()},o}(),D=function(){function o(f){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=[f.url],this.attrs=f.attrs,this.bitrate=f.bitrate,f.details&&(this.details=f.details),this.id=f.id||0,this.name=f.name,this.width=f.width||0,this.height=f.height||0,this.audioCodec=f.audioCodec,this.videoCodec=f.videoCodec,this.unknownCodecs=f.unknownCodecs,this.codecSet=[f.videoCodec,f.audioCodec].filter(function(S){return S}).join(",").replace(/\.[^.,]+/g,"")}var L,m;return L=o,(m=[{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(f){var S=f%this.url.length;this._urlId!==S&&(this.details=void 0,this._urlId=S)}}])&&R(L.prototype,m),o}()},"./src/types/loader.ts":function(N,w,h){var R,T,A,k;h.r(w),h.d(w,"PlaylistContextType",function(){return R}),h.d(w,"PlaylistLevelType",function(){return A}),(T=R||(R={})).MANIFEST="manifest",T.LEVEL="level",T.AUDIO_TRACK="audioTrack",T.SUBTITLE_TRACK="subtitleTrack",(k=A||(A={})).MAIN="main",k.AUDIO="audio",k.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":function(N,w,h){h.r(w),h.d(w,"ChunkMetadata",function(){return R});var R=function(T,A,k,I,D,o){I===void 0&&(I=0),D===void 0&&(D=-1),o===void 0&&(o=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=T,this.sn=A,this.id=k,this.size=I,this.part=D,this.partial=o}},"./src/utils/attr-list.ts":function(N,w,h){h.r(w),h.d(w,"AttrList",function(){return A});var R=/^(\d+)x(\d+)$/,T=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function k(D){for(var o in typeof D=="string"&&(D=k.parseAttrList(D)),D)D.hasOwnProperty(o)&&(this[o]=D[o])}var I=k.prototype;return I.decimalInteger=function(D){var o=parseInt(this[D],10);return o>Number.MAX_SAFE_INTEGER?1/0:o},I.hexadecimalInteger=function(D){if(this[D]){var o=(this[D]||"0x").slice(2);o=(1&o.length?"0":"")+o;for(var L=new Uint8Array(o.length/2),m=0;m<o.length/2;m++)L[m]=parseInt(o.slice(2*m,2*m+2),16);return L}return null},I.hexadecimalIntegerAsNumber=function(D){var o=parseInt(this[D],16);return o>Number.MAX_SAFE_INTEGER?1/0:o},I.decimalFloatingPoint=function(D){return parseFloat(this[D])},I.optionalFloat=function(D,o){var L=this[D];return L?parseFloat(L):o},I.enumeratedString=function(D){return this[D]},I.bool=function(D){return this[D]==="YES"},I.decimalResolution=function(D){var o=R.exec(this[D]);if(o!==null)return{width:parseInt(o[1],10),height:parseInt(o[2],10)}},k.parseAttrList=function(D){var o,L={};for(T.lastIndex=0;(o=T.exec(D))!==null;){var m=o[2];m.indexOf('"')===0&&m.lastIndexOf('"')===m.length-1&&(m=m.slice(1,-1)),L[o[1]]=m}return L},k}()},"./src/utils/binary-search.ts":function(N,w,h){h.r(w),w.default={search:function(R,T){for(var A=0,k=R.length-1,I=null,D=null;A<=k;){var o=T(D=R[I=(A+k)/2|0]);if(o>0)A=I+1;else{if(!(o<0))return D;k=I-1}}return null}}},"./src/utils/buffer-helper.ts":function(N,w,h){h.r(w),h.d(w,"BufferHelper",function(){return A});var R=h("./src/utils/logger.ts"),T={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function k(){}return k.isBuffered=function(I,D){try{if(I){for(var o=k.getBuffered(I),L=0;L<o.length;L++)if(D>=o.start(L)&&D<=o.end(L))return!0}}catch{}return!1},k.bufferInfo=function(I,D,o){try{if(I){var L,m=k.getBuffered(I),f=[];for(L=0;L<m.length;L++)f.push({start:m.start(L),end:m.end(L)});return this.bufferedInfo(f,D,o)}}catch{}return{len:0,start:D,end:D,nextStart:void 0}},k.bufferedInfo=function(I,D,o){D=Math.max(0,D),I.sort(function(n,d){var p=n.start-d.start;return p||d.end-n.end});var L=[];if(o)for(var m=0;m<I.length;m++){var f=L.length;if(f){var S=L[f-1].end;I[m].start-S<o?I[m].end>S&&(L[f-1].end=I[m].end):L.push(I[m])}else L.push(I[m])}else L=I;for(var E,c=0,e=D,a=D,t=0;t<L.length;t++){var s=L[t].start,l=L[t].end;if(D+o>=s&&D<l)e=s,c=(a=l)-D;else if(D+o<s){E=s;break}}return{len:c,start:e||0,end:a||0,nextStart:E}},k.getBuffered=function(I){try{return I.buffered}catch(D){return R.logger.log("failed to get media.buffered",D),T}},k}()},"./src/utils/cea-608-parser.ts":function(N,w,h){h.r(w),h.d(w,"Row",function(){return s}),h.d(w,"CaptionScreen",function(){return l});var R,T,A=h("./src/utils/logger.ts"),k={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},I=function(v){var r=v;return k.hasOwnProperty(v)&&(r=k[v]),String.fromCharCode(r)},D=15,o=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},m={17:2,18:4,21:6,22:8,23:10,19:13,20:15},f={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},S={25:2,26:4,29:6,30:8,31:10,27:13,28:15},E=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(T=R||(R={}))[T.ERROR=0]="ERROR",T[T.TEXT=1]="TEXT",T[T.WARNING=2]="WARNING",T[T.INFO=2]="INFO",T[T.DEBUG=3]="DEBUG",T[T.DATA=3]="DATA";var c=function(){function v(){this.time=null,this.verboseLevel=R.ERROR}return v.prototype.log=function(r,i){this.verboseLevel>=r&&A.logger.log(this.time+" ["+r+"] "+i)},v}(),e=function(v){for(var r=[],i=0;i<v.length;i++)r.push(v[i].toString(16));return r},a=function(){function v(i,u,y,b,_){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=i||"white",this.underline=u||!1,this.italics=y||!1,this.background=b||"black",this.flash=_||!1}var r=v.prototype;return r.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(i){for(var u=["foreground","underline","italics","background","flash"],y=0;y<u.length;y++){var b=u[y];i.hasOwnProperty(b)&&(this[b]=i[b])}},r.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},r.equals=function(i){return this.foreground===i.foreground&&this.underline===i.underline&&this.italics===i.italics&&this.background===i.background&&this.flash===i.flash},r.copy=function(i){this.foreground=i.foreground,this.underline=i.underline,this.italics=i.italics,this.background=i.background,this.flash=i.flash},r.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},v}(),t=function(){function v(i,u,y,b,_,x){this.uchar=void 0,this.penState=void 0,this.uchar=i||" ",this.penState=new a(u,y,b,_,x)}var r=v.prototype;return r.reset=function(){this.uchar=" ",this.penState.reset()},r.setChar=function(i,u){this.uchar=i,this.penState.copy(u)},r.setPenState=function(i){this.penState.copy(i)},r.equals=function(i){return this.uchar===i.uchar&&this.penState.equals(i.penState)},r.copy=function(i){this.uchar=i.uchar,this.penState.copy(i.penState)},r.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},v}(),s=function(){function v(i){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var u=0;u<o;u++)this.chars.push(new t);this.logger=i,this.pos=0,this.currPenState=new a}var r=v.prototype;return r.equals=function(i){for(var u=!0,y=0;y<o;y++)if(!this.chars[y].equals(i.chars[y])){u=!1;break}return u},r.copy=function(i){for(var u=0;u<o;u++)this.chars[u].copy(i.chars[u])},r.isEmpty=function(){for(var i=!0,u=0;u<o;u++)if(!this.chars[u].isEmpty()){i=!1;break}return i},r.setCursor=function(i){this.pos!==i&&(this.pos=i),this.pos<0?(this.logger.log(R.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>o&&(this.logger.log(R.DEBUG,"Too large cursor position "+this.pos),this.pos=o)},r.moveCursor=function(i){var u=this.pos+i;if(i>1)for(var y=this.pos+1;y<u+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(u)},r.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},r.insertChar=function(i){i>=144&&this.backSpace();var u=I(i);this.pos>=o?this.logger.log(R.ERROR,"Cannot insert "+i.toString(16)+" ("+u+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(u,this.currPenState),this.moveCursor(1))},r.clearFromPos=function(i){var u;for(u=i;u<o;u++)this.chars[u].reset()},r.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},r.clearToEndOfRow=function(){this.clearFromPos(this.pos)},r.getTextString=function(){for(var i=[],u=!0,y=0;y<o;y++){var b=this.chars[y].uchar;b!==" "&&(u=!1),i.push(b)}return u?"":i.join("")},r.setPenStyles=function(i){this.currPenState.setStyles(i),this.chars[this.pos].setPenState(this.currPenState)},v}(),l=function(){function v(i){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var u=0;u<D;u++)this.rows.push(new s(i));this.logger=i,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var r=v.prototype;return r.reset=function(){for(var i=0;i<D;i++)this.rows[i].clear();this.currRow=14},r.equals=function(i){for(var u=!0,y=0;y<D;y++)if(!this.rows[y].equals(i.rows[y])){u=!1;break}return u},r.copy=function(i){for(var u=0;u<D;u++)this.rows[u].copy(i.rows[u])},r.isEmpty=function(){for(var i=!0,u=0;u<D;u++)if(!this.rows[u].isEmpty()){i=!1;break}return i},r.backSpace=function(){this.rows[this.currRow].backSpace()},r.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},r.insertChar=function(i){this.rows[this.currRow].insertChar(i)},r.setPen=function(i){this.rows[this.currRow].setPenStyles(i)},r.moveCursor=function(i){this.rows[this.currRow].moveCursor(i)},r.setCursor=function(i){this.logger.log(R.INFO,"setCursor: "+i),this.rows[this.currRow].setCursor(i)},r.setPAC=function(i){this.logger.log(R.INFO,"pacData = "+JSON.stringify(i));var u=i.row-1;if(this.nrRollUpRows&&u<this.nrRollUpRows-1&&(u=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==u){for(var y=0;y<D;y++)this.rows[y].clear();var b=this.currRow+1-this.nrRollUpRows,_=this.lastOutputScreen;if(_){var x=_.rows[b].cueStartTime,C=this.logger.time;if(x&&C!==null&&x<C)for(var O=0;O<this.nrRollUpRows;O++)this.rows[u-this.nrRollUpRows+O+1].copy(_.rows[b+O])}}this.currRow=u;var P=this.rows[this.currRow];if(i.indent!==null){var F=i.indent,M=Math.max(F-1,0);P.setCursor(i.indent),i.color=P.chars[M].penState.foreground}var B={foreground:i.color,underline:i.underline,italics:i.italics,background:"black",flash:!1};this.setPen(B)},r.setBkgData=function(i){this.logger.log(R.INFO,"bkgData = "+JSON.stringify(i)),this.backSpace(),this.setPen(i),this.insertChar(32)},r.setRollUpRows=function(i){this.nrRollUpRows=i},r.rollUp=function(){if(this.nrRollUpRows!==null){this.logger.log(R.TEXT,this.getDisplayText());var i=this.currRow+1-this.nrRollUpRows,u=this.rows.splice(i,1)[0];u.clear(),this.rows.splice(this.currRow,0,u),this.logger.log(R.INFO,"Rolling up")}else this.logger.log(R.DEBUG,"roll_up but nrRollUpRows not set yet")},r.getDisplayText=function(i){i=i||!1;for(var u=[],y="",b=-1,_=0;_<D;_++){var x=this.rows[_].getTextString();x&&(b=_+1,i?u.push("Row "+b+": '"+x+"'"):u.push(x.trim()))}return u.length>0&&(y=i?"["+u.join(" | ")+"]":u.join(`
|
||
`)),y},r.getTextAndFormat=function(){return this.rows},v}(),n=function(){function v(i,u,y){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=i,this.outputFilter=u,this.mode=null,this.verbose=0,this.displayedMemory=new l(y),this.nonDisplayedMemory=new l(y),this.lastOutputScreen=new l(y),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=y}var r=v.prototype;return r.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},r.getHandler=function(){return this.outputFilter},r.setHandler=function(i){this.outputFilter=i},r.setPAC=function(i){this.writeScreen.setPAC(i)},r.setBkgData=function(i){this.writeScreen.setBkgData(i)},r.setMode=function(i){i!==this.mode&&(this.mode=i,this.logger.log(R.INFO,"MODE="+i),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=i)},r.insertChars=function(i){for(var u=0;u<i.length;u++)this.writeScreen.insertChar(i[u]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(R.INFO,y+": "+this.writeScreen.getDisplayText(!0)),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(R.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},r.ccRCL=function(){this.logger.log(R.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},r.ccBS=function(){this.logger.log(R.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},r.ccAOF=function(){},r.ccAON=function(){},r.ccDER=function(){this.logger.log(R.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},r.ccRU=function(i){this.logger.log(R.INFO,"RU("+i+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(i)},r.ccFON=function(){this.logger.log(R.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},r.ccRDC=function(){this.logger.log(R.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},r.ccTR=function(){this.logger.log(R.INFO,"TR"),this.setMode("MODE_TEXT")},r.ccRTD=function(){this.logger.log(R.INFO,"RTD"),this.setMode("MODE_TEXT")},r.ccEDM=function(){this.logger.log(R.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},r.ccCR=function(){this.logger.log(R.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},r.ccENM=function(){this.logger.log(R.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},r.ccEOC=function(){if(this.logger.log(R.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var i=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=i,this.writeScreen=this.nonDisplayedMemory,this.logger.log(R.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},r.ccTO=function(i){this.logger.log(R.INFO,"TO("+i+") - Tab Offset"),this.writeScreen.moveCursor(i)},r.ccMIDROW=function(i){var u={flash:!1};if(u.underline=i%2==1,u.italics=i>=46,u.italics)u.foreground="white";else{var y=Math.floor(i/2)-16;u.foreground=["white","green","blue","cyan","red","yellow","magenta"][y]}this.logger.log(R.INFO,"MIDROW: "+JSON.stringify(u)),this.writeScreen.setPen(u)},r.outputDataUpdate=function(i){i===void 0&&(i=!1);var u=this.logger.time;u!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,u,this.lastOutputScreen),i&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:u):this.cueStartTime=u,this.lastOutputScreen.copy(this.displayedMemory))},r.cueSplitAtTime=function(i){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,i,this.displayedMemory),this.cueStartTime=i))},v}(),d=function(){function v(i,u,y){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new c;this.channels=[null,new n(i,u,b),new n(i+1,y,b)],this.cmdHistory={a:null,b:null},this.logger=b}var r=v.prototype;return r.getHandler=function(i){return this.channels[i].getHandler()},r.setHandler=function(i,u){this.channels[i].setHandler(u)},r.addData=function(i,u){var y,b,_,x=!1;this.logger.time=i;for(var C=0;C<u.length;C+=2)if(b=127&u[C],_=127&u[C+1],b!==0||_!==0){if(this.logger.log(R.DATA,"["+e([u[C],u[C+1]])+"] -> ("+e([b,_])+")"),(y=this.parseCmd(b,_))||(y=this.parseMidrow(b,_)),y||(y=this.parsePAC(b,_)),y||(y=this.parseBackgroundAttributes(b,_)),!y&&(x=this.parseChars(b,_))){var O=this.currentChannel;O&&O>0?this.channels[O].insertChars(x):this.logger.log(R.WARNING,"No channel found yet. TEXT-MODE?")}y||x||this.logger.log(R.WARNING,"Couldn't parse cleaned data "+e([b,_])+" orig: "+e([u[C],u[C+1]]))}},r.parseCmd=function(i,u){var y=this.cmdHistory;if(!((i===20||i===28||i===21||i===29)&&u>=32&&u<=47||(i===23||i===31)&&u>=33&&u<=35))return!1;if(g(i,u,y))return p(null,null,y),this.logger.log(R.DEBUG,"Repeated command ("+e([i,u])+") is dropped"),!0;var b=i===20||i===21||i===23?1:2,_=this.channels[b];return i===20||i===21||i===28||i===29?u===32?_.ccRCL():u===33?_.ccBS():u===34?_.ccAOF():u===35?_.ccAON():u===36?_.ccDER():u===37?_.ccRU(2):u===38?_.ccRU(3):u===39?_.ccRU(4):u===40?_.ccFON():u===41?_.ccRDC():u===42?_.ccTR():u===43?_.ccRTD():u===44?_.ccEDM():u===45?_.ccCR():u===46?_.ccENM():u===47&&_.ccEOC():_.ccTO(u-32),p(i,u,y),this.currentChannel=b,!0},r.parseMidrow=function(i,u){var y=0;if((i===17||i===25)&&u>=32&&u<=47){if((y=i===17?1:2)!==this.currentChannel)return this.logger.log(R.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[y];return!!b&&(b.ccMIDROW(u),this.logger.log(R.DEBUG,"MIDROW ("+e([i,u])+")"),!0)}return!1},r.parsePAC=function(i,u){var y,b=this.cmdHistory;if(!((i>=17&&i<=23||i>=25&&i<=31)&&u>=64&&u<=127||(i===16||i===24)&&u>=64&&u<=95))return!1;if(g(i,u,b))return p(null,null,b),!0;var _=i<=23?1:2;y=u>=64&&u<=95?_===1?L[i]:f[i]:_===1?m[i]:S[i];var x=this.channels[_];return!!x&&(x.setPAC(this.interpretPAC(y,u)),p(i,u,b),this.currentChannel=_,!0)},r.interpretPAC=function(i,u){var y,b={color:null,italics:!1,indent:null,underline:!1,row:i};return y=u>95?u-96:u-64,b.underline=(1&y)==1,y<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(b.italics=!0,b.color="white"):b.indent=4*Math.floor((y-16)/2),b},r.parseChars=function(i,u){var y,b,_=null,x=null;if(i>=25?(y=2,x=i-8):(y=1,x=i),x>=17&&x<=19?(b=x===17?u+80:x===18?u+112:u+144,this.logger.log(R.INFO,"Special char '"+I(b)+"' in channel "+y),_=[b]):i>=32&&i<=127&&(_=u===0?[i]:[i,u]),_){var C=e(_);this.logger.log(R.DEBUG,"Char codes = "+C.join(",")),p(i,u,this.cmdHistory)}return _},r.parseBackgroundAttributes=function(i,u){var y;if(!((i===16||i===24)&&u>=32&&u<=47||(i===23||i===31)&&u>=45&&u<=47))return!1;var b={};i===16||i===24?(y=Math.floor((u-32)/2),b.background=E[y],u%2==1&&(b.background=b.background+"_semi")):u===45?b.background="transparent":(b.foreground="black",u===47&&(b.underline=!0));var _=i<=23?1:2;return this.channels[_].setBkgData(b),p(i,u,this.cmdHistory),!0},r.reset=function(){for(var i=0;i<Object.keys(this.channels).length;i++){var u=this.channels[i];u&&u.reset()}this.cmdHistory={a:null,b:null}},r.cueSplitAtTime=function(i){for(var u=0;u<this.channels.length;u++){var y=this.channels[u];y&&y.cueSplitAtTime(i)}},v}();function p(v,r,i){i.a=v,i.b=r}function g(v,r,i){return i.a===v&&i.b===r}w.default=d},"./src/utils/codecs.ts":function(N,w,h){h.r(w),h.d(w,"isCodecType",function(){return T}),h.d(w,"isCodecSupportedInMp4",function(){return A});var R={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 T(k,I){var D=R[I];return!!D&&D[k.slice(0,4)]===!0}function A(k,I){return MediaSource.isTypeSupported((I||"video")+'/mp4;codecs="'+k+'"')}},"./src/utils/cues.ts":function(N,w,h){h.r(w);var R=h("./src/utils/vttparser.ts"),T=h("./src/utils/webvtt-parser.ts"),A=h("./src/utils/texttrack-utils.ts"),k=/\s/,I={newCue:function(D,o,L,m){for(var f,S,E,c,e,a=[],t=self.VTTCue||self.TextTrackCue,s=0;s<m.rows.length;s++)if(E=!0,c=0,e="",!(f=m.rows[s]).isEmpty()){for(var l=0;l<f.chars.length;l++)k.test(f.chars[l].uchar)&&E?c++:(e+=f.chars[l].uchar,E=!1);f.cueStartTime=o,o===L&&(L+=1e-4),c>=16?c--:c++;var n=Object(R.fixLineBreaks)(e.trim()),d=Object(T.generateCueId)(o,L,n);D&&D.cues&&D.cues.getCueById(d)||((S=new t(o,L,n)).id=d,S.line=s+1,S.align="left",S.position=10+Math.min(80,10*Math.floor(8*c/32)),a.push(S))}return D&&a.length&&(a.sort(function(p,g){return p.line==="auto"||g.line==="auto"?0:p.line>8&&g.line>8?g.line-p.line:p.line-g.line}),a.forEach(function(p){return Object(A.addCueToTrack)(D,p)})),a}};w.default=I},"./src/utils/discontinuities.ts":function(N,w,h){h.r(w),h.d(w,"findFirstFragWithCC",function(){return k}),h.d(w,"shouldAlignOnDiscontinuities",function(){return I}),h.d(w,"findDiscontinuousReferenceFrag",function(){return D}),h.d(w,"adjustSlidingStart",function(){return L}),h.d(w,"alignStream",function(){return m}),h.d(w,"alignPDT",function(){return f});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/logger.ts"),A=h("./src/controller/level-helper.ts");function k(S,E){for(var c=null,e=0,a=S.length;e<a;e++){var t=S[e];if(t&&t.cc===E){c=t;break}}return c}function I(S,E,c){return!(!E.details||!(c.endCC>c.startCC||S&&S.cc<c.startCC))}function D(S,E){var c=S.fragments,e=E.fragments;if(e.length&&c.length){var a=k(c,e[0].cc);if(a&&(!a||a.startPTS))return a;T.logger.log("No frag in previous level to align on")}else T.logger.log("No fragments to align")}function o(S,E){if(S){var c=S.start+E;S.start=S.startPTS=c,S.endPTS=c+S.duration}}function L(S,E){for(var c=E.fragments,e=0,a=c.length;e<a;e++)o(c[e],S);E.fragmentHint&&o(E.fragmentHint,S),E.alignedSliding=!0}function m(S,E,c){E&&(function(e,a,t){if(I(e,t,a)){var s=D(t.details,a);s&&Object(R.isFiniteNumber)(s.start)&&(T.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),L(s.start,a))}}(S,c,E),!c.alignedSliding&&E.details&&f(c,E.details),c.alignedSliding||!E.details||c.skippedSegments||Object(A.adjustSliding)(E.details,c))}function f(S,E){if(E.fragments.length&&S.hasProgramDateTime&&E.hasProgramDateTime){var c=E.fragments[0].programDateTime,e=S.fragments[0].programDateTime,a=(e-c)/1e3+E.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(T.logger.log("Adjusting PTS using programDateTime delta "+(e-c)+"ms, sliding:"+a.toFixed(3)+" "+S.url+" "),L(a,S))}}},"./src/utils/ewma-bandwidth-estimator.ts":function(N,w,h){h.r(w);var R=h("./src/utils/ewma.ts"),T=function(){function A(I,D,o){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=o,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(I),this.fast_=new R.default(D)}var k=A.prototype;return k.update=function(I,D){var o=this.slow_,L=this.fast_;this.slow_.halfLife!==I&&(this.slow_=new R.default(I,o.getEstimate(),o.getTotalWeight())),this.fast_.halfLife!==D&&(this.fast_=new R.default(D,L.getEstimate(),L.getTotalWeight()))},k.sample=function(I,D){var o=(I=Math.max(I,this.minDelayMs_))/1e3,L=8*D/o;this.fast_.sample(o,L),this.slow_.sample(o,L)},k.canEstimate=function(){var I=this.fast_;return I&&I.getTotalWeight()>=this.minWeight_},k.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},k.destroy=function(){},A}();w.default=T},"./src/utils/ewma.ts":function(N,w,h){h.r(w);var R=function(){function T(k,I,D){I===void 0&&(I=0),D===void 0&&(D=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=k,this.alpha_=k?Math.exp(Math.log(.5)/k):0,this.estimate_=I,this.totalWeight_=D}var A=T.prototype;return A.sample=function(k,I){var D=Math.pow(this.alpha_,k);this.estimate_=I*(1-D)+D*this.estimate_,this.totalWeight_+=k},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var k=1-Math.pow(this.alpha_,this.totalWeight_);if(k)return this.estimate_/k}return this.estimate_},T}();w.default=R},"./src/utils/fetch-loader.ts":function(N,w,h){h.r(w),h.d(w,"fetchSupported",function(){return m});var R=h("./src/polyfills/number.ts"),T=h("./src/loader/load-stats.ts"),A=h("./src/demux/chunk-cache.ts");function k(c){var e=typeof Map=="function"?new Map:void 0;return(k=function(a){if(a===null||(t=a,Function.toString.call(t).indexOf("[native code]")===-1))return a;var t;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(a))return e.get(a);e.set(a,s)}function s(){return I(a,arguments,L(this).constructor)}return s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),o(s,a)})(c)}function I(c,e,a){return(I=D()?Reflect.construct:function(t,s,l){var n=[null];n.push.apply(n,s);var d=new(Function.bind.apply(t,n));return l&&o(d,l.prototype),d}).apply(null,arguments)}function D(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function o(c,e){return(o=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(c,e)}function L(c){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(c)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var f=function(){function c(a){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=a.fetchSetup||S,this.controller=new self.AbortController,this.stats=new T.LoadStats}var e=c.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var a=this.response;a&&a.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var a;this.abortInternal(),(a=this.callbacks)!==null&&a!==void 0&&a.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(a,t,s){var l=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var d=function(r,i){var u={method:"GET",mode:"cors",credentials:"same-origin",signal:i};return r.rangeEnd&&(u.headers=new self.Headers({Range:"bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)})),u}(a,this.controller.signal),p=s.onProgress,g=a.responseType==="arraybuffer",v=g?"byteLength":"length";this.context=a,this.config=t,this.callbacks=s,this.request=this.fetchSetup(a,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){l.abortInternal(),s.onTimeout(n,a,l.response)},t.timeout),self.fetch(this.request).then(function(r){if(l.response=l.loader=r,!r.ok){var i=r.status,u=r.statusText;throw new E(u||"fetch, bad network response",i,r)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(r.headers.get("Content-Length")||"0"),p&&Object(R.isFiniteNumber)(t.highWaterMark)?l.loadProgressively(r,n,a,t.highWaterMark,p):g?r.arrayBuffer():r.text()}).then(function(r){var i=l.response;self.clearTimeout(l.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=r[v];var u={url:i.url,data:r};p&&!Object(R.isFiniteNumber)(t.highWaterMark)&&p(n,a,r,i),s.onSuccess(u,n,a,i)}).catch(function(r){if(self.clearTimeout(l.requestTimeout),!n.aborted){var i=r.code||0;s.onError({code:i,text:r.message},a,r.details)}})},e.getCacheAge=function(){var a=null;if(this.response){var t=this.response.headers.get("age");a=t?parseFloat(t):null}return a},e.loadProgressively=function(a,t,s,l,n){l===void 0&&(l=0);var d=new A.default,p=a.body.getReader();return function g(){return p.read().then(function(v){if(v.done)return d.dataLength&&n(t,s,d.flush(),a),Promise.resolve(new ArrayBuffer(0));var r=v.value,i=r.length;return t.loaded+=i,i<l||d.dataLength?(d.push(r),d.dataLength>=l&&n(t,s,d.flush(),a)):n(t,s,r,a),g()}).catch(function(){return Promise.reject()})}()},c}();function S(c,e){return new self.Request(c.url,e)}var E=function(c){var e,a;function t(s,l,n){var d;return(d=c.call(this,s)||this).code=void 0,d.details=void 0,d.code=l,d.details=n,d}return a=c,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,o(e,a),t}(k(Error));w.default=f},"./src/utils/imsc1-ttml-parser.ts":function(N,w,h){h.r(w),h.d(w,"IMSC1_CODEC",function(){return L}),h.d(w,"parseIMSC1",function(){return E});var R=h("./src/utils/mp4-tools.ts"),T=h("./src/utils/vttparser.ts"),A=h("./src/utils/vttcue.ts"),k=h("./src/demux/id3.ts"),I=h("./src/utils/timescale-conversion.ts"),D=h("./src/utils/webvtt-parser.ts");function o(){return(o=Object.assign||function(n){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var g in p)Object.prototype.hasOwnProperty.call(p,g)&&(n[g]=p[g])}return n}).apply(this,arguments)}var L="stpp.ttml.im1t",m=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,f=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,S={left:"start",center:"center",right:"end",start:"start",end:"end"};function E(n,d,p,g,v){var r=Object(R.findBox)(new Uint8Array(n),["mdat"]);if(r.length!==0){var i=r[0],u=Object(k.utf8ArrayToStr)(new Uint8Array(n,i.start,i.end-i.start)),y=Object(I.toTimescaleFromScale)(d,1,p);try{g(function(b,_){var x=new DOMParser().parseFromString(b,"text/xml").getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var C={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(C).reduce(function(U,j){return U[j]=x.getAttribute("ttp:"+j)||C[j],U},{}),P=x.getAttribute("xml:space")!=="preserve",F=e(c(x,"styling","style")),M=e(c(x,"layout","region")),B=c(x,"body","[begin]");return[].map.call(B,function(U){var j=a(U,P);if(!j||!U.hasAttribute("begin"))return null;var V=l(U.getAttribute("begin"),O),W=l(U.getAttribute("dur"),O),X=l(U.getAttribute("end"),O);if(V===null)throw s(U);if(X===null){if(W===null)throw s(U);X=V+W}var q=new A.default(V-_,X-_,j);q.id=Object(D.generateCueId)(q.startTime,q.endTime,q.text);var $=M[U.getAttribute("region")],ie=F[U.getAttribute("style")];q.position=10,q.size=80;var se=function(de,te){var ne="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(ce,H){var oe=t(te,ne,H)||t(de,ne,H);return oe&&(ce[H]=oe),ce},{})}($,ie),le=se.textAlign;if(le){var re=S[le];re&&(q.lineAlign=re),q.align=le}return o(q,se),q}).filter(function(U){return U!==null})}(u,y))}catch(b){v(b)}}else v(new Error("Could not parse IMSC1 mdat"))}function c(n,d,p){var g=n.getElementsByTagName(d)[0];return g?[].slice.call(g.querySelectorAll(p)):[]}function e(n){return n.reduce(function(d,p){var g=p.getAttribute("xml:id");return g&&(d[g]=p),d},{})}function a(n,d){return[].slice.call(n.childNodes).reduce(function(p,g,v){var r;return g.nodeName==="br"&&v?p+`
|
||
`:(r=g.childNodes)!==null&&r!==void 0&&r.length?a(g,d):d?p+g.textContent.trim().replace(/\s+/g," "):p+g.textContent},"")}function t(n,d,p){return n.hasAttributeNS(d,p)?n.getAttributeNS(d,p):null}function s(n){return new Error("Could not parse ttml timestamp "+n)}function l(n,d){if(!n)return null;var p=Object(T.parseTimeStamp)(n);return p===null&&(m.test(n)?p=function(g,v){var r=m.exec(g),i=(0|r[4])+(0|r[5])/v.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/v.frameRate}(n,d):f.test(n)&&(p=function(g,v){var r=f.exec(g),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/v.frameRate;case"t":return i/v.tickRate}return i}(n,d))),p}},"./src/utils/logger.ts":function(N,w,h){h.r(w),h.d(w,"enableLogs",function(){return I}),h.d(w,"logger",function(){return D});var R=function(){},T={trace:R,debug:R,log:R,warn:R,info:R,error:R},A=T;function k(o){var L=self.console[o];return L?L.bind(self.console,"["+o+"] >"):R}function I(o){if(self.console&&o===!0||typeof o=="object"){(function(L){for(var m=arguments.length,f=new Array(m>1?m-1:0),S=1;S<m;S++)f[S-1]=arguments[S];f.forEach(function(E){A[E]=L[E]?L[E].bind(L):k(E)})})(o,"debug","log","info","warn","error");try{A.log()}catch{A=T}}else A=T}var D=T},"./src/utils/mediakeys-helper.ts":function(N,w,h){var R,T;h.r(w),h.d(w,"KeySystems",function(){return R}),h.d(w,"requestMediaKeySystemAccess",function(){return A}),(T=R||(R={})).WIDEVINE="com.widevine.alpha",T.PLAYREADY="com.microsoft.playready";var A=typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":function(N,w,h){function R(){return self.MediaSource||self.WebKitMediaSource}h.r(w),h.d(w,"getMediaSource",function(){return R})},"./src/utils/mp4-tools.ts":function(N,w,h){h.r(w),h.d(w,"bin2str",function(){return I}),h.d(w,"readUint16",function(){return D}),h.d(w,"readUint32",function(){return o}),h.d(w,"writeUint32",function(){return L}),h.d(w,"findBox",function(){return m}),h.d(w,"parseSegmentIndex",function(){return f}),h.d(w,"parseInitSegment",function(){return S}),h.d(w,"getStartDTS",function(){return E}),h.d(w,"getDuration",function(){return c}),h.d(w,"computeRawDurationFromSamples",function(){return e}),h.d(w,"offsetStartDTS",function(){return a}),h.d(w,"segmentValidRange",function(){return t}),h.d(w,"appendUint8Array",function(){return s});var R=h("./src/utils/typed-array.ts"),T=h("./src/loader/fragment.ts"),A=Math.pow(2,32)-1,k=[].push;function I(l){return String.fromCharCode.apply(null,l)}function D(l,n){"data"in l&&(n+=l.start,l=l.data);var d=l[n]<<8|l[n+1];return d<0?65536+d:d}function o(l,n){"data"in l&&(n+=l.start,l=l.data);var d=l[n]<<24|l[n+1]<<16|l[n+2]<<8|l[n+3];return d<0?4294967296+d:d}function L(l,n,d){"data"in l&&(n+=l.start,l=l.data),l[n]=d>>24,l[n+1]=d>>16&255,l[n+2]=d>>8&255,l[n+3]=255&d}function m(l,n){var d,p,g,v=[];if(!n.length)return v;"data"in l?(d=l.data,p=l.start,g=l.end):(p=0,g=(d=l).byteLength);for(var r=p;r<g;){var i=o(d,r),u=i>1?r+i:g;if(I(d.subarray(r+4,r+8))===n[0])if(n.length===1)v.push({data:d,start:r+8,end:u});else{var y=m({data:d,start:r+8,end:u},n.slice(1));y.length&&k.apply(v,y)}r=u}return v}function f(l){var n=m(l,["moov"])[0],d=n?n.end:null,p=m(l,["sidx"]);if(!p||!p[0])return null;var g=[],v=p[0],r=v.data[0],i=r===0?8:16,u=o(v,i);i+=4,i+=r===0?8:16,i+=2;var y=v.end+0,b=D(v,i);i+=2;for(var _=0;_<b;_++){var x=i,C=o(v,x);x+=4;var O=2147483647&C;if((2147483648&C)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var P=o(v,x);x+=4,g.push({referenceSize:O,subsegmentDuration:P,info:{duration:P/u,start:y,end:y+O-1}}),y+=O,i=x+=4}return{earliestPresentationTime:0,timescale:u,version:r,referencesCount:b,references:g,moovEndOffset:d}}function S(l){for(var n=[],d=m(l,["moov","trak"]),p=0;p<d.length;p++){var g=d[p],v=m(g,["tkhd"])[0];if(v){var r=v.data[v.start],i=r===0?12:20,u=o(v,i),y=m(g,["mdia","mdhd"])[0];if(y){var b=o(y,i=(r=y.data[y.start])===0?12:20),_=m(g,["mdia","hdlr"])[0];if(_){var x=I(_.data.subarray(_.start+8,_.start+12)),C={soun:T.ElementaryStreamTypes.AUDIO,vide:T.ElementaryStreamTypes.VIDEO}[x];if(C){var O=m(g,["mdia","minf","stbl","stsd"])[0],P=void 0;O&&(P=I(O.data.subarray(O.start+12,O.start+16))),n[u]={timescale:b,type:C},n[C]={timescale:b,id:u,codec:P}}}}}}return m(l,["moov","mvex","trex"]).forEach(function(F){var M=o(F,4),B=n[M];B&&(B.default={duration:o(F,12),flags:o(F,20)})}),n}function E(l,n){return m(n,["moof","traf"]).reduce(function(d,p){var g=m(p,["tfdt"])[0],v=g.data[g.start],r=m(p,["tfhd"]).reduce(function(i,u){var y=o(u,4),b=l[y];if(b){var _=o(g,4);v===1&&(_*=Math.pow(2,32),_+=o(g,8));var x=_/(b.timescale||9e4);if(isFinite(x)&&(i===null||x<i))return x}return i},null);return r!==null&&isFinite(r)&&(d===null||r<d)?r:d},null)||0}function c(l,n){for(var d=0,p=0,g=0,v=m(l,["moof","traf"]),r=0;r<v.length;r++){var i=v[r],u=m(i,["tfhd"])[0],y=n[o(u,4)];if(y){var b=y.default,_=o(u,0)|(b==null?void 0:b.flags),x=b==null?void 0:b.duration;8&_&&(x=o(u,2&_?12:8));for(var C=y.timescale||9e4,O=m(i,["trun"]),P=0;P<O.length;P++)d=x?x*o(O[P],4):e(O[P]),y.type===T.ElementaryStreamTypes.VIDEO?p+=d/C:y.type===T.ElementaryStreamTypes.AUDIO&&(g+=d/C)}}if(p===0&&g===0){var F=f(l);if(F!=null&&F.references)return F.references.reduce(function(M,B){return M+B.info.duration||0},0)}return p||g}function e(l){var n=o(l,0),d=8;1&n&&(d+=4),4&n&&(d+=4);for(var p=0,g=o(l,4),v=0;v<g;v++)256&n&&(p+=o(l,d),d+=4),512&n&&(d+=4),1024&n&&(d+=4),2048&n&&(d+=4);return p}function a(l,n,d){m(n,["moof","traf"]).forEach(function(p){m(p,["tfhd"]).forEach(function(g){var v=o(g,4),r=l[v];if(r){var i=r.timescale||9e4;m(p,["tfdt"]).forEach(function(u){var y=u.data[u.start],b=o(u,4);if(y===0)L(u,4,b-d*i);else{b*=Math.pow(2,32),b+=o(u,8),b-=d*i,b=Math.max(b,0);var _=Math.floor(b/(A+1)),x=Math.floor(b%(A+1));L(u,4,_),L(u,8,x)}})}})})}function t(l){var n={valid:null,remainder:null},d=m(l,["moof"]);if(!d)return n;if(d.length<2)return n.remainder=l,n;var p=d[d.length-1];return n.valid=Object(R.sliceUint8)(l,0,p.start-8),n.remainder=Object(R.sliceUint8)(l,p.start-8),n}function s(l,n){var d=new Uint8Array(l.length+n.length);return d.set(l),d.set(n,l.length),d}},"./src/utils/output-filter.ts":function(N,w,h){h.r(w),h.d(w,"default",function(){return R});var R=function(){function T(k,I){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=k,this.trackName=I}var A=T.prototype;return A.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},A.newCue=function(k,I,D){(this.startTime===null||this.startTime>k)&&(this.startTime=k),this.endTime=I,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},T}()},"./src/utils/texttrack-utils.ts":function(N,w,h){h.r(w),h.d(w,"sendAddTrackEvent",function(){return T}),h.d(w,"addCueToTrack",function(){return A}),h.d(w,"clearCurrentCues",function(){return k}),h.d(w,"removeCuesInRange",function(){return I}),h.d(w,"getCuesInRange",function(){return D});var R=h("./src/utils/logger.ts");function T(o,L){var m;try{m=new Event("addtrack")}catch{(m=document.createEvent("Event")).initEvent("addtrack",!1,!1)}m.track=o,L.dispatchEvent(m)}function A(o,L){var m=o.mode;if(m==="disabled"&&(o.mode="hidden"),o.cues&&!o.cues.getCueById(L.id))try{if(o.addCue(L),!o.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(S){R.logger.debug("[texttrack-utils]: "+S);var f=new self.TextTrackCue(L.startTime,L.endTime,L.text);f.id=L.id,o.addCue(f)}m==="disabled"&&(o.mode=m)}function k(o){var L=o.mode;if(L==="disabled"&&(o.mode="hidden"),o.cues)for(var m=o.cues.length;m--;)o.removeCue(o.cues[m]);L==="disabled"&&(o.mode=L)}function I(o,L,m){var f=o.mode;if(f==="disabled"&&(o.mode="hidden"),o.cues&&o.cues.length>0)for(var S=D(o.cues,L,m),E=0;E<S.length;E++)o.removeCue(S[E]);f==="disabled"&&(o.mode=f)}function D(o,L,m){var f=[],S=function(a,t){if(t<a[0].startTime)return 0;var s=a.length-1;if(t>a[s].endTime)return-1;for(var l=0,n=s;l<=n;){var d=Math.floor((n+l)/2);if(t<a[d].startTime)n=d-1;else{if(!(t>a[d].startTime&&l<s))return d;l=d+1}}return a[l].startTime-t<t-a[n].startTime?l:n}(o,L);if(S>-1)for(var E=S,c=o.length;E<c;E++){var e=o[E];if(e.startTime>=L&&e.endTime<=m)f.push(e);else if(e.startTime>m)return f}return f}},"./src/utils/time-ranges.ts":function(N,w,h){h.r(w),w.default={toString:function(R){for(var T="",A=R.length,k=0;k<A;k++)T+="["+R.start(k).toFixed(3)+","+R.end(k).toFixed(3)+"]";return T}}},"./src/utils/timescale-conversion.ts":function(N,w,h){function R(I,D,o,L){o===void 0&&(o=1),L===void 0&&(L=!1);var m=I*D*o;return L?Math.round(m):m}function T(I,D,o,L){return o===void 0&&(o=1),L===void 0&&(L=!1),R(I,D,1/o,L)}function A(I,D){return D===void 0&&(D=!1),R(I,1e3,1/9e4,D)}function k(I,D){return D===void 0&&(D=1),R(I,9e4,1/D)}h.r(w),h.d(w,"toTimescaleFromBase",function(){return R}),h.d(w,"toTimescaleFromScale",function(){return T}),h.d(w,"toMsFromMpegTsClock",function(){return A}),h.d(w,"toMpegTsClockFromTimescale",function(){return k})},"./src/utils/typed-array.ts":function(N,w,h){function R(T,A,k){return Uint8Array.prototype.slice?T.slice(A,k):new Uint8Array(Array.prototype.slice.call(T,A,k))}h.r(w),h.d(w,"sliceUint8",function(){return R})},"./src/utils/vttcue.ts":function(N,w,h){h.r(w),w.default=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],T=["start","middle","end","left","right"];function A(o,L){if(typeof L!="string"||!Array.isArray(o))return!1;var m=L.toLowerCase();return!!~o.indexOf(m)&&m}function k(o){return A(T,o)}function I(o){for(var L=arguments.length,m=new Array(L>1?L-1:0),f=1;f<L;f++)m[f-1]=arguments[f];for(var S=1;S<arguments.length;S++){var E=arguments[S];for(var c in E)o[c]=E[c]}return o}function D(o,L,m){var f=this,S={enumerable:!0};f.hasBeenReset=!1;var E="",c=!1,e=o,a=L,t=m,s=null,l="",n=!0,d="auto",p="start",g=50,v="middle",r=50,i="middle";Object.defineProperty(f,"id",I({},S,{get:function(){return E},set:function(u){E=""+u}})),Object.defineProperty(f,"pauseOnExit",I({},S,{get:function(){return c},set:function(u){c=!!u}})),Object.defineProperty(f,"startTime",I({},S,{get:function(){return e},set:function(u){if(typeof u!="number")throw new TypeError("Start time must be set to a number.");e=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",I({},S,{get:function(){return a},set:function(u){if(typeof u!="number")throw new TypeError("End time must be set to a number.");a=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",I({},S,{get:function(){return t},set:function(u){t=""+u,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",I({},S,{get:function(){return s},set:function(u){s=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",I({},S,{get:function(){return l},set:function(u){var y=function(b){return A(R,b)}(u);if(y===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=y,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",I({},S,{get:function(){return n},set:function(u){n=!!u,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",I({},S,{get:function(){return d},set:function(u){if(typeof u!="number"&&u!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");d=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",I({},S,{get:function(){return p},set:function(u){var y=k(u);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");p=y,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",I({},S,{get:function(){return g},set:function(u){if(u<0||u>100)throw new Error("Position must be between 0 and 100.");g=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",I({},S,{get:function(){return v},set:function(u){var y=k(u);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");v=y,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",I({},S,{get:function(){return r},set:function(u){if(u<0||u>100)throw new Error("Size must be between 0 and 100.");r=u,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",I({},S,{get:function(){return i},set:function(u){var y=k(u);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");i=y,this.hasBeenReset=!0}})),f.displayState=void 0}return D.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},D}()},"./src/utils/vttparser.ts":function(N,w,h){h.r(w),h.d(w,"parseTimeStamp",function(){return A}),h.d(w,"fixLineBreaks",function(){return m}),h.d(w,"VTTParser",function(){return f});var R=h("./src/utils/vttcue.ts"),T=function(){function S(){}return S.prototype.decode=function(E,c){if(!E)return"";if(typeof E!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(E))},S}();function A(S){function E(e,a,t,s){return 3600*(0|e)+60*(0|a)+(0|t)+parseFloat(s||0)}var c=S.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return c?parseFloat(c[2])>59?E(c[2],c[3],0,c[4]):E(c[1],c[2],c[3],c[4]):null}var k=function(){function S(){this.values=Object.create(null)}var E=S.prototype;return E.set=function(c,e){this.get(c)||e===""||(this.values[c]=e)},E.get=function(c,e,a){return a?this.has(c)?this.values[c]:e[a]:this.has(c)?this.values[c]:e},E.has=function(c){return c in this.values},E.alt=function(c,e,a){for(var t=0;t<a.length;++t)if(e===a[t]){this.set(c,e);break}},E.integer=function(c,e){/^-?\d+$/.test(e)&&this.set(c,parseInt(e,10))},E.percent=function(c,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var a=parseFloat(e);if(a>=0&&a<=100)return this.set(c,a),!0}return!1},S}();function I(S,E,c,e){var a=e?S.split(e):[S];for(var t in a)if(typeof a[t]=="string"){var s=a[t].split(c);s.length===2&&E(s[0],s[1])}}var D=new R.default(0,0,""),o=D.align==="middle"?"middle":"center";function L(S,E,c){var e=S;function a(){var s=A(S);if(s===null)throw new Error("Malformed timestamp: "+e);return S=S.replace(/^[^\sa-zA-Z-]+/,""),s}function t(){S=S.replace(/^\s+/,"")}if(t(),E.startTime=a(),t(),S.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+e);S=S.substr(3),t(),E.endTime=a(),t(),function(s,l){var n=new k;I(s,function(g,v){var r;switch(g){case"region":for(var i=c.length-1;i>=0;i--)if(c[i].id===v){n.set(g,c[i].region);break}break;case"vertical":n.alt(g,v,["rl","lr"]);break;case"line":r=v.split(","),n.integer(g,r[0]),n.percent(g,r[0])&&n.set("snapToLines",!1),n.alt(g,r[0],["auto"]),r.length===2&&n.alt("lineAlign",r[1],["start",o,"end"]);break;case"position":r=v.split(","),n.percent(g,r[0]),r.length===2&&n.alt("positionAlign",r[1],["start",o,"end","line-left","line-right","auto"]);break;case"size":n.percent(g,v);break;case"align":n.alt(g,v,["start",o,"end","left","right"])}},/:/,/\s/),l.region=n.get("region",null),l.vertical=n.get("vertical","");var d=n.get("line","auto");d==="auto"&&D.line===-1&&(d=-1),l.line=d,l.lineAlign=n.get("lineAlign","start"),l.snapToLines=n.get("snapToLines",!0),l.size=n.get("size",100),l.align=n.get("align",o);var p=n.get("position","auto");p==="auto"&&D.position===50&&(p=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=p}(S,E)}function m(S){return S.replace(/<br(?: \/)?>/gi,`
|
||
`)}var f=function(){function S(){this.state="INITIAL",this.buffer="",this.decoder=new T,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var E=S.prototype;return E.parse=function(c){var e=this;function a(){var d=e.buffer,p=0;for(d=m(d);p<d.length&&d[p]!=="\r"&&d[p]!==`
|
||
`;)++p;var g=d.substr(0,p);return d[p]==="\r"&&++p,d[p]===`
|
||
`&&++p,e.buffer=d.substr(p),g}c&&(e.buffer+=e.decoder.decode(c,{stream:!0}));try{var t="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;var s=(t=a()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var l=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(l?l=!1:t=a(),e.state){case"HEADER":/:/.test(t)?I(t,function(d,p){},/:/):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",t.indexOf("-->")===-1){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{L(t,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var n=t.indexOf("-->")!==-1;if(!t||n&&(l=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
||
`),e.cue.text+=t;continue;case"BADCUE":t||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},E.flush=function(){var c=this;try{if((c.cue||c.state==="HEADER")&&(c.buffer+=`
|
||
|
||
`,c.parse()),c.state==="INITIAL"||c.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){c.onparsingerror&&c.onparsingerror(e)}return c.onflush&&c.onflush(),this},S}()},"./src/utils/webvtt-parser.ts":function(N,w,h){h.r(w),h.d(w,"generateCueId",function(){return m}),h.d(w,"parseWebVTT",function(){return f});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/vttparser.ts"),A=h("./src/demux/id3.ts"),k=h("./src/utils/timescale-conversion.ts"),I=h("./src/remux/mp4-remuxer.ts"),D=/\r\n|\n\r|\n|\r/g,o=function(S,E,c){return c===void 0&&(c=0),S.substr(c,E.length)===E},L=function(S){for(var E=5381,c=S.length;c;)E=33*E^S.charCodeAt(--c);return(E>>>0).toString()};function m(S,E,c){return L(S.toString())+L(E.toString())+L(c)}function f(S,E,c,e,a,t,s,l){var n,d=new T.VTTParser,p=Object(A.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(D,`
|
||
`).split(`
|
||
`),g=[],v=Object(k.toMpegTsClockFromTimescale)(E,c),r="00:00.000",i=0,u=0,y=!0,b=!1;d.oncue=function(_){var x=e[a],C=e.ccOffset,O=(i-v)/9e4;if(x!=null&&x.new&&(u!==void 0?C=e.ccOffset=x.start:function(B,U,j){var V=B[U],W=B[V.prevCC];if(!W||!W.new&&V.new)return B.ccOffset=B.presentationOffset=V.start,void(V.new=!1);for(;(X=W)!==null&&X!==void 0&&X.new;){var X;B.ccOffset+=V.start-W.start,V.new=!1,W=B[(V=W).prevCC]}B.presentationOffset=j}(e,a,O)),O&&(C=O-e.presentationOffset),b){var P=_.endTime-_.startTime,F=Object(I.normalizePts)(9e4*(_.startTime+C-u),9e4*t)/9e4;_.startTime=F,_.endTime=F+P}var M=_.text.trim();_.text=decodeURIComponent(encodeURIComponent(M)),_.id||(_.id=m(_.startTime,_.endTime,M)),_.endTime>0&&g.push(_)},d.onparsingerror=function(_){n=_},d.onflush=function(){n?l(n):s(g)},p.forEach(function(_){if(y){if(o(_,"X-TIMESTAMP-MAP=")){y=!1,b=!0,_.substr(16).split(",").forEach(function(x){o(x,"LOCAL:")?r=x.substr(6):o(x,"MPEGTS:")&&(i=parseInt(x.substr(7)))});try{u=function(x){var C=parseInt(x.substr(-3)),O=parseInt(x.substr(-6,2)),P=parseInt(x.substr(-9,2)),F=x.length>9?parseInt(x.substr(0,x.indexOf(":"))):0;if(!(Object(R.isFiniteNumber)(C)&&Object(R.isFiniteNumber)(O)&&Object(R.isFiniteNumber)(P)&&Object(R.isFiniteNumber)(F)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+x);return C+=1e3*O,(C+=6e4*P)+36e5*F}(r)/1e3}catch(x){b=!1,n=x}return}_===""&&(y=!1)}d.parse(_+`
|
||
`)}),d.flush()}},"./src/utils/xhr-loader.ts":function(N,w,h){h.r(w);var R=h("./src/utils/logger.ts"),T=h("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,k=function(){function I(o){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=o?o.xhrSetup:null,this.stats=new T.LoadStats,this.retryDelay=0}var D=I.prototype;return D.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},D.abortInternal=function(){var o=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),o&&(o.onreadystatechange=null,o.onprogress=null,o.readyState!==4&&(this.stats.aborted=!0,o.abort()))},D.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},D.load=function(o,L,m){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=o,this.config=L,this.callbacks=m,this.retryDelay=L.retryDelay,this.loadInternal()},D.loadInternal=function(){var o=this.config,L=this.context;if(o){var m=this.loader=new self.XMLHttpRequest,f=this.stats;f.loading.first=0,f.loaded=0;var S=this.xhrSetup;try{if(S)try{S(m,L.url)}catch{m.open("GET",L.url,!0),S(m,L.url)}m.readyState||m.open("GET",L.url,!0)}catch(E){return void this.callbacks.onError({code:m.status,text:E.message},L,m)}L.rangeEnd&&m.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),m.onreadystatechange=this.readystatechange.bind(this),m.onprogress=this.loadprogress.bind(this),m.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.timeout),m.send()}},D.readystatechange=function(){var o=this.context,L=this.loader,m=this.stats;if(o&&L){var f=L.readyState,S=this.config;if(!m.aborted&&f>=2)if(self.clearTimeout(this.requestTimeout),m.loading.first===0&&(m.loading.first=Math.max(self.performance.now(),m.loading.start)),f===4){L.onreadystatechange=null,L.onprogress=null;var E=L.status;if(E>=200&&E<300){var c,e;if(m.loading.end=Math.max(self.performance.now(),m.loading.first),e=o.responseType==="arraybuffer"?(c=L.response).byteLength:(c=L.responseText).length,m.loaded=m.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(m,o,c,L),!this.callbacks)return;var t={url:L.responseURL,data:c};this.callbacks.onSuccess(t,m,o,L)}else m.retry>=S.maxRetry||E>=400&&E<499?(R.logger.error(E+" while loading "+o.url),this.callbacks.onError({code:E,text:L.statusText},o,L)):(R.logger.warn(E+" while loading "+o.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,S.maxRetryDelay),m.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),S.timeout)}},D.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))},D.loadprogress=function(o){var L=this.stats;L.loaded=o.loaded,o.lengthComputable&&(L.total=o.total)},D.getCacheAge=function(){var o=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");o=L?parseFloat(L):null}return o},I}();w.default=k}}).default);var it=mr(Lt.exports);const yr={name:"d-icon"},Le=Object.assign(yr,{props:{icon:String,size:[Number,String]},setup:function(N){const w=N,h=we(()=>({fontSize:/^\d+$/.test(w.size)?w.size+"px":w.size}));return(R,T)=>(Y(),Z("i",{class:be(["d-icon iconfont",N.icon]),style:je(G(h))},null,6))}});Le.__scopeId="data-v-0c690e66";Ve("data-v-4cb76d59");const Er={class:"d-player-top"},Tr={class:"top-title"},Sr={class:"top-title"};He();const br={props:{title:{default:""}},setup(N){Date.prototype.format=function(R){let T={"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds()};for(var A in T)new RegExp("("+A+")").test(R)&&(R=R.replace(RegExp.$1,RegExp.$1.length==1?T[A]:("00"+T[A]).substr((""+T[A]).length)));return R};let w=ye("00:00:00");w.value=new Date().format("hh:mm:ss");let h=null;return h=setInterval(()=>{w.value=new Date().format("hh:mm:ss")},1e3),yt(()=>{clearInterval(h)}),(R,T)=>(Y(),Z("div",Er,[K("p",Tr,J(N.title||""),1),K("p",Sr,J(G(w)),1)]))},__scopeId:"data-v-4cb76d59"};Ve("data-v-ac2469ec");const Lr={class:"d-status"},Ar={class:"d-flex-center"},kr={class:"d-flex-center"},_r=ue("5X速播放中 ");He();var At=xe({props:["state"],setup:N=>(w,h)=>pe((Y(),Z("div",Lr,[pe(K("li",Ar,[z(Le,{size:"18",class:"d-status-icon",icon:"icon-volume-"+(N.state.volume==0?"mute":N.state.volume>.5?"up":"down")},null,8,["icon"]),ue(" "+J(~~(100*N.state.volume))+"% ",1)],512),[[me,N.state.handleType=="volume"]]),pe(K("li",kr,[z(Le,{size:"12",icon:"icon-play"}),z(Le,{size:"12",icon:"icon-play",style:{"margin-right":"5px"}}),_r],512),[[me,N.state.handleType=="playbackRate"||N.state.isMultiplesPlay]])],512)),[[me,N.state.handleType||N.state.isMultiplesPlay]])});At.__scopeId="data-v-ac2469ec",Ve("data-v-385f7870");const Dr=["checked","true-value","false-value"],Rr=K("span",{class:"d-switch_action"},null,-1);He();var rt=xe({props:{modelValue:{type:[Number,String,Boolean]},width:{type:String,default:"40px"},trueValue:{type:[Number,String,Boolean],default:!0},falseValue:{type:[Number,String,Boolean],default:!0},activeColor:{type:[String],default:"#409EFF"}},emits:["update:modelValue","change"],setup(N,{emit:w}){const h=N;ut(k=>({"014e5dc0":N.width,e4e32852:N.activeColor}));const R=ye(null),T=we(()=>h.modelValue===h.trueValue),A=()=>{Et(()=>{const k=R.value.checked;w("update:modelValue",k),w("change",k)})};return(k,I)=>(Y(),Z("div",{class:be(["d-switch",{"is-checked":G(T)}])},[K("input",{class:"d-switch__input",ref:R,type:"checkbox",checked:G(T),onChange:A,"true-value":N.trueValue,"false-value":N.falseValue},null,40,Dr),Rr],2))}});rt.__scopeId="data-v-385f7870",Ve("data-v-b2384226");const Ir={key:0},Cr=K("i",{class:"rotating iconfont icon-loading f50"},null,-1),wr=[K("i",{class:"rotating iconfont icon-loading f50"},null,-1),K("p",null,"正在缓冲...",-1)],xr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ue("重新播放 ")],Or=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ue("请求错误 ")];He();var kt=xe({props:{loadType:String,text:{type:String,default:""}},setup(N){const w=N,{proxy:h}=wt(),R=["loadstart","waiting","ended","error","stalled"],T=()=>{h.$parent.play()},A=we(()=>{let k="background: rgba(0, 0, 0, .1);z-index:1";return w.loadType=="loadstart"&&(k="background: rgba(0, 0, 0, 1);;z-index:3"),k});return(k,I)=>pe((Y(),Z("div",{class:"d-loading",style:je(G(A))},[K("div",null,[N.loadType=="loadstart"?(Y(),Z("span",Ir,[Cr,K("p",null,J(N.text),1)])):ae("",!0),pe(K("span",null,wr,512),[[me,N.loadType=="waiting"]]),pe(K("span",null,[K("p",{onClick:T,class:"d-flex-x d-pointer"},xr)],512),[[me,N.loadType=="ended"]]),pe(K("span",null,[K("p",{onClick:T,class:"d-flex-x d-pointer"},Or)],512),[[me,N.loadType=="error"||N.loadType=="stalled"]])])],4)),[[me,R.includes(N.loadType)]])}});kt.__scopeId="data-v-b2384226";const Ke=function(N,w,h,R=!1){N&&w&&h&&N.addEventListener(w,h,R)},Ee=function(N,w,h,R=!1){N&&w&&h&&N.removeEventListener(w,h,R)};Ve("data-v-5a794390");const Pr=["onMousedown"];He();var $e=xe(lt(ot({},{name:"DSlider"}),{props:{modelValue:{required:!0,type:Number,default:0},disabled:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},hover:{type:Boolean,default:!0},hoverText:{type:String,default:""},preload:{type:Number,default:0},size:{type:String,default:"10px"}},emits:["update:modelValue","change","onMousemove"],setup:function(N,{emit:w}){const h=N;ut(e=>({"5242b67b":N.size}));const R=ye(null),T=ye(null),A=Se({dragging:!1,hoverPosition:0,hoverTipsLeft:"50%"}),k=we(()=>{let e=h.modelValue<0?0:h.modelValue>1?1:h.modelValue;return h.vertical?`height:${100*e}%`:`width:${100*e}%`}),I=we(()=>{let e=h.preload<0?0:h.preload>1?1:h.preload;return h.vertical?`height:${100*e}%`:`width:${100*e}%`}),D=we(()=>{let e=A.hoverPosition<0?0:A.hoverPosition>1?1:A.hoverPosition;return h.vertical?`bottom:${100*e}%`:`left:${100*e}%`}),o=e=>{e.preventDefault()},L=e=>{h.disabled||(e.preventDefault(),A.dragging=!0,f(e),Ke(window,"mousemove",E),Ke(window,"touchmove",E),Ke(window,"mouseup",c),Ke(window,"touchend",c))},m=e=>{if(!h.hover)return;let a=S(e);if(w("onMousemove",e,a),A.hoverPosition=a,h.vertical)return;let t=R.value,s=T.value.clientWidth/2,l=e.clientX-t.getBoundingClientRect().left;l<s?A.hoverTipsLeft=s-l+"px":t.clientWidth-l<s?A.hoverTipsLeft=t.clientWidth-l-s+"px":A.hoverTipsLeft="50%"},f=e=>{let a=S(e);w("update:modelValue",a),w("change",e,a)},S=e=>{let a=R.value,t=0;if(h.vertical){let s=a.clientHeight;t=(a.getBoundingClientRect().bottom-e.clientY)/s}else t=(e.clientX-a.getBoundingClientRect().left)/a.clientWidth;return t<0?0:t>1?1:t},E=e=>{f(e)},c=e=>{A.dragging&&(Ee(window,"mousemove",E),Ee(window,"touchmove",E),Ee(window,"mouseup",c),Ee(window,"touchend",c),Ee(window,"contextmenu",c),setTimeout(()=>{A.dragging=!1},0))};return(e,a)=>(Y(),Z("div",{ref:R,class:be(["d-slider",{"is-vertical":h.vertical}]),onMousedown:It(L,["stop"]),onContextmenu:o},[K("div",{class:"d-slider__runway",onMousemove:m},[pe(K("div",{class:"d-slider__cursor",style:je(G(D))},[pe(K("div",{class:"d-slider__tips",ref:T,style:je({left:G(A).hoverTipsLeft})},J(h.hoverText),5),[[me,h.hoverText]])],4),[[me,h.hover]]),K("div",{class:"d-slider__preload",style:je(G(I))},null,4),K("div",{class:"d-slider__bar",style:je(G(k))},null,4)],32)],42,Pr))}}));$e.__scopeId="data-v-5a794390";Ve("data-v-570fa0d1");const Fr={key:0,class:"d-player-dialog"},Mr={class:"d-player-dialog-body"},Nr={class:"d-player-dialog-title"},Br={class:"d-player-hotkey-panel"},Ur={class:"d-player-filter-panel"},Gr={class:"d-player-filter-panel-item"},jr=K("span",null,"饱和度",-1),Kr={class:"d-player-filter-panel-item"},Vr=K("span",null,"亮度",-1),Hr={class:"d-player-filter-panel-item"},Wr=K("span",null,"对比度",-1),Yr={key:0,class:"d-player-contextmenu"},qr=["dplayerKeyCode"],zr=K("input",{class:"d-player-copyText"},null,-1);He();var _t=xe({setup(N){const w=Se({show:!1,dialogType:"",dialogTitle:"",version:"1.3.1-beta.6",mouseX:0,mouseY:0}),h=[{label:"视频色彩调整",key:"filter"},{label:"快捷键说明",key:"hotkey"},{label:"复制视频网址",key:"copy"},{label:"版本:1.3.1-beta.6",key:"version"}],R=[{key:"Space",label:"播放/暂停"},{key:"→",label:"单次快进10s,长按5倍速播放"},{key:"←",label:"快退5s"},{key:"↑",label:"音量增加10%"},{key:"↓",label:"音量增加降低10%"},{key:"Esc",label:"退出全屏/退出网页全屏"},{key:"F",label:"全屏/退出全屏"}],T=Se({saturate:.392,brightness:.392,contrast:.392}),A=we(()=>({left:w.mouseX+"px",top:w.mouseY+"px"}));Xe(T,L=>{let m=document.querySelector("#dPlayerVideo"),f=(2.55*L.saturate).toFixed(2),S=(2.55*L.brightness).toFixed(2),E=(2.55*L.contrast).toFixed(2);m.style.filter=`saturate(${f}) brightness(${S}) contrast(${E})`});const k=()=>{T.saturate=.392,T.brightness=.392,T.contrast=.392},I=L=>{L.key=="Escape"&&o(0)},D=L=>{L.preventDefault(),Ke(window,"keydown",I),Ke(window,"click",o);let m=document.querySelector("#refPlayerWrap"),f=m.clientWidth;m.clientHeight,w.mouseX=L.clientX-m.getBoundingClientRect().left,f-w.mouseX<130&&(w.mouseX=w.mouseX+(f-w.mouseX-130)),w.mouseY=L.clientY-m.getBoundingClientRect().top,w.show=!0},o=L=>{let m=L.path[0].tagName=="LI",f=L.path[0].attributes.dplayerKeyCode&&L.path[0].attributes.dplayerKeyCode.value,S=h.map(E=>E.key);if(m&&S.includes(f))if(w.dialogTitle=L.path[0].innerText,w.dialogType=f,f=="copy"){let E=document.querySelector(".d-player-copyText");E.value=window.location.href,E.select(),document.execCommand("copy"),w.dialogType=""}else f=="version"&&(w.dialogType="");w.show=!1,Ee(window,"keydown",I),Ee(window,"click",o)};return mt(()=>{let L=document.querySelector("#refPlayerWrap");Ee(window,"keydown",I),Ee(window,"click",o),Ee(L,"contextmenu",D),Ke(L,"contextmenu",D)}),yt(()=>{let L=document.querySelector("#refPlayerWrap");Ee(window,"keydown",I),Ee(window,"click",o),Ee(L,"contextmenu",D)}),(L,m)=>(Y(),Z("div",null,[z(at,{name:"d-fade-in"},{default:Q(()=>[G(w).dialogType?(Y(),Z("div",Fr,[K("div",Mr,[K("h5",Nr,[ue(J(G(w).dialogTitle)+" ",1),K("i",{onClick:m[0]||(m[0]=f=>G(w).dialogType=!1),class:"icon icon-close"},"X")]),pe(K("ul",Br,[(Y(),Z(Ce,null,Fe(R,f=>K("li",{class:"d-player-hotkey-panel-item",key:f.key},[K("span",null,J(f.key),1),K("span",null,J(f.label),1)])),64))],512),[[me,G(w).dialogType=="hotkey"]]),pe(K("ul",Ur,[K("li",Gr,[jr,z($e,{class:"filter-panel-slider",size:"5px",modelValue:G(T).saturate,"onUpdate:modelValue":m[1]||(m[1]=f=>G(T).saturate=f)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(T).saturate)),1)]),K("li",Kr,[Vr,z($e,{class:"filter-panel-slider",size:"5px",modelValue:G(T).brightness,"onUpdate:modelValue":m[2]||(m[2]=f=>G(T).brightness=f)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(T).brightness)),1)]),K("li",Hr,[Wr,z($e,{class:"filter-panel-slider",size:"5px",modelValue:G(T).contrast,"onUpdate:modelValue":m[3]||(m[3]=f=>G(T).contrast=f)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(T).contrast)),1)]),K("span",{onClick:k,title:"重置","aria-label":"重置",class:"d-player-filter-reset"},"重置")],512),[[me,G(w).dialogType=="filter"]])])])):ae("",!0)]),_:1}),G(w).show?(Y(),Z("div",Yr,[K("ul",{class:"d-player-contextmenu-body",style:je(G(A))},[(Y(),Z(Ce,null,Fe(h,f=>K("li",{dplayerKeyCode:f.key,key:f.key},J(f.label),9,qr)),64))],4),zr])):ae("",!0)]))}});_t.__scopeId="data-v-570fa0d1";const nt=N=>{let w=~~(N/3600),h=~~(N%3600/60),R=~~(N%60);return w=w<10?"0"+w:w,h=h<10?"0"+h:h,R=R<10?"0"+R:R,`${w}:${h}:${R}`},et="ontouchstart"in window,pt=["loadstart","play","pause","playing","seeking","seeked","waiting","durationchange","progress","canplay","timeupdate","ended","error","stalled"],Xr={width:{type:String,default:"800px"},height:{type:String,default:"450px"},color:{type:String,default:"#409eff"},src:{required:!0,type:String,default:""},title:{type:String,default:""},type:{type:String,default:"video/mp4"},poster:{type:String,default:""},webFullScreen:{type:Boolean,default:!1},speed:{type:Boolean,default:!0},currentTime:{type:Number,default:0},playsinline:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},speedRate:{type:Array,default:()=>["2.0","1.5","1.25","1.0","0.75","0.5"]},autoPlay:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},mirror:{type:Boolean,default:!1},ligthOff:{type:Boolean,default:!1},volume:{type:[String,Number],default:.3},control:{type:Boolean,default:!0},controlBtns:{type:Array,default:["audioTrack","quality","speedRate","volume","setting","pip","pageFullScreen","fullScreen"]},preload:{type:String,default:"auto"}};Ve("data-v-01791e9e");const $r={class:"d-player-video",id:"dPlayerVideo"},Qr=["controls","webkit-playsinline","playsinline","volume","muted","loop","preload","src","poster"],Zr={class:"d-player-lightoff"},Jr={key:1,class:"d-player-state"},ei={class:"d-play-btn"},ti=["onKeyup","onKeydown"],ri={class:"d-control-progress"},ii={class:"d-tool-bar"},ni={key:0,class:"d-tool-item d-tool-time audioTrack-btn"},ai=K("span",{style:{margin:"0 3px"}},"/",-1),si={class:"total-time"},oi={class:"d-tool-bar"},li={key:0,class:"d-tool-item quality-btn"},ui={class:"d-tool-item-main"},di={class:"speed-main",style:{"text-align":"center"}},ci=["onClick"],hi={key:1,class:"d-tool-item speedRate-btn"},fi={class:"d-tool-item-main"},gi={class:"speed-main"},vi=["onClick"],pi={key:2,class:"d-tool-item volume-btn"},mi={class:"d-tool-item-main volume-box",style:{width:"52px"}},yi={class:"volume-text-size"},Ei={key:3,class:"d-tool-item setting-btn"},Ti={class:"d-tool-item-main"},Si={class:"speed-main"},bi=ue(" 镜像画面 "),Li=ue(" 循环播放 "),Ai=ue(" 关灯模式 "),ki=K("div",{class:"d-tool-item-main"},"画中画",-1),_i=K("div",{class:"d-tool-item-main"},"网页全屏",-1),Di=K("div",{class:"d-tool-item-main"},"全屏",-1);He();var tt=xe(lt(ot({},{name:"vue3VideoPlay",inheritAttrs:!1}),{props:Xr,emits:[...pt,"mirrorChange","loopChange","lightOffChange"],setup:function(N,{expose:w,emit:h}){const R=N;ut(C=>({"51d4439c":G(S),"77e758a6":C.width,b8a1afc0:C.height}));const T=new it({fragLoadingTimeOut:2e3}),A=ye(null),k=ye(null),I=ye(null),D=ye(null),o=Se(lt(ot({dVideo:null},R),{muted:R.muted,playBtnState:R.autoPlay?"pause":"play",loadStateType:"loadstart",fullScreen:!1,handleType:"",currentTime:"00:00:00",preloadBar:0,totalTime:"00:00:00",isVideoHovering:!0,speedActive:"1.0",playProgress:0,isMultiplesPlay:!1,longPressTimeout:null,progressCursorTime:"00:00:00",qualityLevels:[],currentLevel:0})),L=(...C)=>O=>C.reverse().reduce((P,F)=>F(P),O),m=pt.reduce((C,O)=>{var P;return C[`on${P=O,P.charAt(0).toUpperCase()+P.slice(1)}`]=F=>{o.loadStateType=O,h(O,F)},C},{});m.onCanplay=L(m.onCanplay,()=>{o.playBtnState!="play"&&o.dVideo.play(),o.autoPlay&&(o.dVideo.play(),o.playBtnState="pause")}),m.onEnded=L(m.onEnded,()=>{o.playBtnState="replay"}),m.onDurationchange=C=>{h("durationchange",C),R.currentTime!=0&&(o.dVideo.currentTime=R.currentTime),m.onTimeupdate(C)},m.onProgress=C=>{console.log("缓冲中..."),h("progress",C);let O=C.target.duration,P=C.target.buffered,F=C.target.buffered.length&&C.target.buffered.end(P-1);o.preloadBar=F/O},m.onTimeupdate=C=>{h("timeupdate",C);let O=C.duration||C.target.duration||0,P=C.currentTime||C.target.currentTime;o.playProgress=P/O,o.currentTime=nt(P),o.totalTime=nt(O)},m.onError=L(m.onError,()=>{o.playBtnState="replay"});let f=Ct();for(let C in f)m[C]=f[C];const S=(E=o.color,`${parseInt("0x"+E.slice(1,3))},${parseInt("0x"+E.slice(3,5))},${parseInt("0x"+E.slice(5,7))}`);var E;const c=vt(500,()=>{o.handleType=""}),e=C=>{C.preventDefault(),C.code=="ArrowUp"?o.volume=o.volume+.1>1?1:o.volume+.1:o.volume=o.volume-.1<0?0:o.volume-.1,o.muted=!1,o.handleType="volume",c()},a=C=>{R.speed&&(o.dVideo.currentTime=o.dVideo.currentTime<10?.1:o.dVideo.currentTime-10,m.onTimeupdate(o.dVideo),l())},t=C=>{C.preventDefault();let O=C.type;if(C.key=="ArrowRight"){if(l(),O=="keyup"){if(clearTimeout(o.longPressTimeout),!R.speed&&!o.longPressTimeout)return;o.isMultiplesPlay?(o.dVideo.playbackRate=o.speedActive,o.isMultiplesPlay=!1):(o.dVideo.currentTime=o.dVideo.currentTime+10,m.onTimeupdate(o.dVideo))}else if(O=="keydown"){if(!R.speed)return;o.isMultiplesPlay&&clearTimeout(o.longPressTimeout),o.longPressTimeout=setTimeout(()=>{o.isMultiplesPlay=!0,o.dVideo.playbackRate=5,o.handleType="playbackRate",c()},500)}}},s=()=>{et||D.value.focus()},l=()=>{o.loadStateType="play",o.dVideo.play().catch(()=>{setTimeout(()=>{o.playBtnState="replay",o.loadStateType="error"},500)}),o.playBtnState="pause"},n=()=>{o.dVideo.pause(),o.playBtnState="play"},d=C=>{C&&C.preventDefault(),o.playBtnState=="play"||o.playBtnState=="replay"?l():o.playBtnState=="pause"&&n()},p=()=>{o.muted=!o.muted,o.volume==0&&(o.volume=.05)},g=(C,O)=>{let P=o.dVideo.duration||o.dVideo.target.duration;o.dVideo.currentTime=P*O,o.playBtnState=="play"&&(o.dVideo.play(),o.playBtnState="pause")},v=(C,O)=>{o.progressCursorTime=nt(o.dVideo.duration*O)},r=vt(2500,()=>{o.isVideoHovering=!1}),i=C=>{o.isVideoHovering=!0,r()},u=C=>{h("mirrorChange",C,o.dVideo)},y=C=>{h("loopChange",C,o.dVideo)},b=C=>{h("lightOffChange",C,o.dVideo)},_=()=>{var C;C=o.dVideo,document.pictureInPictureElement?document.exitPictureInPicture().catch(O=>{console.log(O,"Video failed to leave Picture-in-Picture mode.")}):C.requestPictureInPicture().catch(O=>{console.log(O,"Video failed to enter Picture-in-Picture mode.")})},x=()=>{o.fullScreen=(C=>{let O=document,P=O.webkitIsFullScreen||O.fullscreen;return P?(document.exitFullscreen||O.webkitExitFullScreen).call(O):(C.requestFullscreen||C.webkitRequestFullScreen).call(C),!P})(A.value)};return Xe(()=>R.src,()=>{Et(()=>{o.dVideo.canPlayType(R.type)||o.dVideo.canPlayType("application/vnd.apple.mpegurl")?o.muted=R.autoPlay:it.isSupported()&&(T.detachMedia(),T.attachMedia(o.dVideo),T.on(it.Events.MEDIA_ATTACHED,()=>{T.loadSource(R.src),T.on("hlsManifestParsed",(C,O)=>{console.log(O),o.currentLevel=O.level,o.qualityLevels=O.levels||[]})}),T.on("hlsLevelSwitching",(C,O)=>{console.log(O),console.log("LEVEL_SWITCHING")}),T.on("hlsLevelSwitched",(C,O)=>{o.currentLevel=O.level,console.log("LEVEL_SWITCHED")}))})},{immediate:!0}),mt(()=>{o.dVideo=k,s()}),w({play:l,pause:n,togglePlay:d}),(C,O)=>(Y(),Z("div",{ref:A,id:"refPlayerWrap",class:be(["d-player-wrap",{"web-full-screen":G(o).webFullScreen,"is-lightoff":G(o).lightOff,"d-player-wrap-hover":G(o).playBtnState=="play"||G(o).isVideoHovering}]),onMousemove:i},[K("div",$r,[K("video",Tt({ref:k,class:["d-player-video-main",{"video-mirror":G(o).mirror}],id:"dPlayerVideoMain",controls:!(!G(et)||!G(o).speed),"webkit-playsinline":R.playsinline,playsinline:R.playsinline},G(m),{volume:G(o).volume,muted:G(o).muted,loop:G(o).loop,preload:C.preload,width:"100%",height:"100%",src:R.src,poster:R.poster}),"您的浏览器不支持Video标签。",16,Qr)]),z(at,{name:"d-fade-in"},{default:Q(()=>[pe(K("div",Zr,null,512),[[me,G(o).lightOff]])]),_:1}),G(o).fullScreen?(Y(),fe(br,{key:0,title:R.title},null,8,["title"])):ae("",!0),G(et)?ae("",!0):(Y(),Z("div",Jr,[z(at,{name:"d-scale-out"},{default:Q(()=>[pe(K("div",ei,[z(Le,{icon:"icon-play",size:40})],512),[[me,G(o).playBtnState=="play"]])]),_:1}),z(At,{state:G(o)},null,8,["state"])])),G(et)?ae("",!0):(Y(),Z("input",{key:2,type:"input",readonly:"readonly",ref:D,onDblclick:x,onKeyup:[Je(x,["f"]),O[0]||(O[0]=Je(P=>G(o).webFullScreen=!1,["esc"])),t],onClick:d,onKeydown:[Je(d,["space"]),Je(a,["arrow-left"]),Je(e,["arrow-up","arrow-down"]),t],class:"d-player-input",maxlength:"0"},null,40,ti)),z(kt,{loadType:G(o).loadStateType},null,8,["loadType"]),z(_t),!G(et)&&G(o).control?(Y(),Z("div",{key:3,class:"d-player-control",ref:I},[K("div",ri,[z($e,{class:"d-progress-bar",onOnMousemove:v,onChange:g,disabled:!G(o).speed,hoverText:G(o).progressCursorTime,modelValue:G(o).playProgress,"onUpdate:modelValue":O[1]||(O[1]=P=>G(o).playProgress=P),preload:G(o).preloadBar},null,8,["disabled","hoverText","modelValue","preload"])]),K("div",{class:"d-control-tool",onClick:s},[K("div",ii,[K("div",{class:"d-tool-item",onClick:d},[z(Le,{size:"24",icon:`icon-${G(o).playBtnState}`},null,8,["icon"])]),R.controlBtns.includes("audioTrack")?(Y(),Z("div",ni,[K("span",null,J(G(o).currentTime),1),ai,K("span",si,J(G(o).totalTime),1)])):ae("",!0)]),K("div",oi,[G(o).qualityLevels.length&&R.controlBtns.includes("quality")?(Y(),Z("div",li,[ue(J(G(o).qualityLevels.length&&(G(o).qualityLevels[G(o).currentLevel]||{}).height)+"P ",1),K("div",ui,[K("ul",di,[(Y(!0),Z(Ce,null,Fe(G(o).qualityLevels,(P,F)=>(Y(),Z("li",{class:be({"speed-active":G(o).currentLevel==F}),onClick:M=>((B,U)=>{T.currentLevel=U,o.currentLevel=U})(0,F),key:P},J(P.height)+"P",11,ci))),128))])])])):ae("",!0),R.controlBtns.includes("speedRate")?(Y(),Z("div",hi,[ue(J(G(o).speedActive=="1.0"?"倍速":G(o).speedActive+"x")+" ",1),K("div",fi,[K("ul",gi,[(Y(!0),Z(Ce,null,Fe(G(o).speedRate,P=>(Y(),Z("li",{class:be({"speed-active":G(o).speedActive==P}),onClick:F=>(M=>{o.speedActive=M,o.dVideo.playbackRate=M})(P),key:P},J(P)+"x",11,vi))),128))])])])):ae("",!0),R.controlBtns.includes("volume")?(Y(),Z("div",pi,[K("div",mi,[K("div",{class:be(["volume-main",{"is-muted":G(o).muted}])},[K("span",yi,J(G(o).muted?0:~~(100*G(o).volume))+"%",1),z($e,{onChange:O[2]||(O[2]=P=>G(o).muted=!1),hover:!1,size:"5px",vertical:!0,modelValue:G(o).volume,"onUpdate:modelValue":O[3]||(O[3]=P=>G(o).volume=P)},null,8,["modelValue"])],2)]),K("span",{onClick:p,style:{display:"flex"}},[z(Le,{size:"20",icon:"icon-volume-"+(G(o).volume==0||G(o).muted?"mute":G(o).volume>.5?"up":"down")},null,8,["icon"])])])):ae("",!0),R.controlBtns.includes("setting")?(Y(),Z("div",Ei,[z(Le,{size:"20",class:"rotateHover",icon:"icon-settings"}),K("div",Ti,[K("ul",Si,[K("li",null,[bi,z(rt,{onChange:u,modelValue:G(o).mirror,"onUpdate:modelValue":O[4]||(O[4]=P=>G(o).mirror=P)},null,8,["modelValue"])]),K("li",null,[Li,z(rt,{onChange:y,modelValue:G(o).loop,"onUpdate:modelValue":O[5]||(O[5]=P=>G(o).loop=P)},null,8,["modelValue"])]),K("li",null,[Ai,z(rt,{onChange:b,modelValue:G(o).lightOff,"onUpdate:modelValue":O[6]||(O[6]=P=>G(o).lightOff=P)},null,8,["modelValue"])])])])])):ae("",!0),R.controlBtns.includes("pip")?(Y(),Z("div",{key:4,class:"d-tool-item pip-btn",onClick:_},[z(Le,{size:"20",icon:"icon-pip"}),ki])):ae("",!0),R.controlBtns.includes("pageFullScreen")?(Y(),Z("div",{key:5,class:"d-tool-item pip-btn",onClick:O[7]||(O[7]=P=>G(o).webFullScreen=!G(o).webFullScreen)},[z(Le,{size:"20",icon:"icon-web-screen"}),_i])):ae("",!0),R.controlBtns.includes("fullScreen")?(Y(),Z("div",{key:6,class:"d-tool-item fullScreen-btn",onClick:x},[Di,z(Le,{size:"20",icon:"icon-screen"})])):ae("",!0)])])],512)):ae("",!0)],34))}}));function Ri(N){N.component(tt.name,tt)}tt.__scopeId="data-v-01791e9e",tt.install=Ri;const Ii=xe({__name:"index",setup(N){return(w,h)=>(Y(),fe(G(tt)))}}),Ci={class:"text-right mt-[15px]"},wi=xe({__name:"index",props:{width:{type:String,default:"350px"},value:{type:String,default:""},placeholder:{type:String,default:""},required:{type:Boolean,default:!0},maxlength:{type:Number,default:10}},emits:["confirm"],setup(N,{emit:w}){const h=N,R=ye(h.value),T=ye(!1);Xe(T,()=>{T.value||(R.value="")});const A=()=>{if(!/[\S]+/.test(R.value)){st.error(h.placeholder||"不能为空");return}w("confirm",R.value),T.value=!1};return(k,I)=>{const D=St,o=bt,L=Ot;return Y(),fe(L,{placement:"top",trigger:"click",width:h.width,visible:T.value,"onUpdate:visible":I[2]||(I[2]=m=>T.value=m)},{reference:Q(()=>[xt(k.$slots,"default")]),default:Q(()=>[z(D,{modelValue:R.value,"onUpdate:modelValue":I[0]||(I[0]=m=>R.value=m),placeholder:h.placeholder,clearable:"",class:"mr-[10px]",maxlength:h.maxlength,"show-word-limit":!0},null,8,["modelValue","placeholder","maxlength"]),K("div",Ci,[z(o,{onClick:I[1]||(I[1]=m=>T.value=!1)},{default:Q(()=>[ue(J(G(ee)("cancel")),1)]),_:1}),z(o,{type:"primary",onClick:A},{default:Q(()=>[ue(J(G(ee)("confirm")),1)]),_:1})])]),_:3},8,["width","visible"])}}}),xi={class:"group-wrap w-[180px] p-[15px] h-full border-r border-color flex flex-col"},Oi={class:"group-list flex-1 my-[10px]"},Pi=["onClick"],Fi={key:0,class:"leading-none operate py-[10px]"},Mi={class:"text-center w-full"},Ni={class:"attachment-list-wrap flex flex-col p-[15px] flex-1 overflow-hidden"},Bi={class:"flex"},Ui={key:1},Gi={class:"flex-1 my-[15px] h-0"},ji={key:0,class:"flex flex-wrap"},Ki=["onClick"],Vi=["src"],Hi={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60"},Wi={class:"flex items-center"},Yi={class:"truncate my-[10px] cursor-pointer text-base flex-1 text-center"},qi={class:"text-center w-full"},zi={class:"text-center w-full"},Xi={class:"text-center w-full"},$i={class:"text-center w-full"},Qi={key:1,class:"flex flex-wrap"},Zi={class:"attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center h-[120px]"},Ji=["src"],en={class:"flex items-center"},tn={class:"truncate my-[10px] cursor-pointer text-base flex-1 text-center"},rn={key:2,class:"flex items-center justify-center"},nn={class:"flex items-center"},an={class:"flex h-full justify-end items-center"},sn={class:"dialog-footer"},on=xe({__name:"attachment",props:{limit:{type:Number,default:1},type:{type:String,default:"image"},scene:{type:String,default:"select"}},setup(N,{expose:w}){const h=N,R=ye(!1),T=Se({}),A=Se({data:[]}),k=Se({loading:!0,page:1,total:0,limit:h.scene=="select"?10:20,data:[]});h.scene=="select"?(k.limit=10,h.type=="icon"&&(k.limit=20)):(k.limit=20,h.type=="icon"&&(k.limit=30));const I=Se({name:""}),D=Se({real_name:"",cate_id:0}),o=dt(()=>{(h.type=="icon"?lr:ur)({type:h.type,...I}).then(y=>{A.data=y.data}).catch(()=>{})});o();const L=dt((u=1)=>{const y=h.type=="icon"?dr:cr;k.loading=!0,k.page=u,y({page:k.page,limit:k.limit,att_type:h.type,...D}).then(b=>{if(k.data=b.data.data,k.total=b.data.total,k.loading=!1,h.scene=="attachment"&&a(),h.type!="icon")for(let _=0;_<k.data.length;_++)k.data[_].image_list=[],k.data[_].image_list.push(Ge(b.data.data[_].url))}).catch(()=>{k.loading=!1})});L(),Xe(()=>D.cate_id,()=>{L()});const m=u=>{ir({type:h.type,name:u}).then(y=>{o(1)}).catch(()=>{})},f=(u,y)=>{nr({id:A.data[y].id,name:u}).then(b=>{A.data[y].name=u}).catch(()=>{})},S=u=>{ct.confirm(ee("upload.deleteCategoryTips"),ee("warning"),{confirmButtonText:ee("confirm"),cancelButtonText:ee("cancel"),type:"warning"}).then(()=>{ar(A.data[u].id).then(()=>{A.data.splice(u,1)}).catch(()=>{})})},E=ye(null),c=we(()=>{const u={};return u.token=Pt(),u["site-id"]=Ft.get("siteId")||0,{action:`/adminapi//sys/${h.type}`,multiple:!0,data:{cate_id:D.cate_id},headers:u,onSuccess:(y,b,_)=>{var x;y.code>=1?(L(),(x=E.value)==null||x.handleRemove(b)):(b.status="fail",st({message:y.msg,type:"error"}))}}}),e=ye(!1);Xe(e,()=>{if(e.value){const u=Object.keys(De(T));k.data.forEach(y=>{u.includes(y.att_id)||(T[y.att_id]=De(y))})}else a()});const a=()=>{const u=Object.keys(De(T));u.length&&(u.forEach(y=>{delete T[y]}),e.value=!1)},t=u=>{if(T[u.att_id])delete T[u.att_id];else if(h.scene=="select"){const y=Object.keys(De(T)),b=y.length;if(h.limit==1&&b==h.limit)delete T[y[0]];else if(b>=h.limit){st.info(ee("upload.triggerUpperLimit"));return}T[u.att_id]=De(u)}else T[u.att_id]=De(u)},s=(u=null)=>{const y=u===null?Object.keys(De(T)):[k.data[u].att_id];ct.confirm(ee("upload.deleteAttachmentTips"),ee("warning"),{confirmButtonText:ee("confirm"),cancelButtonText:ee("cancel"),type:"warning"}).then(()=>{sr({att_ids:y}).then(()=>{L()}).catch(()=>{})})},l=Se({cateId:"",loading:!1,visible:!1}),n=(u=null)=>{const y=u===null?Object.keys(De(T)):[k.data[u].att_id];l.visible=!0,l.cateId=A.data[0].id,l.confirm=()=>{l.loading=!0,or({cate_id:l.cateId,att_ids:y}).then(()=>{l.visible=!1,l.loading=!1,L()}).catch(()=>{l.loading=!1})}},d=ye(!0);Xe(T,()=>{d.value=Object.keys(De(T)).length==0});const p=Se({show:!1,index:0}),g=u=>{p.show=!0,p.index=u},v=we(()=>De(k.data).map(u=>Ge(u.url))),r=Se({visible:!1,src:""}),i=u=>{r.visible=!0,r.src=Ge(k.data[u].url)};return w({selectedFile:T}),(u,y)=>{const b=St,_=rr,x=wi,C=Mt,O=Nt,P=Bt,F=Ut,M=bt,B=Gt,U=jt,j=Kt,V=Vt,W=Ht,X=Wt,q=Yt,$=qt,ie=zt,se=Xt,le=$t,re=Qt,de=Zt,te=Jt,ne=Ii,ce=er;return Y(),Z("div",{class:be(["flex border-t border-b main-wrap border-color w-full",N.scene=="select"?"h-[40vh]":"h-full"])},[K("div",xi,[z(b,{modelValue:I.name,"onUpdate:modelValue":y[0]||(y[0]=H=>I.name=H),class:"m-0",placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),clearable:"","prefix-icon":"Search",onInput:y[1]||(y[1]=H=>G(o)())},null,8,["modelValue","placeholder"]),K("div",Oi,[z(F,null,{default:Q(()=>[K("div",{class:be(["group-item p-[10px] leading-none text-xs rounded cursor-pointer",{active:D.cate_id==0}]),onClick:y[2]||(y[2]=H=>D.cate_id=0)},J(G(ee)("selectPlaceholder")),3),(Y(!0),Z(Ce,null,Fe(A.data,(H,oe)=>(Y(),Z("div",{class:be(["group-item px-[10px] text-xs rounded cursor-pointer flex",{active:D.cate_id==H.id}]),key:oe},[K("div",{class:"flex-1 leading-none truncate py-[10px]",onClick:he=>D.cate_id=H.id},J(H.name),9,Pi),N.scene=="attachment"&&h.type!="icon"?(Y(),Z("div",Fi,[N.scene=="attachment"?(Y(),fe(P,{key:0,"hide-on-click":!1},{dropdown:Q(()=>[z(O,null,{default:Q(()=>[z(C,{class:"text-center"},{default:Q(()=>[z(x,{placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),onConfirm:he=>f(he,oe),value:H.name},{default:Q(()=>[K("span",null,J(G(ee)("edit")),1)]),_:2},1032,["placeholder","onConfirm","value"])]),_:2},1024),z(C,{onClick:he=>S(oe)},{default:Q(()=>[K("div",Mi,J(G(ee)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Q(()=>[z(_,{name:"element-MoreFilled",class:"cursor-pointer ml-[10px]",size:"14px"}),ue(" "+J(H.name)+" ",1)]),_:2},1024)):ae("",!0)])):ae("",!0)],2))),128))]),_:1})]),h.type!="icon"?(Y(),fe(x,{key:0,placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),onConfirm:m},{default:Q(()=>[z(M,null,{default:Q(()=>[ue(J(G(ee)("upload.addAttachmentCategory")),1)]),_:1})]),_:1},8,["placeholder"])):ae("",!0)]),K("div",Ni,[z(j,{gutter:15,class:"h-[32px]"},{default:Q(()=>[z(U,{span:10},{default:Q(()=>[K("div",Bi,[h.type!="icon"?(Y(),fe(B,Tt({key:0},G(c),{ref_key:"uploadRef",ref:E}),{default:Q(()=>[z(M,{type:"primary"},{default:Q(()=>[ue(J(G(ee)("upload.upload"+N.type))+" "+J(u.isOpen),1)]),_:1})]),_:1},16)):ae("",!0),N.scene=="attachment"&&h.type!="icon"?(Y(),Z("div",Ui,[R.value===!1?(Y(),fe(M,{key:0,class:"ml-[10px]",type:"primary",onClick:y[3]||(y[3]=H=>R.value=!0)},{default:Q(()=>[ue(J(G(ee)("edit")),1)]),_:1})):(Y(),fe(M,{key:1,class:"ml-[10px]",type:"primary",onClick:y[4]||(y[4]=H=>R.value=!1)},{default:Q(()=>[ue(J(G(ee)("complete")),1)]),_:1}))])):ae("",!0)])]),_:1}),z(U,{span:14,class:"text-right"},{default:Q(()=>[z(b,{modelValue:D.real_name,"onUpdate:modelValue":y[5]||(y[5]=H=>D.real_name=H),class:"m-0 w-[200px]",clearable:"",placeholder:G(ee)("upload.placeholder"+N.type+"Name"),"prefix-icon":"Search",onInput:y[6]||(y[6]=H=>G(L)())},null,8,["modelValue","placeholder"])]),_:1})]),_:1}),pe((Y(),Z("div",Gi,[z(F,null,{default:Q(()=>[k.data.length&&(R.value===!0||N.scene!="attachment")?(Y(),Z("div",ji,[(Y(!0),Z(Ce,null,Fe(k.data,(H,oe)=>(Y(),Z("div",{class:be(["attachment-item mr-[10px]",N.scene=="select"?"w-[100px]":"w-[120px]"]),key:oe},[K("div",{class:be(["attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center",N.scene=="select"?"h-[100px]":"h-[120px]"]),onClick:he=>t(H)},[N.type=="image"?(Y(),fe(V,{key:0,src:G(Ge)(H.url),fit:"contain"},null,8,["src"])):N.type=="video"?(Y(),Z("video",{key:1,src:G(Ge)(H.url)},null,8,Vi)):N.type=="icon"?(Y(),fe(_,{key:2,name:H.url,size:"40px"},null,8,["name"])):ae("",!0),pe(K("div",Hi,[z(_,{name:"element-Select",color:"#fff",size:"40px"})],512),[[me,T[H.att_id]]])],10,Ki),K("div",Wi,[z(W,{placement:"top"},{content:Q(()=>[ue(J(H.real_name),1)]),default:Q(()=>[K("div",Yi,J(H.real_name),1)]),_:2},1024),N.scene=="attachment"?(Y(),fe(P,{key:0,"hide-on-click":!1,class:"attachment-action hidden"},{dropdown:Q(()=>[z(O,null,{default:Q(()=>[H.att_type=="image"?(Y(),fe(C,{key:0,class:"text-center",onClick:he=>g(oe)},{default:Q(()=>[K("div",qi,J(G(ee)("lookOver")),1)]),_:2},1032,["onClick"])):ae("",!0),H.att_type=="video"?(Y(),fe(C,{key:1,class:"text-center",onClick:he=>i(oe)},{default:Q(()=>[K("div",zi,J(G(ee)("lookOver")),1)]),_:2},1032,["onClick"])):ae("",!0),z(C,{class:"text-center",onClick:he=>n(oe)},{default:Q(()=>[K("div",Xi,J(G(ee)("upload.move")),1)]),_:2},1032,["onClick"]),z(C,{onClick:he=>s(oe)},{default:Q(()=>[K("div",$i,J(G(ee)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Q(()=>[z(_,{name:"element-MoreFilled",class:"cursor-pointer ml-[8px]",size:"14px"})]),_:2},1024)):ae("",!0)])],2))),128))])):k.data.length&&R.value===!1?(Y(),Z("div",Qi,[(Y(!0),Z(Ce,null,Fe(k.data,(H,oe)=>(Y(),Z("div",{class:"attachment-item mr-[10px] w-[120px]",key:oe},[K("div",Zi,[N.type=="image"?(Y(),fe(V,{key:0,src:G(Ge)(H.url),fit:"contain","preview-src-list":H.image_list},null,8,["src","preview-src-list"])):N.type=="video"?(Y(),Z("video",{key:1,src:G(Ge)(H.url)},null,8,Ji)):N.type=="icon"?(Y(),fe(_,{key:2,name:H.url,size:"40px"},null,8,["name"])):ae("",!0)]),K("div",en,[z(W,{placement:"top"},{content:Q(()=>[ue(J(H.real_name),1)]),default:Q(()=>[K("div",tn,J(H.real_name),1)]),_:2},1024)])]))),128))])):(Y(),Z("div",rn,[k.loading?ae("",!0):(Y(),fe(X,{key:0,description:N.type=="icon"?G(ee)("upload.iconEmpty"):G(ee)("upload.attachmentEmpty"),"image-size":100},null,8,["description"]))]))]),_:1})])),[[ce,k.loading]]),z(j,{gutter:20},{default:Q(()=>[N.scene=="attachment"&&R.value===!0?(Y(),fe(U,{key:0,span:8},{default:Q(()=>[K("div",nn,[z(q,{modelValue:e.value,"onUpdate:modelValue":y[7]||(y[7]=H=>e.value=H),label:G(ee)("selectAll"),size:"large"},null,8,["modelValue","label"]),z(M,{class:"ml-[15px]",disabled:d.value,onClick:y[8]||(y[8]=H=>s())},{default:Q(()=>[ue(J(G(ee)("delete")),1)]),_:1},8,["disabled"]),z(M,{disabled:d.value,onClick:y[9]||(y[9]=H=>n())},{default:Q(()=>[ue(J(G(ee)("upload.move")),1)]),_:1},8,["disabled"])])]),_:1})):ae("",!0),z(U,{span:N.scene=="attachment"?16:24},{default:Q(()=>[K("div",an,[z($,{"current-page":k.page,"onUpdate:current-page":y[10]||(y[10]=H=>k.page=H),small:!0,"page-size":k.limit,"onUpdate:page-size":y[11]||(y[11]=H=>k.limit=H),"page-sizes":[10,20,30,40,60],layout:"total, sizes, prev, pager, next, jumper",total:k.total,onSizeChange:y[12]||(y[12]=H=>G(L)()),onCurrentChange:G(L)},null,8,["current-page","page-size","total","onCurrentChange"])])]),_:1},8,["span"])]),_:1})]),N.scene=="attachment"?(Y(),Z(Ce,{key:0},[z(de,{modelValue:l.visible,"onUpdate:modelValue":y[16]||(y[16]=H=>l.visible=H),title:G(ee)("upload.moveCategory"),width:"350px"},{footer:Q(()=>[K("span",sn,[z(M,{onClick:y[14]||(y[14]=H=>l.visible=!1)},{default:Q(()=>[ue(J(G(ee)("cancel")),1)]),_:1}),z(M,{type:"primary",loading:l.loading,onClick:y[15]||(y[15]=H=>l.confirm())},{default:Q(()=>[ue(J(G(ee)("confirm")),1)]),_:1},8,["loading"])])]),default:Q(()=>[z(re,{"label-width":"60px"},{default:Q(()=>[z(le,{label:G(ee)("upload.moveTo"),style:{"margin-bottom":"0"}},{default:Q(()=>[z(se,{modelValue:l.cateId,"onUpdate:modelValue":y[13]||(y[13]=H=>l.cateId=H),class:"input-width"},{default:Q(()=>[(Y(!0),Z(Ce,null,Fe(A.data,(H,oe)=>(Y(),fe(ie,{label:H.name,value:H.id,key:oe},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"]),p.show?(Y(),fe(te,{key:0,"url-list":G(v),onClose:y[17]||(y[17]=H=>p.show=!1),"initial-index":p.index,"zoom-rate":1},null,8,["url-list","initial-index"])):ae("",!0),z(de,{modelValue:r.visible,"onUpdate:modelValue":y[18]||(y[18]=H=>r.visible=H),width:"50%","align-center":"","destroy-on-close":!0,"custom-class":"video-preview"},{default:Q(()=>[z(ne,{src:r.src,width:"100%"},null,8,["src"])]),_:1},8,["modelValue"])],64)):ae("",!0)],2)}}});const xn=tr(on,[["__scopeId","data-v-2fad8e3c"]]);export{Ii as _,xn as a};
|