mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2026-01-22 18:48:10 +00:00
23 lines
372 KiB
JavaScript
23 lines
372 KiB
JavaScript
import{q as Re,h as Y,c as Z,A as Le,x as je,u as G,p as Ve,g as He,i as he,d as xe,y as me,z as Te,a as K,e as z,t as J,r as Ee,B as ae,n as Se,s as et,v as mt,o as yt,w as Q,F as we,G as Fe,T as at,ct as ut,D as Et,a5 as It,cr as Ct,bT as Tt,I as ge,S as Ze,C as wt,b as xt,bN as Ot,N as ee,a2 as st,Z as St,E as bt,ab as Pt,cK as Ft,W as Mt,aF as De,R as Ge,aG as dt,cL as Nt,cM as Bt,aa as ct,cN as Ut,cO as Gt,cP as jt,cQ as Kt,cR as Vt,cS as Ht,as as Wt,cT as Yt,aq as qt,ar as zt,Y as Xt,al as $t,ag as Qt,aM as Zt,a3 as Jt,av as er,aT as tr,_ as rr,$ as ir,ad as nr,cU as ar,a4 as sr,cV as or,cW as lr,cX as ur,cY as dr}from"./index-d1ed2ead.js";/* empty css *//* empty css *//* empty css *//* empty css *//* 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 cr}from"./index.vue_vue_type_script_setup_true_lang-723f0499.js";import{_ as hr}from"./_plugin-vue_export-helper-c27b6911.js";var fr=Object.defineProperty,gr=Object.defineProperties,vr=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,pr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,ft=(N,x,h)=>x in N?fr(N,x,{enumerable:!0,configurable:!0,writable:!0,value:h}):N[x]=h,ot=(N,x)=>{for(var h in x||(x={}))pr.call(x,h)&&ft(N,h,x[h]);if(ht)for(var h of ht(x))mr.call(x,h)&&ft(N,h,x[h]);return N},lt=(N,x)=>gr(N,vr(x));function gt(N,x,h,R){var T,A=!1,D=0;function C(){T&&clearTimeout(T)}function _(){for(var o=arguments.length,L=new Array(o),m=0;m<o;m++)L[m]=arguments[m];var f=this,E=Date.now()-D;function y(){D=Date.now(),h.apply(f,L)}function d(){T=void 0}A||(R&&!T&&y(),C(),R===void 0&&E>N?y():x!==!0&&(T=setTimeout(R?d:y,R===void 0?N-E:N)))}return typeof x!="boolean"&&(R=h,h=x,x=void 0),_.cancel=function(){C(),A=!0},_}function vt(N,x,h){return h===void 0?gt(N,x,!1):gt(N,h,x!==!1)}function yr(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 x={};function h(R){if(x[R])return x[R].exports;var T=x[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=x,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 D in R)h.d(A,D,function(C){return R[C]}.bind(null,D));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,x,h){var R=Object.prototype.hasOwnProperty,T="~";function A(){}function D(L,m,f){this.fn=L,this.context=m,this.once=f||!1}function C(L,m,f,E,y){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new D(f,E||L,y),e=T?T+m:m;return L._events[e]?L._events[e].fn?L._events[e]=[L._events[e],d]:L._events[e].push(d):(L._events[e]=d,L._eventsCount++),L}function _(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 E=0,y=f.length,d=new Array(y);E<y;E++)d[E]=f[E].fn;return d},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,E,y,d){var e=T?T+L:L;if(!this._events[e])return!1;var a,t,s=this._events[e],u=arguments.length;if(s.fn){switch(s.once&&this.removeListener(L,s.fn,void 0,!0),u){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,E),!0;case 5:return s.fn.call(s.context,m,f,E,y),!0;case 6:return s.fn.call(s.context,m,f,E,y,d),!0}for(t=1,a=new Array(u-1);t<u;t++)a[t-1]=arguments[t];s.fn.apply(s.context,a)}else{var n,l=s.length;for(t=0;t<l;t++)switch(s[t].once&&this.removeListener(L,s[t].fn,void 0,!0),u){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,E);break;default:if(!a)for(n=1,a=new Array(u-1);n<u;n++)a[n-1]=arguments[n];s[t].fn.apply(s[t].context,a)}}return!0},o.prototype.on=function(L,m,f){return C(this,L,m,f,!1)},o.prototype.once=function(L,m,f){return C(this,L,m,f,!0)},o.prototype.removeListener=function(L,m,f,E){var y=T?T+L:L;if(!this._events[y])return this;if(!m)return _(this,y),this;var d=this._events[y];if(d.fn)d.fn!==m||E&&!d.once||f&&d.context!==f||_(this,y);else{for(var e=0,a=[],t=d.length;e<t;e++)(d[e].fn!==m||E&&!d[e].once||f&&d[e].context!==f)&&a.push(d[e]);a.length?this._events[y]=a.length===1?a[0]:a:_(this,y)}return this},o.prototype.removeAllListeners=function(L){var m;return L?(m=T?T+L:L,this._events[m]&&_(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,x,h){var R,T,A,D,C;R=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,T=/^([^\/?#]*)([^]*)$/,A=/(?:\/|^)\.(?=\/)/g,D=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,C={buildAbsoluteURL:function(_,o,L){if(L=L||{},_=_.trim(),!(o=o.trim())){if(!L.alwaysNormalize)return _;var m=C.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");return m.path=C.normalizePath(m.path),C.buildURLFromParts(m)}var f=C.parseURL(o);if(!f)throw new Error("Error trying to parse relative URL.");if(f.scheme)return L.alwaysNormalize?(f.path=C.normalizePath(f.path),C.buildURLFromParts(f)):o;var E=C.parseURL(_);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var y=T.exec(E.path);E.netLoc=y[1],E.path=y[2]}E.netLoc&&!E.path&&(E.path="/");var d={scheme:E.scheme,netLoc:f.netLoc,path:null,params:f.params,query:f.query,fragment:f.fragment};if(!f.netLoc&&(d.netLoc=E.netLoc,f.path[0]!=="/"))if(f.path){var e=E.path,a=e.substring(0,e.lastIndexOf("/")+1)+f.path;d.path=C.normalizePath(a)}else d.path=E.path,f.params||(d.params=E.params,f.query||(d.query=E.query));return d.path===null&&(d.path=L.alwaysNormalize?C.normalizePath(f.path):f.path),C.buildURLFromParts(d)},parseURL:function(_){var o=R.exec(_);return o?{scheme:o[1]||"",netLoc:o[2]||"",path:o[3]||"",params:o[4]||"",query:o[5]||"",fragment:o[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(A,"");_.length!==(_=_.replace(D,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}},N.exports=C},"./node_modules/webworkify-webpack/index.js":function(N,x,h){function R(o){var L={};function m(E){if(L[E])return L[E].exports;var y=L[E]={i:E,l:!1,exports:{}};return o[E].call(y.exports,y,y.exports,m),y.l=!0,y.exports}m.m=o,m.c=L,m.i=function(E){return E},m.d=function(E,y,d){m.o(E,y)||Object.defineProperty(E,y,{configurable:!1,enumerable:!0,get:d})},m.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},m.n=function(E){var y=E&&E.__esModule?function(){return E.default}:function(){return E};return m.d(y,"a",y),y},m.o=function(E,y){return Object.prototype.hasOwnProperty.call(E,y)},m.p="/",m.oe=function(E){throw console.error(E),E};var f=m(m.s=ENTRY_MODULE);return f.default||f}var T="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function D(o){return(o+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function C(o,L,m){var f={};f[m]=[];var E=L.toString(),y=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!y)return f;for(var d,e=y[1],a=new RegExp("(\\\\n|\\W)"+D(e)+A,"g");d=a.exec(E);)d[3]!=="dll-reference"&&f[m].push(d[3]);for(a=new RegExp("\\("+D(e)+'\\("(dll-reference\\s('+T+'))"\\)\\)'+A,"g");d=a.exec(E);)o[d[2]]||(f[m].push(d[1]),o[d[2]]=h(d[1]).m),f[d[2]]=f[d[2]]||[],f[d[2]].push(d[4]);for(var t,s=Object.keys(f),u=0;u<s.length;u++)for(var n=0;n<f[s[u]].length;n++)t=f[s[u]][n],isNaN(1*t)||(f[s[u]][n]=1*f[s[u]][n]);return f}function _(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]},u={main:[]},n={main:{}};_(s);)for(var l=Object.keys(s),v=0;v<l.length;v++){var g=l[v],p=s[g].pop();if(n[g]=n[g]||{},!n[g][p]&&a[g][p]){n[g][p]=!0,u[g]=u[g]||[],u[g].push(p);for(var r=C(a,a[g][p],g),i=Object.keys(r),c=0;c<i.length;c++)s[i[c]]=s[i[c]]||[],s[i[c]]=s[i[c]].concat(r[i[c]])}}return u}(m,o),E="";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__; })",E=E+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+f[a].map(function(s){return JSON.stringify(s)+": "+m[a][s].toString()}).join(",")+`});
|
||
`}),E=E+"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 y=new window.Blob([E],{type:"text/javascript"});if(L.bare)return y;var d=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(y),e=new window.Worker(d);return e.objectURL=d,e}},"./src/config.ts":function(N,x,h){h.r(x),h.d(x,"hlsDefaultConfig",function(){return l}),h.d(x,"mergeConfig",function(){return v}),h.d(x,"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"),D=h("./src/controller/subtitle-stream-controller.ts"),C=h("./src/controller/subtitle-track-controller.ts"),_=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"),E=h("./src/utils/xhr-loader.ts"),y=h("./src/utils/fetch-loader.ts"),d=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(p){for(var r=1;r<arguments.length;r++){var i=arguments[r];for(var c in i)Object.prototype.hasOwnProperty.call(i,c)&&(p[c]=i[c])}return p}).apply(this,arguments)}function s(p,r){var i=Object.keys(p);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(p);r&&(c=c.filter(function(S){return Object.getOwnPropertyDescriptor(p,S).enumerable})),i.push.apply(i,c)}return i}function u(p){for(var r=1;r<arguments.length;r++){var i=arguments[r]!=null?arguments[r]:{};r%2?s(Object(i),!0).forEach(function(c){n(p,c,i[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach(function(c){Object.defineProperty(p,c,Object.getOwnPropertyDescriptor(i,c))})}return p}function n(p,r,i){return r in p?Object.defineProperty(p,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):p[r]=i,p}var l=u(u({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:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:_.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:d.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:D.SubtitleStreamController,subtitleTrackController:C.default,timelineController:o.TimelineController,audioStreamController:T.default,audioTrackController:A.default,emeController:f.default});function v(p,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({},p,r)}function g(p){var r=p.loader;r!==y.default&&r!==E.default?(a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),p.progressive=!1):Object(y.fetchSupported)()&&(p.loader=y.default,p.progressive=!0,p.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":function(N,x,h){h.r(x);var R=h("./src/polyfills/number.ts"),T=h("./src/utils/ewma-bandwidth-estimator.ts"),A=h("./src/events.ts"),D=h("./src/utils/buffer-helper.ts"),C=h("./src/errors.ts"),_=h("./src/types/loader.ts"),o=h("./src/utils/logger.ts");function L(f,E){for(var y=0;y<E.length;y++){var d=E[y];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,d.key,d)}}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 E,y,d=f.prototype;return d.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)},d.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)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(e,a){var t,s=a.frag;s.type===_.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=s,this.partCurrent=(t=a.part)!=null?t:null,this.timer=self.setInterval(this.onCheck,100)))},d.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)},d._abandonRulesCheck=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.autoLevelEnabled,u=t.config,n=t.media;if(e&&n){var l=a?a.stats:e.stats,v=a?a.duration:e.duration;if(l.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()-l.loading.start,p=Math.abs(n.playbackRate);if(!(g<=500*v/p)){var r=t.levels,i=t.minAutoLevel,c=r[e.level],S=l.total||Math.max(l.loaded,Math.round(v*c.maxBitrate/8)),b=Math.max(1,l.bwEstimate?l.bwEstimate/8:1e3*l.loaded/g),k=(S-l.loaded)/b,I=n.currentTime,w=(D.BufferHelper.bufferInfo(n,I,u.maxBufferHole).end-I)/p;if(!(w>=2*v/p||k<=w)){var O,P=Number.POSITIVE_INFINITY;for(O=e.level-1;O>i&&!((P=v*r[O].maxBitrate/(6.4*b))<w);O--);if(!(P>=k)){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: `+k.toFixed(3)+` s
|
||
Estimated load time for the next fragment: `+P.toFixed(3)+` s
|
||
Time to underbuffer: `+w.toFixed(3)+" s"),t.nextLoadLevel=O,this.bwEstimator.sample(g,l.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:l})}}}}}},d.onFragLoaded=function(e,a){var t=a.frag,s=a.part;if(t.type===_.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(t.sn)){var u=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 l=this.hls.levels[t.level],v=(l.loaded?l.loaded.bytes:0)+u.loaded,g=(l.loaded?l.loaded.duration:0)+n;l.loaded={bytes:v,duration:g},l.realBitrate=Math.round(8*v/g)}if(t.bitrateTest){var p={stats:u,frag:t,part:s,id:t.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,p),t.bitrateTest=!1}}},d.onFragBuffered=function(e,a){var t=a.frag,s=a.part,u=s?s.stats:t.stats;if(!u.aborted&&t.type===_.PlaylistLevelType.MAIN&&t.sn!=="initSegment"){var n=u.parsing.end-u.loading.start;this.bwEstimator.sample(n,u.loaded),u.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},d.onError=function(e,a){switch(a.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.maxAutoLevel,u=t.config,n=t.minAutoLevel,l=t.media,v=a?a.duration:e?e.duration:0,g=l?l.currentTime:0,p=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():u.abrEwmaDefaultEstimate,i=(D.BufferHelper.bufferInfo(l,g,u.maxBufferHole).end-g)/p,c=this.findBestLevel(r,n,s,i,u.abrBandWidthFactor,u.abrBandWidthUpFactor);if(c>=0)return c;o.logger.trace((i?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=v?Math.min(v,u.maxStarvationDelay):u.maxStarvationDelay,b=u.abrBandWidthFactor,k=u.abrBandWidthUpFactor;if(!i){var I=this.bitrateTestDelay;I&&(S=(v?Math.min(v,u.maxLoadingDelay):u.maxLoadingDelay)-I,o.logger.trace("bitrate test took "+Math.round(1e3*I)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),b=k=1)}return c=this.findBestLevel(r,n,s,i+S,b,k),Math.max(c,0)},d.findBestLevel=function(e,a,t,s,u,n){for(var l,v=this.fragCurrent,g=this.partCurrent,p=this.lastLoadedFragLevel,r=this.hls.levels,i=r[p],c=!(i==null||(l=i.details)===null||l===void 0||!l.live),S=i==null?void 0:i.codecSet,b=g?g.duration:v?v.duration:0,k=t;k>=a;k--){var I=r[k];if(I&&(!S||I.codecSet===S)){var w=I.details,O=(g?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||b,P=void 0;P=k<=p?u*e:n*e;var F=r[k].maxBitrate,M=F*O/P;if(o.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+k+"/"+Math.round(P)+"/"+F+"/"+O+"/"+s+"/"+M),P>F&&(!M||c&&!this.bitrateTestDelay||M<s))return k}}return-1},E=f,(y=[{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(E.prototype,y),f}();x.default=m},"./src/controller/audio-stream-controller.ts":function(N,x,h){h.r(x);var R=h("./src/polyfills/number.ts"),T=h("./src/controller/base-stream-controller.ts"),A=h("./src/events.ts"),D=h("./src/utils/buffer-helper.ts"),C=h("./src/controller/fragment-tracker.ts"),_=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"),E=h("./src/types/transmuxer.ts"),y=h("./src/controller/fragment-finders.ts"),d=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 l=1;l<arguments.length;l++){var v=arguments[l];for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(n[g]=v[g])}return n}).apply(this,arguments)}function s(n,l){return(s=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v})(n,l)}var u=function(n){var l,v;function g(r,i){var c;return(c=n.call(this,r,i,"[audio-stream-controller]")||this).videoBuffer=null,c.videoTrackCC=-1,c.waitingVideoCC=-1,c.audioSwitch=!1,c.trackId=-1,c.waitingData=null,c.mainDetails=null,c.bufferFlushed=!1,c._registerListeners(),c}v=n,(l=g).prototype=Object.create(v.prototype),l.prototype.constructor=l,s(l,v);var p=g.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._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)},p._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)},p.onInitPtsFound=function(r,i){var c=i.frag,S=i.id,b=i.initPTS;if(S==="main"){var k=c.cc;this.initPTS[c.cc]=b,this.log("InitPTS for cc: "+k+" found from main: "+b),this.videoTrackCC=k,this.state===T.State.WAITING_INIT_PTS&&this.tick()}},p.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()},p.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_TRACK:var r,i=this.levels,c=this.trackId,S=i==null||(r=i[c])===null||r===void 0?void 0:r.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=T.State.WAITING_INIT_PTS}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,k=performance.now(),I=this.retryDate;(!I||k>=I||(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 w=this.waitingData;if(w){var O=w.frag,P=w.part,F=w.cache,M=w.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=D.BufferHelper.bufferInfo(this.mediaBuffer,U,this.config.maxBufferHole);Object(y.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()},p.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=T.State.IDLE)},p.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}},p.doTickIdle=function(){var r,i,c=this.hls,S=this.levels,b=this.media,k=this.trackId,I=c.config;if(S&&S[k]&&(b||!this.startFragRequested&&I.startFragPrefetch)){var w=S[k].details;if(!w||w.live&&this.levelLastLoaded!==k||this.waitForCdnTuneIn(w))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,w))return c.trigger(A.Events.BUFFER_EOS,{type:"audio"}),void(this.state=T.State.ENDED);var B=w.fragments[0].start,U=O.end;if(M){var j=this.getLoadPosition();U=j,w.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,w);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,w,U):this.loadKey(V,w):this.bufferFlushed=!0}}}}},p.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)},p.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},p.onAudioTracksUpdated=function(r,i){var c=i.audioTracks;this.resetTransmuxer(),this.levels=c.map(function(S){return new _.Level(S)})},p.onAudioTrackSwitching=function(r,i){var c=!!i.url;this.trackId=i.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),c?this.setInterval(100):this.resetTransmuxer(),c?(this.audioSwitch=!0,this.state=T.State.IDLE):this.state=T.State.STOPPED,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},p.onLevelLoaded=function(r,i){this.mainDetails=i.details},p.onAudioTrackLoaded=function(r,i){var c,S=this.levels,b=i.details,k=i.id;if(S){this.log("Track "+k+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var I=S[k],w=0;if(b.live||(c=I.details)!==null&&c!==void 0&&c.live){var O=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!O)return;!I.details&&b.hasProgramDateTime&&O.hasProgramDateTime?(Object(d.alignPDT)(b,O),w=b.fragments[0].start):w=this.alignPlaylists(b,I.details)}I.details=b,this.levelLastLoaded=k,this.startFragRequested||!this.mainDetails&&b.live||this.setStartPosition(I.details,w),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 "+k)},p._handleFragmentLoadProgress=function(r){var i,c=r.frag,S=r.part,b=r.payload,k=this.config,I=this.trackId,w=this.levels;if(w){var O=w[I];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=k.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[c.cc],U=(i=c.initSegment)===null||i===void 0?void 0:i.data;if(B!==void 0){var j=S?S.index:-1,V=j!==-1,H=new E.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,b.byteLength,j,V);M.push(b,U,F,"",c,S,P.totalduration,!1,H,B)}else a.logger.log("Unknown video PTS for cc "+c.cc+", waiting for video PTS before demuxing audio frag "+c.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+I),(this.waitingData=this.waitingData||{frag:c,part:S,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 "+c.sn+" of level "+c.level+" will not be buffered")},p._handleFragmentLoadComplete=function(r){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,r)},p.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},p.onBufferCreated=function(r,i){var c=i.tracks.audio;c&&(this.mediaBuffer=c.buffer),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer)},p.onFragBuffered=function(r,i){var c=i.frag,S=i.part;c.type===o.PlaylistLevelType.AUDIO&&(this.fragContextChanged(c)?this.warn("Fragment "+c.sn+(S?" p: "+S.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(c.sn!=="initSegment"&&(this.fragPrevious=c,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(c,S)))},p.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 c=!0,S=this.getFwdBufferInfo(this.mediaBuffer,o.PlaylistLevelType.AUDIO);S&&S.len>.5&&(c=!this.reduceMaxBufferLength(S.len)),c&&(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()}}},p.onBufferFlushed=function(r,i){i.type===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},p._handleTransmuxComplete=function(r){var i,c="audio",S=this.hls,b=r.remuxResult,k=r.chunkMeta,I=this.getCurrentContext(k);if(!I)return this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(k.level);var w=I.frag,O=I.part,P=b.audio,F=b.text,M=b.id3,B=b.initSegment;if(!this.fragContextChanged(w)){if(this.state=T.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),B!=null&&B.tracks&&(this._bufferInitSegment(B.tracks,w,k),S.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:c,tracks:B.tracks})),P){var U=P.startPTS,j=P.endPTS,V=P.startDTS,H=P.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:U,endPTS:j,startDTS:V,endDTS:H}),w.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,U,j,V,H),this.bufferFragmentData(P,w,O,k)}if(M!=null&&(i=M.samples)!==null&&i!==void 0&&i.length){var X=t({frag:w,id:c},M);S.trigger(A.Events.FRAG_PARSING_METADATA,X)}if(F){var q=t({frag:w,id:c},F);S.trigger(A.Events.FRAG_PARSING_USERDATA,q)}}},p._bufferInitSegment=function(r,i,c){if(this.state===T.State.PARSING){r.video&&delete r.video;var S=r.audio;if(S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,r);var b=S.initSegment;if(b!=null&&b.byteLength){var k={type:"audio",frag:i,part:null,chunkMeta:c,parent:i.type,data:b};this.hls.trigger(A.Events.BUFFER_APPENDING,k)}this.tick()}}},p.loadFragment=function(r,i,c){var S=this.fragmentTracker.getState(r);this.fragCurrent=r,(this.audioSwitch||S===C.FragmentState.NOT_LOADED||S===C.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,c)))},p.completeAudioSwitch=function(){var r=this.hls,i=this.media,c=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:c})},g}(T.default);x.default=u},"./src/controller/audio-track-controller.ts":function(N,x,h){h.r(x);var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/controller/base-playlist-controller.ts"),D=h("./src/types/loader.ts");function C(L,m){for(var f=0;f<m.length;f++){var E=m[f];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(L,E.key,E)}}function _(L,m){return(_=Object.setPrototypeOf||function(f,E){return f.__proto__=E,f})(L,m)}var o=function(L){var m,f;function E(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=E).prototype=Object.create(f.prototype),m.prototype.constructor=m,_(m,f);var y,d,e=E.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,u=t.details,n=this.tracksInGroup[s];if(n){var l=n.details;n.details=t.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,t,l))}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 u=this.tracks.filter(function(l){return!s||l.groupId===s});this.selectDefaultTrack&&!u.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var n={audioTracks:u};this.log("Updating audio tracks, "+u.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===D.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 u=t[a],n=u.id,l=u.groupId,v=l===void 0?"":l,g=u.name,p=u.type,r=u.url;if(this.trackId=a,this.trackName=g,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:v,name:g,type:p,url:r}),!u.details||u.details.live){var i=this.switchParams(u.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 u=t[s];if((!this.selectDefaultTrack||u.default)&&(!a||a===u.name))return u.id}return-1},e.loadPlaylist=function(a){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var s=t.id,u=t.groupId,n=t.url;if(a)try{n=a.addDirectives(n)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:u,deliveryDirectives:a||null})}},y=E,(d=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}])&&C(y.prototype,d),E}(A.default);x.default=o},"./src/controller/base-playlist-controller.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return _});var R=h("./src/polyfills/number.ts"),T=h("./src/types/level.ts"),A=h("./src/controller/level-helper.ts"),D=h("./src/utils/logger.ts"),C=h("./src/errors.ts"),_=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=D.logger.log.bind(D.logger,f+":"),this.warn=D.logger.warn.bind(D.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===C.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 E=f==null?void 0:f.renditionReports;if(E)for(var y=0;y<E.length;y++){var d=E[y],e=""+d.URI;if(e===m.substr(-e.length)){var a=parseInt(d["LAST-MSN"]),t=parseInt(d["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,E){var y=this,d=f.details,e=f.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(d.advancedDateTime=Date.now()-a,d.live||E!=null&&E.live){if(d.reloaded(E),E&&this.log("live playlist "+m+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),E&&d.fragments.length>0&&Object(A.mergeDetails)(E,d),!this.canLoad||!d.live)return;var t,s=void 0,u=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var n=this.hls.config.lowLatencyMode,l=d.lastPartSn,v=d.endSN,g=d.lastPartIndex,p=l===v;g!==-1?(s=p?v+1:l,u=p?n?0:g:g+1):s=v+1;var r=d.age,i=r+d.ageHeader,c=Math.min(i-d.partTarget,1.5*d.targetduration);if(c>0){if(E&&c>E.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+E.tuneInGoal+" to: "+c+" with playlist age: "+d.age),c=0;else{var S=Math.floor(c/d.targetduration);s+=S,u!==void 0&&(u+=Math.round(c%d.targetduration/d.partTarget)),this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+r.toFixed(2)+"s goal: "+c+" skip sn "+S+" to part "+u)}d.tuneInGoal=c}if(t=this.getDeliveryDirectives(d,f.deliveryDirectives,s,u),n||!p)return void this.loadPlaylist(t)}else t=this.getDeliveryDirectives(d,f.deliveryDirectives,s,u);var b=Object(A.computeReloadInterval)(d,e);s!==void 0&&d.canBlockReload&&(b-=d.partTarget||1),this.log("reload live playlist "+m+" in "+Math.round(b)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(t)},b)}else this.clearTimer()},L.getDeliveryDirectives=function(m,f,E,y){var d=Object(T.getSkipValue)(m,E);return f!=null&&f.skip&&m.deltaUpdateFailed&&(E=f.msn,y=f.part,d=T.HlsSkip.No),new T.HlsUrlParameters(E,y,d)},L.retryLoadingOrFail=function(m){var f,E=this,y=this.hls.config,d=this.retryCount<y.levelLoadingMaxRetry;if(d)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)*y.levelLoadingRetryDelay,y.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.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 d},o}()},"./src/controller/base-stream-controller.ts":function(N,x,h){h.r(x),h.d(x,"State",function(){return n}),h.d(x,"default",function(){return l});var R=h("./src/polyfills/number.ts"),T=h("./src/task-loop.ts"),A=h("./src/controller/fragment-tracker.ts"),D=h("./src/utils/buffer-helper.ts"),C=h("./src/utils/logger.ts"),_=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"),E=h("./src/controller/fragment-finders.ts"),y=h("./src/controller/level-helper.ts"),d=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(v,g){for(var p=0;p<g.length;p++){var r=g[p];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(v,r.key,r)}}function u(v,g){return(u=Object.setPrototypeOf||function(p,r){return p.__proto__=r,p})(v,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"},l=function(v){var g,p;function r(b,k,I){var w;return(w=v.call(this)||this).hls=void 0,w.fragPrevious=null,w.fragCurrent=null,w.fragmentTracker=void 0,w.transmuxer=null,w._state=n.STOPPED,w.media=void 0,w.mediaBuffer=void 0,w.config=void 0,w.bitrateTest=!1,w.lastCurrentTime=0,w.nextLoadPosition=0,w.startPosition=0,w.loadedmetadata=!1,w.fragLoadError=0,w.retryDate=0,w.levels=null,w.fragmentLoader=void 0,w.levelLastLoaded=null,w.startFragRequested=!1,w.decrypter=void 0,w.initPTS=[],w.onvseeking=null,w.onvended=null,w.logPrefix="",w.log=void 0,w.warn=void 0,w.logPrefix=I,w.log=C.logger.log.bind(C.logger,I+":"),w.warn=C.logger.warn.bind(C.logger,I+":"),w.hls=b,w.fragmentLoader=new d.default(b.config),w.fragmentTracker=k,w.config=b.config,w.decrypter=new e.default(b,b.config),b.on(_.Events.KEY_LOADED,w.onKeyLoaded,function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(w)),w}p=v,(g=r).prototype=Object.create(p.prototype),g.prototype.constructor=g,u(g,p);var i,c,S=r.prototype;return S.doTick=function(){this.onTickEnd()},S.onTickEnd=function(){},S.startLoad=function(b){},S.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},S._streamEnded=function(b,k){var I=this.fragCurrent,w=this.fragmentTracker;if(!k.live&&I&&I.sn===k.endSN&&!b.nextStart){var O=w.getState(I);return O===A.FragmentState.PARTIAL||O===A.FragmentState.OK}return!1},S.onMediaAttached=function(b,k){var I=this.media=this.mediaBuffer=k.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),I.addEventListener("seeking",this.onvseeking),I.addEventListener("ended",this.onvended);var w=this.config;this.levels&&w.autoStartLoad&&this.state===n.STOPPED&&this.startLoad(w.startPosition)},S.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()},S.onMediaSeeking=function(){var b=this.config,k=this.fragCurrent,I=this.media,w=this.mediaBuffer,O=this.state,P=I?I.currentTime:0,F=D.BufferHelper.bufferInfo(w||I,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(k&&!F.len){var M=b.maxFragLookUpTolerance,B=k.start-M,U=P>k.start+k.duration+M;(P<B||U)&&(U&&k.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),k.loader.abort()),this.resetLoadingState())}I&&(this.lastCurrentTime=P),this.loadedmetadata||F.len||(this.nextLoadPosition=this.startPosition=P),this.tickImmediate()},S.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},S.onKeyLoaded=function(b,k){if(this.state===n.KEY_LOADING&&k.frag===this.fragCurrent&&this.levels){this.state=n.IDLE;var I=this.levels[k.frag.level].details;I&&this.loadFragment(k.frag,I,k.frag.start)}},S.onHandlerDestroying=function(){this.stopLoad(),v.prototype.onHandlerDestroying.call(this)},S.onHandlerDestroyed=function(){this.state=n.STOPPED,this.hls.off(_.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,v.prototype.onHandlerDestroyed.call(this)},S.loadKey=function(b,k){this.log("Loading key for "+b.sn+" of ["+k.startSN+"-"+k.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level),this.state=n.KEY_LOADING,this.fragCurrent=b,this.hls.trigger(_.Events.KEY_LOADING,{frag:b})},S.loadFragment=function(b,k,I){this._loadFragForPlayback(b,k,I)},S._loadFragForPlayback=function(b,k,I){var w=this;this._doFragLoad(b,k,I,function(O){if(w.fragContextChanged(b))return w.warn("Fragment "+b.sn+(O.part?" p: "+O.part.index:"")+" of level "+b.level+" was dropped during download."),void w.fragmentTracker.removeFragment(b);b.stats.chunkCount++,w._handleFragmentLoadProgress(O)}).then(function(O){if(O){w.fragLoadError=0;var P=w.state;if(!w.fragContextChanged(b))return"payload"in O&&(w.log("Loaded fragment "+b.sn+" of level "+b.level),w.hls.trigger(_.Events.FRAG_LOADED,O),w.state===n.BACKTRACKING)?(w.fragmentTracker.backtrack(b,O),void w.resetFragmentLoading(b)):void w._handleFragmentLoadComplete(O);(P===n.FRAG_LOADING||P===n.BACKTRACKING||!w.fragCurrent&&P===n.PARSING)&&(w.fragmentTracker.removeFragment(b),w.state=n.IDLE)}}).catch(function(O){w.warn(O),w.resetFragmentLoading(b)})},S.flushMainBuffer=function(b,k,I){if(I===void 0&&(I=null),b-k){var w={startOffset:b,endOffset:k,type:I};this.fragLoadError=0,this.hls.trigger(_.Events.BUFFER_FLUSHING,w)}},S._loadInitSegment=function(b){var k=this;this._doFragLoad(b).then(function(I){if(!I||k.fragContextChanged(b)||!k.levels)throw new Error("init load aborted");return I}).then(function(I){var w=k.hls,O=I.payload,P=b.decryptdata;if(O&&O.byteLength>0&&P&&P.key&&P.iv&&P.method==="AES-128"){var F=self.performance.now();return k.decrypter.webCryptoDecrypt(new Uint8Array(O),P.key.buffer,P.iv.buffer).then(function(M){var B=self.performance.now();return w.trigger(_.Events.FRAG_DECRYPTED,{frag:b,payload:M,stats:{tstart:F,tdecrypt:B}}),I.payload=M,I})}return I}).then(function(I){var w=k.fragCurrent,O=k.hls,P=k.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;k.state=n.IDLE,k.fragLoadError=0,b.data=new Uint8Array(I.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),I.frag===w&&O.trigger(_.Events.FRAG_BUFFERED,{stats:M,frag:w,part:null,id:b.type}),k.tick()}).catch(function(I){k.warn(I),k.resetFragmentLoading(b)})},S.fragContextChanged=function(b){var k=this.fragCurrent;return!b||!k||b.level!==k.level||b.sn!==k.sn||b.urlId!==k.urlId},S.fragBufferedComplete=function(b,k){var I=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(k?" part: "+k.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+a.default.toString(D.BufferHelper.getBuffered(I))),this.state=n.IDLE,this.tick()},S._handleFragmentLoadComplete=function(b){var k=this.transmuxer;if(k){var I=b.frag,w=b.part,O=b.partsLoaded,P=!O||O.length===0||O.some(function(M){return!M}),F=new L.ChunkMetadata(I.level,I.sn,I.stats.chunkCount+1,0,w?w.index:-1,!P);k.flush(F)}},S._handleFragmentLoadProgress=function(b){},S._doFragLoad=function(b,k,I,w){var O=this;if(I===void 0&&(I=null),!this.levels)throw new Error("frag load aborted, missing levels");if(I=Math.max(b.start,I||0),this.config.lowLatencyMode&&k){var P=k.partList;if(P&&w){I>b.end&&k.fragmentHint&&(b=k.fragmentHint);var F=this.getNextPart(P,b,I);if(F>-1){var M=P[F];return this.log("Loading part sn: "+b.sn+" p: "+M.index+" cc: "+b.cc+" of playlist ["+k.startSN+"-"+k.endSN+"] parts [0-"+F+"-"+(P.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(I.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,part:P[F],targetBufferTime:I}),this.doFragPartsLoad(b,P,F,w).catch(function(B){return O.handleFragLoadError(B)})}if(!b.url||this.loadedEndOfParts(P,I))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(k?"of ["+k.startSN+"-"+k.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(I.toFixed(3))),Object(R.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,targetBufferTime:I}),this.fragmentLoader.load(b,w).catch(function(B){return O.handleFragLoadError(B)})},S.doFragPartsLoad=function(b,k,I,w){var O=this;return new Promise(function(P,F){var M=[];(function B(U){var j=k[U];O.fragmentLoader.loadPart(b,j,w).then(function(V){M[j.index]=V;var H=V.part;O.hls.trigger(_.Events.FRAG_LOADED,V);var X=k[U+1];if(!X||X.fragment!==b)return P({frag:b,part:H,partsLoaded:M});B(U+1)}).catch(F)})(I)})},S.handleFragLoadError=function(b){var k=b.data;return k&&k.details===o.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(k.frag,k.part):this.hls.trigger(_.Events.ERROR,k),null},S._handleTransmuxerFlush=function(b){var k=this.getCurrentContext(b);if(k&&this.state===n.PARSING){var I=k.frag,w=k.part,O=k.level,P=self.performance.now();I.stats.parsing.end=P,w&&(w.stats.parsing.end=P),this.updateLevelTiming(I,w,O,b.partial)}else this.fragCurrent||(this.state=n.IDLE)},S.getCurrentContext=function(b){var k=this.levels,I=b.level,w=b.sn,O=b.part;if(!k||!k[I])return this.warn("Levels object was unset while buffering fragment "+w+" of level "+I+". The current chunk will not be buffered."),null;var P=k[I],F=O>-1?Object(y.getPartWith)(P,w,O):null,M=F?F.fragment:Object(y.getFragmentWithSN)(P,w,this.fragCurrent);return M?{frag:M,part:F,level:P}:null},S.bufferFragmentData=function(b,k,I,w){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:k,part:I,chunkMeta:w,parent:k.type,data:F};this.hls.trigger(_.Events.BUFFER_APPENDING,M),b.dropped&&b.independent&&!I&&this.flushBufferGap(k)}}},S.flushBufferGap=function(b){var k=this.media;if(k)if(D.BufferHelper.isBuffered(k,k.currentTime)){var I=k.currentTime,w=D.BufferHelper.bufferInfo(k,I,0),O=b.duration,P=Math.min(2*this.config.maxFragLookUpTolerance,.25*O),F=Math.max(Math.min(b.start-P,w.end-P),I+P);b.start-F>P&&this.flushMainBuffer(F,b.start)}else this.flushMainBuffer(0,b.start)},S.getFwdBufferInfo=function(b,k){var I=this.config,w=this.getLoadPosition();if(!Object(R.isFiniteNumber)(w))return null;var O=D.BufferHelper.bufferInfo(b,w,I.maxBufferHole);if(O.len===0&&O.nextStart!==void 0){var P=this.fragmentTracker.getBufferedFrag(w,k);if(P&&O.nextStart<P.end)return D.BufferHelper.bufferInfo(b,w,Math.max(O.nextStart,I.maxBufferHole))}return O},S.getMaxBufferLength=function(b){var k,I=this.config;return k=b?Math.max(8*I.maxBufferSize/b,I.maxBufferLength):I.maxBufferLength,Math.min(k,I.maxMaxBufferLength)},S.reduceMaxBufferLength=function(b){var k=this.config,I=b||k.maxBufferLength;return k.maxMaxBufferLength>=I&&(k.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+k.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(b,k){var I,w,O=k.fragments,P=O.length;if(!P)return null;var F,M=this.config,B=O[0].start;if(k.live){var U=M.initialLiveManifestSize;if(P<U)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+U+")"),null;k.PTSKnown||this.startFragRequested||this.startPosition!==-1||(F=this.getInitialLiveFragment(k,O),this.startPosition=F?this.hls.liveSyncPosition||F.start:b)}else b<=B&&(F=O[0]);if(!F){var j=M.lowLatencyMode?k.partEnd:k.fragmentEnd;F=this.getFragmentAtPosition(b,j,k)}return(I=F)===null||I===void 0||!I.initSegment||(w=F)!==null&&w!==void 0&&w.initSegment.data||this.bitrateTest||(F=F.initSegment),F},S.getNextPart=function(b,k,I){for(var w=-1,O=!1,P=!0,F=0,M=b.length;F<M;F++){var B=b[F];if(P=P&&!B.independent,w>-1&&I<B.start)break;var U=B.loaded;!U&&(O||B.independent||P)&&B.fragment===k&&(w=F),O=U}return w},S.loadedEndOfParts=function(b,k){var I=b[b.length-1];return I&&k>I.start&&I.loaded},S.getInitialLiveFragment=function(b,k){var I=this.fragPrevious,w=null;if(I){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+I.programDateTime),w=Object(E.findFragmentByPDT)(k,I.endProgramDateTime,this.config.maxFragLookUpTolerance)),!w){var O=I.sn+1;if(O>=b.startSN&&O<=b.endSN){var P=k[O-b.startSN];I.cc===P.cc&&(w=P,this.log("Live playlist, switching playlist, load frag with next SN: "+w.sn))}w||(w=Object(E.findFragWithCC)(k,I.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+w.sn)}}else{var F=this.hls.liveSyncPosition;F!==null&&(w=this.getFragmentAtPosition(F,this.bitrateTest?b.fragmentEnd:b.edge,b))}return w},S.getFragmentAtPosition=function(b,k,I){var w,O=this.config,P=this.fragPrevious,F=I.fragments,M=I.endSN,B=I.fragmentHint,U=O.maxFragLookUpTolerance,j=!!(O.lowLatencyMode&&I.partList&&B);if(j&&B&&!this.bitrateTest&&(F=F.concat(B),M=B.sn),b<k){var V=b>k-U?0:U;w=Object(E.findFragmentByPTS)(P,F,b,V)}else w=F[F.length-1];if(w){var H=w.sn-I.startSN,X=P&&w.level===P.level,q=F[H+1];if(this.fragmentTracker.getState(w)===A.FragmentState.BACKTRACKED){w=null;for(var $=H;F[$]&&this.fragmentTracker.getState(F[$])===A.FragmentState.BACKTRACKED;)w=P?F[$--]:F[--$];w||(w=q)}else P&&w.sn===P.sn&&!j&&X&&(w.sn<M&&this.fragmentTracker.getState(q)!==A.FragmentState.OK?(this.log("SN "+w.sn+" just loaded, load next one: "+q.sn),w=q):w=null)}return w},S.synchronizeToLiveEdge=function(b){var k=this.config,I=this.media;if(I){var w=this.hls.liveSyncPosition,O=I.currentTime,P=b.fragments[0].start,F=b.edge,M=O>=P-k.maxFragLookUpTolerance&&O<=F;if(w!==null&&I.duration>w&&(O<w||!M)){var B=k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:k.liveMaxLatencyDurationCount*b.targetduration;(!M&&I.readyState<4||O<F-B)&&(this.loadedmetadata||(this.nextLoadPosition=w),I.readyState&&(this.warn("Playback: "+O.toFixed(3)+" is located too far from the end of live sliding playlist: "+F+", reset currentTime to : "+w.toFixed(3)),I.currentTime=w))}}},S.alignPlaylists=function(b,k){var I=this.levels,w=this.levelLastLoaded,O=this.fragPrevious,P=w!==null?I[w]:null,F=b.fragments.length;if(!F)return this.warn("No fragments in live playlist"),0;var M=b.fragments[0].start,B=!k,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: "+(k?k.startSN:"na")+"->"+b.startSN+" prev-sn: "+(O?O.sn:"na")+" fragments: "+F),j}return M},S.waitForCdnTuneIn=function(b){return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,3*b.partTarget)},S.setStartPosition=function(b,k){var I=this.startPosition;if(I<k&&(I=-1),I===-1||this.lastCurrentTime===-1){var w=b.startTimeOffset;Object(R.isFiniteNumber)(w)?(I=k+w,w<0&&(I+=b.totalduration),I=Math.min(Math.max(k,I),k+b.totalduration),this.log("Start time offset "+w+" found in playlist, adjust startPosition to "+I),this.startPosition=I):b.live?I=this.hls.liveSyncPosition||k:this.startPosition=I=0,this.lastCurrentTime=I}this.nextLoadPosition=I},S.getLoadPosition=function(){var b=this.media,k=0;return this.loadedmetadata&&b?k=b.currentTime:this.nextLoadPosition&&(k=this.nextLoadPosition),k},S.handleFragLoadAborted=function(b,k){this.transmuxer&&b.sn!=="initSegment"&&b.stats.aborted&&(this.warn("Fragment "+b.sn+(k?" part"+k.index:"")+" of level "+b.level+" was aborted"),this.resetFragmentLoading(b))},S.resetFragmentLoading=function(b){this.fragCurrent&&this.fragContextChanged(b)||(this.state=n.IDLE)},S.onFragmentOrKeyLoadError=function(b,k){if(!k.fatal){var I=k.frag;if(I&&I.type===b){var w=this.fragCurrent;console.assert(w&&I.sn===w.sn&&I.level===w.level&&I.urlId===w.urlId,"Frag load error must match current frag to retry");var O=this.config;if(this.fragLoadError+1<=O.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(I.level))return;var P=Math.min(Math.pow(2,this.fragLoadError)*O.fragLoadingRetryDelay,O.fragLoadingMaxRetryTimeout);this.warn("Fragment "+I.sn+" of "+b+" "+I.level+" failed to load, retrying in "+P+"ms"),this.retryDate=self.performance.now()+P,this.fragLoadError++,this.state=n.FRAG_LOADING_WAITING_RETRY}else k.levelRetry?(b===t.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=n.IDLE):(C.logger.error(k.details+" reaches max retry, redispatch as fatal ..."),k.fatal=!0,this.hls.stopLoad(),this.state=n.ERROR)}}},S.afterBufferFlushed=function(b,k,I){if(b){var w=D.BufferHelper.getBuffered(b);this.fragmentTracker.detectEvictedFragments(k,w,I),this.state===n.ENDED&&this.resetLoadingState()}},S.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=n.IDLE},S.resetLiveStartWhenNotLoaded=function(b){if(!this.loadedmetadata){this.startFragRequested=!1;var k=this.levels?this.levels[b].details:null;if(k!=null&&k.live)return this.startPosition=-1,this.setStartPosition(k,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},S.updateLevelTiming=function(b,k,I,w){var O=this,P=I.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=w?0:Object(y.updateFragPTSDTS)(P,b,B.startPTS,B.endPTS,B.startDTS,B.endDTS);return O.hls.trigger(_.Events.LEVEL_PTS_UPDATED,{details:P,level:I,drift:j,type:M,frag:b,start:B.startPTS,end:B.endPTS}),!0}return F},!1)?(this.state=n.PARSED,this.hls.trigger(_.Events.FRAG_PARSED,{frag:b,part:k})):this.resetLoadingState()},S.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=r,(c=[{key:"state",get:function(){return this._state},set:function(b){var k=this._state;k!==b&&(this._state=b,this.log(k+"->"+b))}}])&&s(i.prototype,c),r}(T.default)},"./src/controller/buffer-controller.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return E});var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts"),D=h("./src/errors.ts"),C=h("./src/utils/buffer-helper.ts"),_=h("./src/utils/mediasource-helper.ts"),o=h("./src/loader/fragment.ts"),L=h("./src/controller/buffer-operation-queue.ts"),m=Object(_.getMediaSource)(),f=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function y(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,u=a.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),s&&(a.updateMediaElementDuration(),t.trigger(T.Events.MEDIA_ATTACHED,{media:s})),u&&u.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 d=y.prototype;return d.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},d.destroy=function(){this.unregisterListeners(),this.details=null},d.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)},d.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)},d._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},d.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")},d.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}},d.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)},d.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()},d.onBufferCodecs=function(e,a){var t=this,s=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(u){if(s){var n=t.tracks[u];if(n&&typeof n.buffer.changeType=="function"){var l=a[u],v=l.codec,g=l.levelCodec,p=l.container;if((n.levelCodec||n.codec).replace(f,"$1")!==(g||v).replace(f,"$1")){var r=p+";codecs="+(g||v);t.appendChangeType(u,r)}}}else t.pendingTracks[u]=a[u]}),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},d.appendChangeType=function(e,a){var t=this,s=this.operationQueue,u={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(u,e)},d.onBufferAppending=function(e,a){var t=this,s=this.hls,u=this.operationQueue,n=this.tracks,l=a.data,v=a.type,g=a.frag,p=a.part,r=a.chunkMeta,i=r.buffering[v],c=self.performance.now();i.start=c;var S=g.stats.buffering,b=p?p.stats.buffering:null;S.start===0&&(S.start=c),b&&b.start===0&&(b.start=c);var k=n.audio,I=v==="audio"&&r.id===1&&(k==null?void 0:k.container)==="audio/mpeg",w={execute:function(){if(i.executeStart=self.performance.now(),I){var O=t.sourceBuffer[v];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(l,v)},onStart:function(){},onComplete:function(){var O=self.performance.now();i.executeEnd=i.end=O,S.first===0&&(S.first=O),b&&b.first===0&&(b.first=O);var P=t.sourceBuffer,F={};for(var M in P)F[M]=C.BufferHelper.getBuffered(P[M]);t.appendError=0,t.hls.trigger(T.Events.BUFFER_APPENDED,{type:v,frag:g,part:p,chunkMeta:r,parent:g.type,timeRanges:F})},onError:function(O){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+v+" SourceBuffer",O);var P={type:D.ErrorTypes.MEDIA_ERROR,parent:g.type,details:D.ErrorDetails.BUFFER_APPEND_ERROR,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=D.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,P.details=D.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)}};u.append(w,v)},d.onBufferFlushing=function(e,a){var t=this,s=this.operationQueue,u=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(l){A.logger.warn("[buffer-controller]: Failed to remove from "+n+" SourceBuffer",l)}}};a.type?s.append(u(a.type),a.type):this.getSourceBufferTypes().forEach(function(n){s.append(u(n),n)})},d.onFragParsed=function(e,a){var t=this,s=a.frag,u=a.part,n=[],l=u?u.elementaryStreams:s.elementaryStreams;l[o.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(l[o.ElementaryStreamTypes.AUDIO]&&n.push("audio"),l[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 v=self.performance.now();s.stats.buffering.end=v,u&&(u.stats.buffering.end=v);var g=u?u.stats:s.stats;t.hls.trigger(T.Events.FRAG_BUFFERED,{frag:s,part:u,stats:g,id:s.type})},n)},d.onFragChanged=function(e,a){this.flushBackBuffer()},d.onBufferEos=function(e,a){var t=this;this.getSourceBufferTypes().reduce(function(s,u){var n=t.sourceBuffer[u];return a.type&&a.type!==u||n&&!n.ended&&(n.ended=!0,A.logger.log("[buffer-controller]: "+u+" sourceBuffer now EOS")),s&&!(n&&!n.ended)},!0)&&this.blockBuffers(function(){var s=t.mediaSource;s&&s.readyState==="open"&&s.endOfStream()})},d.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())},d.flushBackBuffer=function(){var e=this.hls,a=this.details,t=this.media,s=this.sourceBuffer;if(t&&a!==null){var u=this.getSourceBufferTypes();if(u.length){var n=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(R.isFiniteNumber)(n)&&!(n<0)){var l=t.currentTime,v=a.levelTargetDuration,g=Math.max(n,v),p=Math.floor(l/v)*v-g;u.forEach(function(r){var i=s[r];if(i){var c=C.BufferHelper.getBuffered(i);c.length>0&&p>c.start(0)&&(e.trigger(T.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),a.live&&e.trigger(T.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),e.trigger(T.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:r}))}})}}}},d.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,u=e.fragments[0].start+e.totalduration,n=t.duration,l=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)):(u>l&&u>n||!Object(R.isFiniteNumber)(n))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+u.toFixed(3)),s.duration=u)}},d.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),u=Math.max(s,s+e.totalduration);a.setLiveSeekableRange(s,u)}},d.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 u=this.getSourceBufferTypes();if(u.length===0)return void this.hls.trigger(T.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});u.forEach(function(n){a.executeNext(n)})}},d.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 u in e)if(!a[u]){var n=e[u];if(!n)throw Error("source buffer exists for track "+u+", however track does not");var l=n.levelCodec||n.codec,v=n.container+";codecs="+l;A.logger.log("[buffer-controller]: creating sourceBuffer("+v+")");try{var g=a[u]=t.addSourceBuffer(v),p=u;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[u]={buffer:g,codec:l,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:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:r,mimeType:v})}}s&&this.hls.trigger(T.Events.BUFFER_CREATED,{tracks:this.tracks})},d._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},d._onSBUpdateEnd=function(e){var a=this.operationQueue;a.current(e).onComplete(),a.shiftAndExecuteNext(e)},d._onSBUpdateError=function(e,a){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(T.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(a)},d.removeExecutor=function(e,a,t){var s=this.media,u=this.mediaSource,n=this.operationQueue,l=this.sourceBuffer[e];if(!s||!u||!l)return A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(e);var v=Object(R.isFiniteNumber)(s.duration)?s.duration:1/0,g=Object(R.isFiniteNumber)(u.duration)?u.duration:1/0,p=Math.max(0,a),r=Math.min(t,v,g);r>p?(A.logger.log("[buffer-controller]: Removing ["+p+","+r+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(p,r)):n.shiftAndExecuteNext(e)},d.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)},d.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,u=a.map(function(n){return s.appendBlocker(n)});Promise.all(u).then(function(){e(),a.forEach(function(n){var l=t.sourceBuffer[n];l&&l.updating||s.shiftAndExecuteNext(n)})})},d.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},d.addBufferListener=function(e,a,t){var s=this.sourceBuffer[e];if(s){var u=t.bind(this,e);this.listeners[e].push({event:a,listener:u}),s.addEventListener(a,u)}},d.removeBufferListeners=function(e){var a=this.sourceBuffer[e];a&&this.listeners[e].forEach(function(t){a.removeEventListener(t.event,t.listener)})},y}()},"./src/controller/buffer-operation-queue.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return T});var R=h("./src/utils/logger.ts"),T=function(){function A(C){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=C}var D=A.prototype;return D.append=function(C,_){var o=this.queues[_];o.push(C),o.length===1&&this.buffers[_]&&this.executeNext(_)},D.insertAbort=function(C,_){this.queues[_].unshift(C),this.executeNext(_)},D.appendBlocker=function(C){var _,o=new Promise(function(m){_=m}),L={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,C),o},D.executeNext=function(C){var _=this.buffers,o=this.queues,L=_[C],m=o[C];if(m.length){var f=m[0];try{f.execute()}catch(E){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),f.onError(E),L&&L.updating||(m.shift(),this.executeNext(C))}}},D.shiftAndExecuteNext=function(C){this.queues[C].shift(),this.executeNext(C)},D.current=function(C){return this.queues[C][0]},A}()},"./src/controller/cap-level-controller.ts":function(N,x,h){h.r(x);var R=h("./src/events.ts");function T(D,C){for(var _=0;_<C.length;_++){var o=C[_];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(D,o.key,o)}}var A=function(){function D(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 C,_,o,L=D.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){D.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 E=this.hls;this.restrictedLevels=[],this.firstLevel=f.firstLevel,E.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,E=this.hls.levels;if(!E.length)return-1;var y=E.filter(function(d,e){return D.isLevelAllowed(e,f.restrictedLevels)&&e<=m});return this.clientRect=null,D.getMaxLevelByMediaSize(y,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 E=m.getBoundingClientRect();f.width=E.width,f.height=E.height,f.width||f.height||(f.width=E.right-E.left||m.width||0,f.height=E.bottom-E.top||m.height||0)}return this.clientRect=f,f},D.isLevelAllowed=function(m,f){return f===void 0&&(f=[]),f.indexOf(m)===-1},D.getMaxLevelByMediaSize=function(m,f,E){if(!m||!m.length)return-1;for(var y,d,e=m.length-1,a=0;a<m.length;a+=1){var t=m[a];if((t.width>=f||t.height>=E)&&(y=t,!(d=m[a+1])||y.width!==d.width||y.height!==d.height)){e=a;break}}return e},C=D,o=[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}],(_=[{key:"mediaWidth",get:function(){return this.getDimensions().width*D.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*D.contentScaleFactor}}])&&T(C.prototype,_),o&&T(C,o),D}();x.default=A},"./src/controller/eme-controller.ts":function(N,x,h){h.r(x);var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/utils/logger.ts"),D=h("./src/utils/mediakeys-helper.ts");function C(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 _=function(){function o(E){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=E,this._config=E.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(E){switch(E){case D.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+E+'"')},f._attemptKeySystemAccess=function(E,y,d){var e=this,a=function(s,u,n,l){switch(s){case D.KeySystems.WIDEVINE:return function(v,g,p){var r={audioCapabilities:[],videoCapabilities:[]};return v.forEach(function(i){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:p.audioRobustness||""})}),g.forEach(function(i){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:p.videoRobustness||""})}),[r]}(u,n,l);default:throw new Error("Unknown key-system: "+s)}}(E,y,d,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var t=this.requestMediaKeySystemAccess(E,a);this.mediaKeysPromise=t.then(function(s){return e._onMediaKeySystemAccessObtained(E,s)}),t.catch(function(s){A.logger.error('Failed to obtain key-system "'+E+'" access:',s)})},f._onMediaKeySystemAccessObtained=function(E,y){var d=this;A.logger.log('Access for key-system "'+E+'" obtained');var e={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:y,mediaKeySystemDomain:E};this._mediaKeysList.push(e);var a=Promise.resolve().then(function(){return y.createMediaKeys()}).then(function(t){return e.mediaKeys=t,A.logger.log('Media-keys created for key-system "'+E+'"'),d._onMediaKeysCreated(),t});return a.catch(function(t){A.logger.error("Failed to create media-keys:",t)}),a},f._onMediaKeysCreated=function(){var E=this;this._mediaKeysList.forEach(function(y){y.mediaKeysSession||(y.mediaKeysSession=y.mediaKeys.createSession(),E._onNewMediaKeySession(y.mediaKeysSession))})},f._onNewMediaKeySession=function(E){var y=this;A.logger.log("New key-system session "+E.sessionId),E.addEventListener("message",function(d){y._onKeySessionMessage(E,d.message)},!1)},f._onKeySessionMessage=function(E,y){A.logger.log("Got EME message event, creating license request"),this._requestLicense(y,function(d){A.logger.log("Received license data (length: "+(d&&d.byteLength)+"), updating key-session"),E.update(d)})},f.onMediaEncrypted=function(E){var y=this;if(A.logger.log('Media is encrypted using "'+E.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 d=function(e){y._media&&(y._attemptSetMediaKeys(e),y._generateRequestWithPreferredKeySession(E.initDataType,E.initData))};this.mediaKeysPromise.then(d).catch(d)},f._attemptSetMediaKeys=function(E){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var y=this._mediaKeysList[0];if(!y||!y.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(y.mediaKeys),this._hasSetMediaKeys=!0}},f._generateRequestWithPreferredKeySession=function(E,y){var d=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(!y)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 "'+E+'" init data type'),e.mediaKeysSessionInitialized=!0,a.generateRequest(E,y).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(t){A.logger.error("Error generating key-session request:",t),d.hls.trigger(R.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})}},f._createLicenseXhr=function(E,y,d){var e=new XMLHttpRequest;e.responseType="arraybuffer",e.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,e,E,y,d);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,e,E),a=void 0}catch(t){A.logger.error(t)}try{e.readyState||e.open("POST",E,!0),a&&a.call(this.hls,e,E)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return e},f._onLicenseRequestReadyStageChange=function(E,y,d,e){switch(E.readyState){case 4:if(E.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var a=E.response,t=this._licenseResponseCallback;if(t)try{a=t.call(this.hls,E,y)}catch(u){A.logger.error(u)}e(a)}else{if(A.logger.error("License Request XHR failed ("+y+"). Status: "+E.status+" ("+E.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(d,e)}}},f._generateLicenseRequestChallenge=function(E,y){switch(E.mediaKeySystemDomain){case D.KeySystems.WIDEVINE:return y}throw new Error("unsupported key-system: "+E.mediaKeySystemDomain)},f._requestLicense=function(E,y){A.logger.log("Requesting content license for key-system");var d=this._mediaKeysList[0];if(!d)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(d.mediaKeySystemDomain),a=this._createLicenseXhr(e,E,y);A.logger.log("Sending license request to URL: "+e);var t=this._generateLicenseRequestChallenge(d,E);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(E,y){if(this._emeEnabled){var d=y.media;this._media=d,d.addEventListener("encrypted",this._onMediaEncrypted)}},f.onMediaDetached=function(){var E=this._media,y=this._mediaKeysList;E&&(E.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(y.map(function(d){if(d.mediaKeysSession)return d.mediaKeysSession.close().catch(function(){})})).then(function(){return E.setMediaKeys(null)}).catch(function(){}))},f.onManifestParsed=function(E,y){if(this._emeEnabled){var d=y.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),e=y.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(D.KeySystems.WIDEVINE,d,e)}},L=o,(m=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&C(L.prototype,m),o}();x.default=_},"./src/controller/fps-controller.ts":function(N,x,h){h.r(x);var R=h("./src/events.ts"),T=h("./src/utils/logger.ts"),A=function(){function 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=_,this.registerListeners()}var C=D.prototype;return C.setStreamController=function(_){this.streamController=_},C.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},C.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},C.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},C.onMediaAttaching=function(_,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)}},C.checkFPS=function(_,o,L){var m=performance.now();if(o){if(this.lastTime){var f=m-this.lastTime,E=L-this.lastDroppedFrames,y=o-this.lastDecodedFrames,d=1e3*E/f,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:E,currentDecoded:y,totalDroppedFrames:L}),d>0&&E>e.config.fpsDroppedMonitoringThreshold*y){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}},C.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var o=_.getVideoPlaybackQuality();this.checkFPS(_,o.totalVideoFrames,o.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},D}();x.default=A},"./src/controller/fragment-finders.ts":function(N,x,h){h.r(x),h.d(x,"findFragmentByPDT",function(){return A}),h.d(x,"findFragmentByPTS",function(){return D}),h.d(x,"fragmentWithinToleranceTest",function(){return C}),h.d(x,"pdtWithinToleranceTest",function(){return _}),h.d(x,"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 E=0;E<L.length;++E){var y=L[E];if(_(m,f,y))return y}return null}function D(L,m,f,E){f===void 0&&(f=0),E===void 0&&(E=0);var y=null;if(L?y=m[L.sn-m[0].sn+1]||null:f===0&&m[0].start===0&&(y=m[0]),y&&C(f,E,y)===0)return y;var d=T.default.search(m,C.bind(null,f,E));return d||y}function C(L,m,f){L===void 0&&(L=0),m===void 0&&(m=0);var E=Math.min(m,f.duration+(f.deltaPTS?f.deltaPTS:0));return f.start+f.duration-E<=L?1:f.start-E>L&&f.start?-1:0}function _(L,m,f){var E=1e3*Math.min(m,f.duration+(f.deltaPTS?f.deltaPTS:0));return(f.endProgramDateTime||0)-E>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,x,h){h.r(x),h.d(x,"FragmentState",function(){return R}),h.d(x,"FragmentTracker",function(){return C});var R,T,A=h("./src/events.ts"),D=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 C=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,E){if(E===D.PlaylistLevelType.MAIN){var y=this.activeFragment,d=this.activeParts;if(!y)return null;if(d)for(var e=d.length;e--;){var a=d[e],t=a?a.end:y.appendedPTS;if(a.start<=f&&t!==void 0&&f<=t)return e>9&&(this.activeParts=d.slice(e-9)),a}else if(y.start<=f&&y.appendedPTS!==void 0&&f<=y.appendedPTS)return y}return this.getBufferedFrag(f,E)},m.getBufferedFrag=function(f,E){for(var y=this.fragments,d=Object.keys(y),e=d.length;e--;){var a=y[d[e]];if((a==null?void 0:a.body.type)===E&&a.buffered){var t=a.body;if(t.start<=f&&f<=t.end)return t}}return null},m.detectEvictedFragments=function(f,E,y){var d=this;Object.keys(this.fragments).forEach(function(e){var a=d.fragments[e];if(a)if(a.buffered){var t=a.range[f];t&&t.time.some(function(s){var u=!d.isTimeBuffered(s.startPTS,s.endPTS,E);return u&&d.removeFragment(a.body),u})}else a.body.type===y&&d.removeFragment(a.body)})},m.detectPartialFragments=function(f){var E=this,y=this.timeRanges,d=f.frag,e=f.part;if(y&&d.sn!=="initSegment"){var a=o(d),t=this.fragments[a];t&&(Object.keys(y).forEach(function(s){var u=d.elementaryStreams[s];if(u){var n=y[s],l=e!==null||u.partial===!0;t.range[s]=E.getBufferedTimes(d,e,l,n)}}),t.backtrack=t.loaded=null,Object.keys(t.range).length?t.buffered=!0:this.removeFragment(t.body))}},m.fragBuffered=function(f){var E=o(f),y=this.fragments[E];y&&(y.backtrack=y.loaded=null,y.buffered=!0)},m.getBufferedTimes=function(f,E,y,d){for(var e={time:[],partial:y},a=E?E.start:f.start,t=E?E.end:f.end,s=f.minEndPTS||t,u=f.maxStartPTS||a,n=0;n<d.length;n++){var l=d.start(n)-this.bufferPadding,v=d.end(n)+this.bufferPadding;if(u>=l&&s<=v){e.time.push({startPTS:Math.max(a,d.start(n)),endPTS:Math.min(t,d.end(n))});break}if(a<v&&t>l)e.partial=!0,e.time.push({startPTS:Math.max(a,d.start(n)),endPTS:Math.min(t,d.end(n))});else if(t<=l)break}return e},m.getPartialFragment=function(f){var E,y,d,e=null,a=0,t=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(function(u){var n=s[u];n&&_(n)&&(y=n.body.start-t,d=n.body.end+t,f>=y&&f<=d&&(E=Math.min(f-y,d-f),a<=E&&(e=n.body,a=E)))}),e},m.getState=function(f){var E=o(f),y=this.fragments[E];return y?y.buffered?_(y)?R.PARTIAL:R.OK:y.backtrack?R.BACKTRACKED:R.APPENDING:R.NOT_LOADED},m.backtrack=function(f,E){var y=o(f),d=this.fragments[y];if(!d||d.backtrack)return null;var e=d.backtrack=E||d.loaded;return d.loaded=null,e},m.getBacktrackData=function(f){var E=o(f),y=this.fragments[E];if(y){var d,e=y.backtrack;if(e!=null&&(d=e.payload)!==null&&d!==void 0&&d.byteLength)return e;this.removeFragment(f)}return null},m.isTimeBuffered=function(f,E,y){for(var d,e,a=0;a<y.length;a++){if(d=y.start(a)-this.bufferPadding,e=y.end(a)+this.bufferPadding,f>=d&&E<=e)return!0;if(E<=d)return!1}return!1},m.onFragLoaded=function(f,E){var y=E.frag,d=E.part;if(y.sn!=="initSegment"&&!y.bitrateTest&&!d){var e=o(y);this.fragments[e]={body:y,loaded:E,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(f,E){var y=this,d=E.frag,e=E.part,a=E.timeRanges;if(d.type===D.PlaylistLevelType.MAIN)if(this.activeFragment=d,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 u=a[s];if(y.detectEvictedFragments(s,u),!e)for(var n=0;n<u.length;n++)d.appendedPTS=Math.max(u.end(n),d.appendedPTS||0)})},m.onFragBuffered=function(f,E){this.detectPartialFragments(E)},m.hasFragment=function(f){var E=o(f);return!!this.fragments[E]},m.removeFragmentsInRange=function(f,E,y){var d=this;Object.keys(this.fragments).forEach(function(e){var a=d.fragments[e];if(a&&a.buffered){var t=a.body;t.type===y&&t.start<E&&t.end>f&&d.removeFragment(t)}})},m.removeFragment=function(f){var E=o(f);f.stats.loaded=0,f.clearElementaryStreamInfo(),delete this.fragments[E]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function _(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,x,h){h.r(x),h.d(x,"STALL_MINIMUM_DURATION_MS",function(){return C}),h.d(x,"MAX_START_GAP_JUMP",function(){return _}),h.d(x,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return o}),h.d(x,"SKIP_BUFFER_RANGE_START",function(){return L}),h.d(x,"default",function(){return m});var R=h("./src/utils/buffer-helper.ts"),T=h("./src/errors.ts"),A=h("./src/events.ts"),D=h("./src/utils/logger.ts"),C=250,_=2,o=.1,L=.05,m=function(){function f(y,d,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=y,this.media=d,this.fragmentTracker=e,this.hls=a}var E=f.prototype;return E.destroy=function(){this.hls=this.fragmentTracker=this.media=null},E.poll=function(y){var d=this.config,e=this.media,a=this.stalled,t=e.currentTime,s=e.seeking,u=this.seeking&&!s,n=!this.seeking&&s;if(this.seeking=s,t===y){if((n||u)&&(this.stalled=null),!e.paused&&!e.ended&&e.playbackRate!==0&&R.BufferHelper.getBuffered(e).length){var l=R.BufferHelper.bufferInfo(e,t,0),v=l.len>0,g=l.nextStart||0;if(v||g){if(s){var p=l.len>_,r=!g||g-t>_&&!this.fragmentTracker.getPartialFragment(t);if(p||r)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var i,c=Math.max(g,l.start||0)-t,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=!(S==null||(i=S.details)===null||i===void 0)&&i.live?2*S.details.targetduration:_;if(c>0&&c<=b)return void this._trySkipBufferHole(null)}var k=self.performance.now();if(a!==null){var I=k-a;!s&&I>=C&&this._reportStall(l.len);var w=R.BufferHelper.bufferInfo(e,t,d.maxBufferHole);this._tryFixBufferStall(w,I)}else this.stalled=k}}}else if(this.moved=!0,a!==null){if(this.stallReported){var O=self.performance.now()-a;D.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},E._tryFixBufferStall=function(y,d){var e=this.config,a=this.fragmentTracker,t=this.media.currentTime,s=a.getPartialFragment(t);s&&this._trySkipBufferHole(s)||y.len>e.maxBufferHole&&d>1e3*e.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},E._reportStall=function(y){var d=this.hls,e=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+y+")"),d.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},E._trySkipBufferHole=function(y){for(var d=this.config,e=this.hls,a=this.media,t=a.currentTime,s=0,u=R.BufferHelper.getBuffered(a),n=0;n<u.length;n++){var l=u.start(n);if(t+d.maxBufferHole>=s&&t<l){var v=Math.max(l+L,a.currentTime+o);return D.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+v),this.moved=!0,this.stalled=null,a.currentTime=v,y&&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 "+v,frag:y}),v}s=u.end(n)}return 0},E._tryNudgeBuffer=function(){var y=this.config,d=this.hls,e=this.media,a=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<y.nudgeMaxRetry){var s=a+t*y.nudgeOffset;D.logger.warn("Nudging 'currentTime' from "+a+" to "+s),e.currentTime=s,d.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else D.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+y.nudgeMaxRetry+" nudges"),d.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,x,h){h.r(x);var R=h("./src/events.ts"),T=h("./src/utils/texttrack-utils.ts"),A=h("./src/demux/id3.ts"),D=function(){function C(o){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=o,this._registerListeners()}var _=C.prototype;return _.destroy=function(){this._unregisterListeners()},_._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)},_._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)},_.onMediaAttached=function(o,L){this.media=L.media},_.onMediaDetaching=function(){this.id3Track&&(Object(T.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.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")}},_.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 E=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,y=0;y<f.length;y++){var d=A.getID3Frames(f[y].data);if(d){var e=f[y].pts,a=y<f.length-1?f[y+1].pts:m.end;a-e<=0&&(a=e+.25);for(var t=0;t<d.length;t++){var s=d[t];if(!A.isTimeStampFrame(s)){var u=new E(e,a,"");u.value=s,this.id3Track.addCue(u)}}}}}},_.onBufferFlushing=function(o,L){var m=L.startOffset,f=L.endOffset,E=L.type;if(!E||E==="audio"){var y=this.id3Track;y&&Object(T.removeCuesInRange)(y,m,f)}},C}();x.default=D},"./src/controller/latency-controller.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return C});var R=h("./src/errors.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts");function 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(_,m.key,m)}}var C=function(){function _(f){var E=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return E.timeupdate()},this.hls=f,this.config=f.config,this.registerListeners()}var o,L,m=_.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,E){this.media=E.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,E){var y=E.details;this.levelDetails=y,y.advanced&&this.timeupdate(),!y.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},m.onError=function(f,E){E.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,E=this.levelDetails;if(f&&E){this.currentTime=f.currentTime;var y=this.computeLatency();if(y!==null){this._latency=y;var d=this.config,e=d.lowLatencyMode,a=d.maxLiveSyncPlaybackRate;if(e&&a!==1){var t=this.targetLatency;if(t!==null){var s=y-t,u=s<Math.min(this.maxLatency,t+E.targetduration);if(E.live&&u&&s>.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,a)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;f.playbackRate=Math.min(n,Math.max(1,l))}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=_,(L=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var f=this.config,E=this.levelDetails;return f.liveMaxLatencyDuration!==void 0?f.liveMaxLatencyDuration:E?f.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var f=this.levelDetails;if(f===null)return null;var E=f.holdBack,y=f.partHoldBack,d=f.targetduration,e=this.config,a=e.liveSyncDuration,t=e.liveSyncDurationCount,s=e.lowLatencyMode,u=this.hls.userConfig,n=s&&y||E;(u.liveSyncDuration||u.liveSyncDurationCount||n===0)&&(n=a!==void 0?a:t*d);var l=d;return n+Math.min(1*this.stallCount,l)}},{key:"liveSyncPosition",get:function(){var f=this.estimateLiveEdge(),E=this.targetLatency,y=this.levelDetails;if(f===null||E===null||y===null)return null;var d=y.edge,e=f-E-this.edgeStalled,a=d-y.totalduration,t=d-(this.config.lowLatencyMode&&y.partTarget||y.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 E=3*(this.config.lowLatencyMode&&f.partTarget||f.targetduration);return Math.max(f.age-E,0)}},{key:"forwardBufferLength",get:function(){var f=this.media,E=this.levelDetails;if(!f||!E)return 0;var y=f.buffered.length;return y?f.buffered.end(y-1):E.edge-this.currentTime}}])&&D(o.prototype,L),_}()},"./src/controller/level-controller.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return y});var R=h("./src/types/level.ts"),T=h("./src/events.ts"),A=h("./src/errors.ts"),D=h("./src/utils/codecs.ts"),C=h("./src/controller/level-helper.ts"),_=h("./src/controller/base-playlist-controller.ts"),o=h("./src/types/loader.ts");function L(){return(L=Object.assign||function(d){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(d[t]=a[t])}return d}).apply(this,arguments)}function m(d,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(d,t.key,t)}}function f(d,e){return(f=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(d,e)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),y=function(d){var e,a;function t(l){var v;return(v=d.call(this,l,"[level-controller]")||this)._levels=[],v._firstLevel=-1,v._startLevel=void 0,v.currentLevelIndex=-1,v.manualLevelIndex=-1,v.onParsedComplete=void 0,v._registerListeners(),v}a=d,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,f(e,a);var s,u,n=t.prototype;return n._registerListeners=function(){var l=this.hls;l.on(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(T.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.on(T.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(T.Events.ERROR,this.onError,this)},n._unregisterListeners=function(){var l=this.hls;l.off(T.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(T.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.off(T.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(T.Events.ERROR,this.onError,this)},n.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,d.prototype.destroy.call(this)},n.startLoad=function(){this._levels.forEach(function(l){l.loadError=0}),d.prototype.startLoad.call(this)},n.onManifestLoaded=function(l,v){var g,p,r=[],i=[],c=[],S={},b=!1,k=!1,I=!1;if(v.levels.forEach(function(F){var M=F.attrs;b=b||!(!F.width||!F.height),k=k||!!F.videoCodec,I=I||!!F.audioCodec,E&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var B=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;(p=S[B])?p.url.push(F.url):(p=new R.Level(F),S[B]=p,r.push(p)),M&&(M.AUDIO&&Object(C.addGroupId)(p,"audio",M.AUDIO),M.SUBTITLES&&Object(C.addGroupId)(p,"text",M.SUBTITLES))}),(b||k)&&I&&(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(D.isCodecSupportedInMp4)(M,"audio"))&&(!B||Object(D.isCodecSupportedInMp4)(B,"video"))}),v.audioTracks&&(i=v.audioTracks.filter(function(F){return!F.audioCodec||Object(D.isCodecSupportedInMp4)(F.audioCodec,"audio")}),Object(C.assignTrackIdsByGroup)(i)),v.subtitles&&(c=v.subtitles,Object(C.assignTrackIdsByGroup)(c)),r.length>0){g=r[0].bitrate,r.sort(function(F,M){return F.bitrate-M.bitrate}),this._levels=r;for(var w=0;w<r.length;w++)if(r[w].bitrate===g){this._firstLevel=w,this.log("manifest loaded, "+r.length+" level(s) found, first bitrate: "+g);break}var O=I&&!k,P={levels:r,audioTracks:i,subtitleTracks:c,firstLevel:this._firstLevel,stats:v.stats,audio:I,video:k,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:v.url,reason:"no level with compatible codecs found in manifest"})},n.onError=function(l,v){if(d.prototype.onError.call(this,l,v),!v.fatal){var g=v.context,p=this._levels[this.currentLevelIndex];if(g&&(g.type===o.PlaylistContextType.AUDIO_TRACK&&p.audioGroupIds&&g.groupId===p.audioGroupIds[p.urlId]||g.type===o.PlaylistContextType.SUBTITLE_TRACK&&p.textGroupIds&&g.groupId===p.textGroupIds[p.urlId]))this.redundantFailover(this.currentLevelIndex);else{var r,i=!1,c=!0;switch(v.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(v.frag){var S=this._levels[v.frag.level];S?(S.fragmentError++,S.fragmentError>this.hls.config.fragLoadingMaxRetry&&(r=v.frag.level)):r=v.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:g&&(g.deliveryDirectives&&(c=!1),r=g.level),i=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:r=v.level,i=!0}r!==void 0&&this.recoverLevel(v,r,i,c)}}},n.recoverLevel=function(l,v,g,p){var r=l.details,i=this._levels[v];if(i.loadError++,g){if(!this.retryLoadingOrFail(l))return void(this.currentLevelIndex=-1);l.levelRetry=!0}if(p){var c=i.url.length;if(c>1&&i.loadError<c)l.levelRetry=!0,this.redundantFailover(v);else if(this.manualLevelIndex===-1){var S=v===0?this._levels.length-1:v-1;this.currentLevelIndex!==S&&this._levels[S].loadError===0&&(this.warn(r+": switch to "+S),l.levelRetry=!0,this.hls.nextAutoLevel=S)}}},n.redundantFailover=function(l){var v=this._levels[l],g=v.url.length;if(g>1){var p=(v.urlId+1)%g;this.warn("Switching to redundant URL-id "+p),this._levels.forEach(function(r){r.urlId=p}),this.level=l}},n.onFragLoaded=function(l,v){var g=v.frag;if(g!==void 0&&g.type===o.PlaylistLevelType.MAIN){var p=this._levels[g.level];p!==void 0&&(p.fragmentError=0,p.loadError=0)}},n.onLevelLoaded=function(l,v){var g,p,r=v.level,i=v.details,c=this._levels[r];if(!c)return this.warn("Invalid level index "+r),void((p=v.deliveryDirectives)!==null&&p!==void 0&&p.skip&&(i.deltaUpdateFailed=!0));r===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(r,v,c.details)):(g=v.deliveryDirectives)!==null&&g!==void 0&&g.skip&&(i.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(l,v){var g=this.hls.levels[this.currentLevelIndex];if(g&&g.audioGroupIds){for(var p=-1,r=this.hls.audioTracks[v.id].groupId,i=0;i<g.audioGroupIds.length;i++)if(g.audioGroupIds[i]===r){p=i;break}p!==g.urlId&&(g.urlId=p,this.startLoad())}},n.loadPlaylist=function(l){var v=this.currentLevelIndex,g=this._levels[v];if(this.canLoad&&g&&g.url.length>0){var p=g.urlId,r=g.url[p];if(l)try{r=l.addDirectives(r)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("Attempt loading level index "+v+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+p+" "+r),this.clearTimer(),this.hls.trigger(T.Events.LEVEL_LOADING,{url:r,level:v,id:p,deliveryDirectives:l||null})}},n.removeLevel=function(l,v){var g=function(r,i){return i!==v},p=this._levels.filter(function(r,i){return i!==l||r.url.length>1&&v!==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 c=r.details;return c!=null&&c.fragments&&c.fragments.forEach(function(S){S.level=i}),r});this._levels=p,this.hls.trigger(T.Events.LEVELS_UPDATED,{levels:p})},s=t,(u=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var v,g=this._levels;if(g.length!==0&&(this.currentLevelIndex!==l||(v=g[l])===null||v===void 0||!v.details)){if(l<0||l>=g.length){var p=l<0;if(this.hls.trigger(T.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:p,reason:"invalid level idx"}),p)return;l=Math.min(l,g.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=g[r],c=g[l];this.log("switching to level "+l+" from "+r),this.currentLevelIndex=l;var S=L({},c,{level:l,maxBitrate:c.maxBitrate,uri:c.uri,urlId:c.urlId});delete S._urlId,this.hls.trigger(T.Events.LEVEL_SWITCHING,S);var b=c.details;if(!b||b.live){var k=this.switchParams(c.uri,i==null?void 0:i.details);this.loadPlaylist(k)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}])&&m(s.prototype,u),t}(_.default)},"./src/controller/level-helper.ts":function(N,x,h){h.r(x),h.d(x,"addGroupId",function(){return A}),h.d(x,"assignTrackIdsByGroup",function(){return D}),h.d(x,"updatePTS",function(){return C}),h.d(x,"updateFragPTSDTS",function(){return o}),h.d(x,"mergeDetails",function(){return L}),h.d(x,"mapPartIntersection",function(){return m}),h.d(x,"mapFragmentIntersection",function(){return f}),h.d(x,"adjustSliding",function(){return E}),h.d(x,"addSliding",function(){return y}),h.d(x,"computeReloadInterval",function(){return d}),h.d(x,"getFragmentWithSN",function(){return e}),h.d(x,"getPartWith",function(){return a});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/logger.ts");function A(t,s,u){switch(s){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(u);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(u)}}function D(t){var s={};t.forEach(function(u){var n=u.groupId||"";u.id=s[n]=s[n]||0,s[n]++})}function C(t,s,u){_(t[s],t[u])}function _(t,s){var u=s.startPTS;if(Object(R.isFiniteNumber)(u)){var n,l=0;s.sn>t.sn?(l=u-t.start,n=t):(l=t.start-u,n=s),n.duration!==l&&(n.duration=l)}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,u,n,l,v){n-u<=0&&(T.logger.warn("Fragment should have a positive duration",s),n=u+s.duration,v=l+s.duration);var g=u,p=n,r=s.startPTS,i=s.endPTS;if(Object(R.isFiniteNumber)(r)){var c=Math.abs(r-u);Object(R.isFiniteNumber)(s.deltaPTS)?s.deltaPTS=Math.max(c,s.deltaPTS):s.deltaPTS=c,g=Math.max(u,r),u=Math.min(u,r),l=Math.min(l,s.startDTS),p=Math.min(n,i),n=Math.max(n,i),v=Math.max(v,s.endDTS)}s.duration=n-u;var S=u-s.start;s.appendedPTS=n,s.start=s.startPTS=u,s.maxStartPTS=g,s.startDTS=l,s.endPTS=n,s.minEndPTS=p,s.endDTS=v;var b,k=s.sn;if(!t||k<t.startSN||k>t.endSN)return 0;var I=k-t.startSN,w=t.fragments;for(w[I]=s,b=I;b>0;b--)_(w[b],w[b-1]);for(b=I;b<w.length-1;b++)_(w[b],w[b+1]);return t.fragmentHint&&_(w[w.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,S}function L(t,s){for(var u=null,n=t.fragments,l=n.length-1;l>=0;l--){var v=n[l].initSegment;if(v){u=v;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var g,p=0;if(f(t,s,function(k,I){var w;k.relurl&&(p=k.cc-I.cc),Object(R.isFiniteNumber)(k.startPTS)&&Object(R.isFiniteNumber)(k.endPTS)&&(I.start=I.startPTS=k.startPTS,I.startDTS=k.startDTS,I.appendedPTS=k.appendedPTS,I.maxStartPTS=k.maxStartPTS,I.endPTS=k.endPTS,I.endDTS=k.endDTS,I.minEndPTS=k.minEndPTS,I.duration=k.endPTS-k.startPTS,I.duration&&(g=I),s.PTSKnown=s.alignedSliding=!0),I.elementaryStreams=k.elementaryStreams,I.loader=k.loader,I.stats=k.stats,I.urlId=k.urlId,k.initSegment?(I.initSegment=k.initSegment,u=k.initSegment):I.initSegment&&I.initSegment.relurl!=((w=u)===null||w===void 0?void 0:w.relurl)||(I.initSegment=u)}),s.skippedSegments&&(s.deltaUpdateFailed=s.fragments.some(function(k){return!k}),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(p){T.logger.warn("discontinuity sliding from playlist, take drift into account");for(var c=0;c<i.length;c++)i[c].cc+=p}s.skippedSegments&&(s.startCC=s.fragments[0].cc),m(t.partList,s.partList,function(k,I){I.elementaryStreams=k.elementaryStreams,I.stats=k.stats}),g?o(s,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):E(t,s),i.length&&(s.totalduration=s.edge-i[0].start),s.driftStartTime=t.driftStartTime,s.driftStart=t.driftStart;var S=s.advancedDateTime;if(s.advanced&&S){var b=s.edge;s.driftStart||(s.driftStartTime=S,s.driftStart=b),s.driftEndTime=S,s.driftEnd=b}else s.driftEndTime=t.driftEndTime,s.driftEnd=t.driftEnd,s.advancedDateTime=t.advancedDateTime}function m(t,s,u){if(t&&s)for(var n=0,l=0,v=t.length;l<=v;l++){var g=t[l],p=s[l+n];g&&p&&g.index===p.index&&g.fragment.sn===p.fragment.sn?u(g,p):n--}}function f(t,s,u){for(var n=s.skippedSegments,l=Math.max(t.startSN,s.startSN)-s.startSN,v=(t.fragmentHint?1:0)+(n?s.endSN:Math.min(t.endSN,s.endSN))-s.startSN,g=s.startSN-t.startSN,p=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,r=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,i=l;i<=v;i++){var c=r[g+i],S=p[i];n&&!S&&i<n&&(S=s.fragments[i]=c),c&&S&&u(c,S)}}function E(t,s){var u=s.startSN+s.skippedSegments-t.startSN,n=t.fragments;u<0||u>=n.length||y(s,n[u].start)}function y(t,s){if(s){for(var u=t.fragments,n=t.skippedSegments;n<u.length;n++)u[n].start+=s;t.fragmentHint&&(t.fragmentHint.start+=s)}}function d(t,s){var u,n=1e3*t.levelTargetDuration,l=n/2,v=t.age,g=v>0&&v<3*n,p=s.loading.end-s.loading.start,r=t.availabilityDelay;if(t.updated===!1)if(g){var i=333*t.misses;u=Math.max(Math.min(l,2*p),i),t.availabilityDelay=(t.availabilityDelay||0)+u}else u=l;else g?(r=Math.min(r||n/2,v),t.availabilityDelay=r,u=r+n-v):u=n-p;return Math.round(u)}function e(t,s,u){if(!t||!t.details)return null;var n=t.details,l=n.fragments[s-n.startSN];return l||((l=n.fragmentHint)&&l.sn===s?l:s<n.startSN&&u&&u.sn===s?u:null)}function a(t,s,u){if(!t||!t.details)return null;var n=t.details.partList;if(n)for(var l=n.length;l--;){var v=n[l];if(v.index===u&&v.fragment.sn===s)return v}return null}},"./src/controller/stream-controller.ts":function(N,x,h){h.r(x),h.d(x,"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"),D=h("./src/events.ts"),C=h("./src/utils/buffer-helper.ts"),_=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"),E=h("./src/controller/gap-controller.ts"),y=h("./src/errors.ts"),d=h("./src/utils/logger.ts");function e(s,u){for(var n=0;n<u.length;n++){var l=u[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(s,l.key,l)}}function a(s,u){return(a=Object.setPrototypeOf||function(n,l){return n.__proto__=l,n})(s,u)}var t=function(s){var u,n;function l(r,i){var c;return(c=s.call(this,r,i,"[stream-controller]")||this).audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.stalled=!1,c.couldBacktrack=!1,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}n=s,(u=l).prototype=Object.create(n.prototype),u.prototype.constructor=u,a(u,n);var v,g,p=l.prototype;return p._registerListeners=function(){var r=this.hls;r.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(D.Events.ERROR,this.onError,this),r.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var r=this.hls;r.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(D.Events.ERROR,this.onError,this),r.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},p.startLoad=function(r){if(this.levels){var i=this.lastCurrentTime,c=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var S=c.startLevel;S===-1&&(c.config.testBandwidth?(S=0,this.bitrateTest=!0):S=c.nextAutoLevel),this.level=c.nextLoadLevel=S,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},p.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},p.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_LEVEL:var r,i=this.levels,c=this.level,S=i==null||(r=i[c])===null||r===void 0?void 0:r.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=T.State.IDLE;break}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,k=self.performance.now(),I=this.retryDate;(!I||k>=I||(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()},p.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},p.doTickIdle=function(){var r,i,c=this.hls,S=this.levelLastLoaded,b=this.levels,k=this.media,I=c.config,w=c.nextLoadLevel;if(S!==null&&(k||!this.startFragRequested&&I.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&b&&b[w]){var O=b[w];this.level=c.nextLoadLevel=w;var P=O.details;if(!P||this.state===T.State.WAITING_LEVEL||P.live&&this.levelLastLoaded!==w)this.state=T.State.WAITING_LEVEL;else{var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:k,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(D.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)===_.FragmentState.OK&&this.nextLoadPosition>B){var V=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(k,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))}}}},p.loadFragment=function(r,i,c){var S,b=this.fragmentTracker.getState(r);if(this.fragCurrent=r,b===_.FragmentState.BACKTRACKED){var k=this.fragmentTracker.getBacktrackData(r);if(k)return this._handleFragmentLoadProgress(k),void this._handleFragmentLoadComplete(k);b=_.FragmentState.NOT_LOADED}b===_.FragmentState.NOT_LOADED||b===_.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,c)):b===_.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},p.getAppendedFrag=function(r){var i=this.fragmentTracker.getAppendedFrag(r,o.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},p.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,o.PlaylistLevelType.MAIN)},p.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},p.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},p.nextLevelSwitch=function(){var r=this.levels,i=this.media;if(i!=null&&i.readyState){var c,S=this.getAppendedFrag(i.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!i.paused&&r){var b=r[this.hls.nextLoadLevel],k=this.fragLastKbps;c=k&&this.fragCurrent?this.fragCurrent.duration*b.maxBitrate/(1e3*k)+1:0}else c=0;var I=this.getBufferedFrag(i.currentTime+c);if(I){var w=this.followingBufferedFrag(I);if(w){this.abortCurrentFrag();var O=w.maxStartPTS?w.maxStartPTS:w.start,P=w.duration,F=Math.max(I.end,O+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},p.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()},p.flushMainBuffer=function(r,i){s.prototype.flushMainBuffer.call(this,r,i,this.altAudio?"video":null)},p.onMediaAttached=function(r,i){s.prototype.onMediaAttached.call(this,r,i);var c=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),c.addEventListener("playing",this.onvplaying),c.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,c,this.fragmentTracker,this.hls)},p.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)},p.onMediaPlaying=function(){this.tick()},p.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()},p.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(D.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},p.onManifestParsed=function(r,i){var c,S=!1,b=!1;i.levels.forEach(function(k){(c=k.audioCodec)&&(c.indexOf("mp4a.40.2")!==-1&&(S=!0),c.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=S&&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},p.onLevelLoading=function(r,i){var c=this.levels;if(c&&this.state===T.State.IDLE){var S=c[i.level];(!S.details||S.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(S.details))&&(this.state=T.State.WAITING_LEVEL)}},p.onLevelLoaded=function(r,i){var c,S=this.levels,b=i.level,k=i.details,I=k.totalduration;if(S){this.log("Level "+b+" loaded ["+k.startSN+","+k.endSN+"], cc ["+k.startCC+", "+k.endCC+"] duration:"+I);var w=this.fragCurrent;!w||this.state!==T.State.FRAG_LOADING&&this.state!==T.State.FRAG_LOADING_WAITING_RETRY||w.level!==i.level&&w.loader&&(this.state=T.State.IDLE,w.loader.abort());var O=S[b],P=0;if(k.live||(c=O.details)!==null&&c!==void 0&&c.live){if(k.fragments[0]||(k.deltaUpdateFailed=!0),k.deltaUpdateFailed)return;P=this.alignPlaylists(k,O.details)}if(O.details=k,this.levelLastLoaded=b,this.hls.trigger(D.Events.LEVEL_UPDATED,{details:k,level:b}),this.state===T.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(k))return;this.state=T.State.IDLE}this.startFragRequested?k.live&&this.synchronizeToLiveEdge(k):this.setStartPosition(k,P),this.tick()}else this.warn("Levels were reset while loading level "+b)},p._handleFragmentLoadProgress=function(r){var i,c=r.frag,S=r.part,b=r.payload,k=this.levels;if(k){var I=k[c.level],w=I.details;if(w){var O=I.videoCodec,P=w.PTSKnown||!w.live,F=(i=c.initSegment)===null||i===void 0?void 0:i.data,M=this._getAudioCodec(I),B=this.transmuxer=this.transmuxer||new m.default(this.hls,o.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=S?S.index:-1,j=U!==-1,V=new f.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,b.byteLength,U,j),H=this.initPTS[c.cc];B.push(b,F,M,O,c,S,w.totalduration,P,V,H)}else this.warn("Dropping fragment "+c.sn+" of level "+c.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+c.sn+" of level "+c.level+" will not be buffered")},p.onAudioTrackSwitching=function(r,i){var c=this.altAudio,S=!!i.url,b=i.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var k=this.fragCurrent;k!=null&&k.loader&&(this.log("Switching to main audio track, cancel main fragment load"),k.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var I=this.hls;c&&I.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),I.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:b})}},p.onAudioTrackSwitched=function(r,i){var c=i.id,S=!!this.hls.audioTracks[c].url;if(S){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=S,this.tick()},p.onBufferCreated=function(r,i){var c,S,b=i.tracks,k=!1;for(var I in b){var w=b[I];if(w.id==="main"){if(S=I,c=w,I==="video"){var O=b[I];O&&(this.videoBuffer=O.buffer)}}else k=!0}k&&c?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=c.buffer):this.mediaBuffer=this.media},p.onFragBuffered=function(r,i){var c=i.frag,S=i.part;if(!c||c.type===o.PlaylistLevelType.MAIN){if(this.fragContextChanged(c))return this.warn("Fragment "+c.sn+(S?" p: "+S.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===T.State.PARSED&&(this.state=T.State.IDLE));var b=S?S.stats:c.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),c.sn!=="initSegment"&&(this.fragPrevious=c),this.fragBufferedComplete(c,S)}},p.onError=function(r,i){switch(i.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(o.PlaylistLevelType.MAIN,i);break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.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 y.ErrorDetails.BUFFER_FULL_ERROR:if(i.parent==="main"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)){var c=!0,S=this.getFwdBufferInfo(this.media,o.PlaylistLevelType.MAIN);S&&S.len>.5&&(c=!this.reduceMaxBufferLength(S.len)),c&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},p.checkBuffer=function(){var r=this.media,i=this.gapController;if(r&&i&&r.readyState){var c=C.BufferHelper.getBuffered(r);!this.loadedmetadata&&c.length?(this.loadedmetadata=!0,this.seekToStartPos()):i.poll(this.lastCurrentTime),this.lastCurrentTime=r.currentTime}},p.onFragLoadEmergencyAborted=function(){this.state=T.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},p.onBufferFlushed=function(r,i){var c=i.type;if(c!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(c===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,c,o.PlaylistLevelType.MAIN)}},p.onLevelsUpdated=function(r,i){this.levels=i.levels},p.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},p.seekToStartPos=function(){var r=this.media,i=r.currentTime,c=this.startPosition;if(c>=0&&i<c){if(r.seeking)return void d.logger.log("could not seek to "+c+", already seeking at "+i);var S=C.BufferHelper.getBuffered(r),b=(S.length?S.start(0):0)-c;b>0&&b<this.config.maxBufferHole&&(d.logger.log("adjusting start position by "+b+" to match buffer start"),c+=b,this.startPosition=c),this.log("seek to target start position "+c+" from current time "+i),r.currentTime=c}},p._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},p._loadBitrateTestFrag=function(r){var i=this;this._doFragLoad(r).then(function(c){var S=i.hls;if(c&&!S.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(),S.trigger(D.Events.FRAG_LOADED,c)}})},p._handleTransmuxComplete=function(r){var i,c="main",S=this.hls,b=r.remuxResult,k=r.chunkMeta,I=this.getCurrentContext(k);if(!I)return this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(k.level);var w=I.frag,O=I.part,P=I.level,F=b.video,M=b.text,B=b.id3,U=b.initSegment,j=this.altAudio?void 0:b.audio;if(!this.fragContextChanged(w)){if(this.state=T.State.PARSING,U){U.tracks&&(this._bufferInitSegment(P,U.tracks,w,k),S.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:c,tracks:U.tracks}));var V=U.initPTS,H=U.timescale;Object(R.isFiniteNumber)(V)&&(this.initPTS[w.cc]=V,S.trigger(D.Events.INIT_PTS_FOUND,{frag:w,id:c,initPTS:V,timescale:H}))}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(w);w.setElementaryStreamInfo(F.type,w.start,q,w.start,ie,!0)}w.setElementaryStreamInfo(F.type,X,q,$,ie),this.bufferFragmentData(F,w,O,k)}}else if(b.independent===!1)return void this.backtrack(w);if(j){var se=j.startPTS,le=j.endPTS,re=j.startDTS,fe=j.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:le,startDTS:re,endDTS:fe}),w.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,se,le,re,fe),this.bufferFragmentData(j,w,O,k)}if(B!=null&&(i=B.samples)!==null&&i!==void 0&&i.length){var te={frag:w,id:c,samples:B.samples};S.trigger(D.Events.FRAG_PARSING_METADATA,te)}if(M){var ne={frag:w,id:c,samples:M.samples};S.trigger(D.Events.FRAG_PARSING_USERDATA,ne)}}},p._bufferInitSegment=function(r,i,c,S){var b=this;if(this.state===T.State.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var k=i.audio,I=i.video,w=i.audiovideo;if(k){var O=r.audioCodec,P=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(O&&(O=O.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),k.metadata.channelCount!==1&&P.indexOf("firefox")===-1&&(O="mp4a.40.5")),P.indexOf("android")!==-1&&k.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+'"'),k.levelCodec=O,k.id="main",this.log("Init audio buffer, container:"+k.container+", codecs[selected/level/parsed]=["+(O||"")+"/"+(r.audioCodec||"")+"/"+k.codec+"]")}I&&(I.levelCodec=r.videoCodec,I.id="main",this.log("Init video buffer, container:"+I.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+I.codec+"]")),w&&this.log("Init audiovideo buffer, container:"+w.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+w.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,i),Object.keys(i).forEach(function(F){var M=i[F].initSegment;M!=null&&M.byteLength&&b.hls.trigger(D.Events.BUFFER_APPENDING,{type:F,data:M,frag:c,part:null,chunkMeta:S,parent:c.type})}),this.tick()}},p.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},p.checkFragmentChanged=function(){var r=this.media,i=null;if(r&&r.readyState>1&&r.seeking===!1){var c=r.currentTime;if(C.BufferHelper.isBuffered(r,c)?i=this.getAppendedFrag(c):C.BufferHelper.isBuffered(r,c+.1)&&(i=this.getAppendedFrag(c+.1)),i){var S=this.fragPlaying,b=i.level;S&&i.sn===S.sn&&S.level===b&&i.urlId===S.urlId||(this.hls.trigger(D.Events.FRAG_CHANGED,{frag:i}),S&&S.level===b||this.hls.trigger(D.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=i)}}},v=l,(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(v.prototype,g),l}(T.default)},"./src/controller/subtitle-stream-controller.ts":function(N,x,h){h.r(x),h.d(x,"SubtitleStreamController",function(){return d});var R=h("./src/events.ts"),T=h("./src/utils/logger.ts"),A=h("./src/utils/buffer-helper.ts"),D=h("./src/controller/fragment-finders.ts"),C=h("./src/utils/discontinuities.ts"),_=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 E(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 y(e,a){return(y=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t})(e,a)}var d=function(e){var a,t;function s(v,g){var p;return(p=e.call(this,v,g,"[subtitle-stream-controller]")||this).levels=[],p.currentTrackId=-1,p.tracksBuffered=[],p.mainDetails=null,p._registerListeners(),p}t=e,(a=s).prototype=Object.create(t.prototype),a.prototype.constructor=a,y(a,t);var u,n,l=s.prototype;return l.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},l._registerListeners=function(){var v=this.hls;v.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(R.Events.ERROR,this.onError,this),v.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),v.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),v.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l._unregisterListeners=function(){var v=this.hls;v.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(R.Events.ERROR,this.onError,this),v.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),v.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),v.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l.startLoad=function(){this.stopLoad(),this.state=L.State.IDLE,this.setInterval(500),this.tick()},l.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},l.onLevelLoaded=function(v,g){this.mainDetails=g.details},l.onSubtitleFragProcessed=function(v,g){var p=g.frag,r=g.success;if(this.fragPrevious=p,this.state=L.State.IDLE,r){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var c,S=p.start,b=0;b<i.length;b++)if(S>=i[b].start&&S<=i[b].end){c=i[b];break}var k=p.start+p.duration;c?c.end=k:(c={start:S,end:k},i.push(c)),this.fragmentTracker.fragBuffered(p)}}},l.onBufferFlushing=function(v,g){var p=g.startOffset,r=g.endOffset;if(p===0&&r!==Number.POSITIVE_INFINITY){var i=this.currentTrackId,c=this.levels;if(!c.length||!c[i]||!c[i].details)return;var S=r-c[i].details.targetduration;if(S<=0)return;g.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(b){for(var k=0;k<b.length;)if(b[k].end<=S)b.shift();else{if(!(b[k].start<S))break;b[k].start=S,k++}}),this.fragmentTracker.removeFragmentsInRange(p,S,m.PlaylistLevelType.SUBTITLE)}},l.onError=function(v,g){var p,r=g.frag;r&&r.type===m.PlaylistLevelType.SUBTITLE&&((p=this.fragCurrent)!==null&&p!==void 0&&p.loader&&this.fragCurrent.loader.abort(),this.state=L.State.IDLE)},l.onSubtitleTracksUpdated=function(v,g){var p=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){p.tracksBuffered[i.id]=[]}),this.mediaBuffer=null},l.onSubtitleTrackSwitch=function(v,g){if(this.currentTrackId=g.id,this.levels.length&&this.currentTrackId!==-1){var p=this.levels[this.currentTrackId];p!=null&&p.details?(this.mediaBuffer=this.mediaBufferTimeRanges,this.setInterval(500)):this.mediaBuffer=null}else this.clearInterval()},l.onSubtitleTrackLoaded=function(v,g){var p,r=g.details,i=g.id,c=this.currentTrackId,S=this.levels;if(S.length){var b=S[c];if(!(i>=S.length||i!==c)&&b){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||(p=b.details)!==null&&p!==void 0&&p.live){var k=this.mainDetails;if(r.deltaUpdateFailed||!k)return;var I=k.fragments[0];b.details?this.alignPlaylists(r,b.details)===0&&I&&Object(_.addSliding)(r,I.start):r.hasProgramDateTime&&k.hasProgramDateTime?Object(C.alignPDT)(r,k):I&&Object(_.addSliding)(r,I.start)}b.details=r,this.levelLastLoaded=i,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE&&(Object(D.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0))}}},l._handleFragmentLoadComplete=function(v){var g=v.frag,p=v.payload,r=g.decryptdata,i=this.hls;if(!this.fragContextChanged(g)&&p&&p.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){var c=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(p),r.key.buffer,r.iv.buffer).then(function(S){var b=performance.now();i.trigger(R.Events.FRAG_DECRYPTED,{frag:g,payload:S,stats:{tstart:c,tdecrypt:b}})})}},l.doTick=function(){if(this.media){if(this.state===L.State.IDLE){var v,g=this.currentTrackId,p=this.levels;if(!p.length||!p[g]||!p[g].details)return;var r=p[g].details,i=r.targetduration,c=this.config,S=this.media,b=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,S.currentTime-i,c.maxBufferHole),k=b.end;if(b.len>this.getMaxBufferLength()+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var I,w=r.fragments,O=w.length,P=r.edge,F=this.fragPrevious;if(k<P){var M=c.maxFragLookUpTolerance;F&&r.hasProgramDateTime&&(I=Object(D.findFragmentByPDT)(w,F.endProgramDateTime,M)),I||!(I=Object(D.findFragmentByPTS)(F,w,k,M))&&F&&F.start<w[0].start&&(I=w[0])}else I=w[O-1];(v=I)!==null&&v!==void 0&&v.encrypted?(T.logger.log("Loading key for "+I.sn),this.state=L.State.KEY_LOADING,this.hls.trigger(R.Events.KEY_LOADING,{frag:I})):I&&this.fragmentTracker.getState(I)===o.FragmentState.NOT_LOADED&&this.loadFragment(I,r,k)}}else this.state=L.State.IDLE},l.loadFragment=function(v,g,p){this.fragCurrent=v,e.prototype.loadFragment.call(this,v,g,p)},u=s,(n=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&E(u.prototype,n),s}(L.default)},"./src/controller/subtitle-track-controller.ts":function(N,x,h){h.r(x);var R=h("./src/events.ts"),T=h("./src/utils/texttrack-utils.ts"),A=h("./src/controller/base-playlist-controller.ts"),D=h("./src/types/loader.ts");function C(m,f){for(var E=0;E<f.length;E++){var y=f[E];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(m,y.key,y)}}function _(m,f){return(_=Object.setPrototypeOf||function(E,y){return E.__proto__=y,E})(m,f)}var o=function(m){var f,E;function y(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}E=m,(f=y).prototype=Object.create(E.prototype),f.prototype.constructor=f,_(f,E);var d,e,a=y.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 u=s.id,n=s.details,l=this.trackId,v=this.tracksInGroup[l];if(v){var g=v.details;v.details=s.details,this.log("subtitle track "+u+" loaded ["+n.startSN+"-"+n.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,g))}else this.warn("Invalid subtitle track id "+u)},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 u=s.textGroupIds[s.urlId];if(this.groupId!==u){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(p){return!u||p.groupId===u});this.tracksInGroup=l;var v=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=u;var g={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,g),v!==-1&&this.setSubtitleTrack(v,n)}}},a.findTrackId=function(t){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var n=s[u];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===D.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 u=s.id,n=s.groupId,l=s.url;if(t)try{l=t.addDirectives(l)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:l,id:u,groupId:n,deliveryDirectives:t||null})}},a.toggleTrackModes=function(t){var s=this,u=this.media,n=this.subtitleDisplay,l=this.trackId;if(u){var v=L(u.textTracks),g=v.filter(function(i){return i.groupId===s.groupId});if(t===-1)[].slice.call(v).forEach(function(i){i.mode="disabled"});else{var p=g[l];p&&(p.mode="disabled")}var r=g[t];r&&(r.mode=n?"showing":"hidden")}},a.setSubtitleTrack=function(t,s){var u,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(u=n[t])!==null&&u!==void 0&&u.details)||t<-1||t>=n.length)){this.clearTimer();var l=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,l){var v=l.id,g=l.groupId,p=g===void 0?"":g,r=l.name,i=l.type,c=l.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:p,name:r,type:i,url:c});var S=this.switchParams(l.url,s==null?void 0:s.details);this.loadPlaylist(S)}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),u=0;u<s.length;u++)if(s[u].mode==="hidden")t=u;else if(s[u].mode==="showing"){t=u;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},d=y,(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)}}])&&C(d.prototype,e),y}(A.default);function L(m){for(var f=[],E=0;E<m.length;E++){var y=m[E];y.kind==="subtitles"&&y.label&&f.push(m[E])}return f}x.default=o},"./src/controller/timeline-controller.ts":function(N,x,h){h.r(x),h.d(x,"TimelineController",function(){return f});var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/utils/cea-608-parser.ts"),D=h("./src/utils/output-filter.ts"),C=h("./src/utils/webvtt-parser.ts"),_=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 y(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 D.default(this,"textTrack1"),t=new D.default(this,"textTrack2"),s=new D.default(this,"textTrack3"),u=new D.default(this,"textTrack4");this.cea608Parser1=new A.default(1,a,t),this.cea608Parser2=new A.default(3,s,u)}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 d=y.prototype;return d.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},d.addCues=function(e,a,t,s,u){for(var n,l,v,g,p=!1,r=u.length;r--;){var i=u[r],c=(n=i[0],l=i[1],v=a,g=t,Math.min(l,g)-Math.max(n,v));if(c>=0&&(i[0]=Math.min(i[0],a),i[1]=Math.max(i[1],t),p=!0,c/(t-a)>.5))return}if(p||u.push([a,t]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,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})}},d.onInitPtsFound=function(e,a){var t=this,s=a.frag,u=a.id,n=a.initPTS,l=a.timescale,v=this.unparsedVttFrags;u==="main"&&(this.initPTS[s.cc]=n,this.timescale[s.cc]=l),v.length&&(this.unparsedVttFrags=[],v.forEach(function(g){t.onFragLoaded(T.Events.FRAG_LOADED,g)}))},d.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},d.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},d.createNativeTrack=function(e){if(!this.captionsTracks[e]){var a=this.captionsProperties,t=this.captionsTracks,s=this.media,u=a[e],n=u.label,l=u.languageCode,v=this.getExistingTrack(e);if(v)t[e]=v,Object(_.clearCurrentCues)(t[e]),Object(_.sendAddTrackEvent)(t[e],s);else{var g=this.createTextTrack("captions",n,l);g&&(g[e]=!0,t[e]=g)}}},d.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]})}}},d.createTextTrack=function(e,a,t){var s=this.media;if(s)return s.addTextTrack(e,a,t)},d.onMediaAttaching=function(e,a){this.media=a.media,this._cleanTracks()},d.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(a){Object(_.clearCurrentCues)(e[a]),delete e[a]}),this.nonNativeCaptionsTracks={}},d.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())},d._cleanTracks=function(){var e=this.media;if(e){var a=e.textTracks;if(a)for(var t=0;t<a.length;t++)Object(_.clearCurrentCues)(a[t])}},d.onSubtitleTracksUpdated=function(e,a){var t=this;this.textTracks=[];var s=a.subtitleTracks||[],u=s.some(function(g){return g.textCodec===o.IMSC1_CODEC});if(this.config.enableWebVTT||u&&this.config.enableIMSC1){var n=this.tracks&&s&&this.tracks.length===s.length;if(this.tracks=s||[],this.config.renderTextTracksNatively){var l=this.media?this.media.textTracks:[];this.tracks.forEach(function(g,p){var r;if(p<l.length){for(var i=null,c=0;c<l.length;c++)if(E(l[c],g)){i=l[c];break}i&&(r=i)}r?Object(_.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 v=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:v})}}},d.onManifestLoaded=function(e,a){var t=this;this.config.enableCEA708Captions&&a.captions&&a.captions.forEach(function(s){var u=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(u){var n="textTrack"+u[1],l=t.captionsProperties[n];l&&(l.label=s.name,s.lang&&(l.languageCode=s.lang),l.media=s)}})},d.onFragLoading=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2,u=this.lastSn;if(this.enabled&&t&&s&&a.frag.type===L.PlaylistLevelType.MAIN){var n=a.frag.sn;n!==u+1&&(t.reset(),s.reset()),this.lastSn=n}},d.onFragLoaded=function(e,a){var t=a.frag,s=a.payload,u=this.initPTS,n=this.unparsedVttFrags;if(t.type===L.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(R.isFiniteNumber)(u[t.cc]))return n.push(a),void(u.length&&this.hls.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")}));var l=t.decryptdata;if(l==null||l.key==null||l.method!=="AES-128"){var v=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),v&&v.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")})},d._parseIMSC1=function(e,a){var t=this,s=this.hls;Object(o.parseIMSC1)(a,this.initPTS[e.cc],this.timescale[e.cc],function(u){t._appendCues(u,e.level),s.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(u){m.logger.log("Failed to parse IMSC1: "+u),s.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:u})})},d._parseVTTs=function(e,a,t){var s=this,u=this.hls;Object(C.parseWebVTT)(a,this.initPTS[e.cc],this.timescale[e.cc],t,e.cc,e.start,function(n){s._appendCues(n,e.level),u.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),u.trigger(T.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})},d._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"})},d._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(_.addCueToTrack)(s,n)})}else{var u=this.tracks[a].default?"default":"subtitles"+a;t.trigger(T.Events.CUES_PARSED,{type:"subtitles",cues:e,track:u})}},d.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)}},d.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},d.onFragParsingUserdata=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2;if(this.enabled&&t&&s)for(var u=0;u<a.samples.length;u++){var n=a.samples[u].bytes;if(n){var l=this.extractCea608Data(n);t.addData(a.samples[u].pts,l[0]),s.addData(a.samples[u].pts,l[1])}}},d.onBufferFlushing=function(e,a){var t=a.startOffset,s=a.endOffset,u=a.endOffsetSubtitles,n=a.type,l=this.media;if(l&&!(l.currentTime<s)){if(!n||n==="video"){var v=this.captionsTracks;Object.keys(v).forEach(function(p){return Object(_.removeCuesInRange)(v[p],t,s)})}if(this.config.renderTextTracksNatively&&t===0&&u!==void 0){var g=this.textTracks;Object.keys(g).forEach(function(p){return Object(_.removeCuesInRange)(g[p],t,u)})}}},d.extractCea608Data=function(e){for(var a=31&e[0],t=2,s=[[],[]],u=0;u<a;u++){var n=e[t++],l=127&e[t++],v=127&e[t++],g=3&n;l===0&&v===0||4&n&&(g!==0&&g!==1||(s[g].push(l),s[g].push(v)))}return s},y}();function E(y,d){return y&&y.label===d.name&&!(y.textTrack1||y.textTrack2)}},"./src/crypt/aes-crypto.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return R});var R=function(){function T(A,D){this.subtle=void 0,this.aesIV=void 0,this.subtle=A,this.aesIV=D}return T.prototype.decrypt=function(A,D){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},D,A)},T}()},"./src/crypt/aes-decryptor.ts":function(N,x,h){h.r(x),h.d(x,"removePadding",function(){return T}),h.d(x,"default",function(){return A});var R=h("./src/utils/typed-array.ts");function T(D){var C=D.byteLength,_=C&&new DataView(D.buffer).getUint8(C-1);return _?Object(R.sliceUint8)(D,0,C-_):D}var A=function(){function D(){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 C=D.prototype;return C.uint8ArrayToUint32Array_=function(_){for(var o=new DataView(_),L=new Uint32Array(4),m=0;m<4;m++)L[m]=o.getUint32(4*m);return L},C.initTable=function(){var _=this.sBox,o=this.invSBox,L=this.subMix,m=L[0],f=L[1],E=L[2],y=L[3],d=this.invSubMix,e=d[0],a=d[1],t=d[2],s=d[3],u=new Uint32Array(256),n=0,l=0,v=0;for(v=0;v<256;v++)u[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var g=l^l<<1^l<<2^l<<3^l<<4;g=g>>>8^255&g^99,_[n]=g,o[g]=n;var p=u[n],r=u[p],i=u[r],c=257*u[g]^16843008*g;m[n]=c<<24|c>>>8,f[n]=c<<16|c>>>16,E[n]=c<<8|c>>>24,y[n]=c,c=16843009*i^65537*r^257*p^16843008*n,e[g]=c<<24|c>>>8,a[g]=c<<16|c>>>16,t[g]=c<<8|c>>>24,s[g]=c,n?(n=p^u[u[u[i^p]]],l^=u[u[l]]):n=l=1}},C.expandKey=function(_){for(var o=this.uint8ArrayToUint32Array_(_),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 E,y,d,e,a=this.ksRows=4*(f+6+1),t=this.keySchedule=new Uint32Array(a),s=this.invKeySchedule=new Uint32Array(a),u=this.sBox,n=this.rcon,l=this.invSubMix,v=l[0],g=l[1],p=l[2],r=l[3];for(E=0;E<a;E++)E<f?d=t[E]=o[E]:(e=d,E%f==0?(e=u[(e=e<<8|e>>>24)>>>24]<<24|u[e>>>16&255]<<16|u[e>>>8&255]<<8|u[255&e],e^=n[E/f|0]<<24):f>6&&E%f==4&&(e=u[e>>>24]<<24|u[e>>>16&255]<<16|u[e>>>8&255]<<8|u[255&e]),t[E]=d=(t[E-f]^e)>>>0);for(y=0;y<a;y++)E=a-y,e=3&y?t[E]:t[E-4],s[y]=y<4||E<=4?e:v[u[e>>>24]]^g[u[e>>>16&255]]^p[u[e>>>8&255]]^r[u[255&e]],s[y]=s[y]>>>0}},C.networkToHostOrderSwap=function(_){return _<<24|(65280&_)<<8|(16711680&_)>>8|_>>>24},C.decrypt=function(_,o,L){for(var m,f,E,y,d,e,a,t,s,u,n,l,v,g,p=this.keySize+6,r=this.invKeySchedule,i=this.invSBox,c=this.invSubMix,S=c[0],b=c[1],k=c[2],I=c[3],w=this.uint8ArrayToUint32Array_(L),O=w[0],P=w[1],F=w[2],M=w[3],B=new Int32Array(_),U=new Int32Array(B.length),j=this.networkToHostOrderSwap;o<B.length;){for(s=j(B[o]),u=j(B[o+1]),n=j(B[o+2]),l=j(B[o+3]),d=s^r[0],e=l^r[1],a=n^r[2],t=u^r[3],v=4,g=1;g<p;g++)m=S[d>>>24]^b[e>>16&255]^k[a>>8&255]^I[255&t]^r[v],f=S[e>>>24]^b[a>>16&255]^k[t>>8&255]^I[255&d]^r[v+1],E=S[a>>>24]^b[t>>16&255]^k[d>>8&255]^I[255&e]^r[v+2],y=S[t>>>24]^b[d>>16&255]^k[e>>8&255]^I[255&a]^r[v+3],d=m,e=f,a=E,t=y,v+=4;m=i[d>>>24]<<24^i[e>>16&255]<<16^i[a>>8&255]<<8^i[255&t]^r[v],f=i[e>>>24]<<24^i[a>>16&255]<<16^i[t>>8&255]<<8^i[255&d]^r[v+1],E=i[a>>>24]<<24^i[t>>16&255]<<16^i[d>>8&255]<<8^i[255&e]^r[v+2],y=i[t>>>24]<<24^i[d>>16&255]<<16^i[e>>8&255]<<8^i[255&a]^r[v+3],U[o]=j(m^O),U[o+1]=j(y^P),U[o+2]=j(E^F),U[o+3]=j(f^M),O=s,P=u,F=n,M=l,o+=4}return U.buffer},D}()},"./src/crypt/decrypter.ts":function(N,x,h){h.r(x),h.d(x,"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"),D=h("./src/utils/logger.ts"),C=h("./src/utils/mp4-tools.ts"),_=h("./src/utils/typed-array.ts"),o=function(){function L(f,E,y){var d=(y===void 0?{}:y).removePKCS7Padding,e=d===void 0||d;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=E,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 E=new Uint8Array(f);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(E):E}this.reset()},m.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},m.decrypt=function(f,E,y,d){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(f),E,y);var e=this.flush();e&&d(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(f),E,y).then(d)},m.softwareDecrypt=function(f,E,y){var d=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(f=Object(C.appendUint8Array)(a,f),this.remainderData=null);var t=this.getValidChunk(f);if(!t.length)return null;d&&(y=d);var s=this.softwareDecrypter;s||(s=this.softwareDecrypter=new A.default),s.expandKey(E);var u=e;return this.currentResult=s.decrypt(t.buffer,0,y),this.currentIV=Object(_.sliceUint8)(t,-16).buffer,u||null},m.webCryptoDecrypt=function(f,E,y){var d=this,e=this.subtle;return this.key===E&&this.fastAesKey||(this.key=E,this.fastAesKey=new T.default(e,E)),this.fastAesKey.expandKey().then(function(a){return e?new R.default(e,y).decrypt(f.buffer,a):Promise.reject(new Error("web crypto not initialized"))}).catch(function(a){return d.onWebCryptoError(a,f,E,y)})},m.onWebCryptoError=function(f,E,y,d){return D.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",f),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,y,d)},m.getValidChunk=function(f){var E=f,y=f.length-f.length%16;return y!==f.length&&(E=Object(_.sliceUint8)(f,0,y),this.remainderData=Object(_.sliceUint8)(f,y)),E},m.logOnce=function(f){this.logEnabled&&(D.logger.log("[decrypter.ts]: "+f),this.logEnabled=!1)},L}()},"./src/crypt/fast-aes-key.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return R});var R=function(){function T(A,D){this.subtle=void 0,this.key=void 0,this.subtle=A,this.key=D}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,x,h){h.r(x);var R=h("./src/demux/base-audio-demuxer.ts"),T=h("./src/demux/adts.ts"),A=h("./src/utils/logger.ts"),D=h("./src/demux/id3.ts");function C(o,L){return(C=Object.setPrototypeOf||function(m,f){return m.__proto__=f,m})(o,L)}var _=function(o){var L,m;function f(y,d){var e;return(e=o.call(this)||this).observer=void 0,e.config=void 0,e.observer=y,e.config=d,e}m=o,(L=f).prototype=Object.create(m.prototype),L.prototype.constructor=L,C(L,m);var E=f.prototype;return E.resetInitSegment=function(y,d,e){o.prototype.resetInitSegment.call(this,y,d,e),this._audioTrack={container:"audio/adts",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},f.probe=function(y){if(!y)return!1;for(var d=(D.getID3Data(y,0)||[]).length,e=y.length;d<e;d++)if(T.probe(y,d))return A.logger.log("ADTS sync word found !"),!0;return!1},E.canParse=function(y,d){return T.canParse(y,d)},E.appendFrame=function(y,d,e){T.initTrackConfig(y,this.observer,d,e,y.manifestCodec);var a=T.appendFrame(y,d,e,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},f}(R.default);_.minProbeByteLength=9,x.default=_},"./src/demux/adts.ts":function(N,x,h){h.r(x),h.d(x,"getAudioConfig",function(){return D}),h.d(x,"isHeaderPattern",function(){return C}),h.d(x,"getHeaderLength",function(){return _}),h.d(x,"getFullFrameLength",function(){return o}),h.d(x,"canGetFrameLength",function(){return L}),h.d(x,"isHeader",function(){return m}),h.d(x,"canParse",function(){return f}),h.d(x,"probe",function(){return E}),h.d(x,"initTrackConfig",function(){return y}),h.d(x,"getFrameDuration",function(){return d}),h.d(x,"parseFrameHeader",function(){return e}),h.d(x,"appendFrame",function(){return a});var R=h("./src/utils/logger.ts"),T=h("./src/errors.ts"),A=h("./src/events.ts");function D(t,s,u,n){var l,v,g,p,r=navigator.userAgent.toLowerCase(),i=n,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];l=1+((192&s[u+2])>>>6);var S=(60&s[u+2])>>>2;if(!(S>c.length-1))return g=(1&s[u+2])<<2,g|=(192&s[u+3])>>>6,R.logger.log("manifest codec:"+n+", ADTS type:"+l+", samplingIndex:"+S),/firefox/i.test(r)?S>=6?(l=5,p=new Array(4),v=S-3):(l=2,p=new Array(2),v=S):r.indexOf("android")!==-1?(l=2,p=new Array(2),v=S):(l=5,p=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&S>=6?v=S-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(S>=6&&g===1||/vivaldi/i.test(r))||!n&&g===1)&&(l=2,p=new Array(2)),v=S)),p[0]=l<<3,p[0]|=(14&S)>>1,p[1]|=(1&S)<<7,p[1]|=g<<3,l===5&&(p[1]|=(14&v)>>1,p[2]=(1&v)<<7,p[2]|=8,p[3]=0),{config:p,samplerate:c[S],channelCount:g,codec:"mp4a.40."+l,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:"+S})}function C(t,s){return t[s]===255&&(246&t[s+1])==240}function _(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&&C(t,s)}function f(t,s){return L(t,s)&&C(t,s)&&o(t,s)<=t.length-s}function E(t,s){if(m(t,s)){var u=_(t,s);if(s+u>=t.length)return!1;var n=o(t,s);if(n<=u)return!1;var l=s+n;return l===t.length||m(t,l)}return!1}function y(t,s,u,n,l){if(!t.samplerate){var v=D(s,u,n,l);if(!v)return;t.config=v.config,t.samplerate=v.samplerate,t.channelCount=v.channelCount,t.codec=v.codec,t.manifestCodec=v.manifestCodec,R.logger.log("parsed codec:"+t.codec+", rate:"+v.samplerate+", channels:"+v.channelCount)}}function d(t){return 9216e4/t}function e(t,s,u,n,l){var v=_(t,s),g=o(t,s);if((g-=v)>0)return{headerLength:v,frameLength:g,stamp:u+n*l}}function a(t,s,u,n,l){var v=e(s,u,n,l,d(t.samplerate));if(v){var g,p=v.frameLength,r=v.headerLength,i=v.stamp,c=r+p,S=Math.max(0,u+c-s.length);S?(g=new Uint8Array(c-r)).set(s.subarray(u+r,s.length),0):g=s.subarray(u+r,u+c);var b={unit:g,pts:i};return S||t.samples.push(b),{sample:b,length:c,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(N,x,h){h.r(x),h.d(x,"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"),D=h("./src/utils/mp4-tools.ts"),C=h("./src/utils/typed-array.ts"),_=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,E,y){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,E){return!1},m.appendFrame=function(f,E,y){},m.demux=function(f,E){this.cachedData&&(f=Object(D.appendUint8Array)(this.cachedData,f),this.cachedData=null);var y,d,e=T.getID3Data(f,0),a=e?e.length:0,t=this._audioTrack,s=this._id3Track,u=e?T.getTimeStamp(e):void 0,n=f.length;for(this.frameIndex!==0&&this.initPTS!==null||(this.initPTS=o(u,E)),e&&e.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:e}),d=this.initPTS;a<n;){if(this.canParse(f,a)){var l=this.appendFrame(t,f,a);l?(this.frameIndex++,d=l.sample.pts,y=a+=l.length):a=n}else T.canParse(f,a)?(e=T.getID3Data(f,a),s.samples.push({pts:d,dts:d,data:e}),y=a+=e.length):a++;if(a===n&&y!==n){var v=Object(C.sliceUint8)(f,y);this.cachedData?this.cachedData=Object(D.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:t,avcTrack:Object(A.dummyTrack)(),id3Track:s,textTrack:Object(A.dummyTrack)()}},m.demuxSampleAes=function(f,E,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},m.flush=function(f){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,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};x.default=_},"./src/demux/chunk-cache.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return R});var R=function(){function T(){this.chunks=[],this.dataLength=0}var A=T.prototype;return A.push=function(D){this.chunks.push(D),this.dataLength+=D.length},A.flush=function(){var D,C=this.chunks,_=this.dataLength;return C.length?(D=C.length===1?C[0]:function(o,L){for(var m=new Uint8Array(L),f=0,E=0;E<o.length;E++){var y=o[E];m.set(y,f),f+=y.length}return m}(C,_),this.reset(),D):new Uint8Array(0)},A.reset=function(){this.chunks.length=0,this.dataLength=0},T}()},"./src/demux/dummy-demuxed-track.ts":function(N,x,h){function R(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}h.r(x),h.d(x,"dummyTrack",function(){return R})},"./src/demux/exp-golomb.ts":function(N,x,h){h.r(x);var R=h("./src/utils/logger.ts"),T=function(){function A(C){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=C,this.bytesAvailable=C.byteLength,this.word=0,this.bitsAvailable=0}var D=A.prototype;return D.loadWord=function(){var C=this.data,_=this.bytesAvailable,o=C.byteLength-_,L=new Uint8Array(4),m=Math.min(4,_);if(m===0)throw new Error("no bytes available");L.set(C.subarray(o,o+m)),this.word=new DataView(L.buffer).getUint32(0),this.bitsAvailable=8*m,this.bytesAvailable-=m},D.skipBits=function(C){var _;this.bitsAvailable>C?(this.word<<=C,this.bitsAvailable-=C):(C-=this.bitsAvailable,C-=(_=C>>3)>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=C,this.bitsAvailable-=C)},D.readBits=function(C){var _=Math.min(this.bitsAvailable,C),o=this.word>>>32-_;return C>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),(_=C-_)>0&&this.bitsAvailable?o<<_|this.readBits(_):o},D.skipLZ=function(){var C;for(C=0;C<this.bitsAvailable;++C)if(this.word&2147483648>>>C)return this.word<<=C,this.bitsAvailable-=C,C;return this.loadWord(),C+this.skipLZ()},D.skipUEG=function(){this.skipBits(1+this.skipLZ())},D.skipEG=function(){this.skipBits(1+this.skipLZ())},D.readUEG=function(){var C=this.skipLZ();return this.readBits(C+1)-1},D.readEG=function(){var C=this.readUEG();return 1&C?1+C>>>1:-1*(C>>>1)},D.readBoolean=function(){return this.readBits(1)===1},D.readUByte=function(){return this.readBits(8)},D.readUShort=function(){return this.readBits(16)},D.readUInt=function(){return this.readBits(32)},D.skipScalingList=function(C){for(var _=8,o=8,L=0;L<C;L++)o!==0&&(o=(_+this.readEG()+256)%256),_=o===0?_:o},D.readSPS=function(){var C,_,o,L=0,m=0,f=0,E=0,y=this.readUByte.bind(this),d=this.readBits.bind(this),e=this.readUEG.bind(this),a=this.readBoolean.bind(this),t=this.skipBits.bind(this),s=this.skipEG.bind(this),u=this.skipUEG.bind(this),n=this.skipScalingList.bind(this);y();var l=y();if(d(5),t(3),y(),u(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var v=e();if(v===3&&t(1),u(),u(),t(1),a())for(_=v!==3?8:12,o=0;o<_;o++)a()&&n(o<6?16:64)}u();var g=e();if(g===0)e();else if(g===1)for(t(1),s(),s(),C=e(),o=0;o<C;o++)s();u(),t(1);var p=e(),r=e(),i=d(1);i===0&&t(1),t(1),a()&&(L=e(),m=e(),f=e(),E=e());var c=[1,1];if(a()&&a())switch(y()){case 1:c=[1,1];break;case 2:c=[12,11];break;case 3:c=[10,11];break;case 4:c=[16,11];break;case 5:c=[40,33];break;case 6:c=[24,11];break;case 7:c=[20,11];break;case 8:c=[32,11];break;case 9:c=[80,33];break;case 10:c=[18,11];break;case 11:c=[15,11];break;case 12:c=[64,33];break;case 13:c=[160,99];break;case 14:c=[4,3];break;case 15:c=[3,2];break;case 16:c=[2,1];break;case 255:c=[y()<<8|y(),y()<<8|y()]}return{width:Math.ceil(16*(p+1)-2*L-2*m),height:(2-i)*(r+1)*16-(i?2:4)*(f+E),pixelRatio:c}},D.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();x.default=T},"./src/demux/id3.ts":function(N,x,h){h.r(x),h.d(x,"isHeader",function(){return T}),h.d(x,"isFooter",function(){return A}),h.d(x,"getID3Data",function(){return D}),h.d(x,"canParse",function(){return _}),h.d(x,"getTimeStamp",function(){return o}),h.d(x,"isTimeStampFrame",function(){return L}),h.d(x,"getID3Frames",function(){return f}),h.d(x,"decodeFrame",function(){return E}),h.d(x,"utf8ArrayToStr",function(){return t}),h.d(x,"testables",function(){return s});var R,T=function(u,n){return n+10<=u.length&&u[n]===73&&u[n+1]===68&&u[n+2]===51&&u[n+3]<255&&u[n+4]<255&&u[n+6]<128&&u[n+7]<128&&u[n+8]<128&&u[n+9]<128},A=function(u,n){return n+10<=u.length&&u[n]===51&&u[n+1]===68&&u[n+2]===73&&u[n+3]<255&&u[n+4]<255&&u[n+6]<128&&u[n+7]<128&&u[n+8]<128&&u[n+9]<128},D=function(u,n){for(var l=n,v=0;T(u,n);)v+=10,v+=C(u,n+6),A(u,n+10)&&(v+=10),n+=v;if(v>0)return u.subarray(l,l+v)},C=function(u,n){var l=0;return l=(127&u[n])<<21,l|=(127&u[n+1])<<14,l|=(127&u[n+2])<<7,l|=127&u[n+3]},_=function(u,n){return T(u,n)&&C(u,n+6)+10<=u.length-n},o=function(u){for(var n=f(u),l=0;l<n.length;l++){var v=n[l];if(L(v))return a(v)}},L=function(u){return u&&u.key==="PRIV"&&u.info==="com.apple.streaming.transportStreamTimestamp"},m=function(u){var n=String.fromCharCode(u[0],u[1],u[2],u[3]),l=C(u,4);return{type:n,size:l,data:u.subarray(10,10+l)}},f=function(u){for(var n=0,l=[];T(u,n);){for(var v=C(u,n+6),g=(n+=10)+v;n+8<g;){var p=m(u.subarray(n)),r=E(p);r&&l.push(r),n+=p.size+10}A(u,n)&&(n+=10)}return l},E=function(u){return u.type==="PRIV"?y(u):u.type[0]==="W"?e(u):d(u)},y=function(u){if(!(u.size<2)){var n=t(u.data,!0),l=new Uint8Array(u.data.subarray(n.length+1));return{key:u.type,info:n,data:l.buffer}}},d=function(u){if(!(u.size<2)){if(u.type==="TXXX"){var n=1,l=t(u.data.subarray(n),!0);n+=l.length+1;var v=t(u.data.subarray(n));return{key:u.type,info:l,data:v}}var g=t(u.data.subarray(1));return{key:u.type,data:g}}},e=function(u){if(u.type==="WXXX"){if(u.size<2)return;var n=1,l=t(u.data.subarray(n),!0);n+=l.length+1;var v=t(u.data.subarray(n));return{key:u.type,info:l,data:v}}var g=t(u.data);return{key:u.type,data:g}},a=function(u){if(u.data.byteLength===8){var n=new Uint8Array(u.data),l=1&n[3],v=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return v/=45,l&&(v+=4772185884e-2),Math.round(v)}},t=function(u,n){n===void 0&&(n=!1);var l=(R||self.TextDecoder===void 0||(R=new self.TextDecoder("utf-8")),R);if(l){var v=l.decode(u);if(n){var g=v.indexOf("\0");return g!==-1?v.substring(0,g):v}return v.replace(/\0/g,"")}for(var p,r,i,c=u.length,S="",b=0;b<c;){if((p=u[b++])===0&&n)return S;if(p!==0&&p!==3)switch(p>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(p);break;case 12:case 13:r=u[b++],S+=String.fromCharCode((31&p)<<6|63&r);break;case 14:r=u[b++],i=u[b++],S+=String.fromCharCode((15&p)<<12|(63&r)<<6|(63&i)<<0)}}return S},s={decodeTextFrame:d}},"./src/demux/mp3demuxer.ts":function(N,x,h){h.r(x);var R=h("./src/demux/base-audio-demuxer.ts"),T=h("./src/demux/id3.ts"),A=h("./src/utils/logger.ts"),D=h("./src/demux/mpegaudio.ts");function C(o,L){return(C=Object.setPrototypeOf||function(m,f){return m.__proto__=f,m})(o,L)}var _=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,C(L,m);var E=f.prototype;return E.resetInitSegment=function(y,d,e){o.prototype.resetInitSegment.call(this,y,d,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},f.probe=function(y){if(!y)return!1;for(var d=(T.getID3Data(y,0)||[]).length,e=y.length;d<e;d++)if(D.probe(y,d))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},E.canParse=function(y,d){return D.canParse(y,d)},E.appendFrame=function(y,d,e){if(this.initPTS!==null)return D.appendFrame(y,d,e,this.initPTS,this.frameIndex)},f}(R.default);_.minProbeByteLength=4,x.default=_},"./src/demux/mp4demuxer.ts":function(N,x,h){h.r(x);var R=h("./src/utils/mp4-tools.ts"),T=h("./src/demux/dummy-demuxed-track.ts"),A=function(){function D(_,o){this.remainderData=null,this.config=void 0,this.config=o}var C=D.prototype;return C.resetTimeStamp=function(){},C.resetInitSegment=function(){},C.resetContiguity=function(){},D.probe=function(_){return Object(R.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},C.demux=function(_){var o=_,L=Object(T.dummyTrack)();if(this.config.progressive){this.remainderData&&(o=Object(R.appendUint8Array)(this.remainderData,_));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)()}},C.flush=function(){var _=Object(T.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(T.dummyTrack)(),avcTrack:_,id3Track:Object(T.dummyTrack)(),textTrack:Object(T.dummyTrack)()}},C.demuxSampleAes=function(_,o,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},C.destroy=function(){},D}();A.minProbeByteLength=1024,x.default=A},"./src/demux/mpegaudio.ts":function(N,x,h){h.r(x),h.d(x,"appendFrame",function(){return _}),h.d(x,"parseHeader",function(){return o}),h.d(x,"isHeaderPattern",function(){return L}),h.d(x,"isHeader",function(){return m}),h.d(x,"canParse",function(){return f}),h.d(x,"probe",function(){return E});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],D=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],C=[0,1,1,4];function _(y,d,e,a,t){if(!(e+24>d.length)){var s=o(d,e);if(s&&e+s.frameLength<=d.length){var u=a+t*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:d.subarray(e,e+s.frameLength),pts:u,dts:u};return y.config=[],y.channelCount=s.channelCount,y.samplerate=s.sampleRate,y.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}}function o(y,d){var e=y[d+1]>>3&3,a=y[d+1]>>1&3,t=y[d+2]>>4&15,s=y[d+2]>>2&3;if(e!==1&&t!==0&&t!==15&&s!==3){var u=y[d+2]>>1&1,n=y[d+3]>>6,l=1e3*T[14*(e===3?3-a:a===3?3:4)+t-1],v=A[3*(e===3?0:e===2?1:2)+s],g=n===3?1:2,p=D[e][a],r=C[a],i=8*p*r,c=Math.floor(p*l/v+u)*r;if(R===null){var S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);R=S?parseInt(S[1]):0}return R&&R<=87&&a===2&&l>=224e3&&n===0&&(y[d+3]=128|y[d+3]),{sampleRate:v,channelCount:g,frameLength:c,samplesPerFrame:i}}}function L(y,d){return y[d]===255&&(224&y[d+1])==224&&(6&y[d+1])!=0}function m(y,d){return d+1<y.length&&L(y,d)}function f(y,d){return L(y,d)&&4<=y.length-d}function E(y,d){if(d+1<y.length&&L(y,d)){var e=o(y,d),a=4;e!=null&&e.frameLength&&(a=e.frameLength);var t=d+a;return t===y.length||m(y,t)}return!1}},"./src/demux/sample-aes.ts":function(N,x,h){h.r(x);var R=h("./src/crypt/decrypter.ts"),T=h("./src/demux/tsdemuxer.ts"),A=function(){function D(_,o,L){this.keyData=void 0,this.decrypter=void 0,this.keyData=L,this.decrypter=new R.default(_,o,{removePKCS7Padding:!1})}var C=D.prototype;return C.decryptBuffer=function(_,o){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,o)},C.decryptAacSample=function(_,o,L,m){var f=_[o].unit,E=f.subarray(16,f.length-f.length%16),y=E.buffer.slice(E.byteOffset,E.byteOffset+E.length),d=this;this.decryptBuffer(y,function(e){var a=new Uint8Array(e);f.set(a,16),m||d.decryptAacSamples(_,o+1,L)})},C.decryptAacSamples=function(_,o,L){for(;;o++){if(o>=_.length)return void L();if(!(_[o].unit.length<32)){var m=this.decrypter.isSync();if(this.decryptAacSample(_,o,L,m),!m)return}}},C.getAvcEncryptedData=function(_){for(var o=16*Math.floor((_.length-48)/160)+16,L=new Int8Array(o),m=0,f=32;f<=_.length-16;f+=160,m+=16)L.set(_.subarray(f,f+16),m);return L},C.getAvcDecryptedUnit=function(_,o){for(var L=new Uint8Array(o),m=0,f=32;f<=_.length-16;f+=160,m+=16)_.set(L.subarray(m,m+16),f);return _},C.decryptAvcSample=function(_,o,L,m,f,E){var y=Object(T.discardEPB)(f.data),d=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(d.buffer,function(a){f.data=e.getAvcDecryptedUnit(y,a),E||e.decryptAvcSamples(_,o,L+1,m)})},C.decryptAvcSamples=function(_,o,L,m){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;o++,L=0){if(o>=_.length)return void m();for(var f=_[o].units;!(L>=f.length);L++){var E=f[L];if(!(E.data.length<=48||E.type!==1&&E.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,o,L,m,E,y),!y)return}}}},D}();x.default=A},"./src/demux/transmuxer-interface.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return m});var R=h("./node_modules/webworkify-webpack/index.js"),T=h("./src/events.ts"),A=h("./src/demux/transmuxer.ts"),D=h("./src/utils/logger.ts"),C=h("./src/errors.ts"),_=h("./src/utils/mediasource-helper.ts"),o=h("./node_modules/eventemitter3/index.js"),L=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},m=function(){function f(y,d,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=y,this.id=d,this.onTransmuxComplete=e,this.onFlush=a;var s=y.config,u=function(g,p){(p=p||{}).frag=t.frag,p.id=t.id,y.trigger(g,p)};this.observer=new o.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,u),this.observer.on(T.Events.ERROR,u);var n={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(s.enableWorker&&typeof Worker<"u"){var v;D.logger.log("demuxing in webworker");try{v=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(g){y.trigger(T.Events.ERROR,{type:C.ErrorTypes.OTHER_ERROR,details:C.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},v.postMessage({cmd:"init",typeSupported:n,vendor:l,id:d,config:JSON.stringify(s)})}catch(g){D.logger.warn("Error in worker:",g),D.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new A.default(this.observer,n,s,l,d),this.worker=null}}else this.transmuxer=new A.default(this.observer,n,s,l,d)}var E=f.prototype;return E.destroy=function(){var y=this.worker;if(y)y.removeEventListener("message",this.onwmsg),y.terminate(),this.worker=null;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.observer=null},E.push=function(y,d,e,a,t,s,u,n,l,v){var g=this;l.transmuxing.start=self.performance.now();var p=this.transmuxer,r=this.worker,i=s?s.start:t.start,c=t.decryptdata,S=this.frag,b=!(S&&t.cc===S.cc),k=!(S&&l.level===S.level),I=S?l.sn-S.sn:-1,w=this.part?l.part-this.part.index:1,O=!k&&(I===1||I===0&&w===1),P=self.performance.now();(k||I||t.stats.parsing.start===0)&&(t.stats.parsing.start=P),!s||!w&&O||(s.stats.parsing.start=P);var F=new A.TransmuxState(b,O,n,k,i);if(!O||b){D.logger.log("[transmuxer-interface, "+t.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+`
|
||
discontinuity: `+b+`
|
||
trackSwitch: `+k+`
|
||
contiguous: `+O+`
|
||
accurateTimeOffset: `+n+`
|
||
timeOffset: `+i);var M=new A.TransmuxConfig(e,a,d,u,v);this.configureTransmuxer(M)}if(this.frag=t,this.part=s,r)r.postMessage({cmd:"demux",data:y,decryptdata:c,chunkMeta:l,state:F},y instanceof ArrayBuffer?[y]:[]);else if(p){var B=p.push(y,c,l,F);Object(A.isPromise)(B)?B.then(function(U){g.handleTransmuxComplete(U)}):this.handleTransmuxComplete(B)}},E.flush=function(y){var d=this;y.transmuxing.start=self.performance.now();var e=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:y});else if(e){var t=e.flush(y);Object(A.isPromise)(t)?t.then(function(s){d.handleFlushResult(s,y)}):this.handleFlushResult(t,y)}},E.handleFlushResult=function(y,d){var e=this;y.forEach(function(a){e.handleTransmuxComplete(a)}),this.onFlush(d)},E.onWorkerMessage=function(y){var d=y.data,e=this.hls;switch(d.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(d.data);break;case"flush":this.onFlush(d.data);break;default:d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,e.trigger(d.event,d.data)}},E.configureTransmuxer=function(y){var d=this.worker,e=this.transmuxer;d?d.postMessage({cmd:"configure",config:y}):e&&e.configure(y)},E.handleTransmuxComplete=function(y){y.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(y)},f}()},"./src/demux/transmuxer-worker.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return C});var R=h("./src/demux/transmuxer.ts"),T=h("./src/events.ts"),A=h("./src/utils/logger.ts"),D=h("./node_modules/eventemitter3/index.js");function C(m){var f=new D.EventEmitter,E=function(y,d){m.postMessage({event:y,data:d})};f.on(T.Events.FRAG_DECRYPTED,E),f.on(T.Events.ERROR,E),m.addEventListener("message",function(y){var d=y.data;switch(d.cmd){case"init":var e=JSON.parse(d.config);m.transmuxer=new R.default(f,d.typeSupported,e,d.vendor,d.id),Object(A.enableLogs)(e.debug),E("init",null);break;case"configure":m.transmuxer.configure(d.config);break;case"demux":var a=m.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);Object(R.isPromise)(a)?a.then(function(u){_(m,u)}):_(m,a);break;case"flush":var t=d.chunkMeta,s=m.transmuxer.flush(t);Object(R.isPromise)(s)?s.then(function(u){L(m,u,t)}):L(m,s,t)}})}function _(m,f){if((E=f.remuxResult).audio||E.video||E.text||E.id3||E.initSegment){var E,y=[],d=f.remuxResult,e=d.audio,a=d.video;e&&o(y,e),a&&o(y,a),m.postMessage({event:"transmuxComplete",data:f},y)}}function o(m,f){f.data1&&m.push(f.data1.buffer),f.data2&&m.push(f.data2.buffer)}function L(m,f,E){f.forEach(function(y){_(m,y)}),m.postMessage({event:"flush",data:E})}},"./src/demux/transmuxer.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return t}),h.d(x,"isPromise",function(){return u}),h.d(x,"TransmuxConfig",function(){return n}),h.d(x,"TransmuxState",function(){return l});var R,T=h("./src/events.ts"),A=h("./src/errors.ts"),D=h("./src/crypt/decrypter.ts"),C=h("./src/demux/aacdemuxer.ts"),_=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"),E=h("./src/demux/chunk-cache.ts"),y=h("./src/utils/mp4-tools.ts"),d=h("./src/utils/logger.ts");try{R=self.performance.now.bind(self.performance)}catch{d.logger.debug("Unable to use Performance API on this environment"),R=self.Date.now}var e=[{demux:o.default,remux:m.default},{demux:_.default,remux:f.default},{demux:C.default,remux:m.default},{demux:L.default,remux:m.default}],a=1024;e.forEach(function(v){var g=v.demux;a=Math.max(a,g.minProbeByteLength)});var t=function(){function v(p,r,i,c,S){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 E.default,this.observer=p,this.typeSupported=r,this.config=i,this.vendor=c,this.id=S}var g=v.prototype;return g.configure=function(p){this.transmuxConfig=p,this.decrypter&&this.decrypter.reset()},g.push=function(p,r,i,c){var S=this,b=i.transmuxing;b.executeStart=R();var k=new Uint8Array(p),I=this.cache,w=this.config,O=this.currentTransmuxState,P=this.transmuxConfig;c&&(this.currentTransmuxState=c);var F=function(ce,ue){var ve=null;return ce.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(ve=ue),ve}(k,r);if(F&&F.method==="AES-128"){var M=this.getDecrypter();if(!w.enableSoftwareAES)return this.decryptionPromise=M.webCryptoDecrypt(k,F.key.buffer,F.iv.buffer).then(function(ce){var ue=S.push(ce,null,i);return S.decryptionPromise=null,ue}),this.decryptionPromise;var B=M.softwareDecrypt(k,F.key.buffer,F.iv.buffer);if(!B)return b.executeEnd=R(),s(i);k=new Uint8Array(B)}var U=c||O,j=U.contiguous,V=U.discontinuity,H=U.trackSwitch,X=U.accurateTimeOffset,q=U.timeOffset,$=P.audioCodec,ie=P.videoCodec,se=P.defaultInitPts,le=P.duration,re=P.initSegmentData;if((V||H)&&this.resetInitSegment(re,$,ie,le),V&&this.resetInitialTimestamp(se),j||this.resetContiguity(),this.needsProbing(k,V,H)){if(I.dataLength){var fe=I.flush();k=Object(y.appendUint8Array)(fe,k)}this.configureTransmuxer(k,P)}var te=this.transmux(k,F,q,X,i),ne=this.currentTransmuxState;return ne.contiguous=!0,ne.discontinuity=!1,ne.trackSwitch=!1,b.executeEnd=R(),te},g.flush=function(p){var r=this,i=p.transmuxing;i.executeStart=R();var c=this.decrypter,S=this.cache,b=this.currentTransmuxState,k=this.decryptionPromise;if(k)return k.then(function(){return r.flush(p)});var I=[],w=b.timeOffset;if(c){var O=c.flush();O&&I.push(this.push(O,null,p))}var P=S.dataLength;S.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(p)];var B=F.flush(w);return u(B)?B.then(function(U){return r.flushRemux(I,U,p),I}):(this.flushRemux(I,B,p),I)},g.flushRemux=function(p,r,i){var c=r.audioTrack,S=r.avcTrack,b=r.id3Track,k=r.textTrack,I=this.currentTransmuxState,w=I.accurateTimeOffset,O=I.timeOffset;d.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var P=this.remuxer.remux(c,S,b,k,O,w,!0,this.id);p.push({remuxResult:P,chunkMeta:i}),i.transmuxing.executeEnd=R()},g.resetInitialTimestamp=function(p){var r=this.demuxer,i=this.remuxer;r&&i&&(r.resetTimeStamp(p),i.resetTimeStamp(p))},g.resetContiguity=function(){var p=this.demuxer,r=this.remuxer;p&&r&&(p.resetContiguity(),r.resetNextTimestamp())},g.resetInitSegment=function(p,r,i,c){var S=this.demuxer,b=this.remuxer;S&&b&&(S.resetInitSegment(r,i,c),b.resetInitSegment(p,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(p,r,i,c,S){return r&&r.method==="SAMPLE-AES"?this.transmuxSampleAes(p,r,i,c,S):this.transmuxUnencrypted(p,i,c,S)},g.transmuxUnencrypted=function(p,r,i,c){var S=this.demuxer.demux(p,r,!1,!this.config.progressive),b=S.audioTrack,k=S.avcTrack,I=S.id3Track,w=S.textTrack;return{remuxResult:this.remuxer.remux(b,k,I,w,r,i,!1,this.id),chunkMeta:c}},g.transmuxSampleAes=function(p,r,i,c,S){var b=this;return this.demuxer.demuxSampleAes(p,r,i).then(function(k){return{remuxResult:b.remuxer.remux(k.audioTrack,k.avcTrack,k.id3Track,k.textTrack,i,c,!1,b.id),chunkMeta:S}})},g.configureTransmuxer=function(p,r){for(var i,c=this.config,S=this.observer,b=this.typeSupported,k=this.vendor,I=r.audioCodec,w=r.defaultInitPts,O=r.duration,P=r.initSegmentData,F=r.videoCodec,M=0,B=e.length;M<B;M++)if(e[M].demux.probe(p)){i=e[M];break}i||(d.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),i={demux:_.default,remux:f.default});var U=this.demuxer,j=this.remuxer,V=i.remux,H=i.demux;j&&j instanceof V||(this.remuxer=new V(S,c,b,k)),U&&U instanceof H||(this.demuxer=new H(S,c,b),this.probe=H.probe),this.resetInitSegment(P,I,F,O),this.resetInitialTimestamp(w)},g.needsProbing=function(p,r,i){return!this.demuxer||!this.remuxer||r||i},g.getDecrypter=function(){var p=this.decrypter;return p||(p=this.decrypter=new D.default(this.observer,this.config)),p},v}(),s=function(v){return{remuxResult:{},chunkMeta:v}};function u(v){return"then"in v&&v.then instanceof Function}var n=function(v,g,p,r,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=v,this.videoCodec=g,this.initSegmentData=p,this.duration=r,this.defaultInitPts=i},l=function(v,g,p,r,i){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=v,this.contiguous=g,this.accurateTimeOffset=p,this.trackSwitch=r,this.timeOffset=i}},"./src/demux/tsdemuxer.ts":function(N,x,h){h.r(x),h.d(x,"discardEPB",function(){return u});var R=h("./src/demux/adts.ts"),T=h("./src/demux/mpegaudio.ts"),A=h("./src/demux/exp-golomb.ts"),D=h("./src/demux/id3.ts"),C=h("./src/demux/sample-aes.ts"),_=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},E=function(){function n(v,g,p){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=v,this.config=g,this.typeSupported=p}n.probe=function(v){var g=n.syncOffset(v);return!(g<0||(g&&L.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),0))},n.syncOffset=function(v){for(var g=Math.min(1e3,v.length-564),p=0;p<g;){if(v[p]===71&&v[p+188]===71&&v[p+376]===71)return p;p++}return-1},n.createTrack=function(v,g){return{container:v==="video"||v==="audio"?"video/mp2t":void 0,type:v,id:f[v],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:v==="audio"?g:void 0}};var l=n.prototype;return l.resetInitSegment=function(v,g,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video",p),this._audioTrack=n.createTrack("audio",p),this._id3Track=n.createTrack("id3",p),this._txtTrack=n.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=v,this.videoCodec=g,this._duration=p},l.resetTimeStamp=function(){},l.resetContiguity=function(){var v=this._audioTrack,g=this._avcTrack,p=this._id3Track;v&&(v.pesData=null),g&&(g.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},l.demux=function(v,g,p,r){var i;p===void 0&&(p=!1),r===void 0&&(r=!1),p||(this.sampleAes=null);var c=this._avcTrack,S=this._audioTrack,b=this._id3Track,k=c.pid,I=c.pesData,w=S.pid,O=b.pid,P=S.pesData,F=b.pesData,M=!1,B=this.pmtParsed,U=this._pmtId,j=v.length;if(this.remainderData&&(j=(v=Object(o.appendUint8Array)(this.remainderData,v)).length,this.remainderData=null),j<188&&!r)return this.remainderData=v,{audioTrack:S,avcTrack:c,id3Track:b,textTrack:this._txtTrack};var V=Math.max(0,n.syncOffset(v));(j-=(j+V)%188)<v.byteLength&&!r&&(this.remainderData=new Uint8Array(v.buffer,j,v.buffer.byteLength-j));for(var H=V;H<j;H+=188)if(v[H]===71){var X=!!(64&v[H+1]),q=((31&v[H+1])<<8)+v[H+2],$=void 0;if((48&v[H+3])>>4>1){if(($=H+5+v[H+4])===H+188)continue}else $=H+4;switch(q){case k:X&&(I&&(i=a(I))&&this.parseAVCPES(i,!1),I={data:[],size:0}),I&&(I.data.push(v.subarray($,H+188)),I.size+=H+188-$);break;case w:X&&(P&&(i=a(P))&&(S.isAAC?this.parseAACPES(i):this.parseMPEGPES(i)),P={data:[],size:0}),P&&(P.data.push(v.subarray($,H+188)),P.size+=H+188-$);break;case O:X&&(F&&(i=a(F))&&this.parseID3PES(i),F={data:[],size:0}),F&&(F.data.push(v.subarray($,H+188)),F.size+=H+188-$);break;case 0:X&&($+=v[$]+1),U=this._pmtId=d(v,$);break;case U:X&&($+=v[$]+1);var ie=e(v,$,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);(k=ie.avc)>0&&(c.pid=k),(w=ie.audio)>0&&(S.pid=w,S.isAAC=ie.isAAC),(O=ie.id3)>0&&(b.pid=O),M&&!B&&(L.logger.log("reparse from beginning"),M=!1,H=V-188),B=this.pmtParsed=!0;break;case 17:case 8191:break;default:M=!0}}else this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});c.pesData=I,S.pesData=P,b.pesData=F;var se={audioTrack:S,avcTrack:c,id3Track:b,textTrack:this._txtTrack};return r&&this.extractRemainingSamples(se),se},l.flush=function(){var v,g=this.remainderData;return this.remainderData=null,v=g?this.demux(g,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(v),this.sampleAes?this.decrypt(v,this.sampleAes):v},l.extractRemainingSamples=function(v){var g,p=v.audioTrack,r=v.avcTrack,i=v.id3Track,c=r.pesData,S=p.pesData,b=i.pesData;c&&(g=a(c))?(this.parseAVCPES(g,!0),r.pesData=null):r.pesData=c,S&&(g=a(S))?(p.isAAC?this.parseAACPES(g):this.parseMPEGPES(g),p.pesData=null):(S!=null&&S.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=S),b&&(g=a(b))?(this.parseID3PES(g),i.pesData=null):i.pesData=b},l.demuxSampleAes=function(v,g,p){var r=this.demux(v,p,!0,!this.config.progressive),i=this.sampleAes=new C.default(this.observer,this.config,g);return this.decrypt(r,i)},l.decrypt=function(v,g){return new Promise(function(p){var r=v.audioTrack,i=v.avcTrack;r.samples&&r.isAAC?g.decryptAacSamples(r.samples,0,function(){i.samples?g.decryptAvcSamples(i.samples,0,0,function(){p(v)}):p(v)}):i.samples&&g.decryptAvcSamples(i.samples,0,0,function(){p(v)})})},l.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},l.parseAVCPES=function(v,g){var p,r=this,i=this._avcTrack,c=this.parseAVCNALu(v.data),S=this.avcSample,b=!1;v.data=null,S&&c.length&&!i.audFound&&(t(S,i),S=this.avcSample=y(!1,v.pts,v.dts,"")),c.forEach(function(k){switch(k.type){case 1:p=!0,S||(S=r.avcSample=y(!0,v.pts,v.dts,"")),S.frame=!0;var I=k.data;if(b&&I.length>4){var w=new A.default(I).readSliceType();w!==2&&w!==4&&w!==7&&w!==9||(S.key=!0)}break;case 5:p=!0,S||(S=r.avcSample=y(!0,v.pts,v.dts,"")),S.key=!0,S.frame=!0;break;case 6:p=!0;var O=new A.default(u(k.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()],H=0;H<j;H++)V.push(O.readUByte()),V.push(O.readUByte()),V.push(O.readUByte());s(r._txtTrack.samples,{type:3,pts:v.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:v.pts,payloadType:P,uuid:X.join(""),userData:Object(D.utf8ArrayToStr)(ie),userDataBytes:ie})}}else if(F<O.bytesAvailable)for(var le=0;le<F;le++)O.readUByte()}break;case 7:if(p=!0,b=!0,!i.sps){var re=new A.default(k.data).readSPS();i.width=re.width,i.height=re.height,i.pixelRatio=re.pixelRatio,i.sps=[k.data],i.duration=r._duration;for(var fe=k.data.subarray(1,4),te="avc1.",ne=0;ne<3;ne++){var ce=fe[ne].toString(16);ce.length<2&&(ce="0"+ce),te+=ce}i.codec=te}break;case 8:p=!0,i.pps||(i.pps=[k.data]);break;case 9:p=!1,i.audFound=!0,S&&t(S,i),S=r.avcSample=y(!1,v.pts,v.dts,"");break;case 12:p=!1;break;default:p=!1,S&&(S.debug+="unknown NAL "+k.type+" ")}S&&p&&S.units.push(k)}),g&&S&&(t(S,i),this.avcSample=null)},l.getLastNalUnit=function(){var v,g,p=this.avcSample;if(!p||p.units.length===0){var r=this._avcTrack.samples;p=r[r.length-1]}if((v=p)!==null&&v!==void 0&&v.units){var i=p.units;g=i[i.length-1]}return g},l.parseAVCNALu=function(v){var g,p,r=v.byteLength,i=this._avcTrack,c=i.naluState||0,S=c,b=[],k=0,I=-1,w=0;for(c===-1&&(I=0,w=31&v[0],c=0,k=1);k<r;)if(g=v[k++],c)if(c!==1)if(g)if(g===1){if(I>=0){var O={data:v.subarray(I,k-c-1),type:w};b.push(O)}else{var P=this.getLastNalUnit();if(P&&(S&&k<=4-S&&P.state&&(P.data=P.data.subarray(0,P.data.byteLength-S)),(p=k-c-1)>0)){var F=new Uint8Array(P.data.byteLength+p);F.set(P.data,0),F.set(v.subarray(0,p),P.data.byteLength),P.data=F}}k<r?(I=k,w=31&v[k],c=0):c=-1}else c=0;else c=3;else c=g?0:2;else c=g?0:1;if(I>=0&&c>=0){var M={data:v.subarray(I,r),type:w,state:c};b.push(M)}if(b.length===0){var B=this.getLastNalUnit();if(B){var U=new Uint8Array(B.data.byteLength+v.byteLength);U.set(B.data,0),U.set(v,B.data.byteLength),B.data=U}}return i.naluState=c,b},l.parseAACPES=function(v){var g,p,r,i,c,S=0,b=this._audioTrack,k=this.aacOverFlow,I=v.data;if(k){this.aacOverFlow=null;var w=k.sample.unit.byteLength,O=Math.min(k.missing,w),P=w-O;k.sample.unit.set(I.subarray(0,O),P),b.samples.push(k.sample),S=k.missing}for(g=S,p=I.length;g<p-1&&!R.isHeader(I,g);g++);if(g===S||(g<p-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(_.Events.ERROR,_.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:i,reason:r}),!i)){if(R.initTrackConfig(b,this.observer,I,g,this.audioCodec),v.pts!==void 0)c=v.pts;else{if(!k)return void L.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var F=R.getFrameDuration(b.samplerate);c=k.sample.pts+F}for(var M=0;g<p;){if(R.isHeader(I,g)){if(g+5<p){var B=R.appendFrame(b,I,g,c,M);if(B){if(!B.missing){g+=B.length,M++;continue}this.aacOverFlow=B}}break}g++}}},l.parseMPEGPES=function(v){var g=v.data,p=g.length,r=0,i=0,c=v.pts;if(c!==void 0)for(;i<p;)if(T.isHeader(g,i)){var S=T.appendFrame(this._audioTrack,g,i,c,r);if(!S)break;i+=S.length,r++}else i++;else L.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},l.parseID3PES=function(v){v.pts!==void 0?this._id3Track.samples.push(v):L.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},n}();function y(n,l,v,g){return{key:n,frame:!1,pts:l,dts:v,units:[],debug:g,length:0}}function d(n,l){return(31&n[l+10])<<8|n[l+11]}function e(n,l,v,g){var p={audio:-1,avc:-1,id3:-1,isAAC:!0},r=l+3+((15&n[l+1])<<8|n[l+2])-4;for(l+=12+((15&n[l+10])<<8|n[l+11]);l<r;){var i=(31&n[l+1])<<8|n[l+2];switch(n[l]){case 207:if(!g){L.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:p.audio===-1&&(p.audio=i);break;case 21:p.id3===-1&&(p.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:p.avc===-1&&(p.avc=i);break;case 3:case 4:v?p.audio===-1&&(p.audio=i,p.isAAC=!1):L.logger.log("MPEG audio found, not supported in this browser");break;case 36:L.logger.warn("Unsupported HEVC stream type found")}l+=5+((15&n[l+3])<<8|n[l+4])}return p}function a(n){var l,v,g,p,r,i=0,c=n.data;if(!n||n.size===0)return null;for(;c[0].length<19&&c.length>1;){var S=new Uint8Array(c[0].length+c[1].length);S.set(c[0]),S.set(c[1],c[0].length),c[0]=S,c.splice(1,1)}if(((l=c[0])[0]<<16)+(l[1]<<8)+l[2]===1){if((v=(l[4]<<8)+l[5])&&v>n.size-6)return null;var b=l[7];192&b&&(p=536870912*(14&l[9])+4194304*(255&l[10])+16384*(254&l[11])+128*(255&l[12])+(254&l[13])/2,64&b?p-(r=536870912*(14&l[14])+4194304*(255&l[15])+16384*(254&l[16])+128*(255&l[17])+(254&l[18])/2)>54e5&&(L.logger.warn(Math.round((p-r)/9e4)+"s delta between PTS and DTS, align them"),p=r):r=p);var k=(g=l[8])+9;if(n.size<=k)return null;n.size-=k;for(var I=new Uint8Array(n.size),w=0,O=c.length;w<O;w++){var P=(l=c[w]).byteLength;if(k){if(k>P){k-=P;continue}l=l.subarray(k),P-=k,k=0}I.set(l,i),i+=P}return v&&(v-=g+3),{data:I,pts:p,dts:r,len:v}}return null}function t(n,l){if(n.units.length&&n.frame){if(n.pts===void 0){var v=l.samples,g=v.length;if(!g)return void l.dropped++;var p=v[g-1];n.pts=p.pts,n.dts=p.dts}l.samples.push(n)}n.debug.length&&L.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function s(n,l){var v=n.length;if(v>0){if(l.pts>=n[v-1].pts)n.push(l);else for(var g=v-1;g>=0;g--)if(l.pts<n[g].pts){n.splice(g,0,l);break}}else n.push(l)}function u(n){for(var l=n.byteLength,v=[],g=1;g<l-2;)n[g]===0&&n[g+1]===0&&n[g+2]===3?(v.push(g+2),g+=2):g++;if(v.length===0)return n;var p=l-v.length,r=new Uint8Array(p),i=0;for(g=0;g<p;i++,g++)i===v[0]&&(i++,v.shift()),r[g]=n[i];return r}E.minProbeByteLength=188,x.default=E},"./src/errors.ts":function(N,x,h){var R,T,A,D;h.r(x),h.d(x,"ErrorTypes",function(){return R}),h.d(x,"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",(D=A||(A={})).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"},"./src/events.ts":function(N,x,h){var R,T;h.r(x),h.d(x,"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,x,h){h.r(x),h.d(x,"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"),D=h("./src/controller/id3-track-controller.ts"),C=h("./src/controller/latency-controller.ts"),_=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"),E=h("./src/config.ts"),y=h("./node_modules/eventemitter3/index.js"),d=h("./src/events.ts"),e=h("./src/errors.ts");function a(s,u){for(var n=0;n<u.length;n++){var l=u[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(s,l.key,l)}}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 y.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this._media=null,this.url=null;var p=this.config=Object(E.mergeConfig)(s.DefaultConfig,g);this.userConfig=g,Object(f.enableLogs)(p.debug),this._autoLevelCapping=-1,p.progressive&&Object(E.enableStreamingMode)(p);var r=p.abrController,i=p.bufferController,c=p.capLevelController,S=p.fpsController,b=this.abrController=new r(this),k=this.bufferController=new i(this),I=this.capLevelController=new c(this),w=new S(this),O=new T.default(this),P=new A.default(this),F=new D.default(this),M=this.levelController=new _.default(this),B=new o.FragmentTracker(this),U=this.streamController=new L.default(this,B);I.setStreamController(U),w.setStreamController(U);var j=[M,U];this.networkControllers=j;var V=[O,P,b,k,I,w,F,B];this.audioTrackController=this.createController(p.audioTrackController,null,j),this.createController(p.audioStreamController,B,j),this.subtitleTrackController=this.createController(p.subtitleTrackController,null,j),this.createController(p.subtitleStreamController,B,j),this.createController(p.timelineController,null,V),this.emeController=this.createController(p.emeController,null,V),this.latencyController=this.createController(C.default,null,V),this.coreComponents=V}s.isSupported=function(){return Object(m.isSupported)()};var u,n,l,v=s.prototype;return v.createController=function(g,p,r){if(g){var i=p?new g(this,p):new g(this);return r&&r.push(i),i}return null},v.on=function(g,p,r){r===void 0&&(r=this),this._emitter.on(g,p,r)},v.once=function(g,p,r){r===void 0&&(r=this),this._emitter.once(g,p,r)},v.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},v.off=function(g,p,r,i){r===void 0&&(r=this),this._emitter.off(g,p,r,i)},v.listeners=function(g){return this._emitter.listeners(g)},v.emit=function(g,p,r){return this._emitter.emit(g,p,r)},v.trigger=function(g,p){if(this.config.debug)return this.emit(g,g,p);try{return this.emit(g,g,p)}catch(r){f.logger.error("An internal error happened while handling event "+g+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(d.Events.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:r})}return!1},v.listenerCount=function(g){return this._emitter.listenerCount(g)},v.destroy=function(){f.logger.log("destroy"),this.trigger(d.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},v.attachMedia=function(g){f.logger.log("attachMedia"),this._media=g,this.trigger(d.Events.MEDIA_ATTACHING,{media:g})},v.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(d.Events.MEDIA_DETACHING,void 0),this._media=null},v.loadSource=function(g){this.stopLoad();var p=this.media,r=this.url,i=this.url=R.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});f.logger.log("loadSource:"+i),p&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(d.Events.MANIFEST_LOADING,{url:g})},v.startLoad=function(g){g===void 0&&(g=-1),f.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(p){p.startLoad(g)})},v.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},v.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},v.recoverMediaError=function(){f.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},v.removeLevel=function(g,p){p===void 0&&(p=0),this.levelController.removeLevel(g,p)},u=s,l=[{key:"version",get:function(){return"1.0.10"}},{key:"Events",get:function(){return d.Events}},{key:"ErrorTypes",get:function(){return e.ErrorTypes}},{key:"ErrorDetails",get:function(){return e.ErrorDetails}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:E.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 p=!!g;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{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,p=this.config.minAutoBitrate;if(!g)return 0;for(var r=g.length,i=0;i<r;i++)if(g[i].maxBitrate>p)return i;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,p=this.autoLevelCapping;return p===-1&&g&&g.length?g.length-1:p}},{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 p=this.audioTrackController;p&&(p.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 p=this.subtitleTrackController;p&&(p.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 p=this.subtitleTrackController;p&&(p.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(u.prototype,n),l&&a(u,l),s}();t.defaultConfig=void 0},"./src/is-supported.ts":function(N,x,h){h.r(x),h.d(x,"isSupported",function(){return A}),h.d(x,"changeTypeSupported",function(){return D});var R=h("./src/utils/mediasource-helper.ts");function T(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var C=Object(R.getMediaSource)();if(!C)return!1;var _=T(),o=C&&typeof C.isTypeSupported=="function"&&C.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!_||_.prototype&&typeof _.prototype.appendBuffer=="function"&&typeof _.prototype.remove=="function";return!!o&&!!L}function D(){var C,_=T();return typeof(_==null||(C=_.prototype)===null||C===void 0?void 0:C.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return m}),h.d(x,"LoadError",function(){return E});var R=h("./src/polyfills/number.ts"),T=h("./src/errors.ts");function A(y){var d=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(d!==void 0){if(d.has(e))return d.get(e);d.set(e,t)}function t(){return D(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_(t,e)})(y)}function D(y,d,e){return(D=C()?Reflect.construct:function(a,t,s){var u=[null];u.push.apply(u,t);var n=new(Function.bind.apply(a,u));return s&&_(n,s.prototype),n}).apply(null,arguments)}function C(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(y,d){return(_=Object.setPrototypeOf||function(e,a){return e.__proto__=a,e})(y,d)}function o(y){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)})(y)}var L=Math.pow(2,17),m=function(){function y(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var d=y.prototype;return d.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},d.abort=function(){this.loader&&this.loader.abort()},d.load=function(e,a){var t=this,s=e.url;if(!s)return Promise.reject(new E({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 u=this.config,n=u.fLoader,l=u.loader;return new Promise(function(v,g){t.loader&&t.loader.destroy();var p=t.loader=e.loader=n?new n(u):new l(u),r=f(e),i={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:L};e.stats=p.stats,p.load(r,i,{onSuccess:function(c,S,b,k){t.resetLoader(e,p),v({frag:e,part:null,payload:c.data,networkDetails:k})},onError:function(c,S,b){t.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:c,networkDetails:b}))},onAbort:function(c,S,b){t.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:b}))},onTimeout:function(c,S,b){t.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:b}))},onProgress:function(c,S,b,k){a&&a({frag:e,part:null,payload:b,networkDetails:k})}})})},d.loadPart=function(e,a,t){var s=this;this.abort();var u=this.config,n=u.fLoader,l=u.loader;return new Promise(function(v,g){s.loader&&s.loader.destroy();var p=s.loader=e.loader=n?new n(u):new l(u),r=f(e,a),i={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:L};a.stats=p.stats,p.load(r,i,{onSuccess:function(c,S,b,k){s.resetLoader(e,p),s.updateStatsFromPart(e,a);var I={frag:e,part:a,payload:c.data,networkDetails:k};t(I),v(I)},onError:function(c,S,b){s.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:a,response:c,networkDetails:b}))},onAbort:function(c,S,b){e.stats.aborted=a.stats.aborted,s.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:a,networkDetails:b}))},onTimeout:function(c,S,b){s.resetLoader(e,p),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:a,networkDetails:b}))}})})},d.updateStatsFromPart=function(e,a){var t=e.stats,s=a.stats,u=s.total;if(t.loaded+=s.loaded,u){var n=Math.round(e.duration/a.duration),l=Math.min(Math.round(t.loaded/u),n),v=(n-l)*Math.round(t.loaded/l);t.total=t.loaded+v}else t.total=Math.max(t.loaded,t.total);var g=t.loading,p=s.loading;g.start?g.first+=p.first-p.start:(g.start=p.start,g.first=p.first),g.end=p.end},d.resetLoader=function(e,a){e.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},y}();function f(y,d){d===void 0&&(d=null);var e=d||y,a={frag:y,part:d,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 E=function(y){var d,e;function a(t){for(var s,u=arguments.length,n=new Array(u>1?u-1:0),l=1;l<u;l++)n[l-1]=arguments[l];return(s=y.call.apply(y,[this].concat(n))||this).data=void 0,s.data=t,s}return e=y,(d=a).prototype=Object.create(e.prototype),d.prototype.constructor=d,_(d,e),a}(A(Error))},"./src/loader/fragment.ts":function(N,x,h){h.r(x),h.d(x,"ElementaryStreamTypes",function(){return R}),h.d(x,"BaseSegment",function(){return y}),h.d(x,"Fragment",function(){return d}),h.d(x,"Part",function(){return e});var R,T,A=h("./src/polyfills/number.ts"),D=h("./node_modules/url-toolkit/src/url-toolkit.js"),C=h("./src/utils/logger.ts"),_=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,u){return s.__proto__=u,s})(a,t)}function f(a,t){for(var s=0;s<t.length;s++){var u=t[s];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(a,u.key,u)}}function E(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 y=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 u=t.split("@",2),n=[];u.length===1?n[0]=s?s.byteRangeEndOffset:0:n[0]=parseInt(u[1]),n[1]=parseInt(u[0])+n[0],this._byteRange=n},E(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(D.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),a}(),d=function(a){function t(u,n){var l;return(l=a.call(this,n)||this)._decryptdata=null,l.rawProgramDateTime=null,l.programDateTime=null,l.tagList=[],l.duration=0,l.sn=0,l.levelkey=void 0,l.type=void 0,l.loader=null,l.level=-1,l.cc=0,l.startPTS=void 0,l.endPTS=void 0,l.appendedPTS=void 0,l.startDTS=void 0,l.endDTS=void 0,l.start=0,l.deltaPTS=void 0,l.maxStartPTS=void 0,l.minEndPTS=void 0,l.stats=new o.LoadStats,l.urlId=0,l.data=void 0,l.bitrateTest=!1,l.title=null,l.initSegment=null,l.type=u,l}L(t,a);var s=t.prototype;return s.createInitializationVector=function(u){for(var n=new Uint8Array(16),l=12;l<16;l++)n[l]=u>>8*(15-l)&255;return n},s.setDecryptDataFromLevelKey=function(u,n){var l=u;return(u==null?void 0:u.method)==="AES-128"&&u.uri&&!u.iv&&((l=_.LevelKey.fromURI(u.uri)).method=u.method,l.iv=this.createInitializationVector(n),l.keyFormat="identity"),l},s.setElementaryStreamInfo=function(u,n,l,v,g,p){p===void 0&&(p=!1);var r=this.elementaryStreams,i=r[u];i?(i.startPTS=Math.min(i.startPTS,n),i.endPTS=Math.max(i.endPTS,l),i.startDTS=Math.min(i.startDTS,v),i.endDTS=Math.max(i.endDTS,g)):r[u]={startPTS:n,endPTS:l,startDTS:v,endDTS:g,partial:p}},s.clearElementaryStreamInfo=function(){var u=this.elementaryStreams;u[R.AUDIO]=null,u[R.VIDEO]=null,u[R.AUDIOVIDEO]=null},E(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var u=this.sn;typeof u!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&C.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),u=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,u)}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 u=Object(A.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*u}},{key:"encrypted",get:function(){var u;return!((u=this.decryptdata)===null||u===void 0||!u.keyFormat||!this.decryptdata.uri)}}]),t}(y),e=function(a){function t(s,u,n,l,v){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=u,g.index=l;var p=s.enumeratedString("BYTERANGE");return p&&g.setByteRange(p,v),v&&(g.fragOffset=v.fragOffset+v.duration),g}return L(t,a),E(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}(y)},"./src/loader/key-loader.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return D});var R=h("./src/events.ts"),T=h("./src/errors.ts"),A=h("./src/utils/logger.ts"),D=function(){function C(o){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=o,this._registerListeners()}var _=C.prototype;return _._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},_._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},_.destroy=function(){for(var o in this._unregisterListeners(),this.loaders){var L=this.loaders[o];L&&L.destroy()}this.loaders={}},_.onKeyLoading=function(o,L){var m=L.frag,f=m.type,E=this.loaders[f];if(m.decryptdata){var y=m.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(E&&(A.logger.warn("abort previous key loader for type:"+f),E.abort()),!y)return void A.logger.warn("key uri is falsy");var e=d.loader,a=m.loader=this.loaders[f]=new e(d);this.decrypturl=y,this.decryptkey=null;var t={url:y,frag:m,responseType:"arraybuffer"},s={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(t,s,u)}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")},_.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")},_.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})},_.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})},C}()},"./src/loader/level-details.ts":function(N,x,h){h.r(x),h.d(x,"LevelDetails",function(){return A});var R=h("./src/polyfills/number.ts");function T(D,C){for(var _=0;_<C.length;_++){var o=C[_];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(D,o.key,o)}}var A=function(){function D(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 C,_;return D.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},C=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(C.prototype,_),D}()},"./src/loader/level-key.ts":function(N,x,h){h.r(x),h.d(x,"LevelKey",function(){return A});var R=h("./node_modules/url-toolkit/src/url-toolkit.js");function T(D,C){for(var _=0;_<C.length;_++){var o=C[_];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(D,o.key,o)}}var A=function(){function D(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 C,_;return D.fromURL=function(o,L){return new D(o,L)},D.fromURI=function(o){return new D(o)},C=D,(_=[{key:"uri",get:function(){return this._uri}}])&&T(C.prototype,_),D}()},"./src/loader/load-stats.ts":function(N,x,h){h.r(x),h.d(x,"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,x,h){h.r(x),h.d(x,"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"),D=h("./src/loader/level-details.ts"),C=h("./src/loader/level-key.ts"),_=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,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),d=/\.(mp4|m4s|m4v|m4a)$/i,e=function(){function u(){}return u.findGroup=function(n,l){for(var v=0;v<n.length;v++){var g=n[v];if(g.id===l)return g}},u.convertAVC1ToAVCOTI=function(n){var l=n.split(".");if(l.length>2){var v=l.shift()+".";return v+=parseInt(l.shift()).toString(16),v+=("000"+parseInt(l.shift()).toString(16)).substr(-4)}return n},u.resolve=function(n,l){return T.buildAbsoluteURL(l,n,{alwaysNormalize:!0})},u.parseMasterPlaylist=function(n,l){var v,g=[],p={},r=!1;for(m.lastIndex=0;(v=m.exec(n))!=null;)if(v[1]){var i=new _.AttrList(v[1]),c={attrs:i,bitrate:i.decimalInteger("AVERAGE-BANDWIDTH")||i.decimalInteger("BANDWIDTH"),name:i.NAME,url:u.resolve(v[2],l)},S=i.decimalResolution("RESOLUTION");S&&(c.width=S.width,c.height=S.height),a((i.CODECS||"").split(/[ ,]+/).filter(function(k){return k}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=u.convertAVC1ToAVCOTI(c.videoCodec)),g.push(c)}else if(v[3]){var b=new _.AttrList(v[3]);b["DATA-ID"]&&(r=!0,p[b["DATA-ID"]]=b)}return{levels:g,sessionData:r?p:null}},u.parseMasterPlaylistMedia=function(n,l,v,g){var p;g===void 0&&(g=[]);var r=[],i=0;for(f.lastIndex=0;(p=f.exec(n))!==null;){var c=new _.AttrList(p[1]);if(c.TYPE===v){var S={attrs:c,bitrate:0,id:i++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:v,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?u.resolve(c.URI,l):""};if(g.length){var b=u.findGroup(g,S.groupId)||g[0];t(S,b,"audioCodec"),t(S,b,"textCodec")}r.push(S)}}return r},u.parseLevelPlaylist=function(n,l,v,g,p){var r,i,c,S=new D.LevelDetails(l),b=S.fragments,k=null,I=0,w=0,O=0,P=0,F=null,M=new A.Fragment(g,l),B=-1,U=!1;for(E.lastIndex=0,S.m3u8=n;(r=E.exec(n))!==null;){U&&(U=!1,(M=new A.Fragment(g,l)).start=O,M.sn=I,M.cc=P,M.level=v,k&&(M.initSegment=k,M.rawProgramDateTime=k.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,c&&(M.levelkey=c),M.sn=I,M.level=v,M.cc=P,M.urlId=p,b.push(M),M.relurl=(" "+r[3]).slice(1),s(M,F),F=M,O+=M.duration,I++,w=0,U=!0);else if(r[4]){var H=(" "+r[4]).slice(1);F?M.setByteRange(H,F):M.setByteRange(H)}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(y))){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":S.type=q.toUpperCase();break;case"MEDIA-SEQUENCE":I=S.startSN=parseInt(q);break;case"SKIP":var ie=new _.AttrList(q),se=ie.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(se)){S.skippedSegments=se;for(var le=se;le--;)b.unshift(null);I+=se}var re=ie.enumeratedString("RECENTLY-REMOVED-DATERANGES");re&&(S.recentlyRemovedDateranges=re.split(" "));break;case"TARGETDURATION":S.targetduration=parseFloat(q);break;case"VERSION":S.version=parseInt(q);break;case"EXTM3U":break;case"ENDLIST":S.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 fe,te=new _.AttrList(q),ne=te.enumeratedString("METHOD"),ce=te.URI,ue=te.hexadecimalInteger("IV"),ve=te.enumeratedString("KEYFORMATVERSIONS"),ye=te.enumeratedString("KEYID"),W=(fe=te.enumeratedString("KEYFORMAT"))!=null?fe:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(W)>-1){o.logger.warn("Keyformat "+W+" is not supported from the manifest");continue}if(W!=="identity")continue;ne&&(c=C.LevelKey.fromURL(l,ce),ce&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ne)>=0&&(c.method=ne,c.keyFormat=W,ye&&(c.keyID=ye),ve&&(c.keyFormatVersions=ve),c.iv=ue));break;case"START":var de=new _.AttrList(q).decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(de)&&(S.startTimeOffset=de);break;case"MAP":var oe=new _.AttrList(q);M.relurl=oe.URI,oe.BYTERANGE&&M.setByteRange(oe.BYTERANGE),M.level=v,M.sn="initSegment",c&&(M.levelkey=c),M.initSegment=null,k=M,U=!0;break;case"SERVER-CONTROL":var pe=new _.AttrList(q);S.canBlockReload=pe.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=pe.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&pe.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=pe.optionalFloat("PART-HOLD-BACK",0),S.holdBack=pe.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var We=new _.AttrList(q);S.partTarget=We.decimalFloatingPoint("PART-TARGET");break;case"PART":var ke=S.partList;ke||(ke=S.partList=[]);var Oe=w>0?ke[ke.length-1]:void 0,Ye=w++,Me=new A.Part(new _.AttrList(q),M,l,Ye,Oe);ke.push(Me),M.duration+=Me.duration;break;case"PRELOAD-HINT":var Ie=new _.AttrList(q);S.preloadHint=Ie;break;case"RENDITION-REPORT":var $e=new _.AttrList(q);S.renditionReports=S.renditionReports||[],S.renditionReports.push($e);break;default:o.logger.warn("line parsed but not handled: "+r)}}}F&&!F.relurl?(b.pop(),O-=F.duration,S.partList&&(S.fragmentHint=F)):S.partList&&(s(M,F),M.cc=P,S.fragmentHint=M);var qe=b.length,Ce=b[0],Qe=b[qe-1];if((O+=S.skippedSegments*S.targetduration)>0&&qe&&Qe){S.averagetargetduration=O/qe;var ze=Qe.sn;S.endSN=ze!=="initSegment"?ze:0,Ce&&(S.startCC=Ce.cc,Ce.initSegment||S.fragments.every(function(Ne){return Ne.relurl&&(Pe=Ne.relurl,d.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,l)).relurl=Qe.relurl,M.level=v,M.sn="initSegment",Ce.initSegment=M,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(O+=S.fragmentHint.duration),S.totalduration=O,S.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),S},u}();function a(u,n){["video","audio","text"].forEach(function(l){var v=u.filter(function(p){return Object(L.isCodecType)(p,l)});if(v.length){var g=v.filter(function(p){return p.lastIndexOf("avc1",0)===0||p.lastIndexOf("mp4a",0)===0});n[l+"Codec"]=g.length>0?g[0]:v[0],u=u.filter(function(p){return v.indexOf(p)===-1})}}),n.unknownCodecs=u}function t(u,n,l){var v=n[l];v&&(u[l]=v)}function s(u,n){u.rawProgramDateTime?u.programDateTime=Date.parse(u.rawProgramDateTime):n!=null&&n.programDateTime&&(u.programDateTime=n.endProgramDateTime),Object(R.isFiniteNumber)(u.programDateTime)||(u.programDateTime=null,u.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,x,h){h.r(x);var R=h("./src/polyfills/number.ts"),T=h("./src/events.ts"),A=h("./src/errors.ts"),D=h("./src/utils/logger.ts"),C=h("./src/utils/mp4-tools.ts"),_=h("./src/loader/m3u8-parser.ts"),o=h("./src/types/loader.ts"),L=h("./src/utils/attr-list.ts");function m(E,y){var d=E.url;return d!==void 0&&d.indexOf("data:")!==0||(d=y.url),d}var f=function(){function E(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var y=E.prototype;return y.registerListeners=function(){var d=this.hls;d.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(T.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),d.on(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var d=this.hls;d.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(T.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),d.off(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(d){var e=this.hls.config,a=e.pLoader,t=e.loader,s=new(a||t)(e);return d.loader=s,this.loaders[d.type]=s,s},y.getInternalLoader=function(d){return this.loaders[d.type]},y.resetInternalLoader=function(d){this.loaders[d]&&delete this.loaders[d]},y.destroyInternalLoaders=function(){for(var d in this.loaders){var e=this.loaders[d];e&&e.destroy(),this.resetInternalLoader(d)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(d,e){var a=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:o.PlaylistContextType.MANIFEST,url:a,deliveryDirectives:null})},y.onLevelLoading=function(d,e){var a=e.id,t=e.level,s=e.url,u=e.deliveryDirectives;this.load({id:a,groupId:null,level:t,responseType:"text",type:o.PlaylistContextType.LEVEL,url:s,deliveryDirectives:u})},y.onAudioTrackLoading=function(d,e){var a=e.id,t=e.groupId,s=e.url,u=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:o.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:u})},y.onSubtitleTrackLoading=function(d,e){var a=e.id,t=e.groupId,s=e.url,u=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:o.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:u})},y.load=function(d){var e,a,t,s,u,n,l=this.hls.config,v=this.getInternalLoader(d);if(v){var g=v.context;if(g&&g.url===d.url)return void D.logger.trace("[playlist-loader]: playlist request ongoing");D.logger.log("[playlist-loader]: aborting previous loader for type: "+d.type),v.abort()}switch(d.type){case o.PlaylistContextType.MANIFEST:a=l.manifestLoadingMaxRetry,t=l.manifestLoadingTimeOut,s=l.manifestLoadingRetryDelay,u=l.manifestLoadingMaxRetryTimeout;break;case o.PlaylistContextType.LEVEL:case o.PlaylistContextType.AUDIO_TRACK:case o.PlaylistContextType.SUBTITLE_TRACK:a=0,t=l.levelLoadingTimeOut;break;default:a=l.levelLoadingMaxRetry,t=l.levelLoadingTimeOut,s=l.levelLoadingRetryDelay,u=l.levelLoadingMaxRetryTimeout}if(v=this.createInternalLoader(d),(e=d.deliveryDirectives)!==null&&e!==void 0&&e.part&&(d.type===o.PlaylistContextType.LEVEL&&d.level!==null?n=this.hls.levels[d.level].details:d.type===o.PlaylistContextType.AUDIO_TRACK&&d.id!==null?n=this.hls.audioTracks[d.id].details:d.type===o.PlaylistContextType.SUBTITLE_TRACK&&d.id!==null&&(n=this.hls.subtitleTracks[d.id].details),n)){var p=n.partTarget,r=n.targetduration;p&&r&&(t=Math.min(1e3*Math.max(3*p,.8*r),t))}var i={timeout:t,maxRetry:a,retryDelay:s,maxRetryDelay:u,highWaterMark:0},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(d,i,c)},y.loadsuccess=function(d,e,a,t){if(t===void 0&&(t=null),a.isSidxRequest)return this.handleSidxRequest(d,a),void this.handlePlaylistLoaded(d,e,a,t);this.resetInternalLoader(a.type);var s=d.data;s.indexOf("#EXTM3U")===0?(e.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(d,e,a,t):this.handleMasterPlaylist(d,e,a,t)):this.handleManifestParsingError(d,a,"no EXTM3U delimiter",t)},y.loaderror=function(d,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!1,d)},y.loadtimeout=function(d,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!0)},y.handleMasterPlaylist=function(d,e,a,t){var s=this.hls,u=d.data,n=m(d,a),l=_.default.parseMasterPlaylist(u,n),v=l.levels,g=l.sessionData;if(v.length){var p=v.map(function(b){return{id:b.attrs.AUDIO,audioCodec:b.audioCodec}}),r=v.map(function(b){return{id:b.attrs.SUBTITLES,textCodec:b.textCodec}}),i=_.default.parseMasterPlaylistMedia(u,n,"AUDIO",p),c=_.default.parseMasterPlaylistMedia(u,n,"SUBTITLES",r),S=_.default.parseMasterPlaylistMedia(u,n,"CLOSED-CAPTIONS");i.length&&(i.some(function(b){return!b.url})||!v[0].audioCodec||v[0].attrs.AUDIO||(D.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:v,audioTracks:i,subtitles:c,captions:S,url:n,stats:e,networkDetails:t,sessionData:g})}else this.handleManifestParsingError(d,a,"no level found in manifest",t)},y.handleTrackOrLevelPlaylist=function(d,e,a,t){var s=this.hls,u=a.id,n=a.level,l=a.type,v=m(d,a),g=Object(R.isFiniteNumber)(u)?u:0,p=Object(R.isFiniteNumber)(n)?n:g,r=function(k){switch(k.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=_.default.parseLevelPlaylist(d.data,v,p,r,g);if(i.fragments.length){if(l===o.PlaylistContextType.MANIFEST){var c={attrs:new L.AttrList({}),bitrate:0,details:i,name:"",url:v};s.trigger(T.Events.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:v,stats:e,networkDetails:t,sessionData:null})}if(e.parsing.end=performance.now(),i.needSidxRanges){var S,b=(S=i.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:b,isSidxRequest:!0,type:l,level:n,levelDetails:i,id:u,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else a.levelDetails=i,this.handlePlaylistLoaded(d,e,a,t)}else s.trigger(T.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:v,reason:"no fragments found in level",level:typeof a.level=="number"?a.level:void 0})},y.handleSidxRequest=function(d,e){var a=Object(C.parseSegmentIndex)(new Uint8Array(d.data));if(a){var t=a.references,s=e.levelDetails;t.forEach(function(u,n){var l=u.info,v=s.fragments[n];v.byteRange.length===0&&v.setByteRange(String(1+l.end-l.start)+"@"+String(l.start)),v.initSegment&&v.initSegment.setByteRange(String(a.moovEndOffset)+"@0")})}},y.handleManifestParsingError=function(d,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:d.url,reason:a,response:d,context:e,networkDetails:t})},y.handleNetworkError=function(d,e,a,t){a===void 0&&(a=!1),D.logger.warn("[playlist-loader]: A network "+(a?"timeout":"error")+" occurred while loading "+d.type+" level: "+d.level+" id: "+d.id+' group-id: "'+d.groupId+'"');var s=A.ErrorDetails.UNKNOWN,u=!1,n=this.getInternalLoader(d);switch(d.type){case o.PlaylistContextType.MANIFEST:s=a?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case o.PlaylistContextType.LEVEL:s=a?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case o.PlaylistContextType.AUDIO_TRACK:s=a?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case o.PlaylistContextType.SUBTITLE_TRACK:s=a?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1}n&&this.resetInternalLoader(d.type);var l={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:u,url:d.url,loader:n,context:d,networkDetails:e};t&&(l.response=t),this.hls.trigger(T.Events.ERROR,l)},y.handlePlaylistLoaded=function(d,e,a,t){var s=a.type,u=a.level,n=a.id,l=a.groupId,v=a.loader,g=a.levelDetails,p=a.deliveryDirectives;if(g!=null&&g.targetduration){if(v)switch(g.live&&(v.getCacheAge&&(g.ageHeader=v.getCacheAge()||0),v.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:u||0,id:n||0,stats:e,networkDetails:t,deliveryDirectives:p});break;case o.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(T.Events.AUDIO_TRACK_LOADED,{details:g,id:n||0,groupId:l||"",stats:e,networkDetails:t,deliveryDirectives:p});break;case o.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(T.Events.SUBTITLE_TRACK_LOADED,{details:g,id:n||0,groupId:l||"",stats:e,networkDetails:t,deliveryDirectives:p})}}else this.handleManifestParsingError(d,a,"invalid target duration",t)},E}();x.default=f},"./src/polyfills/number.ts":function(N,x,h){h.r(x),h.d(x,"isFiniteNumber",function(){return R}),h.d(x,"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,x,h){h.r(x);var R=function(){function T(){}return T.getSilentFrame=function(A,D){switch(A){case"mp4a.40.2":if(D===1)return new Uint8Array([0,200,0,128,35,128]);if(D===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(D===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(D===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(D===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(D===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(D===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(D===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(D===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}();x.default=R},"./src/remux/mp4-generator.ts":function(N,x,h){h.r(x);var R=Math.pow(2,32)-1,T=function(){function A(){}return A.init=function(){var D;for(D 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(D)&&(A.types[D]=[D.charCodeAt(0),D.charCodeAt(1),D.charCodeAt(2),D.charCodeAt(3)]);var C=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]),_=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:C,audio:_};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]),E=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,m,E,m,f),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,o))},A.box=function(D){for(var C=8,_=arguments.length,o=new Array(_>1?_-1:0),L=1;L<_;L++)o[L-1]=arguments[L];for(var m=o.length,f=m;m--;)C+=o[m].byteLength;var E=new Uint8Array(C);for(E[0]=C>>24&255,E[1]=C>>16&255,E[2]=C>>8&255,E[3]=255&C,E.set(D,4),m=0,C=8;m<f;m++)E.set(o[m],C),C+=o[m].byteLength;return E},A.hdlr=function(D){return A.box(A.types.hdlr,A.HDLR_TYPES[D])},A.mdat=function(D){return A.box(A.types.mdat,D)},A.mdhd=function(D,C){C*=D;var _=Math.floor(C/(R+1)),o=Math.floor(C%(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,D>>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,o>>24,o>>16&255,o>>8&255,255&o,85,196,0,0]))},A.mdia=function(D){return A.box(A.types.mdia,A.mdhd(D.timescale,D.duration),A.hdlr(D.type),A.minf(D))},A.mfhd=function(D){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,255&D]))},A.minf=function(D){return D.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(D)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(D))},A.moof=function(D,C,_){return A.box(A.types.moof,A.mfhd(D),A.traf(_,C))},A.moov=function(D){for(var C=D.length,_=[];C--;)_[C]=A.trak(D[C]);return A.box.apply(null,[A.types.moov,A.mvhd(D[0].timescale,D[0].duration)].concat(_).concat(A.mvex(D)))},A.mvex=function(D){for(var C=D.length,_=[];C--;)_[C]=A.trex(D[C]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(D,C){C*=D;var _=Math.floor(C/(R+1)),o=Math.floor(C%(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,D>>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,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(D){var C,_,o=D.samples||[],L=new Uint8Array(4+o.length);for(C=0;C<o.length;C++)_=o[C].flags,L[C+4]=_.dependsOn<<4|_.isDependedOn<<2|_.hasRedundancy;return A.box(A.types.sdtp,L)},A.stbl=function(D){return A.box(A.types.stbl,A.stsd(D),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(D){var C,_,o,L=[],m=[];for(C=0;C<D.sps.length;C++)o=(_=D.sps[C]).byteLength,L.push(o>>>8&255),L.push(255&o),L=L.concat(Array.prototype.slice.call(_));for(C=0;C<D.pps.length;C++)o=(_=D.pps[C]).byteLength,m.push(o>>>8&255),m.push(255&o),m=m.concat(Array.prototype.slice.call(_));var f=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|D.sps.length].concat(L).concat([D.pps.length]).concat(m))),E=D.width,y=D.height,d=D.pixelRatio[0],e=D.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,E>>8&255,255&E,y>>8&255,255&y,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([d>>24,d>>16&255,d>>8&255,255&d,e>>24,e>>16&255,e>>8&255,255&e])))},A.esds=function(D){var C=D.config.length;return new Uint8Array([0,0,0,0,3,23+C,0,1,0,4,15+C,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([C]).concat(D.config).concat([6,1,2]))},A.mp4a=function(D){var C=D.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,D.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]),A.box(A.types.esds,A.esds(D)))},A.mp3=function(D){var C=D.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,D.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]))},A.stsd=function(D){return D.type==="audio"?D.isAAC||D.codec!=="mp3"?A.box(A.types.stsd,A.STSD,A.mp4a(D)):A.box(A.types.stsd,A.STSD,A.mp3(D)):A.box(A.types.stsd,A.STSD,A.avc1(D))},A.tkhd=function(D){var C=D.id,_=D.duration*D.timescale,o=D.width,L=D.height,m=Math.floor(_/(R+1)),f=Math.floor(_%(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,C>>24&255,C>>16&255,C>>8&255,255&C,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(D,C){var _=A.sdtp(D),o=D.id,L=Math.floor(C/(R+1)),m=Math.floor(C%(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(D,_.length+16+20+8+16+8+8),_)},A.trak=function(D){return D.duration=D.duration||4294967295,A.box(A.types.trak,A.tkhd(D),A.mdia(D))},A.trex=function(D){var C=D.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,255&C,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(D,C){var _,o,L,m,f,E,y=D.samples||[],d=y.length,e=12+16*d,a=new Uint8Array(e);for(C+=8+e,a.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,C>>>24&255,C>>>16&255,C>>>8&255,255&C],0),_=0;_<d;_++)L=(o=y[_]).duration,m=o.size,f=o.flags,E=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,E>>>24&255,E>>>16&255,E>>>8&255,255&E],12+16*_);return A.box(A.types.trun,a)},A.initSegment=function(D){A.types||A.init();var C=A.moov(D),_=new Uint8Array(A.FTYP.byteLength+C.byteLength);return _.set(A.FTYP),_.set(C,A.FTYP.byteLength),_},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,x.default=T},"./src/remux/mp4-remuxer.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return d}),h.d(x,"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"),D=h("./src/events.ts"),C=h("./src/errors.ts"),_=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 u=1;u<arguments.length;u++){var n=arguments[u];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(s[l]=n[l])}return s}).apply(this,arguments)}var f=null,E=null,y=!1,d=function(){function s(n,l,v,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=l,this.typeSupported=v,this.ISGenerated=!1,f===null){var p=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);f=p?parseInt(p[1]):0}if(E===null){var r=navigator.userAgent.match(/Safari\/(\d+)/i);E=r?parseInt(r[1]):0}y=!!f&&f<75||!!E&&E<600}var u=s.prototype;return u.destroy=function(){},u.resetTimeStamp=function(n){_.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=n},u.resetNextTimestamp=function(){_.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},u.resetInitSegment=function(){_.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},u.getVideoStartPts=function(n){var l=!1,v=n.reduce(function(g,p){var r=p.pts-g;return r<-4294967296?(l=!0,e(g,p.pts)):r>0?g:p.pts},n[0].pts);return l&&_.logger.debug("PTS rollover detected"),v},u.remux=function(n,l,v,g,p,r,i,c){var S,b,k,I,w,O,P=p,F=p,M=n.pid>-1,B=l.pid>-1,U=l.samples.length,j=n.samples.length>0,V=U>1;if((!M||j)&&(!B||V)||this.ISGenerated||i){this.ISGenerated||(k=this.generateIS(n,l,p));var H=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}(l.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(O=!0,X>0){_.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+U+" video samples due to a missing keyframe");var q=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(X),l.dropped+=X,F+=(l.samples[0].pts-q)/(l.timescale||9e4)}else X===-1&&(_.logger.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),O=!1);if(this.ISGenerated){if(j&&V){var $=this.getVideoStartPts(l.samples),ie=(e(n.samples[0].pts,$)-$)/l.inputTimeScale;P+=Math.max(0,ie),F+=Math.max(0,-ie)}if(j){if(n.samplerate||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(n,l,p)),b=this.remuxAudio(n,P,this.isAudioContiguous,r,B||V||c===o.PlaylistLevelType.AUDIO?F:void 0),V){var se=b?b.endPTS-b.startPTS:0;l.inputTimeScale||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(n,l,p)),S=this.remuxVideo(l,F,H,se)}}else V&&(S=this.remuxVideo(l,F,H,0));S&&(S.firstKeyFrame=X,S.independent=X!==-1)}}return this.ISGenerated&&(v.samples.length&&(w=this.remuxID3(v,p)),g.samples.length&&(I=this.remuxText(g,p))),{audio:b,video:S,initSegment:k,independent:O,text:I,id3:w}},u.generateIS=function(n,l,v){var g,p,r,i=n.samples,c=l.samples,S=this.typeSupported,b={},k=!Object(R.isFiniteNumber)(this._initPTS),I="audio/mp4";if(k&&(g=p=1/0),n.config&&i.length&&(n.timescale=n.samplerate,n.isAAC||(S.mpeg?(I="audio/mpeg",n.codec=""):S.mp3&&(n.codec="mp3")),b.audio={id:"audio",container:I,codec:n.codec,initSegment:!n.isAAC&&S.mpeg?new Uint8Array(0):A.default.initSegment([n]),metadata:{channelCount:n.channelCount}},k&&(r=n.inputTimeScale,g=p=i[0].pts-Math.round(r*v))),l.sps&&l.pps&&c.length&&(l.timescale=l.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:A.default.initSegment([l]),metadata:{width:l.width,height:l.height}},k)){r=l.inputTimeScale;var w=this.getVideoStartPts(c),O=Math.round(r*v);p=Math.min(p,e(c[0].dts,w)-O),g=Math.min(g,w-O)}if(Object.keys(b).length)return this.ISGenerated=!0,k&&(this._initPTS=g,this._initDTS=p),{tracks:b,initPTS:g,timescale:r}},u.remuxVideo=function(n,l,v,g){var p,r,i,c=n.inputTimeScale,S=n.samples,b=[],k=S.length,I=this._initPTS,w=this.nextAvcDts,O=8,P=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,M=0,B=!1;v&&w!==null||(w=l*c-(S[0].pts-e(S[0].dts,S[0].pts)));for(var U=0;U<k;U++){var j=S[U];j.pts=e(j.pts-I,w),j.dts=e(j.dts-I,w),j.dts>j.pts&&(M=Math.max(Math.min(M,j.pts-j.dts),-18e3)),j.dts<S[U>0?U-1:U].dts&&(B=!0)}B&&S.sort(function(_e,Ue){var Dt=_e.dts-Ue.dts,Rt=_e.pts-Ue.pts;return Dt||Rt}),r=S[0].dts,i=S[S.length-1].dts;var V=Math.round((i-r)/(k-1));if(M<0){if(M<-2*V){_.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(L.toMsFromMpegTsClock)(-V,!0)+" ms");for(var H=M,X=0;X<k;X++)S[X].dts=H=Math.max(H,S[X].pts-V),S[X].pts=Math.max(H,S[X].pts)}else{_.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<k;q++)S[q].dts=S[q].dts+M}r=S[0].dts}if(v){var $=r-w,ie=$>V;if(ie||$<-1){ie?_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)($,!0)+" ms ("+$+"dts) hole between fragments detected, filling it"):_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(-$,!0)+" ms ("+$+"dts) overlapping between fragments detected"),r=w;var se=S[0].pts-$;S[0].dts=r,S[0].pts=se,_.logger.log("Video: First PTS/DTS adjusted: "+Object(L.toMsFromMpegTsClock)(se,!0)+"/"+Object(L.toMsFromMpegTsClock)(r,!0)+", delta: "+Object(L.toMsFromMpegTsClock)($,!0)+" ms")}}y&&(r=Math.max(0,r));for(var le=0,re=0,fe=0;fe<k;fe++){for(var te=S[fe],ne=te.units,ce=ne.length,ue=0,ve=0;ve<ce;ve++)ue+=ne[ve].data.length;re+=ue,le+=ce,te.length=ue,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=S[k-1].dts;var ye,W=re+4*le+8;try{ye=new Uint8Array(W)}catch{return void this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:W,reason:"fail allocating video mdat "+W})}var de=new DataView(ye.buffer);de.setUint32(0,W),ye.set(A.default.types.mdat,4);for(var oe=0;oe<k;oe++){for(var pe=S[oe],We=pe.units,ke=0,Oe=0,Ye=We.length;Oe<Ye;Oe++){var Me=We[Oe],Ie=Me.data,$e=Me.data.byteLength;de.setUint32(O,$e),O+=4,ye.set(Ie,O),O+=$e,ke+=4+$e}if(oe<k-1)p=S[oe+1].dts-pe.dts;else{var qe=this.config,Ce=pe.dts-S[oe>0?oe-1:oe].dts;if(qe.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qe=Math.floor(qe.maxBufferHole*c),ze=(g?P+g*c:this.nextAudioPts)-pe.pts;ze>Qe?((p=ze-Ce)<0&&(p=Ce),_.logger.log("[mp4-remuxer]: It is approximately "+ze/90+" ms to the next segment; using duration "+p/90+" ms for the last video frame.")):p=Ce}else p=Ce}var Ne=Math.round(pe.pts-pe.dts);b.push(new a(pe.key,p,ke,Ne))}if(b.length&&f&&f<70){var Pe=b[0].flags;Pe.dependsOn=2,Pe.isNonSync=0}console.assert(p!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=w=i+p,this.isVideoContiguous=!0;var Be={data1:A.default.moof(n.sequenceNumber++,r,m({},n,{samples:b})),data2:ye,startPTS:P/c,endPTS:(F+p)/c,startDTS:r/c,endDTS:w/c,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(ye.length,"MDAT length must not be zero"),Be},u.remuxAudio=function(n,l,v,g,p){var r=n.inputTimeScale,i=r/(n.samplerate?n.samplerate:r),c=n.isAAC?1024:1152,S=c*i,b=this._initPTS,k=!n.isAAC&&this.typeSupported.mpeg,I=[],w=n.samples,O=k?0:8,P=this.nextAudioPts||-1,F=l*r;if(this.isAudioContiguous=v=v||w.length&&P>0&&(g&&Math.abs(F-P)<9e3||Math.abs(e(w[0].pts-b,F)-P)<20*S),w.forEach(function(Ie){Ie.pts=e(Ie.pts-b,F)}),!v||P<0){if(!(w=w.filter(function(Ie){return Ie.pts>=0})).length)return;P=p===0?0:g?Math.max(0,F):w[0].pts}if(n.isAAC)for(var M=p!==void 0,B=this.config.maxAudioFramesDrift,U=0,j=P;U<w.length;U++){var V=w[U],H=V.pts,X=H-j,q=Math.abs(1e3*X/r);if(X<=-B*S&&M)U===0&&(_.logger.warn("Audio frame @ "+(H/r).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/r)+" ms."),this.nextAudioPts=P=j=H);else if(X>=B*S&&q<1e4&&M){var $=Math.round(X/S);(j=H-$*S)<0&&($--,j+=S),U===0&&(this.nextAudioPts=P=j),_.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||(_.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),le=V.unit.subarray()),w.splice(U,0,{unit:le,pts:se}),j+=S,U++}}V.pts=j,j+=S}for(var re,fe=null,te=null,ne=0,ce=w.length;ce--;)ne+=w[ce].unit.byteLength;for(var ue=0,ve=w.length;ue<ve;ue++){var ye=w[ue],W=ye.unit,de=ye.pts;if(te!==null)I[ue-1].duration=Math.round((de-te)/i);else{if(v&&n.isAAC&&(de=P),fe=de,!(ne>0))return;ne+=O;try{re=new Uint8Array(ne)}catch{return void this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ne,reason:"fail allocating audio mdat "+ne})}k||(new DataView(re.buffer).setUint32(0,ne),re.set(A.default.types.mdat,4))}re.set(W,O);var oe=W.byteLength;O+=oe,I.push(new a(!0,c,oe,0)),te=de}var pe=I.length;if(pe){var We=I[I.length-1];this.nextAudioPts=P=te+i*We.duration;var ke=k?new Uint8Array(0):A.default.moof(n.sequenceNumber++,fe/i,m({},n,{samples:I}));n.samples=[];var Oe=fe/r,Ye=P/r,Me={data1:ke,data2:re,startPTS:Oe,endPTS:Ye,startDTS:Oe,endDTS:Ye,type:"audio",hasAudio:!0,hasVideo:!1,nb:pe};return this.isAudioContiguous=!0,console.assert(re.length,"MDAT length must not be zero"),Me}},u.remuxEmptyAudio=function(n,l,v,g){var p=n.inputTimeScale,r=p/(n.samplerate?n.samplerate:p),i=this.nextAudioPts,c=(i!==null?i:g.startDTS*p)+this._initDTS,S=g.endDTS*p+this._initDTS,b=1024*r,k=Math.ceil((S-c)/b),I=T.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(_.logger.warn("[mp4-remuxer]: remux empty Audio"),I){for(var w=[],O=0;O<k;O++){var P=c+O*b;w.push({unit:I,pts:P,dts:P})}return n.samples=w,this.remuxAudio(n,l,v,!1)}_.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},u.remuxID3=function(n,l){var v=n.samples.length;if(v){for(var g=n.inputTimeScale,p=this._initPTS,r=this._initDTS,i=0;i<v;i++){var c=n.samples[i];c.pts=e(c.pts-p,l*g)/g,c.dts=e(c.dts-r,l*g)/g}var S=n.samples;return n.samples=[],{samples:S}}},u.remuxText=function(n,l){var v=n.samples.length;if(v){for(var g=n.inputTimeScale,p=this._initPTS,r=0;r<v;r++){var i=n.samples[r];i.pts=e(i.pts-p,l*g)/g}n.samples.sort(function(S,b){return S.pts-b.pts});var c=n.samples;return n.samples=[],{samples:c}}},s}();function e(s,u){var n;if(u===null)return s;for(n=u<s?-8589934592:8589934592;Math.abs(s-u)>4294967296;)s+=n;return s}var a=function(s,u,n,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=n,this.cts=l,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,x,h){h.r(x);var R=h("./src/polyfills/number.ts"),T=h("./src/utils/mp4-tools.ts"),A=h("./src/loader/fragment.ts"),D=h("./src/utils/logger.ts"),C=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,E,y){this.audioCodec=E,this.videoCodec=y,this.generateInitSegment(f),this.emitInitSegment=!0},m.generateInitSegment=function(f){var E=this.audioCodec,y=this.videoCodec;if(!f||!f.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var d=this.initData=Object(T.parseInitSegment)(f);E||(E=o(d.audio,A.ElementaryStreamTypes.AUDIO)),y||(y=o(d.video,A.ElementaryStreamTypes.VIDEO));var e={};d.audio&&d.video?e.audiovideo={container:"video/mp4",codec:E+","+y,initSegment:f,id:"main"}:d.audio?e.audio={container:"audio/mp4",codec:E,initSegment:f,id:"audio"}:d.video?e.video={container:"video/mp4",codec:y,initSegment:f,id:"main"}:D.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},m.remux=function(f,E,y,d,e){var a=this.initPTS,t=this.lastEndDTS,s={audio:void 0,video:void 0,text:d,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var u=E.samples;if(!u||!u.length)return s;var n={initPTS:void 0,timescale:1},l=this.initData;if(l&&l.length||(this.generateInitSegment(u),l=this.initData),!l||!l.length)return D.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=_(l,u,t));var v=Object(T.getDuration)(u,l),g=t,p=v+g;Object(T.offsetStartDTS)(l,u,a),v>0?this.lastEndDTS=p:(D.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var r=!!l.audio,i=!!l.video,c="";r&&(c+="audio"),i&&(c+="video");var S={data1:u,startPTS:g,startDTS:g,endPTS:p,endDTS:p,type:c,hasAudio:r,hasVideo:i,nb:1,dropped:0};return s.audio=S.type==="audio"?S:void 0,s.video=S.type!=="audio"?S:void 0,s.text=d,s.id3=y,s.initSegment=n,s},L}(),_=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"}x.default=C},"./src/task-loop.ts":function(N,x,h){h.r(x),h.d(x,"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(D){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,D),!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,x,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 D(o,L){var m=o.canSkipUntil,f=o.canSkipDateRanges,E=o.endSN;return m&&(L!==void 0?L-E:0)<m?f?T.v2:T.Yes:T.No}h.r(x),h.d(x,"HlsSkip",function(){return T}),h.d(x,"getSkipValue",function(){return D}),h.d(x,"HlsUrlParameters",function(){return C}),h.d(x,"Level",function(){return _}),(A=T||(T={})).No="",A.Yes="YES",A.v2="v2";var C=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}(),_=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(E){return E}).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 E=f%this.url.length;this._urlId!==E&&(this.details=void 0,this._urlId=E)}}])&&R(L.prototype,m),o}()},"./src/types/loader.ts":function(N,x,h){var R,T,A,D;h.r(x),h.d(x,"PlaylistContextType",function(){return R}),h.d(x,"PlaylistLevelType",function(){return A}),(T=R||(R={})).MANIFEST="manifest",T.LEVEL="level",T.AUDIO_TRACK="audioTrack",T.SUBTITLE_TRACK="subtitleTrack",(D=A||(A={})).MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":function(N,x,h){h.r(x),h.d(x,"ChunkMetadata",function(){return R});var R=function(T,A,D,C,_,o){C===void 0&&(C=0),_===void 0&&(_=-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=D,this.size=C,this.part=_,this.partial=o}},"./src/utils/attr-list.ts":function(N,x,h){h.r(x),h.d(x,"AttrList",function(){return A});var R=/^(\d+)x(\d+)$/,T=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function D(_){for(var o in typeof _=="string"&&(_=D.parseAttrList(_)),_)_.hasOwnProperty(o)&&(this[o]=_[o])}var C=D.prototype;return C.decimalInteger=function(_){var o=parseInt(this[_],10);return o>Number.MAX_SAFE_INTEGER?1/0:o},C.hexadecimalInteger=function(_){if(this[_]){var o=(this[_]||"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},C.hexadecimalIntegerAsNumber=function(_){var o=parseInt(this[_],16);return o>Number.MAX_SAFE_INTEGER?1/0:o},C.decimalFloatingPoint=function(_){return parseFloat(this[_])},C.optionalFloat=function(_,o){var L=this[_];return L?parseFloat(L):o},C.enumeratedString=function(_){return this[_]},C.bool=function(_){return this[_]==="YES"},C.decimalResolution=function(_){var o=R.exec(this[_]);if(o!==null)return{width:parseInt(o[1],10),height:parseInt(o[2],10)}},D.parseAttrList=function(_){var o,L={};for(T.lastIndex=0;(o=T.exec(_))!==null;){var m=o[2];m.indexOf('"')===0&&m.lastIndexOf('"')===m.length-1&&(m=m.slice(1,-1)),L[o[1]]=m}return L},D}()},"./src/utils/binary-search.ts":function(N,x,h){h.r(x),x.default={search:function(R,T){for(var A=0,D=R.length-1,C=null,_=null;A<=D;){var o=T(_=R[C=(A+D)/2|0]);if(o>0)A=C+1;else{if(!(o<0))return _;D=C-1}}return null}}},"./src/utils/buffer-helper.ts":function(N,x,h){h.r(x),h.d(x,"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 D(){}return D.isBuffered=function(C,_){try{if(C){for(var o=D.getBuffered(C),L=0;L<o.length;L++)if(_>=o.start(L)&&_<=o.end(L))return!0}}catch{}return!1},D.bufferInfo=function(C,_,o){try{if(C){var L,m=D.getBuffered(C),f=[];for(L=0;L<m.length;L++)f.push({start:m.start(L),end:m.end(L)});return this.bufferedInfo(f,_,o)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},D.bufferedInfo=function(C,_,o){_=Math.max(0,_),C.sort(function(n,l){var v=n.start-l.start;return v||l.end-n.end});var L=[];if(o)for(var m=0;m<C.length;m++){var f=L.length;if(f){var E=L[f-1].end;C[m].start-E<o?C[m].end>E&&(L[f-1].end=C[m].end):L.push(C[m])}else L.push(C[m])}else L=C;for(var y,d=0,e=_,a=_,t=0;t<L.length;t++){var s=L[t].start,u=L[t].end;if(_+o>=s&&_<u)e=s,d=(a=u)-_;else if(_+o<s){y=s;break}}return{len:d,start:e||0,end:a||0,nextStart:y}},D.getBuffered=function(C){try{return C.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),T}},D}()},"./src/utils/cea-608-parser.ts":function(N,x,h){h.r(x),h.d(x,"Row",function(){return s}),h.d(x,"CaptionScreen",function(){return u});var R,T,A=h("./src/utils/logger.ts"),D={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},C=function(p){var r=p;return D.hasOwnProperty(p)&&(r=D[p]),String.fromCharCode(r)},_=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},E={25:2,26:4,29:6,30:8,31:10,27:13,28:15},y=["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 d=function(){function p(){this.time=null,this.verboseLevel=R.ERROR}return p.prototype.log=function(r,i){this.verboseLevel>=r&&A.logger.log(this.time+" ["+r+"] "+i)},p}(),e=function(p){for(var r=[],i=0;i<p.length;i++)r.push(p[i].toString(16));return r},a=function(){function p(i,c,S,b,k){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=c||!1,this.italics=S||!1,this.background=b||"black",this.flash=k||!1}var r=p.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 c=["foreground","underline","italics","background","flash"],S=0;S<c.length;S++){var b=c[S];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},p}(),t=function(){function p(i,c,S,b,k,I){this.uchar=void 0,this.penState=void 0,this.uchar=i||" ",this.penState=new a(c,S,b,k,I)}var r=p.prototype;return r.reset=function(){this.uchar=" ",this.penState.reset()},r.setChar=function(i,c){this.uchar=i,this.penState.copy(c)},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()},p}(),s=function(){function p(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 c=0;c<o;c++)this.chars.push(new t);this.logger=i,this.pos=0,this.currPenState=new a}var r=p.prototype;return r.equals=function(i){for(var c=!0,S=0;S<o;S++)if(!this.chars[S].equals(i.chars[S])){c=!1;break}return c},r.copy=function(i){for(var c=0;c<o;c++)this.chars[c].copy(i.chars[c])},r.isEmpty=function(){for(var i=!0,c=0;c<o;c++)if(!this.chars[c].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 c=this.pos+i;if(i>1)for(var S=this.pos+1;S<c+1;S++)this.chars[S].setPenState(this.currPenState);this.setCursor(c)},r.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},r.insertChar=function(i){i>=144&&this.backSpace();var c=C(i);this.pos>=o?this.logger.log(R.ERROR,"Cannot insert "+i.toString(16)+" ("+c+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(c,this.currPenState),this.moveCursor(1))},r.clearFromPos=function(i){var c;for(c=i;c<o;c++)this.chars[c].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=[],c=!0,S=0;S<o;S++){var b=this.chars[S].uchar;b!==" "&&(c=!1),i.push(b)}return c?"":i.join("")},r.setPenStyles=function(i){this.currPenState.setStyles(i),this.chars[this.pos].setPenState(this.currPenState)},p}(),u=function(){function p(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 c=0;c<_;c++)this.rows.push(new s(i));this.logger=i,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var r=p.prototype;return r.reset=function(){for(var i=0;i<_;i++)this.rows[i].clear();this.currRow=14},r.equals=function(i){for(var c=!0,S=0;S<_;S++)if(!this.rows[S].equals(i.rows[S])){c=!1;break}return c},r.copy=function(i){for(var c=0;c<_;c++)this.rows[c].copy(i.rows[c])},r.isEmpty=function(){for(var i=!0,c=0;c<_;c++)if(!this.rows[c].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 c=i.row-1;if(this.nrRollUpRows&&c<this.nrRollUpRows-1&&(c=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==c){for(var S=0;S<_;S++)this.rows[S].clear();var b=this.currRow+1-this.nrRollUpRows,k=this.lastOutputScreen;if(k){var I=k.rows[b].cueStartTime,w=this.logger.time;if(I&&w!==null&&I<w)for(var O=0;O<this.nrRollUpRows;O++)this.rows[c-this.nrRollUpRows+O+1].copy(k.rows[b+O])}}this.currRow=c;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,c=this.rows.splice(i,1)[0];c.clear(),this.rows.splice(this.currRow,0,c),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 c=[],S="",b=-1,k=0;k<_;k++){var I=this.rows[k].getTextString();I&&(b=k+1,i?c.push("Row "+b+": '"+I+"'"):c.push(I.trim()))}return c.length>0&&(S=i?"["+c.join(" | ")+"]":c.join(`
|
||
`)),S},r.getTextAndFormat=function(){return this.rows},p}(),n=function(){function p(i,c,S){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=c,this.mode=null,this.verbose=0,this.displayedMemory=new u(S),this.nonDisplayedMemory=new u(S),this.lastOutputScreen=new u(S),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=S}var r=p.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 c=0;c<i.length;c++)this.writeScreen.insertChar(i[c]);var S=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(R.INFO,S+": "+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 c={flash:!1};if(c.underline=i%2==1,c.italics=i>=46,c.italics)c.foreground="white";else{var S=Math.floor(i/2)-16;c.foreground=["white","green","blue","cyan","red","yellow","magenta"][S]}this.logger.log(R.INFO,"MIDROW: "+JSON.stringify(c)),this.writeScreen.setPen(c)},r.outputDataUpdate=function(i){i===void 0&&(i=!1);var c=this.logger.time;c!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,c,this.lastOutputScreen),i&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:c):this.cueStartTime=c,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))},p}(),l=function(){function p(i,c,S){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new d;this.channels=[null,new n(i,c,b),new n(i+1,S,b)],this.cmdHistory={a:null,b:null},this.logger=b}var r=p.prototype;return r.getHandler=function(i){return this.channels[i].getHandler()},r.setHandler=function(i,c){this.channels[i].setHandler(c)},r.addData=function(i,c){var S,b,k,I=!1;this.logger.time=i;for(var w=0;w<c.length;w+=2)if(b=127&c[w],k=127&c[w+1],b!==0||k!==0){if(this.logger.log(R.DATA,"["+e([c[w],c[w+1]])+"] -> ("+e([b,k])+")"),(S=this.parseCmd(b,k))||(S=this.parseMidrow(b,k)),S||(S=this.parsePAC(b,k)),S||(S=this.parseBackgroundAttributes(b,k)),!S&&(I=this.parseChars(b,k))){var O=this.currentChannel;O&&O>0?this.channels[O].insertChars(I):this.logger.log(R.WARNING,"No channel found yet. TEXT-MODE?")}S||I||this.logger.log(R.WARNING,"Couldn't parse cleaned data "+e([b,k])+" orig: "+e([c[w],c[w+1]]))}},r.parseCmd=function(i,c){var S=this.cmdHistory;if(!((i===20||i===28||i===21||i===29)&&c>=32&&c<=47||(i===23||i===31)&&c>=33&&c<=35))return!1;if(g(i,c,S))return v(null,null,S),this.logger.log(R.DEBUG,"Repeated command ("+e([i,c])+") is dropped"),!0;var b=i===20||i===21||i===23?1:2,k=this.channels[b];return i===20||i===21||i===28||i===29?c===32?k.ccRCL():c===33?k.ccBS():c===34?k.ccAOF():c===35?k.ccAON():c===36?k.ccDER():c===37?k.ccRU(2):c===38?k.ccRU(3):c===39?k.ccRU(4):c===40?k.ccFON():c===41?k.ccRDC():c===42?k.ccTR():c===43?k.ccRTD():c===44?k.ccEDM():c===45?k.ccCR():c===46?k.ccENM():c===47&&k.ccEOC():k.ccTO(c-32),v(i,c,S),this.currentChannel=b,!0},r.parseMidrow=function(i,c){var S=0;if((i===17||i===25)&&c>=32&&c<=47){if((S=i===17?1:2)!==this.currentChannel)return this.logger.log(R.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[S];return!!b&&(b.ccMIDROW(c),this.logger.log(R.DEBUG,"MIDROW ("+e([i,c])+")"),!0)}return!1},r.parsePAC=function(i,c){var S,b=this.cmdHistory;if(!((i>=17&&i<=23||i>=25&&i<=31)&&c>=64&&c<=127||(i===16||i===24)&&c>=64&&c<=95))return!1;if(g(i,c,b))return v(null,null,b),!0;var k=i<=23?1:2;S=c>=64&&c<=95?k===1?L[i]:f[i]:k===1?m[i]:E[i];var I=this.channels[k];return!!I&&(I.setPAC(this.interpretPAC(S,c)),v(i,c,b),this.currentChannel=k,!0)},r.interpretPAC=function(i,c){var S,b={color:null,italics:!1,indent:null,underline:!1,row:i};return S=c>95?c-96:c-64,b.underline=(1&S)==1,S<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(b.italics=!0,b.color="white"):b.indent=4*Math.floor((S-16)/2),b},r.parseChars=function(i,c){var S,b,k=null,I=null;if(i>=25?(S=2,I=i-8):(S=1,I=i),I>=17&&I<=19?(b=I===17?c+80:I===18?c+112:c+144,this.logger.log(R.INFO,"Special char '"+C(b)+"' in channel "+S),k=[b]):i>=32&&i<=127&&(k=c===0?[i]:[i,c]),k){var w=e(k);this.logger.log(R.DEBUG,"Char codes = "+w.join(",")),v(i,c,this.cmdHistory)}return k},r.parseBackgroundAttributes=function(i,c){var S;if(!((i===16||i===24)&&c>=32&&c<=47||(i===23||i===31)&&c>=45&&c<=47))return!1;var b={};i===16||i===24?(S=Math.floor((c-32)/2),b.background=y[S],c%2==1&&(b.background=b.background+"_semi")):c===45?b.background="transparent":(b.foreground="black",c===47&&(b.underline=!0));var k=i<=23?1:2;return this.channels[k].setBkgData(b),v(i,c,this.cmdHistory),!0},r.reset=function(){for(var i=0;i<Object.keys(this.channels).length;i++){var c=this.channels[i];c&&c.reset()}this.cmdHistory={a:null,b:null}},r.cueSplitAtTime=function(i){for(var c=0;c<this.channels.length;c++){var S=this.channels[c];S&&S.cueSplitAtTime(i)}},p}();function v(p,r,i){i.a=p,i.b=r}function g(p,r,i){return i.a===p&&i.b===r}x.default=l},"./src/utils/codecs.ts":function(N,x,h){h.r(x),h.d(x,"isCodecType",function(){return T}),h.d(x,"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(D,C){var _=R[C];return!!_&&_[D.slice(0,4)]===!0}function A(D,C){return MediaSource.isTypeSupported((C||"video")+'/mp4;codecs="'+D+'"')}},"./src/utils/cues.ts":function(N,x,h){h.r(x);var R=h("./src/utils/vttparser.ts"),T=h("./src/utils/webvtt-parser.ts"),A=h("./src/utils/texttrack-utils.ts"),D=/\s/,C={newCue:function(_,o,L,m){for(var f,E,y,d,e,a=[],t=self.VTTCue||self.TextTrackCue,s=0;s<m.rows.length;s++)if(y=!0,d=0,e="",!(f=m.rows[s]).isEmpty()){for(var u=0;u<f.chars.length;u++)D.test(f.chars[u].uchar)&&y?d++:(e+=f.chars[u].uchar,y=!1);f.cueStartTime=o,o===L&&(L+=1e-4),d>=16?d--:d++;var n=Object(R.fixLineBreaks)(e.trim()),l=Object(T.generateCueId)(o,L,n);_&&_.cues&&_.cues.getCueById(l)||((E=new t(o,L,n)).id=l,E.line=s+1,E.align="left",E.position=10+Math.min(80,10*Math.floor(8*d/32)),a.push(E))}return _&&a.length&&(a.sort(function(v,g){return v.line==="auto"||g.line==="auto"?0:v.line>8&&g.line>8?g.line-v.line:v.line-g.line}),a.forEach(function(v){return Object(A.addCueToTrack)(_,v)})),a}};x.default=C},"./src/utils/discontinuities.ts":function(N,x,h){h.r(x),h.d(x,"findFirstFragWithCC",function(){return D}),h.d(x,"shouldAlignOnDiscontinuities",function(){return C}),h.d(x,"findDiscontinuousReferenceFrag",function(){return _}),h.d(x,"adjustSlidingStart",function(){return L}),h.d(x,"alignStream",function(){return m}),h.d(x,"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 D(E,y){for(var d=null,e=0,a=E.length;e<a;e++){var t=E[e];if(t&&t.cc===y){d=t;break}}return d}function C(E,y,d){return!(!y.details||!(d.endCC>d.startCC||E&&E.cc<d.startCC))}function _(E,y){var d=E.fragments,e=y.fragments;if(e.length&&d.length){var a=D(d,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(E,y){if(E){var d=E.start+y;E.start=E.startPTS=d,E.endPTS=d+E.duration}}function L(E,y){for(var d=y.fragments,e=0,a=d.length;e<a;e++)o(d[e],E);y.fragmentHint&&o(y.fragmentHint,E),y.alignedSliding=!0}function m(E,y,d){y&&(function(e,a,t){if(C(e,t,a)){var s=_(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))}}(E,d,y),!d.alignedSliding&&y.details&&f(d,y.details),d.alignedSliding||!y.details||d.skippedSegments||Object(A.adjustSliding)(y.details,d))}function f(E,y){if(y.fragments.length&&E.hasProgramDateTime&&y.hasProgramDateTime){var d=y.fragments[0].programDateTime,e=E.fragments[0].programDateTime,a=(e-d)/1e3+y.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(T.logger.log("Adjusting PTS using programDateTime delta "+(e-d)+"ms, sliding:"+a.toFixed(3)+" "+E.url+" "),L(a,E))}}},"./src/utils/ewma-bandwidth-estimator.ts":function(N,x,h){h.r(x);var R=h("./src/utils/ewma.ts"),T=function(){function A(C,_,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(C),this.fast_=new R.default(_)}var D=A.prototype;return D.update=function(C,_){var o=this.slow_,L=this.fast_;this.slow_.halfLife!==C&&(this.slow_=new R.default(C,o.getEstimate(),o.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,L.getEstimate(),L.getTotalWeight()))},D.sample=function(C,_){var o=(C=Math.max(C,this.minDelayMs_))/1e3,L=8*_/o;this.fast_.sample(o,L),this.slow_.sample(o,L)},D.canEstimate=function(){var C=this.fast_;return C&&C.getTotalWeight()>=this.minWeight_},D.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},D.destroy=function(){},A}();x.default=T},"./src/utils/ewma.ts":function(N,x,h){h.r(x);var R=function(){function T(D,C,_){C===void 0&&(C=0),_===void 0&&(_=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=D,this.alpha_=D?Math.exp(Math.log(.5)/D):0,this.estimate_=C,this.totalWeight_=_}var A=T.prototype;return A.sample=function(D,C){var _=Math.pow(this.alpha_,D);this.estimate_=C*(1-_)+_*this.estimate_,this.totalWeight_+=D},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var D=1-Math.pow(this.alpha_,this.totalWeight_);if(D)return this.estimate_/D}return this.estimate_},T}();x.default=R},"./src/utils/fetch-loader.ts":function(N,x,h){h.r(x),h.d(x,"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 D(d){var e=typeof Map=="function"?new Map:void 0;return(D=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 C(a,arguments,L(this).constructor)}return s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),o(s,a)})(d)}function C(d,e,a){return(C=_()?Reflect.construct:function(t,s,u){var n=[null];n.push.apply(n,s);var l=new(Function.bind.apply(t,n));return u&&o(l,u.prototype),l}).apply(null,arguments)}function _(){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(d,e){return(o=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(d,e)}function L(d){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(d)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var f=function(){function d(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||E,this.controller=new self.AbortController,this.stats=new T.LoadStats}var e=d.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 u=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var l=function(r,i){var c={method:"GET",mode:"cors",credentials:"same-origin",signal:i};return r.rangeEnd&&(c.headers=new self.Headers({Range:"bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)})),c}(a,this.controller.signal),v=s.onProgress,g=a.responseType==="arraybuffer",p=g?"byteLength":"length";this.context=a,this.config=t,this.callbacks=s,this.request=this.fetchSetup(a,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),s.onTimeout(n,a,u.response)},t.timeout),self.fetch(this.request).then(function(r){if(u.response=u.loader=r,!r.ok){var i=r.status,c=r.statusText;throw new y(c||"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"),v&&Object(R.isFiniteNumber)(t.highWaterMark)?u.loadProgressively(r,n,a,t.highWaterMark,v):g?r.arrayBuffer():r.text()}).then(function(r){var i=u.response;self.clearTimeout(u.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=r[p];var c={url:i.url,data:r};v&&!Object(R.isFiniteNumber)(t.highWaterMark)&&v(n,a,r,i),s.onSuccess(c,n,a,i)}).catch(function(r){if(self.clearTimeout(u.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,u,n){u===void 0&&(u=0);var l=new A.default,v=a.body.getReader();return function g(){return v.read().then(function(p){if(p.done)return l.dataLength&&n(t,s,l.flush(),a),Promise.resolve(new ArrayBuffer(0));var r=p.value,i=r.length;return t.loaded+=i,i<u||l.dataLength?(l.push(r),l.dataLength>=u&&n(t,s,l.flush(),a)):n(t,s,r,a),g()}).catch(function(){return Promise.reject()})}()},d}();function E(d,e){return new self.Request(d.url,e)}var y=function(d){var e,a;function t(s,u,n){var l;return(l=d.call(this,s)||this).code=void 0,l.details=void 0,l.code=u,l.details=n,l}return a=d,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,o(e,a),t}(D(Error));x.default=f},"./src/utils/imsc1-ttml-parser.ts":function(N,x,h){h.r(x),h.d(x,"IMSC1_CODEC",function(){return L}),h.d(x,"parseIMSC1",function(){return y});var R=h("./src/utils/mp4-tools.ts"),T=h("./src/utils/vttparser.ts"),A=h("./src/utils/vttcue.ts"),D=h("./src/demux/id3.ts"),C=h("./src/utils/timescale-conversion.ts"),_=h("./src/utils/webvtt-parser.ts");function o(){return(o=Object.assign||function(n){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(n[g]=v[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)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function y(n,l,v,g,p){var r=Object(R.findBox)(new Uint8Array(n),["mdat"]);if(r.length!==0){var i=r[0],c=Object(D.utf8ArrayToStr)(new Uint8Array(n,i.start,i.end-i.start)),S=Object(C.toTimescaleFromScale)(l,1,v);try{g(function(b,k){var I=new DOMParser().parseFromString(b,"text/xml").getElementsByTagName("tt")[0];if(!I)throw new Error("Invalid ttml");var w={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(w).reduce(function(U,j){return U[j]=I.getAttribute("ttp:"+j)||w[j],U},{}),P=I.getAttribute("xml:space")!=="preserve",F=e(d(I,"styling","style")),M=e(d(I,"layout","region")),B=d(I,"body","[begin]");return[].map.call(B,function(U){var j=a(U,P);if(!j||!U.hasAttribute("begin"))return null;var V=u(U.getAttribute("begin"),O),H=u(U.getAttribute("dur"),O),X=u(U.getAttribute("end"),O);if(V===null)throw s(U);if(X===null){if(H===null)throw s(U);X=V+H}var q=new A.default(V-k,X-k,j);q.id=Object(_.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(fe,te){var ne="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(ce,ue){var ve=t(te,ne,ue)||t(fe,ne,ue);return ve&&(ce[ue]=ve),ce},{})}($,ie),le=se.textAlign;if(le){var re=E[le];re&&(q.lineAlign=re),q.align=le}return o(q,se),q}).filter(function(U){return U!==null})}(c,S))}catch(b){p(b)}}else p(new Error("Could not parse IMSC1 mdat"))}function d(n,l,v){var g=n.getElementsByTagName(l)[0];return g?[].slice.call(g.querySelectorAll(v)):[]}function e(n){return n.reduce(function(l,v){var g=v.getAttribute("xml:id");return g&&(l[g]=v),l},{})}function a(n,l){return[].slice.call(n.childNodes).reduce(function(v,g,p){var r;return g.nodeName==="br"&&p?v+`
|
||
`:(r=g.childNodes)!==null&&r!==void 0&&r.length?a(g,l):l?v+g.textContent.trim().replace(/\s+/g," "):v+g.textContent},"")}function t(n,l,v){return n.hasAttributeNS(l,v)?n.getAttributeNS(l,v):null}function s(n){return new Error("Could not parse ttml timestamp "+n)}function u(n,l){if(!n)return null;var v=Object(T.parseTimeStamp)(n);return v===null&&(m.test(n)?v=function(g,p){var r=m.exec(g),i=(0|r[4])+(0|r[5])/p.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/p.frameRate}(n,l):f.test(n)&&(v=function(g,p){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/p.frameRate;case"t":return i/p.tickRate}return i}(n,l))),v}},"./src/utils/logger.ts":function(N,x,h){h.r(x),h.d(x,"enableLogs",function(){return C}),h.d(x,"logger",function(){return _});var R=function(){},T={trace:R,debug:R,log:R,warn:R,info:R,error:R},A=T;function D(o){var L=self.console[o];return L?L.bind(self.console,"["+o+"] >"):R}function C(o){if(self.console&&o===!0||typeof o=="object"){(function(L){for(var m=arguments.length,f=new Array(m>1?m-1:0),E=1;E<m;E++)f[E-1]=arguments[E];f.forEach(function(y){A[y]=L[y]?L[y].bind(L):D(y)})})(o,"debug","log","info","warn","error");try{A.log()}catch{A=T}}else A=T}var _=T},"./src/utils/mediakeys-helper.ts":function(N,x,h){var R,T;h.r(x),h.d(x,"KeySystems",function(){return R}),h.d(x,"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,x,h){function R(){return self.MediaSource||self.WebKitMediaSource}h.r(x),h.d(x,"getMediaSource",function(){return R})},"./src/utils/mp4-tools.ts":function(N,x,h){h.r(x),h.d(x,"bin2str",function(){return C}),h.d(x,"readUint16",function(){return _}),h.d(x,"readUint32",function(){return o}),h.d(x,"writeUint32",function(){return L}),h.d(x,"findBox",function(){return m}),h.d(x,"parseSegmentIndex",function(){return f}),h.d(x,"parseInitSegment",function(){return E}),h.d(x,"getStartDTS",function(){return y}),h.d(x,"getDuration",function(){return d}),h.d(x,"computeRawDurationFromSamples",function(){return e}),h.d(x,"offsetStartDTS",function(){return a}),h.d(x,"segmentValidRange",function(){return t}),h.d(x,"appendUint8Array",function(){return s});var R=h("./src/utils/typed-array.ts"),T=h("./src/loader/fragment.ts"),A=Math.pow(2,32)-1,D=[].push;function C(u){return String.fromCharCode.apply(null,u)}function _(u,n){"data"in u&&(n+=u.start,u=u.data);var l=u[n]<<8|u[n+1];return l<0?65536+l:l}function o(u,n){"data"in u&&(n+=u.start,u=u.data);var l=u[n]<<24|u[n+1]<<16|u[n+2]<<8|u[n+3];return l<0?4294967296+l:l}function L(u,n,l){"data"in u&&(n+=u.start,u=u.data),u[n]=l>>24,u[n+1]=l>>16&255,u[n+2]=l>>8&255,u[n+3]=255&l}function m(u,n){var l,v,g,p=[];if(!n.length)return p;"data"in u?(l=u.data,v=u.start,g=u.end):(v=0,g=(l=u).byteLength);for(var r=v;r<g;){var i=o(l,r),c=i>1?r+i:g;if(C(l.subarray(r+4,r+8))===n[0])if(n.length===1)p.push({data:l,start:r+8,end:c});else{var S=m({data:l,start:r+8,end:c},n.slice(1));S.length&&D.apply(p,S)}r=c}return p}function f(u){var n=m(u,["moov"])[0],l=n?n.end:null,v=m(u,["sidx"]);if(!v||!v[0])return null;var g=[],p=v[0],r=p.data[0],i=r===0?8:16,c=o(p,i);i+=4,i+=r===0?8:16,i+=2;var S=p.end+0,b=_(p,i);i+=2;for(var k=0;k<b;k++){var I=i,w=o(p,I);I+=4;var O=2147483647&w;if((2147483648&w)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var P=o(p,I);I+=4,g.push({referenceSize:O,subsegmentDuration:P,info:{duration:P/c,start:S,end:S+O-1}}),S+=O,i=I+=4}return{earliestPresentationTime:0,timescale:c,version:r,referencesCount:b,references:g,moovEndOffset:l}}function E(u){for(var n=[],l=m(u,["moov","trak"]),v=0;v<l.length;v++){var g=l[v],p=m(g,["tkhd"])[0];if(p){var r=p.data[p.start],i=r===0?12:20,c=o(p,i),S=m(g,["mdia","mdhd"])[0];if(S){var b=o(S,i=(r=S.data[S.start])===0?12:20),k=m(g,["mdia","hdlr"])[0];if(k){var I=C(k.data.subarray(k.start+8,k.start+12)),w={soun:T.ElementaryStreamTypes.AUDIO,vide:T.ElementaryStreamTypes.VIDEO}[I];if(w){var O=m(g,["mdia","minf","stbl","stsd"])[0],P=void 0;O&&(P=C(O.data.subarray(O.start+12,O.start+16))),n[c]={timescale:b,type:w},n[w]={timescale:b,id:c,codec:P}}}}}}return m(u,["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 y(u,n){return m(n,["moof","traf"]).reduce(function(l,v){var g=m(v,["tfdt"])[0],p=g.data[g.start],r=m(v,["tfhd"]).reduce(function(i,c){var S=o(c,4),b=u[S];if(b){var k=o(g,4);p===1&&(k*=Math.pow(2,32),k+=o(g,8));var I=k/(b.timescale||9e4);if(isFinite(I)&&(i===null||I<i))return I}return i},null);return r!==null&&isFinite(r)&&(l===null||r<l)?r:l},null)||0}function d(u,n){for(var l=0,v=0,g=0,p=m(u,["moof","traf"]),r=0;r<p.length;r++){var i=p[r],c=m(i,["tfhd"])[0],S=n[o(c,4)];if(S){var b=S.default,k=o(c,0)|(b==null?void 0:b.flags),I=b==null?void 0:b.duration;8&k&&(I=o(c,2&k?12:8));for(var w=S.timescale||9e4,O=m(i,["trun"]),P=0;P<O.length;P++)l=I?I*o(O[P],4):e(O[P]),S.type===T.ElementaryStreamTypes.VIDEO?v+=l/w:S.type===T.ElementaryStreamTypes.AUDIO&&(g+=l/w)}}if(v===0&&g===0){var F=f(u);if(F!=null&&F.references)return F.references.reduce(function(M,B){return M+B.info.duration||0},0)}return v||g}function e(u){var n=o(u,0),l=8;1&n&&(l+=4),4&n&&(l+=4);for(var v=0,g=o(u,4),p=0;p<g;p++)256&n&&(v+=o(u,l),l+=4),512&n&&(l+=4),1024&n&&(l+=4),2048&n&&(l+=4);return v}function a(u,n,l){m(n,["moof","traf"]).forEach(function(v){m(v,["tfhd"]).forEach(function(g){var p=o(g,4),r=u[p];if(r){var i=r.timescale||9e4;m(v,["tfdt"]).forEach(function(c){var S=c.data[c.start],b=o(c,4);if(S===0)L(c,4,b-l*i);else{b*=Math.pow(2,32),b+=o(c,8),b-=l*i,b=Math.max(b,0);var k=Math.floor(b/(A+1)),I=Math.floor(b%(A+1));L(c,4,k),L(c,8,I)}})}})})}function t(u){var n={valid:null,remainder:null},l=m(u,["moof"]);if(!l)return n;if(l.length<2)return n.remainder=u,n;var v=l[l.length-1];return n.valid=Object(R.sliceUint8)(u,0,v.start-8),n.remainder=Object(R.sliceUint8)(u,v.start-8),n}function s(u,n){var l=new Uint8Array(u.length+n.length);return l.set(u),l.set(n,u.length),l}},"./src/utils/output-filter.ts":function(N,x,h){h.r(x),h.d(x,"default",function(){return R});var R=function(){function T(D,C){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=D,this.trackName=C}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(D,C,_){(this.startTime===null||this.startTime>D)&&(this.startTime=D),this.endTime=C,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},T}()},"./src/utils/texttrack-utils.ts":function(N,x,h){h.r(x),h.d(x,"sendAddTrackEvent",function(){return T}),h.d(x,"addCueToTrack",function(){return A}),h.d(x,"clearCurrentCues",function(){return D}),h.d(x,"removeCuesInRange",function(){return C}),h.d(x,"getCuesInRange",function(){return _});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(E){R.logger.debug("[texttrack-utils]: "+E);var f=new self.TextTrackCue(L.startTime,L.endTime,L.text);f.id=L.id,o.addCue(f)}m==="disabled"&&(o.mode=m)}function D(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 C(o,L,m){var f=o.mode;if(f==="disabled"&&(o.mode="hidden"),o.cues&&o.cues.length>0)for(var E=_(o.cues,L,m),y=0;y<E.length;y++)o.removeCue(E[y]);f==="disabled"&&(o.mode=f)}function _(o,L,m){var f=[],E=function(a,t){if(t<a[0].startTime)return 0;var s=a.length-1;if(t>a[s].endTime)return-1;for(var u=0,n=s;u<=n;){var l=Math.floor((n+u)/2);if(t<a[l].startTime)n=l-1;else{if(!(t>a[l].startTime&&u<s))return l;u=l+1}}return a[u].startTime-t<t-a[n].startTime?u:n}(o,L);if(E>-1)for(var y=E,d=o.length;y<d;y++){var e=o[y];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,x,h){h.r(x),x.default={toString:function(R){for(var T="",A=R.length,D=0;D<A;D++)T+="["+R.start(D).toFixed(3)+","+R.end(D).toFixed(3)+"]";return T}}},"./src/utils/timescale-conversion.ts":function(N,x,h){function R(C,_,o,L){o===void 0&&(o=1),L===void 0&&(L=!1);var m=C*_*o;return L?Math.round(m):m}function T(C,_,o,L){return o===void 0&&(o=1),L===void 0&&(L=!1),R(C,_,1/o,L)}function A(C,_){return _===void 0&&(_=!1),R(C,1e3,1/9e4,_)}function D(C,_){return _===void 0&&(_=1),R(C,9e4,1/_)}h.r(x),h.d(x,"toTimescaleFromBase",function(){return R}),h.d(x,"toTimescaleFromScale",function(){return T}),h.d(x,"toMsFromMpegTsClock",function(){return A}),h.d(x,"toMpegTsClockFromTimescale",function(){return D})},"./src/utils/typed-array.ts":function(N,x,h){function R(T,A,D){return Uint8Array.prototype.slice?T.slice(A,D):new Uint8Array(Array.prototype.slice.call(T,A,D))}h.r(x),h.d(x,"sliceUint8",function(){return R})},"./src/utils/vttcue.ts":function(N,x,h){h.r(x),x.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 D(o){return A(T,o)}function C(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 E=1;E<arguments.length;E++){var y=arguments[E];for(var d in y)o[d]=y[d]}return o}function _(o,L,m){var f=this,E={enumerable:!0};f.hasBeenReset=!1;var y="",d=!1,e=o,a=L,t=m,s=null,u="",n=!0,l="auto",v="start",g=50,p="middle",r=50,i="middle";Object.defineProperty(f,"id",C({},E,{get:function(){return y},set:function(c){y=""+c}})),Object.defineProperty(f,"pauseOnExit",C({},E,{get:function(){return d},set:function(c){d=!!c}})),Object.defineProperty(f,"startTime",C({},E,{get:function(){return e},set:function(c){if(typeof c!="number")throw new TypeError("Start time must be set to a number.");e=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",C({},E,{get:function(){return a},set:function(c){if(typeof c!="number")throw new TypeError("End time must be set to a number.");a=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",C({},E,{get:function(){return t},set:function(c){t=""+c,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",C({},E,{get:function(){return s},set:function(c){s=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",C({},E,{get:function(){return u},set:function(c){var S=function(b){return A(R,b)}(c);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");u=S,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",C({},E,{get:function(){return n},set:function(c){n=!!c,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",C({},E,{get:function(){return l},set:function(c){if(typeof c!="number"&&c!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",C({},E,{get:function(){return v},set:function(c){var S=D(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",C({},E,{get:function(){return g},set:function(c){if(c<0||c>100)throw new Error("Position must be between 0 and 100.");g=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",C({},E,{get:function(){return p},set:function(c){var S=D(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");p=S,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",C({},E,{get:function(){return r},set:function(c){if(c<0||c>100)throw new Error("Size must be between 0 and 100.");r=c,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",C({},E,{get:function(){return i},set:function(c){var S=D(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),f.displayState=void 0}return _.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(N,x,h){h.r(x),h.d(x,"parseTimeStamp",function(){return A}),h.d(x,"fixLineBreaks",function(){return m}),h.d(x,"VTTParser",function(){return f});var R=h("./src/utils/vttcue.ts"),T=function(){function E(){}return E.prototype.decode=function(y,d){if(!y)return"";if(typeof y!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(y))},E}();function A(E){function y(e,a,t,s){return 3600*(0|e)+60*(0|a)+(0|t)+parseFloat(s||0)}var d=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return d?parseFloat(d[2])>59?y(d[2],d[3],0,d[4]):y(d[1],d[2],d[3],d[4]):null}var D=function(){function E(){this.values=Object.create(null)}var y=E.prototype;return y.set=function(d,e){this.get(d)||e===""||(this.values[d]=e)},y.get=function(d,e,a){return a?this.has(d)?this.values[d]:e[a]:this.has(d)?this.values[d]:e},y.has=function(d){return d in this.values},y.alt=function(d,e,a){for(var t=0;t<a.length;++t)if(e===a[t]){this.set(d,e);break}},y.integer=function(d,e){/^-?\d+$/.test(e)&&this.set(d,parseInt(e,10))},y.percent=function(d,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var a=parseFloat(e);if(a>=0&&a<=100)return this.set(d,a),!0}return!1},E}();function C(E,y,d,e){var a=e?E.split(e):[E];for(var t in a)if(typeof a[t]=="string"){var s=a[t].split(d);s.length===2&&y(s[0],s[1])}}var _=new R.default(0,0,""),o=_.align==="middle"?"middle":"center";function L(E,y,d){var e=E;function a(){var s=A(E);if(s===null)throw new Error("Malformed timestamp: "+e);return E=E.replace(/^[^\sa-zA-Z-]+/,""),s}function t(){E=E.replace(/^\s+/,"")}if(t(),y.startTime=a(),t(),E.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+e);E=E.substr(3),t(),y.endTime=a(),t(),function(s,u){var n=new D;C(s,function(g,p){var r;switch(g){case"region":for(var i=d.length-1;i>=0;i--)if(d[i].id===p){n.set(g,d[i].region);break}break;case"vertical":n.alt(g,p,["rl","lr"]);break;case"line":r=p.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=p.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,p);break;case"align":n.alt(g,p,["start",o,"end","left","right"])}},/:/,/\s/),u.region=n.get("region",null),u.vertical=n.get("vertical","");var l=n.get("line","auto");l==="auto"&&_.line===-1&&(l=-1),u.line=l,u.lineAlign=n.get("lineAlign","start"),u.snapToLines=n.get("snapToLines",!0),u.size=n.get("size",100),u.align=n.get("align",o);var v=n.get("position","auto");v==="auto"&&_.position===50&&(v=u.align==="start"||u.align==="left"?0:u.align==="end"||u.align==="right"?100:50),u.position=v}(E,y)}function m(E){return E.replace(/<br(?: \/)?>/gi,`
|
||
`)}var f=function(){function E(){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 y=E.prototype;return y.parse=function(d){var e=this;function a(){var l=e.buffer,v=0;for(l=m(l);v<l.length&&l[v]!=="\r"&&l[v]!==`
|
||
`;)++v;var g=l.substr(0,v);return l[v]==="\r"&&++v,l[v]===`
|
||
`&&++v,e.buffer=l.substr(v),g}d&&(e.buffer+=e.decoder.decode(d,{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 u=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(u?u=!1:t=a(),e.state){case"HEADER":/:/.test(t)?C(t,function(l,v){},/:/):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&&(u=!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},y.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=`
|
||
|
||
`,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){d.onparsingerror&&d.onparsingerror(e)}return d.onflush&&d.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(N,x,h){h.r(x),h.d(x,"generateCueId",function(){return m}),h.d(x,"parseWebVTT",function(){return f});var R=h("./src/polyfills/number.ts"),T=h("./src/utils/vttparser.ts"),A=h("./src/demux/id3.ts"),D=h("./src/utils/timescale-conversion.ts"),C=h("./src/remux/mp4-remuxer.ts"),_=/\r\n|\n\r|\n|\r/g,o=function(E,y,d){return d===void 0&&(d=0),E.substr(d,y.length)===y},L=function(E){for(var y=5381,d=E.length;d;)y=33*y^E.charCodeAt(--d);return(y>>>0).toString()};function m(E,y,d){return L(E.toString())+L(y.toString())+L(d)}function f(E,y,d,e,a,t,s,u){var n,l=new T.VTTParser,v=Object(A.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(_,`
|
||
`).split(`
|
||
`),g=[],p=Object(D.toMpegTsClockFromTimescale)(y,d),r="00:00.000",i=0,c=0,S=!0,b=!1;l.oncue=function(k){var I=e[a],w=e.ccOffset,O=(i-p)/9e4;if(I!=null&&I.new&&(c!==void 0?w=e.ccOffset=I.start:function(B,U,j){var V=B[U],H=B[V.prevCC];if(!H||!H.new&&V.new)return B.ccOffset=B.presentationOffset=V.start,void(V.new=!1);for(;(X=H)!==null&&X!==void 0&&X.new;){var X;B.ccOffset+=V.start-H.start,V.new=!1,H=B[(V=H).prevCC]}B.presentationOffset=j}(e,a,O)),O&&(w=O-e.presentationOffset),b){var P=k.endTime-k.startTime,F=Object(C.normalizePts)(9e4*(k.startTime+w-c),9e4*t)/9e4;k.startTime=F,k.endTime=F+P}var M=k.text.trim();k.text=decodeURIComponent(encodeURIComponent(M)),k.id||(k.id=m(k.startTime,k.endTime,M)),k.endTime>0&&g.push(k)},l.onparsingerror=function(k){n=k},l.onflush=function(){n?u(n):s(g)},v.forEach(function(k){if(S){if(o(k,"X-TIMESTAMP-MAP=")){S=!1,b=!0,k.substr(16).split(",").forEach(function(I){o(I,"LOCAL:")?r=I.substr(6):o(I,"MPEGTS:")&&(i=parseInt(I.substr(7)))});try{c=function(I){var w=parseInt(I.substr(-3)),O=parseInt(I.substr(-6,2)),P=parseInt(I.substr(-9,2)),F=I.length>9?parseInt(I.substr(0,I.indexOf(":"))):0;if(!(Object(R.isFiniteNumber)(w)&&Object(R.isFiniteNumber)(O)&&Object(R.isFiniteNumber)(P)&&Object(R.isFiniteNumber)(F)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+I);return w+=1e3*O,(w+=6e4*P)+36e5*F}(r)/1e3}catch(I){b=!1,n=I}return}k===""&&(S=!1)}l.parse(k+`
|
||
`)}),l.flush()}},"./src/utils/xhr-loader.ts":function(N,x,h){h.r(x);var R=h("./src/utils/logger.ts"),T=h("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,D=function(){function C(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 _=C.prototype;return _.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},_.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()))},_.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},_.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()},_.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 E=this.xhrSetup;try{if(E)try{E(m,L.url)}catch{m.open("GET",L.url,!0),E(m,L.url)}m.readyState||m.open("GET",L.url,!0)}catch(y){return void this.callbacks.onError({code:m.status,text:y.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()}},_.readystatechange=function(){var o=this.context,L=this.loader,m=this.stats;if(o&&L){var f=L.readyState,E=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 y=L.status;if(y>=200&&y<300){var d,e;if(m.loading.end=Math.max(self.performance.now(),m.loading.first),e=o.responseType==="arraybuffer"?(d=L.response).byteLength:(d=L.responseText).length,m.loaded=m.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(m,o,d,L),!this.callbacks)return;var t={url:L.responseURL,data:d};this.callbacks.onSuccess(t,m,o,L)}else m.retry>=E.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+o.url),this.callbacks.onError({code:y,text:L.statusText},o,L)):(R.logger.warn(y+" 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,E.maxRetryDelay),m.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout)}},_.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))},_.loadprogress=function(o){var L=this.stats;L.loaded=o.loaded,o.lengthComputable&&(L.total=o.total)},_.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},C}();x.default=D}}).default);var it=yr(Lt.exports);const Er={name:"d-icon"},Ae=Object.assign(Er,{props:{icon:String,size:[Number,String]},setup:function(N){const x=N,h=Re(()=>({fontSize:/^\d+$/.test(x.size)?x.size+"px":x.size}));return(R,T)=>(Y(),Z("i",{class:Le(["d-icon iconfont",N.icon]),style:je(G(h))},null,6))}});Ae.__scopeId="data-v-0c690e66";Ve("data-v-4cb76d59");const Tr={class:"d-player-top"},Sr={class:"top-title"},br={class:"top-title"};He();const Lr={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 x=Ee("00:00:00");x.value=new Date().format("hh:mm:ss");let h=null;return h=setInterval(()=>{x.value=new Date().format("hh:mm:ss")},1e3),yt(()=>{clearInterval(h)}),(R,T)=>(Y(),Z("div",Tr,[K("p",Sr,J(N.title||""),1),K("p",br,J(G(x)),1)]))},__scopeId:"data-v-4cb76d59"};Ve("data-v-ac2469ec");const Ar={class:"d-status"},kr={class:"d-flex-center"},_r={class:"d-flex-center"},Dr=he("5X速播放中 ");He();var At=xe({props:["state"],setup:N=>(x,h)=>me((Y(),Z("div",Ar,[me(K("li",kr,[z(Ae,{size:"18",class:"d-status-icon",icon:"icon-volume-"+(N.state.volume==0?"mute":N.state.volume>.5?"up":"down")},null,8,["icon"]),he(" "+J(~~(100*N.state.volume))+"% ",1)],512),[[Te,N.state.handleType=="volume"]]),me(K("li",_r,[z(Ae,{size:"12",icon:"icon-play"}),z(Ae,{size:"12",icon:"icon-play",style:{"margin-right":"5px"}}),Dr],512),[[Te,N.state.handleType=="playbackRate"||N.state.isMultiplesPlay]])],512)),[[Te,N.state.handleType||N.state.isMultiplesPlay]])});At.__scopeId="data-v-ac2469ec",Ve("data-v-385f7870");const Rr=["checked","true-value","false-value"],Ir=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:x}){const h=N;ut(D=>({"014e5dc0":N.width,e4e32852:N.activeColor}));const R=Ee(null),T=Re(()=>h.modelValue===h.trueValue),A=()=>{Et(()=>{const D=R.value.checked;x("update:modelValue",D),x("change",D)})};return(D,C)=>(Y(),Z("div",{class:Le(["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,Rr),Ir],2))}});rt.__scopeId="data-v-385f7870",Ve("data-v-b2384226");const Cr={key:0},wr=K("i",{class:"rotating iconfont icon-loading f50"},null,-1),xr=[K("i",{class:"rotating iconfont icon-loading f50"},null,-1),K("p",null,"正在缓冲...",-1)],Or=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),he("重新播放 ")],Pr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),he("请求错误 ")];He();var kt=xe({props:{loadType:String,text:{type:String,default:""}},setup(N){const x=N,{proxy:h}=wt(),R=["loadstart","waiting","ended","error","stalled"],T=()=>{h.$parent.play()},A=Re(()=>{let D="background: rgba(0, 0, 0, .1);z-index:1";return x.loadType=="loadstart"&&(D="background: rgba(0, 0, 0, 1);;z-index:3"),D});return(D,C)=>me((Y(),Z("div",{class:"d-loading",style:je(G(A))},[K("div",null,[N.loadType=="loadstart"?(Y(),Z("span",Cr,[wr,K("p",null,J(N.text),1)])):ae("",!0),me(K("span",null,xr,512),[[Te,N.loadType=="waiting"]]),me(K("span",null,[K("p",{onClick:T,class:"d-flex-x d-pointer"},Or)],512),[[Te,N.loadType=="ended"]]),me(K("span",null,[K("p",{onClick:T,class:"d-flex-x d-pointer"},Pr)],512),[[Te,N.loadType=="error"||N.loadType=="stalled"]])])],4)),[[Te,R.includes(N.loadType)]])}});kt.__scopeId="data-v-b2384226";const Ke=function(N,x,h,R=!1){N&&x&&h&&N.addEventListener(x,h,R)},be=function(N,x,h,R=!1){N&&x&&h&&N.removeEventListener(x,h,R)};Ve("data-v-5a794390");const Fr=["onMousedown"];He();var Xe=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:x}){const h=N;ut(e=>({"5242b67b":N.size}));const R=Ee(null),T=Ee(null),A=Se({dragging:!1,hoverPosition:0,hoverTipsLeft:"50%"}),D=Re(()=>{let e=h.modelValue<0?0:h.modelValue>1?1:h.modelValue;return h.vertical?`height:${100*e}%`:`width:${100*e}%`}),C=Re(()=>{let e=h.preload<0?0:h.preload>1?1:h.preload;return h.vertical?`height:${100*e}%`:`width:${100*e}%`}),_=Re(()=>{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",y),Ke(window,"touchmove",y),Ke(window,"mouseup",d),Ke(window,"touchend",d))},m=e=>{if(!h.hover)return;let a=E(e);if(x("onMousemove",e,a),A.hoverPosition=a,h.vertical)return;let t=R.value,s=T.value.clientWidth/2,u=e.clientX-t.getBoundingClientRect().left;u<s?A.hoverTipsLeft=s-u+"px":t.clientWidth-u<s?A.hoverTipsLeft=t.clientWidth-u-s+"px":A.hoverTipsLeft="50%"},f=e=>{let a=E(e);x("update:modelValue",a),x("change",e,a)},E=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},y=e=>{f(e)},d=e=>{A.dragging&&(be(window,"mousemove",y),be(window,"touchmove",y),be(window,"mouseup",d),be(window,"touchend",d),be(window,"contextmenu",d),setTimeout(()=>{A.dragging=!1},0))};return(e,a)=>(Y(),Z("div",{ref:R,class:Le(["d-slider",{"is-vertical":h.vertical}]),onMousedown:It(L,["stop"]),onContextmenu:o},[K("div",{class:"d-slider__runway",onMousemove:m},[me(K("div",{class:"d-slider__cursor",style:je(G(_))},[me(K("div",{class:"d-slider__tips",ref:T,style:je({left:G(A).hoverTipsLeft})},J(h.hoverText),5),[[Te,h.hoverText]])],4),[[Te,h.hover]]),K("div",{class:"d-slider__preload",style:je(G(C))},null,4),K("div",{class:"d-slider__bar",style:je(G(D))},null,4)],32)],42,Fr))}}));Xe.__scopeId="data-v-5a794390";Ve("data-v-570fa0d1");const Mr={key:0,class:"d-player-dialog"},Nr={class:"d-player-dialog-body"},Br={class:"d-player-dialog-title"},Ur={class:"d-player-hotkey-panel"},Gr={class:"d-player-filter-panel"},jr={class:"d-player-filter-panel-item"},Kr=K("span",null,"饱和度",-1),Vr={class:"d-player-filter-panel-item"},Hr=K("span",null,"亮度",-1),Wr={class:"d-player-filter-panel-item"},Yr=K("span",null,"对比度",-1),qr={key:0,class:"d-player-contextmenu"},zr=["dplayerKeyCode"],Xr=K("input",{class:"d-player-copyText"},null,-1);He();var _t=xe({setup(N){const x=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=Re(()=>({left:x.mouseX+"px",top:x.mouseY+"px"}));et(T,L=>{let m=document.querySelector("#dPlayerVideo"),f=(2.55*L.saturate).toFixed(2),E=(2.55*L.brightness).toFixed(2),y=(2.55*L.contrast).toFixed(2);m.style.filter=`saturate(${f}) brightness(${E}) contrast(${y})`});const D=()=>{T.saturate=.392,T.brightness=.392,T.contrast=.392},C=L=>{L.key=="Escape"&&o(0)},_=L=>{L.preventDefault(),Ke(window,"keydown",C),Ke(window,"click",o);let m=document.querySelector("#refPlayerWrap"),f=m.clientWidth;m.clientHeight,x.mouseX=L.clientX-m.getBoundingClientRect().left,f-x.mouseX<130&&(x.mouseX=x.mouseX+(f-x.mouseX-130)),x.mouseY=L.clientY-m.getBoundingClientRect().top,x.show=!0},o=L=>{let m=L.path[0].tagName=="LI",f=L.path[0].attributes.dplayerKeyCode&&L.path[0].attributes.dplayerKeyCode.value,E=h.map(y=>y.key);if(m&&E.includes(f))if(x.dialogTitle=L.path[0].innerText,x.dialogType=f,f=="copy"){let y=document.querySelector(".d-player-copyText");y.value=window.location.href,y.select(),document.execCommand("copy"),x.dialogType=""}else f=="version"&&(x.dialogType="");x.show=!1,be(window,"keydown",C),be(window,"click",o)};return mt(()=>{let L=document.querySelector("#refPlayerWrap");be(window,"keydown",C),be(window,"click",o),be(L,"contextmenu",_),Ke(L,"contextmenu",_)}),yt(()=>{let L=document.querySelector("#refPlayerWrap");be(window,"keydown",C),be(window,"click",o),be(L,"contextmenu",_)}),(L,m)=>(Y(),Z("div",null,[z(at,{name:"d-fade-in"},{default:Q(()=>[G(x).dialogType?(Y(),Z("div",Mr,[K("div",Nr,[K("h5",Br,[he(J(G(x).dialogTitle)+" ",1),K("i",{onClick:m[0]||(m[0]=f=>G(x).dialogType=!1),class:"icon icon-close"},"X")]),me(K("ul",Ur,[(Y(),Z(we,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),[[Te,G(x).dialogType=="hotkey"]]),me(K("ul",Gr,[K("li",jr,[Kr,z(Xe,{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",Vr,[Hr,z(Xe,{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",Wr,[Yr,z(Xe,{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:D,title:"重置","aria-label":"重置",class:"d-player-filter-reset"},"重置")],512),[[Te,G(x).dialogType=="filter"]])])])):ae("",!0)]),_:1}),G(x).show?(Y(),Z("div",qr,[K("ul",{class:"d-player-contextmenu-body",style:je(G(A))},[(Y(),Z(we,null,Fe(h,f=>K("li",{dplayerKeyCode:f.key,key:f.key},J(f.label),9,zr)),64))],4),Xr])):ae("",!0)]))}});_t.__scopeId="data-v-570fa0d1";const nt=N=>{let x=~~(N/3600),h=~~(N%3600/60),R=~~(N%60);return x=x<10?"0"+x:x,h=h<10?"0"+h:h,R=R<10?"0"+R:R,`${x}:${h}:${R}`},Je="ontouchstart"in window,pt=["loadstart","play","pause","playing","seeking","seeked","waiting","durationchange","progress","canplay","timeupdate","ended","error","stalled"],$r={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 Qr={class:"d-player-video",id:"dPlayerVideo"},Zr=["controls","webkit-playsinline","playsinline","volume","muted","loop","preload","src","poster"],Jr={class:"d-player-lightoff"},ei={key:1,class:"d-player-state"},ti={class:"d-play-btn"},ri=["onKeyup","onKeydown"],ii={class:"d-control-progress"},ni={class:"d-tool-bar"},ai={key:0,class:"d-tool-item d-tool-time audioTrack-btn"},si=K("span",{style:{margin:"0 3px"}},"/",-1),oi={class:"total-time"},li={class:"d-tool-bar"},ui={key:0,class:"d-tool-item quality-btn"},di={class:"d-tool-item-main"},ci={class:"speed-main",style:{"text-align":"center"}},hi=["onClick"],fi={key:1,class:"d-tool-item speedRate-btn"},gi={class:"d-tool-item-main"},vi={class:"speed-main"},pi=["onClick"],mi={key:2,class:"d-tool-item volume-btn"},yi={class:"d-tool-item-main volume-box",style:{width:"52px"}},Ei={class:"volume-text-size"},Ti={key:3,class:"d-tool-item setting-btn"},Si={class:"d-tool-item-main"},bi={class:"speed-main"},Li=he(" 镜像画面 "),Ai=he(" 循环播放 "),ki=he(" 关灯模式 "),_i=K("div",{class:"d-tool-item-main"},"画中画",-1),Di=K("div",{class:"d-tool-item-main"},"网页全屏",-1),Ri=K("div",{class:"d-tool-item-main"},"全屏",-1);He();var tt=xe(lt(ot({},{name:"vue3VideoPlay",inheritAttrs:!1}),{props:$r,emits:[...pt,"mirrorChange","loopChange","lightOffChange"],setup:function(N,{expose:x,emit:h}){const R=N;ut(w=>({"51d4439c":G(E),"77e758a6":w.width,b8a1afc0:w.height}));const T=new it({fragLoadingTimeOut:2e3}),A=Ee(null),D=Ee(null),C=Ee(null),_=Ee(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=(...w)=>O=>w.reverse().reduce((P,F)=>F(P),O),m=pt.reduce((w,O)=>{var P;return w[`on${P=O,P.charAt(0).toUpperCase()+P.slice(1)}`]=F=>{o.loadStateType=O,h(O,F)},w},{});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=w=>{h("durationchange",w),R.currentTime!=0&&(o.dVideo.currentTime=R.currentTime),m.onTimeupdate(w)},m.onProgress=w=>{console.log("缓冲中..."),h("progress",w);let O=w.target.duration,P=w.target.buffered,F=w.target.buffered.length&&w.target.buffered.end(P-1);o.preloadBar=F/O},m.onTimeupdate=w=>{h("timeupdate",w);let O=w.duration||w.target.duration||0,P=w.currentTime||w.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 w in f)m[w]=f[w];const E=(y=o.color,`${parseInt("0x"+y.slice(1,3))},${parseInt("0x"+y.slice(3,5))},${parseInt("0x"+y.slice(5,7))}`);var y;const d=vt(500,()=>{o.handleType=""}),e=w=>{w.preventDefault(),w.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",d()},a=w=>{R.speed&&(o.dVideo.currentTime=o.dVideo.currentTime<10?.1:o.dVideo.currentTime-10,m.onTimeupdate(o.dVideo),u())},t=w=>{w.preventDefault();let O=w.type;if(w.key=="ArrowRight"){if(u(),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",d()},500)}}},s=()=>{Je||_.value.focus()},u=()=>{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"},l=w=>{w&&w.preventDefault(),o.playBtnState=="play"||o.playBtnState=="replay"?u():o.playBtnState=="pause"&&n()},v=()=>{o.muted=!o.muted,o.volume==0&&(o.volume=.05)},g=(w,O)=>{let P=o.dVideo.duration||o.dVideo.target.duration;o.dVideo.currentTime=P*O,o.playBtnState=="play"&&(o.dVideo.play(),o.playBtnState="pause")},p=(w,O)=>{o.progressCursorTime=nt(o.dVideo.duration*O)},r=vt(2500,()=>{o.isVideoHovering=!1}),i=w=>{o.isVideoHovering=!0,r()},c=w=>{h("mirrorChange",w,o.dVideo)},S=w=>{h("loopChange",w,o.dVideo)},b=w=>{h("lightOffChange",w,o.dVideo)},k=()=>{var w;w=o.dVideo,document.pictureInPictureElement?document.exitPictureInPicture().catch(O=>{console.log(O,"Video failed to leave Picture-in-Picture mode.")}):w.requestPictureInPicture().catch(O=>{console.log(O,"Video failed to enter Picture-in-Picture mode.")})},I=()=>{o.fullScreen=(w=>{let O=document,P=O.webkitIsFullScreen||O.fullscreen;return P?(document.exitFullscreen||O.webkitExitFullScreen).call(O):(w.requestFullscreen||w.webkitRequestFullScreen).call(w),!P})(A.value)};return et(()=>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",(w,O)=>{console.log(O),o.currentLevel=O.level,o.qualityLevels=O.levels||[]})}),T.on("hlsLevelSwitching",(w,O)=>{console.log(O),console.log("LEVEL_SWITCHING")}),T.on("hlsLevelSwitched",(w,O)=>{o.currentLevel=O.level,console.log("LEVEL_SWITCHED")}))})},{immediate:!0}),mt(()=>{o.dVideo=D,s()}),x({play:u,pause:n,togglePlay:l}),(w,O)=>(Y(),Z("div",{ref:A,id:"refPlayerWrap",class:Le(["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",Qr,[K("video",Tt({ref:D,class:["d-player-video-main",{"video-mirror":G(o).mirror}],id:"dPlayerVideoMain",controls:!(!G(Je)||!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:w.preload,width:"100%",height:"100%",src:R.src,poster:R.poster}),"您的浏览器不支持Video标签。",16,Zr)]),z(at,{name:"d-fade-in"},{default:Q(()=>[me(K("div",Jr,null,512),[[Te,G(o).lightOff]])]),_:1}),G(o).fullScreen?(Y(),ge(Lr,{key:0,title:R.title},null,8,["title"])):ae("",!0),G(Je)?ae("",!0):(Y(),Z("div",ei,[z(at,{name:"d-scale-out"},{default:Q(()=>[me(K("div",ti,[z(Ae,{icon:"icon-play",size:40})],512),[[Te,G(o).playBtnState=="play"]])]),_:1}),z(At,{state:G(o)},null,8,["state"])])),G(Je)?ae("",!0):(Y(),Z("input",{key:2,type:"input",readonly:"readonly",ref:_,onDblclick:I,onKeyup:[Ze(I,["f"]),O[0]||(O[0]=Ze(P=>G(o).webFullScreen=!1,["esc"])),t],onClick:l,onKeydown:[Ze(l,["space"]),Ze(a,["arrow-left"]),Ze(e,["arrow-up","arrow-down"]),t],class:"d-player-input",maxlength:"0"},null,40,ri)),z(kt,{loadType:G(o).loadStateType},null,8,["loadType"]),z(_t),!G(Je)&&G(o).control?(Y(),Z("div",{key:3,class:"d-player-control",ref:C},[K("div",ii,[z(Xe,{class:"d-progress-bar",onOnMousemove:p,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",ni,[K("div",{class:"d-tool-item",onClick:l},[z(Ae,{size:"24",icon:`icon-${G(o).playBtnState}`},null,8,["icon"])]),R.controlBtns.includes("audioTrack")?(Y(),Z("div",ai,[K("span",null,J(G(o).currentTime),1),si,K("span",oi,J(G(o).totalTime),1)])):ae("",!0)]),K("div",li,[G(o).qualityLevels.length&&R.controlBtns.includes("quality")?(Y(),Z("div",ui,[he(J(G(o).qualityLevels.length&&(G(o).qualityLevels[G(o).currentLevel]||{}).height)+"P ",1),K("div",di,[K("ul",ci,[(Y(!0),Z(we,null,Fe(G(o).qualityLevels,(P,F)=>(Y(),Z("li",{class:Le({"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,hi))),128))])])])):ae("",!0),R.controlBtns.includes("speedRate")?(Y(),Z("div",fi,[he(J(G(o).speedActive=="1.0"?"倍速":G(o).speedActive+"x")+" ",1),K("div",gi,[K("ul",vi,[(Y(!0),Z(we,null,Fe(G(o).speedRate,P=>(Y(),Z("li",{class:Le({"speed-active":G(o).speedActive==P}),onClick:F=>(M=>{o.speedActive=M,o.dVideo.playbackRate=M})(P),key:P},J(P)+"x",11,pi))),128))])])])):ae("",!0),R.controlBtns.includes("volume")?(Y(),Z("div",mi,[K("div",yi,[K("div",{class:Le(["volume-main",{"is-muted":G(o).muted}])},[K("span",Ei,J(G(o).muted?0:~~(100*G(o).volume))+"%",1),z(Xe,{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:v,style:{display:"flex"}},[z(Ae,{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",Ti,[z(Ae,{size:"20",class:"rotateHover",icon:"icon-settings"}),K("div",Si,[K("ul",bi,[K("li",null,[Li,z(rt,{onChange:c,modelValue:G(o).mirror,"onUpdate:modelValue":O[4]||(O[4]=P=>G(o).mirror=P)},null,8,["modelValue"])]),K("li",null,[Ai,z(rt,{onChange:S,modelValue:G(o).loop,"onUpdate:modelValue":O[5]||(O[5]=P=>G(o).loop=P)},null,8,["modelValue"])]),K("li",null,[ki,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:k},[z(Ae,{size:"20",icon:"icon-pip"}),_i])):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(Ae,{size:"20",icon:"icon-web-screen"}),Di])):ae("",!0),R.controlBtns.includes("fullScreen")?(Y(),Z("div",{key:6,class:"d-tool-item fullScreen-btn",onClick:I},[Ri,z(Ae,{size:"20",icon:"icon-screen"})])):ae("",!0)])])],512)):ae("",!0)],34))}}));function Ii(N){N.component(tt.name,tt)}tt.__scopeId="data-v-01791e9e",tt.install=Ii;const Ci=xe({__name:"index",setup(N){return(x,h)=>(Y(),ge(G(tt)))}}),wi={class:"text-right mt-[15px]"},xi=xe({__name:"index",props:{width:{type:String,default:"350px"},modelValue:{type:String,default:""},placeholder:{type:String,default:""},required:{type:Boolean,default:!0},maxlength:{type:Number,default:10}},emits:["confirm"],setup(N,{emit:x}){const h=N,R=Re({get(){return h.modelValue},set(D){x("update:modelValue",D)}}),T=Ee(!1),A=()=>{if(!/[\S]+/.test(R.value)){st.error(h.placeholder||"不能为空");return}x("confirm",R.value),T.value=!1};return(D,C)=>{const _=St,o=bt,L=Pt;return Y(),ge(L,{placement:"top",trigger:"click",width:h.width,visible:T.value,"onUpdate:visible":C[2]||(C[2]=m=>T.value=m)},{reference:Q(()=>[xt(D.$slots,"default")]),default:Q(()=>[z(_,{modelValue:G(R),"onUpdate:modelValue":C[0]||(C[0]=m=>Ot(R)?R.value=m:null),placeholder:h.placeholder,clearable:"",class:"mr-[10px]",maxlength:h.maxlength,"show-word-limit":!0},null,8,["modelValue","placeholder","maxlength"]),K("div",wi,[z(o,{onClick:C[1]||(C[1]=m=>T.value=!1)},{default:Q(()=>[he(J(G(ee)("cancel")),1)]),_:1}),z(o,{type:"primary",onClick:A},{default:Q(()=>[he(J(G(ee)("confirm")),1)]),_:1})])]),_:3},8,["width","visible"])}}}),Oi={class:"group-wrap w-[180px] p-[15px] h-full border-r border-color flex flex-col"},Pi={class:"group-list flex-1 my-[10px] h-0"},Fi=["onClick"],Mi={key:0,class:"leading-none operate py-[10px]"},Ni={class:"text-center w-full"},Bi={class:"attachment-list-wrap flex flex-col p-[15px] flex-1 overflow-hidden"},Ui={class:"flex"},Gi={key:1},ji={class:"flex-1 my-[15px] h-0"},Ki={key:0,class:"flex flex-wrap"},Vi=["onClick"],Hi=["src"],Wi={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60"},Yi={class:"file-box-active absolute z-[1] bottom-0 right-0 w-full h-full"},qi={class:"absolute bottom-[2px] right-[2px] text-white z-[2] leading-none"},zi={class:"flex items-center"},Xi={class:"truncate my-[10px] cursor-pointer text-base flex-1 text-center"},$i={class:"text-center w-full"},Qi={class:"text-center w-full"},Zi={class:"text-center w-full"},Ji={class:"text-center w-full"},en={key:1,class:"flex flex-wrap"},tn={class:"attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center h-[120px]"},rn=["src"],nn={class:"flex items-center"},an={class:"truncate my-[10px] cursor-pointer text-base flex-1 text-center"},sn={key:2,class:"flex items-center justify-center"},on={class:"flex items-center"},ln={class:"flex h-full justify-end items-center"},un={class:"dialog-footer"},dn=xe({__name:"attachment",props:{limit:{type:Number,default:1},type:{type:String,default:"image"},scene:{type:String,default:"select"}},setup(N,{expose:x}){const h=N,R=Ee(""),T=Ee(!1),A=Se({}),D=Se([]),C=Se({data:[]}),_=Se({loading:!0,page:1,total:0,limit:h.scene=="select"?10:20,data:[]});h.scene=="select"?(_.limit=10,h.type=="icon"&&(_.limit=20)):(_.limit=20,h.type=="icon"&&(_.limit=30));const o=Se({name:""}),L=Se({real_name:"",cate_id:0}),m=dt(()=>{(h.type=="icon"?or:lr)({type:h.type,...o}).then(I=>{C.data=I.data}).catch(()=>{})});m();const f=dt((k=1)=>{const I=h.type=="icon"?ur:dr;_.loading=!0,_.page=k,I({page:_.page,limit:_.limit,att_type:h.type,...L}).then(w=>{if(_.data=w.data.data,_.total=w.data.total,_.loading=!1,h.scene=="attachment"&&s(),h.type!="icon")for(let O=0;O<_.data.length;O++)_.data[O].image_list=[],_.data[O].image_list.push(Ge(w.data.data[O].url))}).catch(()=>{_.loading=!1})});f(),et(()=>L.cate_id,()=>{f()});const E=k=>{Nt({type:h.type,name:k}).then(I=>{R.value="",m(1)}).catch(()=>{})},y=(k,I)=>{Bt({id:C.data[I].id,name:k}).then(w=>{C.data[I].name=k}).catch(()=>{})},d=k=>{ct.confirm(ee("upload.deleteCategoryTips"),ee("warning"),{confirmButtonText:ee("confirm"),cancelButtonText:ee("cancel"),type:"warning"}).then(()=>{Ut(C.data[k].id).then(()=>{C.data.splice(k,1)}).catch(()=>{})})},e=Ee(null),a=Re(()=>{const k={};return k.token=Ft(),k["site-id"]=Mt.get("siteId")||0,{action:`/adminapi//sys/${h.type}`,multiple:!0,data:{cate_id:L.cate_id},headers:k,onSuccess:(I,w,O)=>{var P;I.code>=1?(f(),(P=e.value)==null||P.handleRemove(w)):(w.status="fail",st({message:I.msg,type:"error"}))}}}),t=Ee(!1);et(t,()=>{if(t.value){const k=Object.keys(De(A));_.data.forEach(I=>{k.includes(I.att_id)||(A[I.att_id]=De(I))})}else s()});const s=()=>{const k=Object.keys(De(A));k.length&&(k.forEach(I=>{delete A[I]}),t.value=!1)},u=k=>{if(A[k.att_id])delete A[k.att_id],D.splice(D.indexOf(k.att_id),1);else if(h.scene=="select"){const I=Object.keys(De(A)),w=I.length;if(h.limit==1&&w==h.limit)delete A[I[0]],D.splice(D.indexOf(I[0]),1);else if(w>=h.limit){st.info(ee("upload.triggerUpperLimit"));return}A[k.att_id]=De(k),D.push(k.att_id)}else A[k.att_id]=De(k),D.push(k.att_id)},n=k=>{let I=D.indexOf(k);return I==-1?0:I+1},l=(k=null)=>{const I=k===null?Object.keys(De(A)):[_.data[k].att_id];ct.confirm(ee("upload.deleteAttachmentTips"),ee("warning"),{confirmButtonText:ee("confirm"),cancelButtonText:ee("cancel"),type:"warning"}).then(()=>{Gt({att_ids:I}).then(()=>{f()}).catch(()=>{})})},v=Se({cateId:"",loading:!1,visible:!1}),g=(k=null)=>{const I=k===null?Object.keys(De(A)):[_.data[k].att_id];v.visible=!0,v.cateId=C.data[0].id,v.confirm=()=>{v.loading=!0,jt({cate_id:v.cateId,att_ids:I}).then(()=>{v.visible=!1,v.loading=!1,f()}).catch(()=>{v.loading=!1})}},p=Ee(!0);et(A,()=>{p.value=Object.keys(De(A)).length==0});const r=Se({show:!1,index:0}),i=k=>{r.show=!0,r.index=k},c=Re(()=>De(_.data).map(k=>Ge(k.url))),S=Se({visible:!1,src:""}),b=k=>{S.visible=!0,S.src=Ge(_.data[k].url)};return x({selectedFile:A}),(k,I)=>{const w=St,O=cr,P=xi,F=Kt,M=Vt,B=Ht,U=Wt,j=bt,V=Yt,H=qt,X=zt,q=Xt,$=$t,ie=Qt,se=Zt,le=Jt,re=er,fe=tr,te=rr,ne=ir,ce=nr,ue=ar,ve=Ci,ye=sr;return Y(),Z("div",{class:Le(["flex border-t border-b main-wrap border-color w-full",N.scene=="select"?"h-[40vh]":"h-full"])},[K("div",Oi,[z(w,{modelValue:o.name,"onUpdate:modelValue":I[0]||(I[0]=W=>o.name=W),class:"m-0",placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),clearable:"","prefix-icon":"Search",onInput:I[1]||(I[1]=W=>G(m)())},null,8,["modelValue","placeholder"]),K("div",Pi,[z(U,null,{default:Q(()=>[K("div",{class:Le(["group-item p-[10px] leading-none text-xs rounded cursor-pointer",{active:L.cate_id==0}]),onClick:I[2]||(I[2]=W=>L.cate_id=0)},J(G(ee)("selectPlaceholder")),3),(Y(!0),Z(we,null,Fe(C.data,(W,de)=>(Y(),Z("div",{class:Le(["group-item px-[10px] text-xs rounded cursor-pointer flex",{active:L.cate_id==W.id}]),key:de},[K("div",{class:"flex-1 leading-none truncate py-[10px]",onClick:oe=>L.cate_id=W.id},J(W.name),9,Fi),N.scene=="attachment"&&h.type!="icon"?(Y(),Z("div",Mi,[N.scene=="attachment"?(Y(),ge(B,{key:0,"hide-on-click":!1},{dropdown:Q(()=>[z(M,null,{default:Q(()=>[z(F,{class:"text-center"},{default:Q(()=>[z(P,{placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),onConfirm:oe=>y(oe,de),modelValue:W.name,"onUpdate:modelValue":oe=>W.name=oe},{default:Q(()=>[K("span",null,J(G(ee)("edit")),1)]),_:2},1032,["placeholder","onConfirm","modelValue","onUpdate:modelValue"])]),_:2},1024),z(F,{onClick:oe=>d(de)},{default:Q(()=>[K("div",Ni,J(G(ee)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Q(()=>[z(O,{name:"element-MoreFilled",class:"cursor-pointer ml-[10px]",size:"14px"}),he(" "+J(W.name)+" ",1)]),_:2},1024)):ae("",!0)])):ae("",!0)],2))),128))]),_:1})]),h.type!="icon"?(Y(),ge(P,{key:0,placeholder:G(ee)("upload.attachmentCategoryPlaceholder"),onConfirm:E,modelValue:R.value,"onUpdate:modelValue":I[3]||(I[3]=W=>R.value=W)},{default:Q(()=>[z(j,null,{default:Q(()=>[he(J(G(ee)("upload.addAttachmentCategory")),1)]),_:1})]),_:1},8,["placeholder","modelValue"])):ae("",!0)]),K("div",Bi,[z(X,{gutter:15,class:"h-[32px]"},{default:Q(()=>[z(H,{span:10},{default:Q(()=>[K("div",Ui,[h.type!="icon"?(Y(),ge(V,Tt({key:0},G(a),{ref_key:"uploadRef",ref:e}),{default:Q(()=>[z(j,{type:"primary"},{default:Q(()=>[he(J(G(ee)("upload.upload"+N.type))+" "+J(k.isOpen),1)]),_:1})]),_:1},16)):ae("",!0),N.scene=="attachment"&&h.type!="icon"?(Y(),Z("div",Gi,[T.value===!1?(Y(),ge(j,{key:0,class:"ml-[10px]",type:"primary",onClick:I[4]||(I[4]=W=>T.value=!0)},{default:Q(()=>[he(J(G(ee)("edit")),1)]),_:1})):(Y(),ge(j,{key:1,class:"ml-[10px]",type:"primary",onClick:I[5]||(I[5]=W=>T.value=!1)},{default:Q(()=>[he(J(G(ee)("complete")),1)]),_:1}))])):ae("",!0)])]),_:1}),z(H,{span:14,class:"text-right"},{default:Q(()=>[z(w,{modelValue:L.real_name,"onUpdate:modelValue":I[6]||(I[6]=W=>L.real_name=W),class:"m-0 w-[200px]",clearable:"",placeholder:G(ee)("upload.placeholder"+N.type+"Name"),"prefix-icon":"Search",onInput:I[7]||(I[7]=W=>G(f)())},null,8,["modelValue","placeholder"])]),_:1})]),_:1}),me((Y(),Z("div",ji,[z(U,null,{default:Q(()=>[_.data.length&&(T.value===!0||N.scene!="attachment")?(Y(),Z("div",Ki,[(Y(!0),Z(we,null,Fe(_.data,(W,de)=>(Y(),Z("div",{class:Le(["attachment-item mr-[10px]",N.scene=="select"?"w-[100px]":"w-[120px]"]),key:de},[K("div",{class:Le(["attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center",N.scene=="select"?"h-[100px]":"h-[120px]"]),onClick:oe=>u(W)},[N.type=="image"?(Y(),ge(q,{key:0,src:G(Ge)(W.url),fit:"contain"},null,8,["src"])):N.type=="video"?(Y(),Z("video",{key:1,src:G(Ge)(W.url)},null,8,Hi)):N.type=="icon"?(Y(),ge(O,{key:2,name:W.url,size:"40px"},null,8,["name"])):ae("",!0),me(K("div",Wi,[z(O,{name:"element-Select",color:"#fff",size:"40px"}),K("div",Yi,[K("span",qi,J(n(W.att_id)),1)])],512),[[Te,A[W.att_id]]])],10,Vi),K("div",zi,[z($,{placement:"top"},{content:Q(()=>[he(J(W.real_name),1)]),default:Q(()=>[K("div",Xi,J(W.real_name),1)]),_:2},1024),N.scene=="attachment"?(Y(),ge(B,{key:0,"hide-on-click":!1,class:"attachment-action hidden"},{dropdown:Q(()=>[z(M,null,{default:Q(()=>[W.att_type=="image"?(Y(),ge(F,{key:0,class:"text-center",onClick:oe=>i(de)},{default:Q(()=>[K("div",$i,J(G(ee)("lookOver")),1)]),_:2},1032,["onClick"])):ae("",!0),W.att_type=="video"?(Y(),ge(F,{key:1,class:"text-center",onClick:oe=>b(de)},{default:Q(()=>[K("div",Qi,J(G(ee)("lookOver")),1)]),_:2},1032,["onClick"])):ae("",!0),z(F,{class:"text-center",onClick:oe=>g(de)},{default:Q(()=>[K("div",Zi,J(G(ee)("upload.move")),1)]),_:2},1032,["onClick"]),z(F,{onClick:oe=>l(de)},{default:Q(()=>[K("div",Ji,J(G(ee)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Q(()=>[z(O,{name:"element-MoreFilled",class:"cursor-pointer ml-[8px]",size:"14px"})]),_:2},1024)):ae("",!0)])],2))),128))])):_.data.length&&T.value===!1?(Y(),Z("div",en,[(Y(!0),Z(we,null,Fe(_.data,(W,de)=>(Y(),Z("div",{class:"attachment-item mr-[10px] w-[120px]",key:de},[K("div",tn,[N.type=="image"?(Y(),ge(q,{key:0,src:G(Ge)(W.url),fit:"contain","preview-src-list":W.image_list},null,8,["src","preview-src-list"])):N.type=="video"?(Y(),Z("video",{key:1,src:G(Ge)(W.url)},null,8,rn)):N.type=="icon"?(Y(),ge(O,{key:2,name:W.url,size:"40px"},null,8,["name"])):ae("",!0)]),K("div",nn,[z($,{placement:"top"},{content:Q(()=>[he(J(W.real_name),1)]),default:Q(()=>[K("div",an,J(W.real_name),1)]),_:2},1024)])]))),128))])):(Y(),Z("div",sn,[_.loading?ae("",!0):(Y(),ge(ie,{key:0,description:N.type=="icon"?G(ee)("upload.iconEmpty"):G(ee)("upload.attachmentEmpty"),"image-size":100},null,8,["description"]))]))]),_:1})])),[[ye,_.loading]]),z(X,{gutter:20},{default:Q(()=>[N.scene=="attachment"&&T.value===!0?(Y(),ge(H,{key:0,span:8},{default:Q(()=>[K("div",on,[z(se,{modelValue:t.value,"onUpdate:modelValue":I[8]||(I[8]=W=>t.value=W),label:G(ee)("selectAll"),size:"large"},null,8,["modelValue","label"]),z(j,{class:"ml-[15px]",disabled:p.value,onClick:I[9]||(I[9]=W=>l())},{default:Q(()=>[he(J(G(ee)("delete")),1)]),_:1},8,["disabled"]),z(j,{disabled:p.value,onClick:I[10]||(I[10]=W=>g())},{default:Q(()=>[he(J(G(ee)("upload.move")),1)]),_:1},8,["disabled"])])]),_:1})):ae("",!0),z(H,{span:N.scene=="attachment"?16:24},{default:Q(()=>[K("div",ln,[z(le,{"current-page":_.page,"onUpdate:current-page":I[11]||(I[11]=W=>_.page=W),small:!0,"page-size":_.limit,"onUpdate:page-size":I[12]||(I[12]=W=>_.limit=W),"page-sizes":[10,20,30,40,60],layout:"total, sizes, prev, pager, next, jumper",total:_.total,onSizeChange:I[13]||(I[13]=W=>G(f)()),onCurrentChange:G(f)},null,8,["current-page","page-size","total","onCurrentChange"])])]),_:1},8,["span"])]),_:1})]),N.scene=="attachment"?(Y(),Z(we,{key:0},[z(ce,{modelValue:v.visible,"onUpdate:modelValue":I[17]||(I[17]=W=>v.visible=W),title:G(ee)("upload.moveCategory"),width:"350px"},{footer:Q(()=>[K("span",un,[z(j,{onClick:I[15]||(I[15]=W=>v.visible=!1)},{default:Q(()=>[he(J(G(ee)("cancel")),1)]),_:1}),z(j,{type:"primary",loading:v.loading,onClick:I[16]||(I[16]=W=>v.confirm())},{default:Q(()=>[he(J(G(ee)("confirm")),1)]),_:1},8,["loading"])])]),default:Q(()=>[z(ne,{"label-width":"60px"},{default:Q(()=>[z(te,{label:G(ee)("upload.moveTo"),style:{"margin-bottom":"0"}},{default:Q(()=>[z(fe,{modelValue:v.cateId,"onUpdate:modelValue":I[14]||(I[14]=W=>v.cateId=W),class:"input-width"},{default:Q(()=>[(Y(!0),Z(we,null,Fe(C.data,(W,de)=>(Y(),ge(re,{label:W.name,value:W.id,key:de},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"]),r.show?(Y(),ge(ue,{key:0,"url-list":G(c),onClose:I[18]||(I[18]=W=>r.show=!1),"initial-index":r.index,"zoom-rate":1},null,8,["url-list","initial-index"])):ae("",!0),z(ce,{modelValue:S.visible,"onUpdate:modelValue":I[19]||(I[19]=W=>S.visible=W),width:"50%","align-center":"","destroy-on-close":!0,"custom-class":"video-preview"},{default:Q(()=>[z(ve,{src:S.src,width:"100%"},null,8,["src"])]),_:1},8,["modelValue"])],64)):ae("",!0)],2)}}});const Pn=hr(dn,[["__scopeId","data-v-eb48c084"]]);export{Ci as _,Pn as a};
|