@mux/mux-audio 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/mux-audio.js +21 -20
- package/dist/mux-audio.js.map +3 -3
- package/dist/mux-audio.mjs +21 -20
- package/dist/mux-audio.mjs.map +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types-ts3.4/index.d.ts +1 -1
- package/package.json +7 -7
package/dist/mux-audio.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
"use strict";(()=>{var Ji=Object.create;var Yr=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var qi=Object.getOwnPropertyNames;var en=Object.getPrototypeOf,tn=Object.prototype.hasOwnProperty;var zr=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var rn=(j,R,l,P)=>{if(R&&typeof R=="object"||typeof R=="function")for(let L of qi(R))!tn.call(j,L)&&L!==l&&Yr(j,L,{get:()=>R[L],enumerable:!(P=Zi(R,L))||P.enumerable});return j};var sr=(j,R,l)=>(l=j!=null?Ji(en(j)):{},rn(R||!j||!j.__esModule?Yr(l,"default",{value:j,enumerable:!0}):l,j));var Dr=(j,R,l)=>{if(!R.has(j))throw TypeError("Cannot "+l)};var ze=(j,R,l)=>(Dr(j,R,"read from private field"),l?l.call(j):R.get(j)),lt=(j,R,l)=>{if(R.has(j))throw TypeError("Cannot add the same private member more than once");R instanceof WeakSet?R.add(j):R.set(j,l)},ut=(j,R,l,P)=>(Dr(j,R,"write to private field"),P?P.call(j,l):R.set(j,l),l);var At=(j,R,l)=>(Dr(j,R,"access private method"),l);var $r=zr((or,br)=>{(function(){var j,R;j=this,R=function(){return function(){var l={80:function(A,M,O){A.exports=O(728).default},728:function(A,M,O){"use strict";O.d(M,{default:function(){return $i}});var b=O(48),_=O.n(b),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(w){var C=16*Math.random()|0;return(w==="x"?C:3&C|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},D=function(w){return w&&w.nodeName!==void 0?(w.muxId||(w.muxId=w.id||x()),w.muxId):w},E=function(w){var C;w&&w.nodeName!==void 0?w=D(C=w):C=document.querySelector(w);var F=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,w,F]},m=O(640),p=O.n(m),f=p().methodFactory;p().methodFactory=function(w,C,F){var N=f(w,C,F);return function(){for(var K=["[mux]"],V=0;V<arguments.length;V++)K.push(arguments[V]);N.apply(void 0,K)}},p().setLevel(p().getLevel());var e=p();function s(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var w=_().performance,C=w&&w.timing,F=w&&w.timeOrigin||C&&C.navigationStart;return typeof F=="number"&&typeof w.now=="function"?F+w.now():Date.now()}},g=O(678),i=O.n(g),r=function(w){return o(w)[0]},o=function(w){if(typeof w!="string"||w==="")return["localhost"];var C,F=(w.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return F&&(C=(F.match(/[^\.]+\.[^\.]+$/)||[])[0]),[F,C]},c={exists:function(){var w=_().performance;return(w&&w.timing)!==void 0},domContentLoadedEventEnd:function(){var w=_().performance,C=w&&w.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var w=_().performance,C=w&&w.timing;return C&&C.navigationStart}};function t(w,C,F){F=F===void 0?1:F,w[C]=w[C]||0,w[C]+=F}var n=["x-cdn","content-type","x-request-id"];function u(w){var C={};return(w=w||"").trim().split(/[\r\n]+/).forEach(function(F){if(F){var N=F.split(": "),K=N.shift();K&&(n.indexOf(K.toLowerCase())>=0||K.toLowerCase().indexOf("x-litix-")===0)&&(C[K]=N.join(": "))}}),C}var a=function(w){var C={};for(var F in w){var N=w[F];N["DATA-ID"].search("io.litix.data.")!==-1&&(C[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return C};function d(w,C){var F=Object.keys(w);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(w);C&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(w,K).enumerable})),F.push.apply(F,N)}return F}function v(w){for(var C=1;C<arguments.length;C++){var F=arguments[C]!=null?arguments[C]:{};C%2?d(Object(F),!0).forEach(function(N){S(w,N,F[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(F)):d(Object(F)).forEach(function(N){Object.defineProperty(w,N,Object.getOwnPropertyDescriptor(F,N))})}return w}function S(w,C,F){return C in w?Object.defineProperty(w,C,{value:F,enumerable:!0,configurable:!0,writable:!0}):w[C]=F,w}var T=function(w){if(!w)return{};var C=c.navigationStart(),F=w.loading,N=F?F.start:w.trequest,K=F?F.first:w.tfirst,V=F?F.end:w.tload;return{bytesLoaded:w.total,requestStart:Math.round(C+N),responseStart:Math.round(C+K),responseEnd:Math.round(C+V)}},I=function(w){if(w&&typeof w.getAllResponseHeaders=="function")return u(w.getAllResponseHeaders())},k=function(w,C){if(!w||typeof w.getRequests!="function")return{};var F=w.getRequests({state:"executed"});if(F.length===0)return{};var N,K=F[F.length-1],V=r(K.url),H=K.bytesLoaded,Q=new Date(K.requestStartDate).getTime(),J=new Date(K.firstByteDate).getTime(),X=new Date(K.requestEndDate).getTime(),ee=isNaN(K.duration)?0:K.duration,ce=typeof C.getMetricsFor=="function"?C.getMetricsFor(K.mediaType).HttpList:C.getDashMetrics().getHttpRequests(K.mediaType);return ce.length>0&&(N=u(ce[ce.length-1]._responseHeaders||"")),{requestStart:Q,requestResponseStart:J,requestResponseEnd:X,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ee,requestHostname:V}},B=function(w,C){var F=C.getQualityFor(w),N=C.getCurrentTrackFor(w).bitrateList;return N?{currentLevel:F,renditionWidth:N[F].width||null,renditionHeight:N[F].height||null,renditionBitrate:N[F].bandwidth}:{}};function U(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var W=0,G=function(){function w(){(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")})(this,w)}var C,F,N;return C=w,F=[{key:"on",value:function(K,V,H){return V._eventEmitterGuid=V._eventEmitterGuid||++W,this._listeners=this._listeners||{},this._listeners[K]=this._listeners[K]||[],H&&(V=V.bind(H)),this._listeners[K].push(V),V}},{key:"off",value:function(K,V){var H=this._listeners&&this._listeners[K];H&&H.forEach(function(Q,J){Q._eventEmitterGuid===V._eventEmitterGuid&&H.splice(J,1)})}},{key:"one",value:function(K,V,H){var Q=this;V._eventEmitterGuid=V._eventEmitterGuid||++W;var J=function X(){Q.off(K,X),V.apply(H||this,arguments)};J._eventEmitterGuid=V._eventEmitterGuid,this.on(K,J)}},{key:"emit",value:function(K,V){var H=this;if(this._listeners){V=V||{};var Q=this._listeners["before*"]||[],J=this._listeners[K]||[],X=this._listeners["after"+K]||[],ee=function(ce,ye){(ce=ce.slice()).forEach(function(ve){ve.call(H,{type:K},ye)})};ee(Q,V),ee(J,V),ee(X,V)}}}],F&&U(C.prototype,F),N&&U(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}(),z=G;function Y(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var $=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,K.on("playing",function(){V._playheadShouldBeProgressing=!0}),K.on("play",this._startPlaybackHeartbeatInterval.bind(this)),K.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),K.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),K.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),K.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("seeked",function(){K.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),K.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&K.emit("playbackheartbeat")}),K.on("devicesleep",function(H,Q){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var C,F,N;return C=w,(F=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(C.prototype,F),N&&Y(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Z(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function q(w,C,F){return C&&Z(w.prototype,C),F&&Z(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ie=q(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("viewinit",function(){F.viewErrored=!1}),C.on("error",function(){try{var N=C.errorTranslator({player_error_code:C.data.player_error_code,player_error_message:C.data.player_error_message});N?(C.data.player_error_code=N.player_error_code,C.data.player_error_message=N.player_error_message,F.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message)}catch(K){C.mux.log.warn("Exception in error translator callback.",K),F.viewErrored=!0}})});function ne(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ae=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._watchTimeTrackerLastCheckedTime=null,K.on("playbackheartbeat",this._updateWatchTime.bind(this)),K.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,F,N;return C=w,(F=[{key:"_updateWatchTime",value:function(K,V){var H=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=H),t(this.pm.data,"view_watch_time",H-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=H}},{key:"_clearWatchTimeState",value:function(K,V){this._updateWatchTime(K,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ne(C.prototype,F),N&&ne(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function te(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var fe=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackTimeTrackerLastPlayheadPosition=-1,K.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),K.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),K.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,F,N;return C=w,(F=[{key:"_updatePlaybackTime",value:function(){var K=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&K>this._playbackTimeTrackerLastPlayheadPosition){var V=K-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=K}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&te(C.prototype,F),N&&te(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function de(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var re=function(){function w(K){(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K;var V=this._updatePlayheadTime.bind(this);K.on("playbackheartbeat",V),K.on("playbackheartbeatend",V),K.on("timeupdate",V),K.on("destroy",function(){K.off("timeupdate",V)})}var C,F,N;return C=w,(F=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(K,V){var H=this,Q=function(){H.pm.currentFragmentPDT&&H.pm.currentFragmentStart&&(H.pm.data.player_program_time=H.pm.currentFragmentPDT+H.pm.data.player_playhead_time-H.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,Q(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var J=this.pm.getPlayheadTime();J!==void 0&&(this.pm.data.player_playhead_time=J,Q(),this._updateMaxPlayheadPosition())}}}])&&de(C.prototype,F),N&&de(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Ee(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function me(w,C,F){return C&&Ee(w.prototype,C),F&&Ee(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Te=me(function w(C){if(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")}(this,w),!C.disableRebufferTracking){var F,N=function(){if(F){var K=C.data.viewer_time-F;t(C.data,"view_rebuffer_duration",K),F=C.data.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(){return N()}),C.on("rebufferstart",function(){F||(t(C.data,"view_rebuffer_count",1),F=C.data.viewer_time,C.one("rebufferend",function(){N(),F=void 0}))})}});function Me(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var _e=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.disableRebufferTracking||K.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,K.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),K.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),K.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var C,F,N;return C=w,F=[{key:"_checkIfRebuffering",value:function(K,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(K,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var H=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&H>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(K,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(K){this._lastCheckedTime=K,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=K}},{key:"_cleanupRebufferTracker",value:function(K,V){var H=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var Q=this.pm.data.player_playhead_time-this._lastPlayheadTime,J=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Q>0&&J-Q>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+J-Q}))}H?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],F&&Me(C.prototype,F),N&&Me(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}(),ke=_e;function Ie(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Be=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.on("viewinit",function(){var H=K.data,Q=H.view_id;if(!H.view_program_changed){var J=function(X,ee){var ce=ee.viewer_time;X.type==="playing"&&K.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(ce||h.now(),Q):X.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||h.now(),Q)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var C,F,N;return C=w,(F=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(K,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:K}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Ie(C.prototype,F),N&&Ie(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function be(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ue(w,C,F){return C&&be(w.prototype,C),F&&be(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ke=Ue(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("viewinit",function(){F._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){C.on(N,function(){if(F._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&F._lastPlayerWidth>=0&&F._lastSourceWidth>0&&F._lastPlayerHeight>=0&&F._lastSourceHeight>0){var K=C.data.player_playhead_time-F._lastPlayheadPosition;if(K<0)return void(F._lastPlayheadPosition=-1);var V=Math.min(F._lastPlayerWidth/F._lastSourceWidth,F._lastPlayerHeight/F._lastSourceHeight),H=Math.max(0,V-1),Q=Math.max(0,1-V);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,H),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,Q),t(C.data,"view_total_content_playback_time",K),t(C.data,"view_total_upscaling",H*K),t(C.data,"view_total_downscaling",Q*K)}F._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){C.on(N,function(){F._lastPlayheadPosition=C.data.player_playhead_time,F._lastPlayerWidth=C.data.player_width,F._lastPlayerHeight=C.data.player_height,F._lastSourceWidth=C.data.video_source_width,F._lastSourceHeight=C.data.video_source_height})})});function je(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ne(w,C,F){return C&&je(w.prototype,C),F&&je(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var et=Ne(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),this.isSeeking=!1,C.on("seeking",function(N,K){i()(C.data,K),F._lastSeekingTime=h.now(),F.isSeeking===!1&&(F.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){F.isSeeking=!1;var N=F._lastSeekingTime||h.now(),K=h.now()-N;t(C.data,"view_seek_count",1),t(C.data,"view_seek_duration",K);var V=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(V,K)}),C.on("viewend",function(){F.isSeeking=!1})});function Fe(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return tt(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?tt(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function tt(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}function Oe(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Pe=function(w,C){w.push(C),w.sort(function(F,N){return F.viewer_time-N.viewer_time})},Ve=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ce=function(){function w(K){var V=this;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),Ve.forEach(function(Q){return K.on(Q,V._updateAdData.bind(V))});var H=function(){V.isAdBreak=!1};K.on("adbreakstart",function(){V.isAdBreak=!0}),K.on("play",H),K.on("playing",H),K.on("viewend",H),K.on("adrequest",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},J),Pe(V._adRequests,J),t(K.data,"view_ad_request_count"),V.inPrerollPosition()&&(K.data.view_preroll_requested=!0,V._adHasPlayed||t(K.data,"view_preroll_request_count"))}),K.on("adresponse",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},J),Pe(V._adResponses,J);var X=V.findAdRequest(J.ad_request_id);X&&t(K.data,"view_ad_request_time",Math.max(0,J.viewer_time-X.viewer_time))}),K.on("adplay",function(Q,J){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(K.data,"view_ad_played_count")),V.inPrerollPosition()&&!K.data.view_preroll_played&&(K.data.view_preroll_played=!0,V._adRequests.length>0&&(K.data.view_preroll_request_time=Math.max(0,J.viewer_time-V._adRequests[0].viewer_time)),K.data.view_start&&(K.data.view_startup_preroll_request_time=Math.max(0,J.viewer_time-K.data.view_start)),V._prerollPlayTime=J.viewer_time)}),K.on("adplaying",function(Q,J){V.inPrerollPosition()&&K.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(K.data.view_preroll_load_time=J.viewer_time-V._prerollPlayTime,K.data.view_startup_preroll_load_time=J.viewer_time-V._prerollPlayTime)}),K.on("adended",function(){V._wouldBeNewAdPlay=!0}),K.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var C,F,N;return C=w,(F=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(K){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===K)return this._adRequests[V]}},{key:"_updateAdData",value:function(K,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var H=Fe(o(V.ad_tag_url),2),Q=H[0],J=H[1];this.pm.data.view_preroll_ad_tag_domain=J,this.pm.data.view_preroll_ad_tag_hostname=Q}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var X=Fe(o(V.ad_asset_url),2),ee=X[0],ce=X[1];this.pm.data.view_preroll_ad_asset_domain=ce,this.pm.data.view_preroll_ad_asset_hostname=ee}}}}])&&Oe(C.prototype,F),N&&Oe(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Le(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function nt(w,C,F){return C&&Le(w.prototype,C),F&&Le(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var We=nt(function w(C){var F,N;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w);var K=function(){C.disableRebufferTracking||F&&(t(C.data,"view_waiting_rebuffer_duration",h.now()-F),F=!1,_().clearInterval(N))},V=!1,H=function(){V=!1,K()};C.on("waiting",function(){V&&(C.disableRebufferTracking||(t(C.data,"view_waiting_rebuffer_count",1),F=h.now(),N=_().setInterval(function(){if(F){var Q=h.now();t(C.data,"view_waiting_rebuffer_duration",Q-F),F=Q}},250)))}),C.on("playing",function(){K(),V=!0}),C.on("pause",H),C.on("seeking",H)});function ft(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function yt(w,C,F){return C&&ft(w.prototype,C),F&&ft(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Qe=yt(function w(C){var F=this;(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w);var N=function(){F.lastWallClockTime=h.now(),C.on("before*",K)},K=function(V){var H=h.now(),Q=F.lastWallClockTime;F.lastWallClockTime=H,H-Q>3e4&&(C.emit("devicesleep",{viewer_time:Q}),i()(C.data,{viewer_time:Q}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:H}),i()(C.data,{viewer_time:H}),C.send("devicewake"))};C.one("playbackheartbeat",N),C.on("playbackheartbeatend",function(){C.off("before*",K),C.one("playbackheartbeat",N)})}),Ot=O(375),Tt=O(655),at=O.n(Tt),dt="muxData",st=function(){var w;try{w=Ot.parse(at().get(dt)||"")}catch{w={}}return w},xt=function(w){try{at().set(dt,Ot.stringify(w),{expires:7300})}catch{}},Et=function(){var w=st();return w.mux_viewer_id=w.mux_viewer_id||y(),w.msn=w.msn||Math.random(),xt(w),{mux_viewer_id:w.mux_viewer_id,mux_sample_number:w.msn}};function cr(w,C){var F=C.beaconCollectionDomain,N=C.beaconDomain;if(F)return"https://"+F;var K=N||"litix.io";return(w=w||"inferred").match(/^[a-z0-9]+$/)?"https://"+w+"."+K:"https://img.litix.io/a.gif"}var Ut=function(){var w;switch(Rt()){case"cellular":w="cellular";break;case"ethernet":w="wired";break;case"wifi":w="wifi";break;case void 0:break;default:w="other"}return w},Rt=function(){var w=_().navigator,C=w&&(w.connection||w.mozConnection||w.webkitConnection);return C&&C.type};Ut.getConnectionFromAPI=Rt;var $e=Ut,er=tr({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),Nt=tr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function tr(w){var C={};for(var F in w)w.hasOwnProperty(F)&&(C[w[F]]=F);return C}function Kt(w){var C={},F={};return Object.keys(w).forEach(function(N){var K=!1;if(w.hasOwnProperty(N)&&w[N]!==void 0){var V=N.split("_"),H=V[0],Q=er[H];Q||(e.info("Data key word `"+V[0]+"` not expected in "+N),Q=H+"_"),V.splice(1).forEach(function(J){J==="url"&&(K=!0),Nt[J]?Q+=Nt[J]:Number(J)&&Math.floor(Number(J))===Number(J)?Q+=J:(e.info("Data key word `"+J+"` not expected in "+N),Q+="_"+J+"_")}),K?F[Q]=w[N]:C[Q]=w[N]}}),i()(C,F)}var hr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},vr=["hb","requestcompleted","requestfailed","requestcanceled"],ot=function(w,C){this._beaconUrl=w||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},hr,C)};ot.prototype.queueEvent=function(w,C){var F=i()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||w==="eventrateexceeded")&&(this._eventQueue.push(F),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ot.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},ot.prototype.destroy=function(){var w=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,w?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},ot.prototype._clearBeaconQueue=function(){var w=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(w);w>0&&i()(C[C.length-1],Kt({mux_view_message:"event queue truncated"}));var F=this._createPayload(C);It(this._beaconUrl,F,!0,function(){})},ot.prototype._sendBeaconQueue=function(){var w=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var F=this._createPayload(C),N=h.now();It(this._beaconUrl,F,!1,function(K,V){V?(w._eventQueue=C.concat(w._eventQueue),w._failureCount+=1,e.info("Error sending beacon: "+V)):w._failureCount=0,w._roundTripTime=h.now()-N,w._postInFlight=!1})}},ot.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var w=Math.pow(2,this._failureCount-1);return(1+(w*=Math.random()))*this._options.baseTimeBetweenBeacons},ot.prototype._startBeaconSending=function(){var w=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){w._eventQueue.length&&w._sendBeaconQueue(),w._startBeaconSending()},this._getNextBeaconTime()))},ot.prototype._createPayload=function(w){var C,F,N,K=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){C=JSON.stringify({metadata:V,events:F||w}),N=C.length/1024},Q=function(){return N<=K._options.maxPayloadKBSize};return H(),Q()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),F=w.filter(function(J){return vr.indexOf(J.e)===-1}),H()),Q()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),F.forEach(function(J){for(var X in J){var ee=J[X];typeof ee=="string"&&ee.length>51200&&(J[X]=ee.substring(0,51200))}}),H()),C};var It=function(w,C,F,N){if(F&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(w,C))N();else if(_().fetch)_().fetch(w,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var K=new(_()).XMLHttpRequest;return K.onreadystatechange=function(){if(K.readyState===4)return N(null,K.status!==200?"error":void 0)},K.open("POST",w),K.setRequestHeader("Content-Type","text/plain"),void K.send(C)}N()}},rr=ot;function St(w){return St=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},St(w)}var gr=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],Ei=["viewstart","error","ended","viewend"],ir=function(w,C){var F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=w,this.envKey=C,this.eventQueue=new rr(cr(C,F)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=F.sampleRate,this.disableCookies=F.disableCookies,this.respectDoNotTrack=F.respectDoNotTrack;var N=F.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:N.name,viewer_application_version:N.version,viewer_application_engine:N.layout,viewer_device_name:N.product,viewer_device_category:"",viewer_device_manufacturer:N.manufacturer,viewer_os_family:N.os&&N.os.family,viewer_os_architecture:N.os&&N.os.architecture,viewer_os_version:N.os&&N.os.version};var K=$e();K&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:K})),_()!==void 0&&_().location&&_().location.href&&(this.pageLevelData.page_url=_().location.href),this.viewerData=this.disableCookies?{}:Et()};ir.prototype.send=function(w,C){if(w){if(this.respectDoNotTrack&&s())return e.info("Not sending `"+w+"` because Do Not Track is enabled");if(!C||St(C)!=="object")return e.error("A data object was expected in send() but was not provided");var F,N,K=this.disableCookies?{}:(F=st(),N=h.now(),F.session_start&&(F.sst=F.session_start,delete F.session_start),F.session_id&&(F.sid=F.session_id,delete F.session_id),F.session_expires&&(F.sex=F.session_expires,delete F.session_expires),(!F.sex||F.sex<N)&&(F.sid=y(),F.sst=N),F.sex=N+15e5,xt(F),{session_id:F.sid,session_start:F.sst,session_expires:F.sex}),V={};i()(V,this.pageLevelData),i()(V,C),i()(V,K),i()(V,this.viewerData),V.event=w,V.env_key=this.envKey,V.user_id&&(V.viewer_user_id=V.user_id,delete V.user_id);var H=V.mux_sample_number>=this.sampleRate,Q=Kt(this._deduplicateBeaconData(w,V));if(this.lastEventTime=this.mux.utils.now(),H)return e.info("Not sending event due to sample rate restriction",w,V,Q);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",w,V,Q),!this.rateLimited){if(e.info("Sending event",w,V,Q),this.rateLimited=!this.eventQueue.queueEvent(w,Q),this.mux.WINDOW_UNLOADING&&w==="viewend")this.eventQueue.destroy(!0);else if((Ei.indexOf(w)>=0||this.mux.WINDOW_HIDDEN&&w==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",Q=Kt(V),this.eventQueue.queueEvent(V.event,Q),e.error("Beaconing disabled due to rate limit.")}}},ir.prototype.destroy=function(){this.eventQueue.destroy(!1)},ir.prototype._deduplicateBeaconData=function(w,C){var F=this,N={},K=C.view_id;if(!K||w==="viewstart"||w==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},C),K&&(this.previousBeaconData=N),K&&w==="viewend"&&(this.previousBeaconData=null);else{var V=w.indexOf("request")===0;Object.keys(C).forEach(function(H){var Q=C[H];(Q!==F.previousBeaconData[H]||gr.indexOf(H)>-1||function(J,X,ee,ce){return!(!J||X.indexOf("request_")!==0||X!=="request_response_headers"&&St(ee)==="object"&&St(ce)==="object"&&Object.keys(ee||{}).length===Object.keys(ce||{}).length)}(V,H,Q,F.previousBeaconData[H])||function(J,X){return J==="renditionchange"&&X.indexOf("video_source_")===0}(w,H))&&(N[H]=Q,F.previousBeaconData[H]=Q)})}return N};var yi=ir;function Ur(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ti(w,C,F){return C&&Ur(w.prototype,C),F&&Ur(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var xi=Ti(function w(C){(function(X,ee){if(!(X instanceof ee))throw new TypeError("Cannot call a class as a function")})(this,w);var F=0,N=0,K=0,V=0,H=0,Q=0,J=0;C.on("requestcompleted",function(X,ee){var ce,ye,ve=ee.request_start,se=ee.request_response_start,le=ee.request_response_end,Se=ee.request_bytes_loaded;if(V++,se?(ce=se-ve,ye=le-se):ye=le-ve,ye>0&&Se>0){var Ye=Se/ye*8e3;H++,N+=Se,K+=ye,C.data.view_min_request_throughput=Math.min(C.data.view_min_request_throughput||1/0,Ye),C.data.view_average_request_throughput=N/K*8e3,C.data.view_request_count=V,ce>0&&(F+=ce,C.data.view_max_request_latency=Math.max(C.data.view_max_request_latency||0,ce),C.data.view_average_request_latency=F/H)}}),C.on("requestfailed",function(X,ee){V++,Q++,C.data.view_request_count=V,C.data.view_request_failed_count=Q}),C.on("requestcanceled",function(X,ee){V++,J++,C.data.view_request_count=V,C.data.view_request_canceled_count=J})});function Nr(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Si(w,C,F){return C&&Nr(w.prototype,C),F&&Nr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Di=Si(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("before*",function(N,K){var V=K.viewer_time,H=h.now(),Q=F._lastEventTime;if(F._lastEventTime=H,Q&&H-Q>36e5){var J=Object.keys(C.data).reduce(function(X,ee){return ee.indexOf("video_")===0?i()(X,function(ce,ye,ve){return ye in ce?Object.defineProperty(ce,ye,{value:ve,enumerable:!0,configurable:!0,writable:!0}):ce[ye]=ve,ce}({},ee,C.data[ee])):X},{});C.mux.log.info("Received event after at least an hour inactivity, creating a new view"),C.emit("viewinit",i()({viewer_time:V},J)),C.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(C.emit("play",{viewer_time:V}),N.type!=="playing"&&C.emit("playing",{viewer_time:V}))}})});function mr(w){return mr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},mr(w)}function Ai(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return Kr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Kr(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Kr(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}function jr(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function pr(w,C){return pr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(F,N){return F.__proto__=N,F},pr(w,C)}function Li(w){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var F,N=nr(w);if(C){var K=nr(this).constructor;F=Reflect.construct(N,arguments,K)}else F=N.apply(this,arguments);return _i(this,F)}}function _i(w,C){if(C&&(mr(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return we(w)}function we(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}function nr(w){return nr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},nr(w)}var bi=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Oi=function(w){(function(H,Q){if(typeof Q!="function"&&Q!==null)throw new TypeError("Super expression must either be null or a function");H.prototype=Object.create(Q&&Q.prototype,{constructor:{value:H,writable:!0,configurable:!0}}),Object.defineProperty(H,"prototype",{writable:!1}),Q&&pr(H,Q)})(V,w);var C,F,N,K=Li(V);function V(H,Q,J){var X;(function(se,le){if(!(se instanceof le))throw new TypeError("Cannot call a class as a function")})(this,V),(X=K.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),X.NAVIGATION_START=c.navigationStart(),X.mux=H,X.id=Q,(J=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},J)).data=J.data||{},J.data.property_key&&(J.data.env_key=J.data.property_key,delete J.data.property_key),e.setLevel(J.debug?"debug":"warn"),X.getPlayheadTime=J.getPlayheadTime,X.getStateData=J.getStateData||function(){return{}},X.getAdData=J.getAdData||function(){},X.minimumRebufferDuration=J.minimumRebufferDuration,X.sustainedRebufferThreshold=J.sustainedRebufferThreshold,X.playbackHeartbeatTime=J.playbackHeartbeatTime,X.disableRebufferTracking=J.disableRebufferTracking,X.disableRebufferTracking&&X.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),X.disablePlayheadRebufferTracking=J.disablePlayheadRebufferTracking,X.errorTranslator=J.errorTranslator,X.playbackEventDispatcher=new yi(H,J.data.env_key,J),X.data={player_instance_id:y(),mux_sample_rate:J.sampleRate,beacon_domain:J.beaconCollectionDomain?J.beaconCollectionDomain:J.beaconDomain},X.data.view_sequence_number=1,X.data.player_sequence_number=1,X.oldEmit=X.emit,X.emit=function(se,le){le=i()({viewer_time:this.mux.utils.now()},le),this.oldEmit(se,le)};var ee=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(we(X));X.on("viewinit",function(se,le){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,le),this._initializeViewData(),this.one("play",ee),this.one("adbreakstart",ee)});var ce=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(we(X));if(X.on("videochange",function(se,le){ce(le)}),X.on("programchange",function(se,le){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),ce(i()(le,{view_program_changed:!0})),ee(),this.emit("play"),this.emit("playing")}),X.on("fragmentchange",function(se,le){this.currentFragmentPDT=le.currentFragmentPDT,this.currentFragmentStart=le.currentFragmentStart}),X.on("destroy",X.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ye=function(){var se=X.data.view_start!==void 0;X.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&X.mux.WINDOW_HIDDEN&&(X.data.player_is_paused||X.emit("hb"))};window.addEventListener("visibilitychange",ye,!1);var ve=function(se){se.persisted||X.destroy()};window.addEventListener("pagehide",ve,!1),X.on("destroy",function(){window.removeEventListener("visibilitychange",ye),window.removeEventListener("pagehide",ve)})}return X.on("playerready",function(se,le){i()(this.data,le)}),bi.forEach(function(se){X.on(se,function(le,Se){se.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,Se),this._sanitizeData()}),X.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),X.on("viewend",function(se,le){i()(X.data,le)}),X.one("playerready",function(se){var le=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=le-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),X.longResumeTracker=new Di(we(X)),X.errorTracker=new ie(we(X)),new Qe(we(X)),X.seekingTracker=new et(we(X)),X.playheadTime=new re(we(X)),X.playbackHeartbeat=new $(we(X)),new Ke(we(X)),X.watchTimeTracker=new ae(we(X)),new fe(we(X)),X.adTracker=new Ce(we(X)),new ke(we(X)),new Te(we(X)),new Be(we(X)),new We(we(X)),new xi(we(X)),J.hlsjs&&X.addHLSJS(J),J.dashjs&&X.addDashJS(J),X.emit("viewinit",J.data),X}return C=V,F=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(H){var Q=i()({},this.data);if(Q.video_source_is_live===void 0&&(Q.player_source_duration===1/0||Q.video_source_duration===1/0?Q.video_source_is_live=!0:(Q.player_source_duration>0||Q.video_source_duration>0)&&(Q.video_source_is_live=!1)),Q.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(ce){Q[ce]=void 0}),Q.video_source_url=Q.video_source_url||Q.player_source_url,Q.video_source_url){var J=Ai(o(Q.video_source_url),2),X=J[0],ee=J[1];Q.video_source_domain=ee,Q.video_source_hostname=X}delete Q.ad_request_id,this.playbackEventDispatcher.send(H,Q),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){i()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var H=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Q){var J=parseInt(H.data[Q],10);H.data[Q]=isNaN(J)?void 0:J}),["player_source_url","video_source_url"].forEach(function(Q){if(H.data[Q]){var J=H.data[Q].toLowerCase();J.indexOf("data:")!==0&&J.indexOf("blob:")!==0||(H.data[Q]="MSE style URL")}})}},{key:"_resetVideoData",value:function(H,Q){var J=this;Object.keys(this.data).forEach(function(X){X.indexOf("video_")===0&&delete J.data[X]})}},{key:"_resetViewData",value:function(){var H=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("view_")===0&&delete H.data[Q]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(H,Q){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var H=this,Q=this.data.view_id=y(),J=function(){Q===H.data.view_id&&t(H.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",J):J()}},{key:"_restartHeartBeat",value:function(){var H=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){H.data.player_is_paused||H.emit("hb")},1e4))}},{key:"addHLSJS",value:function(H){H.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=H.hlsjs,function(Q,J,X){var ee=arguments.length>4?arguments[4]:void 0,ce=Q.log,ye=Q.utils.secondsToMs,ve=function(pe){var oe,he=parseInt(ee.version);return he===1&&pe.programDateTime!==null&&(oe=pe.programDateTime),he===0&&pe.pdt!==null&&(oe=pe.pdt),oe};if(c.exists()){var se=function(pe,oe){return Q.emit(J,pe,oe)},le=function(pe,oe){var he=oe.levels,ue=oe.audioTracks,ge=oe.url,Re=oe.stats,Ae=oe.networkDetails,it=oe.sessionData,qe={},ct={};he.forEach(function(gt,Gt){qe[Gt]={width:gt.width,height:gt.height,bitrate:gt.bitrate,attrs:gt.attrs}}),ue.forEach(function(gt,Gt){ct[Gt]={name:gt.name,language:gt.lang,bitrate:gt.bitrate}});var ht=T(Re),vt=ht.bytesLoaded,He=ht.requestStart,xr=ht.responseStart,Sr=ht.responseEnd;se("requestcompleted",v(v({},a(it)),{},{request_event_type:pe,request_bytes_loaded:vt,request_start:He,request_response_start:xr,request_response_end:Sr,request_type:"manifest",request_hostname:r(ge),request_response_headers:I(Ae),request_rendition_lists:{media:qe,audio:ct,video:{}}}))};X.on(ee.Events.MANIFEST_LOADED,le);var Se=function(pe,oe){var he=oe.details,ue=oe.level,ge=oe.networkDetails,Re=oe.stats,Ae=T(Re),it=Ae.bytesLoaded,qe=Ae.requestStart,ct=Ae.responseStart,ht=Ae.responseEnd,vt=he.fragments[he.fragments.length-1],He=ve(vt)+ye(vt.duration);se("requestcompleted",{request_event_type:pe,request_bytes_loaded:it,request_start:qe,request_response_start:ct,request_response_end:ht,request_current_level:ue,request_type:"manifest",request_hostname:r(he.url),request_response_headers:I(ge),video_holdback:he.holdBack&&ye(he.holdBack),video_part_holdback:he.partHoldBack&&ye(he.partHoldBack),video_part_target_duration:he.partTarget&&ye(he.partTarget),video_target_duration:he.targetduration&&ye(he.targetduration),video_source_is_live:he.live,player_manifest_newest_program_time:isNaN(He)?void 0:He})};X.on(ee.Events.LEVEL_LOADED,Se);var Ye=function(pe,oe){var he=oe.details,ue=oe.networkDetails,ge=oe.stats,Re=T(ge),Ae=Re.bytesLoaded,it=Re.requestStart,qe=Re.responseStart,ct=Re.responseEnd;se("requestcompleted",{request_event_type:pe,request_bytes_loaded:Ae,request_start:it,request_response_start:qe,request_response_end:ct,request_type:"manifest",request_hostname:r(he.url),request_response_headers:I(ue)})};X.on(ee.Events.AUDIO_TRACK_LOADED,Ye);var Je=function(pe,oe){var he=oe.stats,ue=oe.networkDetails,ge=oe.frag;he=he||ge.stats;var Re=T(he),Ae={request_event_type:pe,request_bytes_loaded:Re.bytesLoaded,request_start:Re.requestStart,request_response_start:Re.responseStart,request_response_end:Re.responseEnd,request_hostname:ue?r(ue.responseURL):void 0,request_response_headers:I(ue),request_media_duration:ge.duration};ge.type==="main"?(Ae.request_type="media",Ae.request_current_level=ge.level,Ae.request_video_width=(X.levels[ge.level]||{}).width,Ae.request_video_height=(X.levels[ge.level]||{}).height):Ae.request_type=ge.type,se("requestcompleted",Ae)};X.on(ee.Events.FRAG_LOADED,Je);var Dt=function(pe,oe){var he=oe.frag,ue=he.start,ge={currentFragmentPDT:ve(he),currentFragmentStart:ye(ue)};se("fragmentchange",ge)};X.on(ee.Events.FRAG_CHANGED,Dt);var De=function(pe,oe){var he=oe.type,ue=oe.details,ge=oe.response,Re=oe.fatal,Ae=oe.context,it=oe.frag;if(ue===ee.ErrorDetails.MANIFEST_LOAD_ERROR||ue===ee.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT||ue===ee.ErrorDetails.LEVEL_LOAD_ERROR||ue===ee.ErrorDetails.LEVEL_LOAD_TIMEOUT){var qe=it&&it.url||Ae&&Ae.url||"";se("requestfailed",{request_error:ue,request_url:qe,request_hostname:r(qe),request_type:ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:ge&&ge.code,request_error_text:ge&&ge.text})}Re&&se("error",{player_error_code:he,player_error_message:ue})};X.on(ee.Events.ERROR,De);var Ze=function(pe,oe){var he=oe.frag,ue=he&&he._url||"";se("requestcanceled",{request_event_type:pe,request_url:ue,request_type:"media",request_hostname:r(ue)})};X.on(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ze);var Ge=function(pe,oe){var he=oe.level,ue=X.levels[he];if(ue&&ue.attrs&&ue.attrs.BANDWIDTH){var ge,Re=ue.attrs.BANDWIDTH,Ae=parseFloat(ue.attrs["FRAME-RATE"]);isNaN(Ae)||(ge=Ae),Re?se("renditionchange",{video_source_fps:ge,video_source_bitrate:Re,video_source_width:ue.width,video_source_height:ue.height}):ce.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};X.on(ee.Events.LEVEL_SWITCHED,Ge),X._stopMuxMonitor=function(){X.off(ee.Events.MANIFEST_LOADED,le),X.off(ee.Events.LEVEL_LOADED,Se),X.off(ee.Events.AUDIO_TRACK_LOADED,Ye),X.off(ee.Events.FRAG_LOADED,Je),X.off(ee.Events.FRAG_CHANGED,Dt),X.off(ee.Events.ERROR,De),X.off(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ze),X.off(ee.Events.LEVEL_SWITCHED,Ge),X.off(ee.Events.DESTROYING,X._stopMuxMonitor),delete X._stopMuxMonitor},X.on(ee.Events.DESTROYING,X._stopMuxMonitor)}else ce.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,H.hlsjs,{},H.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var H;this.hlsjs&&((H=this.hlsjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(H){H.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=H.dashjs,function(Q,J,X){var ee=Q.log;if(X&&X.on){var ce=function(De,Ze){return Q.emit(J,De,Ze)},ye=function(De){var Ze=De.type,Ge=(De.data||{}).url;ce("requestcompleted",{request_event_type:Ze,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(Ge)})};X.on("manifestLoaded",ye);var ve={},se=function(De){var Ze=De.type,Ge=De.fragmentModel,pe=(De.chunk||{}).mediaInfo||{},oe=pe.type,he=pe.bitrateList,ue={};(he=he||[]).forEach(function(vt,He){ue[He]={},ue[He].width=vt.width,ue[He].height=vt.height,ue[He].bitrate=vt.bandwidth,ue[He].attrs={}}),oe==="video"?ve.video=ue:oe==="audio"?ve.audio=ue:ve.media=ue;var ge=k(Ge,X),Re=ge.requestStart,Ae=ge.requestResponseStart,it=ge.requestResponseEnd,qe=ge.requestResponseHeaders,ct=ge.requestMediaDuration,ht=ge.requestHostname;ce("requestcompleted",{request_event_type:Ze,request_start:Re,request_response_start:Ae,request_response_end:it,request_bytes_loaded:-1,request_type:oe+"_init",request_response_headers:qe,request_hostname:ht,request_media_duration:ct,request_rendition_lists:ve})};X.on("initFragmentLoaded",se);var le=function(De){var Ze=De.type,Ge=De.fragmentModel,pe=De.chunk||{},oe=pe.mediaInfo,he=pe.start,ue=(oe||{}).type,ge=k(Ge,X),Re=ge.requestStart,Ae=ge.requestResponseStart,it=ge.requestResponseEnd,qe=ge.requestBytesLoaded,ct=ge.requestResponseHeaders,ht=ge.requestMediaDuration,vt=ge.requestHostname,He=B(ue,X),xr=He.currentLevel,Sr=He.renditionWidth,gt=He.renditionHeight,Gt=He.renditionBitrate;ce("requestcompleted",{request_event_type:Ze,request_start:Re,request_response_start:Ae,request_response_end:it,request_bytes_loaded:qe,request_type:ue,request_response_headers:ct,request_hostname:vt,request_media_start_time:he,request_media_duration:ht,request_current_level:xr,request_labeled_bitrate:Gt,request_video_width:Sr,request_video_height:gt})};X.on("mediaFragmentLoaded",le);var Se={video:void 0,audio:void 0,totalBitrate:void 0},Ye=function(){if(Se.video&&typeof Se.video.bitrate=="number"){if(Se.video.width&&Se.video.height){var De=Se.video.bitrate;return Se.audio&&typeof Se.audio.bitrate=="number"&&(De+=Se.audio.bitrate),De!==Se.totalBitrate?(Se.totalBitrate=De,{video_source_bitrate:De,video_source_height:Se.video.height,video_source_width:Se.video.width}):void 0}ee.warn("have bitrate info for video but missing width/height")}},Je=function(De,Ze,Ge){if(typeof De.newQuality=="number"){var pe=De.mediaType;if(pe==="audio"||pe==="video"){var oe=X.getBitrateInfoListFor(pe).find(function(ue){return ue.qualityIndex===De.newQuality});if(oe&&typeof oe.bitrate=="number"){Se[pe]=oe;var he=Ye();he&&ce("renditionchange",he)}else ee.warn("missing bitrate info for ".concat(pe))}}else ee.warn("missing evt.newQuality in qualityChangeRendered event",De)};X.on("qualityChangeRendered",Je);var Dt=function(De){var Ze=De.error,Ge=De.event,pe=(Ge=Ge||{}).request||{},oe=_().event&&_().event.currentTarget||{};ce("requestfailed",{request_error:Ze+"_"+Ge.id+"_"+pe.type,request_url:Ge.url,request_hostname:r(Ge.url),request_type:pe.mediaType,request_error_code:oe.status,request_error_type:oe.statusText})};X.on("error",Dt),X._stopMuxMonitor=function(){X.off("manifestLoaded",ye),X.off("initFragmentLoaded",se),X.off("mediaFragmentLoaded",le),X.off("qualityChangeRendered",Je),X.off("error",Dt),delete X._stopMuxMonitor}}else ee.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,H.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var H;this.dashjs&&((H=this.dashjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.dashjs=void 0)}}],F&&jr(C.prototype,F),N&&jr(C,N),Object.defineProperty(C,"prototype",{writable:!1}),V}(z),Ri=Oi,Ii=O(153),jt=O.n(Ii);function Er(w){return Er=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Er(w)}function Wr(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return Gr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Gr(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Gr(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}var Pt,Pi=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ci={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};_()&&_().WeakMap&&(Pt=new WeakMap);var Mi="#EXT-X-TARGETDURATION",Fi="#EXT-X-PART-INF",wi="#EXT-X-SERVER-CONTROL",ki="#EXTINF",Bi="#EXT-X-PROGRAM-DATE-TIME",Ui="#EXT-X-VERSION",Ni="#EXT-X-SESSION-DATA",ar=function(w){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(w),this.manifest};ar.prototype.process=function(w){var C;for(this.buffer+=w,C=this.buffer.indexOf(`
|
|
5
|
-
|
|
6
|
-
`)
|
|
7
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Vr(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}var rt={},Wt=function w(C){var F=arguments;typeof C=="string"?w.hasOwnProperty(C)?_().setTimeout(function(){F=Array.prototype.splice.call(F,1),w[C].apply(null,F)},0):e.warn("`"+C+"` is an unknown task"):typeof C=="function"?_().setTimeout(function(){C(w)},0):e.warn("`"+C+"` is invalid.")},Qi={loaded:h.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(w,C){return function(F,N,K){var V=Wr(E(N),3),H=V[0],Q=V[1],J=V[2],X=F.log,ee=F.utils.getComputedStyle,ce=F.utils.secondsToMs;if(!H)return X.error("No element was found with the `"+Q+"` query selector.");if(J!=="video"&&J!=="audio")return X.error("The element of `"+Q+"` was not a media element.");H.mux&&(H.mux.destroy(),delete H.mux,X.warn("Already monitoring this video element, replacing existing event listeners")),(K=i()({automaticErrorTracking:!0},K)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:F.VERSION},K.data),K.getPlayheadTime=function(){return ce(H.currentTime)},K.getStateData=function(){var ve=this.hlsjs&&this.hlsjs.url,se=this.dashjs&&Er(this.dashjs.getSource==="function")&&this.dashjs.getSource(),le={player_is_paused:H.paused,player_playhead_time:ce(H.currentTime),player_width:parseInt(ee(H,"width")),player_height:parseInt(ee(H,"height")),player_autoplay_on:H.autoplay,player_preload_on:H.preload,player_language_code:H.lang,player_is_fullscreen:jt()&&!!(jt().fullscreenElement||jt().webkitFullscreenElement||jt().mozFullScreenElement||jt().msFullscreenElement),video_poster_url:H.poster,video_source_url:ve||se||H.currentSrc,video_source_duration:ce(H.duration),video_source_height:H.videoHeight,video_source_width:H.videoWidth},Se=K.getPlayheadTime();if(H.getStartDate&&Se>0){var Ye=H.getStartDate();if(Ye&&typeof Ye.getTime=="function"&&Ye.getTime()){var Je=Ye.getTime();if(le.player_program_time=Je+Se,H.seekable.length>0){var Dt=Je+H.seekable.end(H.seekable.length-1);le.player_live_edge_program_time=Dt}}}return le},H.mux=H.mux||{},H.mux.deleted=!1,H.mux.emit=function(ve,se){F.emit(Q,ve,se)};var ye=function(){X.error("The monitor for this video element has already been destroyed.")};H.mux.destroy=function(){Object.keys(H.mux.listeners).forEach(function(ve){H.removeEventListener(ve,H.mux.listeners[ve],!1)}),delete H.mux.listeners,H.mux.destroy=ye,H.mux.swapElement=ye,H.mux.emit=ye,H.mux.addHLSJS=ye,H.mux.addDashJS=ye,H.mux.removeHLSJS=ye,H.mux.removeDashJS=ye,H.mux.deleted=!0,F.emit(Q,"destroy")},H.mux.swapElement=function(ve){var se=Wr(E(ve),3),le=se[0],Se=se[1],Ye=se[2];return le?Ye!=="video"&&Ye!=="audio"?F.log.error("The element of `"+Se+"` was not a media element."):(le.muxId=H.muxId,delete H.muxId,le.mux=le.mux||{},le.mux.listeners=i()({},H.mux.listeners),delete H.mux.listeners,Object.keys(le.mux.listeners).forEach(function(Je){H.removeEventListener(Je,le.mux.listeners[Je],!1),le.addEventListener(Je,le.mux.listeners[Je],!1)}),le.mux.swapElement=H.mux.swapElement,le.mux.destroy=H.mux.destroy,delete H.mux,void(H=le)):F.log.error("No element was found with the `"+Se+"` query selector.")},H.mux.addHLSJS=function(ve){F.addHLSJS(Q,ve)},H.mux.addDashJS=function(ve){F.addDashJS(Q,ve)},H.mux.removeHLSJS=function(){F.removeHLSJS(Q)},H.mux.removeDashJS=function(){F.removeDashJS(Q)},F.init(Q,K),F.emit(Q,"playerready"),H.paused||(F.emit(Q,"play"),H.readyState>2&&F.emit(Q,"playing")),H.mux.listeners={},Pi.forEach(function(ve){(ve!=="error"||K.automaticErrorTracking)&&(H.mux.listeners[ve]=function(){var se={};if(ve==="error"){if(!H.error||H.error.code===1)return;se.player_error_code=H.error.code,se.player_error_message=Ci[H.error.code]||H.error.message}F.emit(Q,ve,se)},H.addEventListener(ve,H.mux.listeners[ve],!1))})}(Wt,w,C)},destroyMonitor:function(w){var C=Xi(E(w),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():e.error("A video element monitor for `"+w+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(w,C){var F=D(w);rt[F]?rt[F].addHLSJS(C):e.error("A monitor for `"+F+"` has not been initialized.")},addDashJS:function(w,C){var F=D(w);rt[F]?rt[F].addDashJS(C):e.error("A monitor for `"+F+"` has not been initialized.")},removeHLSJS:function(w){var C=D(w);rt[C]?rt[C].removeHLSJS():e.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(w){var C=D(w);rt[C]?rt[C].removeDashJS():e.error("A monitor for `"+C+"` has not been initialized.")},init:function(w,C){s()&&C&&C.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var F=D(w);rt[F]=new Ri(Wt,F,C)},emit:function(w,C,F){var N=D(w);rt[N]?(rt[N].emit(C,F),C==="destroy"&&delete rt[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:Yi,events:zi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Wt,Qi),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(w){w.persisted||(Wt.WINDOW_UNLOADING=!0)},!1);var $i=Wt},655:function(A,M,O){var b,_;function y(x){return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},y(x);}(function(x){var D=!1;if((_=typeof(b=x)=="function"?b.call(M,O,M,A):b)===void 0||(A.exports=_),D=!0,y(M)==="object"&&(A.exports=x(),D=!0),!D){var E=window.Cookies,m=window.Cookies=x();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var x=function(){for(var D=0,E={};D<arguments.length;D++){var m=arguments[D];for(var p in m)E[p]=m[p]}return E};return function D(E){function m(p,f,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=x({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{s=JSON.stringify(f),/^[\{\[]/.test(s)&&(f=s)}catch{}return f=E.write?E.write(f,p):encodeURIComponent(String(f)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=(p=(p=encodeURIComponent(String(p))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[p,"=",f,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var o=g[r].split("="),c=o.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){s=c;break}p||(s[t]=c)}catch{}}return s}}return m.set=m,m.get=function(p){return m.call(m,p)},m.getJSON=function(){return m.apply({json:!0},[].slice.call(arguments))},m.defaults={},m.remove=function(p,f){m(p,"",x(f,{expires:-1}))},m.withConverter=D,m}(function(){})})},153:function(A,M,O){var b,_=O.g!==void 0?O.g:typeof window!="undefined"?window:{},y=O(558);typeof document!="undefined"?b=document:(b=_["__GLOBAL_DOCUMENT_CACHE@4"])||(b=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),A.exports=b},48:function(A,M,O){var b;b=typeof window!="undefined"?window:O.g!==void 0?O.g:typeof self!="undefined"?self:{},A.exports=b},678:function(A){var M=9007199254740991,O="[object Arguments]",b="[object Function]",_="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function x(S,T,I){switch(I.length){case 0:return S.call(T);case 1:return S.call(T,I[0]);case 2:return S.call(T,I[0],I[1]);case 3:return S.call(T,I[0],I[1],I[2])}return S.apply(T,I)}var D,E,m=Object.prototype,p=m.hasOwnProperty,f=m.toString,e=m.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,T){var I=n(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&u(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||f.call(W)==O)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],k=I.length,B=!!k;for(var U in S)!T&&!p.call(S,U)||B&&(U=="length"||o(U,k))||I.push(U);return I}function r(S,T,I){var k=S[T];p.call(S,T)&&t(k,I)&&(I!==void 0||T in S)||(S[T]=I)}function o(S,T){return!!(T=T==null?M:T)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<T}function c(S){var T=S&&S.constructor;return S===(typeof T=="function"&&T.prototype||m)}function t(S,T){return S===T||S!=S&&T!=T}var n=Array.isArray;function u(S){return S!=null&&function(T){return typeof T=="number"&&T>-1&&T%1==0&&T<=M}(S.length)&&!function(T){var I=a(T)?f.call(T):"";return I==b||I==_}(S)}function a(S){var T=typeof S;return!!S&&(T=="object"||T=="function")}var d,v=(d=function(S,T){if(g||c(T)||u(T))(function(k,B,U,W){U||(U={});for(var G=-1,z=B.length;++G<z;){var Y=B[G],$=W?W(U[Y],k[Y],Y,U,k):void 0;r(U,Y,$===void 0?k[Y]:$)}})(T,function(k){return u(k)?i(k):function(B){if(!c(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(T),S);else for(var I in T)p.call(T,I)&&r(S,I,T[I])},function(S,T){return T=h(T===void 0?S.length-1:T,0),function(){for(var I=arguments,k=-1,B=h(I.length-T,0),U=Array(B);++k<B;)U[k]=I[T+k];k=-1;for(var W=Array(T+1);++k<T;)W[k]=I[k];return W[T]=U,x(S,this,W)}}(function(S,T){var I=-1,k=T.length,B=k>1?T[k-1]:void 0,U=k>2?T[2]:void 0;for(B=d.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(G,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?u(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],G)}(T[0],T[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++I<k;){var W=T[I];W&&d(S,W,I,B)}return S}));A.exports=v},640:function(A,M,O){var b,_;(function(y,x){"use strict";b=function(){var D=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function f(n,u){var a=n[u];if(typeof a.bind=="function")return a.bind(n);try{return Function.prototype.bind.call(a,n)}catch{return function(){return Function.prototype.apply.apply(a,[n,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(n){return n==="debug"&&(n="log"),typeof console!==E&&(n==="trace"&&m?e:console[n]!==void 0?f(console,n):console.log!==void 0?f(console,"log"):D)}function h(n,u){for(var a=0;a<p.length;a++){var d=p[a];this[d]=a<n?D:this.methodFactory(d,n,u)}this.log=this.debug}function g(n,u,a){return function(){typeof console!==E&&(h.call(this,u,a),this[n].apply(this,arguments))}}function i(n,u,a){return s(n)||g.apply(this,arguments)}function r(n,u,a){var d,v=this;u=u==null?"WARN":u;var S="loglevel";function T(U){var W=(p[U]||"silent").toUpperCase();if(typeof window!==E&&S){try{return void(window.localStorage[S]=W)}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+W+";"}catch{}}}function I(){var U;if(typeof window!==E&&S){try{U=window.localStorage[S]}catch{}if(typeof U===E)try{var W=window.document.cookie,G=W.indexOf(encodeURIComponent(S)+"=");G!==-1&&(U=/^([^;]+)/.exec(W.slice(G))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function k(){if(typeof window!==E&&S){try{return void window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof n=="string"?S+=":"+n:typeof n=="symbol"&&(S=void 0),v.name=n,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=a||i,v.getLevel=function(){return d},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(d=U,W!==!1&&T(U),h.call(v,U,n),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,I()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),k()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var B=I();B==null&&(B=u),v.setLevel(B,!1)}var o=new r,c={};o.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[n];return u||(u=c[n]=new r(n,o.getLevel(),o.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return o.noConflict=function(){return typeof window!==E&&window.log===o&&(window.log=t),o},o.getLoggers=function(){return c},o.default=o,o},(_=typeof b=="function"?b.call(M,O,M,A):b)===void 0||(A.exports=_)})()},375:function(A,M){"use strict";var O=Object.prototype.hasOwnProperty;function b(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}M.stringify=function(y,x){x=x||"";var D,E,m=[];for(E in typeof x!="string"&&(x="?"),y)if(O.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=_(E),D=_(D),E===null||D===null)continue;m.push(E+"="+D)}return m.length?x+m.join("&"):""},M.parse=function(y){for(var x,D=/([^=?#&]+)=?([^&]*)/g,E={};x=D.exec(y);){var m=b(x[1]),p=b(x[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},P={};function L(A){var M=P[A];if(M!==void 0)return M.exports;var O=P[A]={exports:{}};return l[A].call(O.exports,O,O.exports,L),O.exports}return L.n=function(A){var M=A&&A.__esModule?function(){return A.default}:function(){return A};return L.d(M,{a:M}),M},L.d=function(A,M){for(var O in M)L.o(M,O)&&!L.o(A,O)&&Object.defineProperty(A,O,{enumerable:!0,get:M[O]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(A,M){return Object.prototype.hasOwnProperty.call(A,M)},L(80)}()},typeof or=="object"&&typeof br=="object"?br.exports=R():typeof or=="object"?or.mux=R():j.mux=R()})()});var lr=zr((Yt,Or)=>{typeof window!="undefined"&&function(R,l){typeof Yt=="object"&&typeof Or=="object"?Or.exports=l():typeof define=="function"&&define.amd?define([],l):typeof Yt=="object"?Yt.Hls=l():R.Hls=l()}(Yt,function(){return function(j){var R={};function l(P){if(R[P])return R[P].exports;var L=R[P]={i:P,l:!1,exports:{}};return j[P].call(L.exports,L,L.exports,l),L.l=!0,L.exports}return l.m=j,l.c=R,l.d=function(P,L,A){l.o(P,L)||Object.defineProperty(P,L,{enumerable:!0,get:A})},l.r=function(P){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(P,"__esModule",{value:!0})},l.t=function(P,L){if(L&1&&(P=l(P)),L&8||L&4&&typeof P=="object"&&P&&P.__esModule)return P;var A=Object.create(null);if(l.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:P}),L&2&&typeof P!="string")for(var M in P)l.d(A,M,function(O){return P[O]}.bind(null,M));return A},l.n=function(P){var L=P&&P.__esModule?function(){return P.default}:function(){return P};return l.d(L,"a",L),L},l.o=function(P,L){return Object.prototype.hasOwnProperty.call(P,L)},l.p="/dist/",l(l.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,l){"use strict";var P=Object.prototype.hasOwnProperty,L="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(L=!1));function M(y,x,D){this.fn=y,this.context=x,this.once=D||!1}function O(y,x,D,E,m){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new M(D,E||y,m),f=L?L+x:x;return y._events[f]?y._events[f].fn?y._events[f]=[y._events[f],p]:y._events[f].push(p):(y._events[f]=p,y._eventsCount++),y}function b(y,x){--y._eventsCount===0?y._events=new A:delete y._events[x]}function _(){this._events=new A,this._eventsCount=0}_.prototype.eventNames=function(){var x=[],D,E;if(this._eventsCount===0)return x;for(E in D=this._events)P.call(D,E)&&x.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(D)):x},_.prototype.listeners=function(x){var D=L?L+x:x,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,f=new Array(p);m<p;m++)f[m]=E[m].fn;return f},_.prototype.listenerCount=function(x){var D=L?L+x:x,E=this._events[D];return E?E.fn?1:E.length:0},_.prototype.emit=function(x,D,E,m,p,f){var e=L?L+x:x;if(!this._events[e])return!1;var s=this._events[e],h=arguments.length,g,i;if(s.fn){switch(s.once&&this.removeListener(x,s.fn,void 0,!0),h){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,D),!0;case 3:return s.fn.call(s.context,D,E),!0;case 4:return s.fn.call(s.context,D,E,m),!0;case 5:return s.fn.call(s.context,D,E,m,p),!0;case 6:return s.fn.call(s.context,D,E,m,p,f),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];s.fn.apply(s.context,g)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(x,s[i].fn,void 0,!0),h){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,D);break;case 3:s[i].fn.call(s[i].context,D,E);break;case 4:s[i].fn.call(s[i].context,D,E,m);break;default:if(!g)for(o=1,g=new Array(h-1);o<h;o++)g[o-1]=arguments[o];s[i].fn.apply(s[i].context,g)}}return!0},_.prototype.on=function(x,D,E){return O(this,x,D,E,!1)},_.prototype.once=function(x,D,E){return O(this,x,D,E,!0)},_.prototype.removeListener=function(x,D,E,m){var p=L?L+x:x;if(!this._events[p])return this;if(!D)return b(this,p),this;var f=this._events[p];if(f.fn)f.fn===D&&(!m||f.once)&&(!E||f.context===E)&&b(this,p);else{for(var e=0,s=[],h=f.length;e<h;e++)(f[e].fn!==D||m&&!f[e].once||E&&f[e].context!==E)&&s.push(f[e]);s.length?this._events[p]=s.length===1?s[0]:s:b(this,p)}return this},_.prototype.removeAllListeners=function(x){var D;return x?(D=L?L+x:x,this._events[D]&&b(this,D)):(this._events=new A,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,j.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,l){(function(P){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,A=/^(?=([^\/?#]*))\1([^]*)$/,M=/(?:\/|^)\.(?=\/)/g,O=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,b={buildAbsoluteURL:function(_,y,x){if(x=x||{},_=_.trim(),y=y.trim(),!y){if(!x.alwaysNormalize)return _;var D=b.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=b.normalizePath(D.path),b.buildURLFromParts(D)}var E=b.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=b.normalizePath(E.path),b.buildURLFromParts(E)):y;var m=b.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=A.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var f={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(f.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)f.path=m.path,E.params||(f.params=m.params,E.query||(f.query=m.query));else{var e=m.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;f.path=b.normalizePath(s)}return f.path===null&&(f.path=x.alwaysNormalize?b.normalizePath(E.path):E.path),b.buildURLFromParts(f)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(M,"");_.length!==(_=_.replace(O,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};j.exports=b})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,l){function P(x){var D={};function E(p){if(D[p])return D[p].exports;var f=D[p]={i:p,l:!1,exports:{}};return x[p].call(f.exports,f,f.exports,E),f.l=!0,f.exports}E.m=x,E.c=D,E.i=function(p){return p},E.d=function(p,f,e){E.o(p,f)||Object.defineProperty(p,f,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var f=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(f,"a",f),f},E.o=function(p,f){return Object.prototype.hasOwnProperty.call(p,f)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function M(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function O(x){return!isNaN(1*x)}function b(x,D,E){var m={};m[E]=[];var p=D.toString(),f=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!f)return m;for(var e=f[1],s=new RegExp("(\\\\n|\\W)"+M(e)+A,"g"),h;h=s.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(s=new RegExp("\\("+M(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+A,"g");h=s.exec(p);)x[h[2]]||(m[E].push(h[1]),x[h[2]]=l(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)O(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(x){var D=Object.keys(x);return D.reduce(function(E,m){return E||x[m].length>0},!1)}function y(x,D){for(var E={main:[D]},m={main:[]},p={main:{}};_(E);)for(var f=Object.keys(E),e=0;e<f.length;e++){var s=f[e],h=E[s],g=h.pop();if(p[s]=p[s]||{},!(p[s][g]||!x[s][g])){p[s][g]=!0,m[s]=m[s]||[],m[s].push(g);for(var i=b(x,x[s][g],s),r=Object.keys(i),o=0;o<r.length;o++)E[r[o]]=E[r[o]]||[],E[r[o]]=E[r[o]].concat(i[r[o]])}}return m}j.exports=function(x,D){D=D||{};var E={main:l.m},m=D.all?{main:Object.keys(E.main)}:y(E,x),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+P.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
|
|
8
|
-
`}),p=p+"new (("+P.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+m.main.map(function(g){return""+JSON.stringify(g)+": "+E.main[g].toString()}).join(",")+"}))(self);";var f=new window.Blob([p],{type:"text/javascript"});if(D.bare)return f;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(f),h=new window.Worker(s);return h.objectURL=s,h}},"./src/config.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"hlsDefaultConfig",function(){return o}),l.d(R,"mergeConfig",function(){return t}),l.d(R,"enableStreamingMode",function(){return n});var P=l("./src/controller/abr-controller.ts"),L=l("./src/controller/audio-stream-controller.ts"),A=l("./src/controller/audio-track-controller.ts"),M=l("./src/controller/subtitle-stream-controller.ts"),O=l("./src/controller/subtitle-track-controller.ts"),b=l("./src/controller/buffer-controller.ts"),_=l("./src/controller/timeline-controller.ts"),y=l("./src/controller/cap-level-controller.ts"),x=l("./src/controller/fps-controller.ts"),D=l("./src/controller/eme-controller.ts"),E=l("./src/controller/cmcd-controller.ts"),m=l("./src/utils/xhr-loader.ts"),p=l("./src/utils/fetch-loader.ts"),f=l("./src/utils/cues.ts"),e=l("./src/utils/mediakeys-helper.ts"),s=l("./src/utils/logger.ts");function h(){return h=Object.assign?Object.assign.bind():function(u){for(var a=1;a<arguments.length;a++){var d=arguments[a];for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&(u[v]=d[v])}return u},h.apply(this,arguments)}function g(u,a){var d=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),d.push.apply(d,v)}return d}function i(u){for(var a=1;a<arguments.length;a++){var d=arguments[a]!=null?arguments[a]:{};a%2?g(Object(d),!0).forEach(function(v){r(u,v,d[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)):g(Object(d)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(d,v))})}return u}function r(u,a,d){return a in u?Object.defineProperty(u,a,{value:d,enumerable:!0,configurable:!0,writable:!0}):u[a]=d,u}var o=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:m.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:P.default,bufferController:b.default,capLevelController:y.default,fpsController:x.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:M.SubtitleStreamController,subtitleTrackController:O.default,timelineController:_.TimelineController,audioStreamController:L.default,audioTrackController:A.default,emeController:D.default,cmcdController:E.default});function c(){return{cueHandler:f.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function t(u,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,a)}function n(u){var a=u.loader;if(a!==p.default&&a!==m.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var d=Object(p.fetchSupported)();d&&(u.loader=p.default,u.progressive=!0,u.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/utils/ewma-bandwidth-estimator.ts"),A=l("./src/events.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/errors.ts"),b=l("./src/types/loader.ts"),_=l("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function x(E,m,p){return m&&y(E.prototype,m),p&&y(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var D=function(){function E(p){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=p;var f=p.config;this.bwEstimator=new L.default(f.abrEwmaSlowVoD,f.abrEwmaFastVoD,f.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(A.Events.FRAG_LOADING,this.onFragLoading,this),f.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(A.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(A.Events.FRAG_LOADING,this.onFragLoading,this),f.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(A.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},m.onFragLoading=function(f,e){var s=e.frag;if(s.type===b.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=s,this.partCurrent=(h=e.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(f,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},m._abandonRulesCheck=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.autoLevelEnabled,g=s.config,i=s.media;if(!(!f||!i)){var r=e?e.stats:f.stats,o=e?e.duration:f.duration;if(r.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!h||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(c<=500*o/t)){var n=s.levels,u=s.minAutoLevel,a=n[f.level],d=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),v=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/c),S=(d-r.loaded)/v,T=i.currentTime,I=(M.BufferHelper.bufferInfo(i,T,g.maxBufferHole).end-T)/t;if(!(I>=2*o/t||S<=I)){var k=Number.POSITIVE_INFINITY,B;for(B=f.level-1;B>u;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*v),k<I)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+f.sn+(e?" part "+e.index:"")+" of level "+f.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
|
|
9
|
-
|
|
1
|
+
"use strict";(()=>{var dn=Object.create;var qr=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty;var ei=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var mn=(j,R,l,C)=>{if(R&&typeof R=="object"||typeof R=="function")for(let L of hn(R))!gn.call(j,L)&&L!==l&&qr(j,L,{get:()=>R[L],enumerable:!(C=cn(R,L))||C.enumerable});return j};var fr=(j,R,l)=>(l=j!=null?dn(vn(j)):{},mn(R||!j||!j.__esModule?qr(l,"default",{value:j,enumerable:!0}):l,j));var _r=(j,R,l)=>{if(!R.has(j))throw TypeError("Cannot "+l)};var qe=(j,R,l)=>(_r(j,R,"read from private field"),l?l.call(j):R.get(j)),ft=(j,R,l)=>{if(R.has(j))throw TypeError("Cannot add the same private member more than once");R instanceof WeakSet?R.add(j):R.set(j,l)},dt=(j,R,l,C)=>(_r(j,R,"write to private field"),C?C.call(j,l):R.set(j,l),l);var At=(j,R,l)=>(_r(j,R,"access private method"),l);var ii=ei((dr,Ir)=>{(function(){var j,R;j=this,R=function(){return function(){var l={80:function(A,w,O){A.exports=O(728).default},728:function(A,w,O){"use strict";O.d(w,{default:function(){return un}});var b=O(48),_=O.n(b),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(F){var P=16*Math.random()|0;return(F==="x"?P:3&P|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},D=function(F){return F&&F.nodeName!==void 0?(F.muxId||(F.muxId=F.id||x()),F.muxId):F},E=function(F){var P;F&&F.nodeName!==void 0?F=D(P=F):P=document.querySelector(F);var M=P&&P.nodeName?P.nodeName.toLowerCase():"";return[P,F,M]},m=O(640),p=O.n(m),f=p().methodFactory;p().methodFactory=function(F,P,M){var N=f(F,P,M);return function(){for(var K=["[mux]"],V=0;V<arguments.length;V++)K.push(arguments[V]);N.apply(void 0,K)}},p().setLevel(p().getLevel());var e=p();function s(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var F=_().performance,P=F&&F.timing,M=P&&P.navigationStart,N=typeof M=="number"&&typeof F.now=="function"?M+F.now():Date.now();return Math.round(N)}},g=O(678),i=O.n(g),r=function(F){return o(F)[0]},o=function(F){if(typeof F!="string"||F==="")return["localhost"];var P,M=(F.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return M&&(P=(M.match(/[^\.]+\.[^\.]+$/)||[])[0]),[M,P]},c={exists:function(){var F=_().performance;return(F&&F.timing)!==void 0},domContentLoadedEventEnd:function(){var F=_().performance,P=F&&F.timing;return P&&P.domContentLoadedEventEnd},navigationStart:function(){var F=_().performance,P=F&&F.timing;return P&&P.navigationStart}};function t(F,P,M){M=M===void 0?1:M,F[P]=F[P]||0,F[P]+=M}var n=["x-cdn","content-type","x-request-id"];function u(F){var P={};return(F=F||"").trim().split(/[\r\n]+/).forEach(function(M){if(M){var N=M.split(": "),K=N.shift();K&&(n.indexOf(K.toLowerCase())>=0||K.toLowerCase().indexOf("x-litix-")===0)&&(P[K]=N.join(": "))}}),P}var a=function(F){var P={};for(var M in F){var N=F[M];N["DATA-ID"].search("io.litix.data.")!==-1&&(P[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return P};function d(F,P){var M=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);P&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(F,K).enumerable})),M.push.apply(M,N)}return M}function v(F){for(var P=1;P<arguments.length;P++){var M=arguments[P]!=null?arguments[P]:{};P%2?d(Object(M),!0).forEach(function(N){S(F,N,M[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(M)):d(Object(M)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(M,N))})}return F}function S(F,P,M){return P in F?Object.defineProperty(F,P,{value:M,enumerable:!0,configurable:!0,writable:!0}):F[P]=M,F}var T=function(F){if(!F)return{};var P=c.navigationStart(),M=F.loading,N=M?M.start:F.trequest,K=M?M.first:F.tfirst,V=M?M.end:F.tload;return{bytesLoaded:F.total,requestStart:Math.round(P+N),responseStart:Math.round(P+K),responseEnd:Math.round(P+V)}},I=function(F){if(F&&typeof F.getAllResponseHeaders=="function")return u(F.getAllResponseHeaders())};function k(F,P){var M=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);P&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(F,K).enumerable})),M.push.apply(M,N)}return M}function B(F){for(var P=1;P<arguments.length;P++){var M=arguments[P]!=null?arguments[P]:{};P%2?k(Object(M),!0).forEach(function(N){U(F,N,M[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(M)):k(Object(M)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(M,N))})}return F}function U(F,P,M){return P in F?Object.defineProperty(F,P,{value:M,enumerable:!0,configurable:!0,writable:!0}):F[P]=M,F}var W=function(F,P){if(!F||typeof F.getRequests!="function")return{};var M=F.getRequests({state:"executed"});if(M.length===0)return{};var N,K=M[M.length-1],V=r(K.url),G=K.url,X=K.bytesLoaded,J=new Date(K.requestStartDate).getTime(),Q=new Date(K.firstByteDate).getTime(),Z=new Date(K.requestEndDate).getTime(),ce=isNaN(K.duration)?0:K.duration,oe=typeof P.getMetricsFor=="function"?P.getMetricsFor(K.mediaType).HttpList:P.getDashMetrics().getHttpRequests(K.mediaType);return oe.length>0&&(N=u(oe[oe.length-1]._responseHeaders||"")),{requestStart:J,requestResponseStart:Q,requestResponseEnd:Z,requestBytesLoaded:X,requestResponseHeaders:N,requestMediaDuration:ce,requestHostname:V,requestUrl:G}},H=function(F,P){var M=P.getQualityFor(F),N=P.getCurrentTrackFor(F).bitrateList;return N?{currentLevel:M,renditionWidth:N[M].width||null,renditionHeight:N[M].height||null,renditionBitrate:N[M].bandwidth}:{}},z=function(F){var P;return(P=F.match(/.*codecs\*?="(.*)"/))===null||P===void 0?void 0:P[1]};function Y(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var $=0,ee=function(){function F(){(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")})(this,F)}var P,M,N;return P=F,M=[{key:"on",value:function(K,V,G){return V._eventEmitterGuid=V._eventEmitterGuid||++$,this._listeners=this._listeners||{},this._listeners[K]=this._listeners[K]||[],G&&(V=V.bind(G)),this._listeners[K].push(V),V}},{key:"off",value:function(K,V){var G=this._listeners&&this._listeners[K];G&&G.forEach(function(X,J){X._eventEmitterGuid===V._eventEmitterGuid&&G.splice(J,1)})}},{key:"one",value:function(K,V,G){var X=this;V._eventEmitterGuid=V._eventEmitterGuid||++$;var J=function Q(){X.off(K,Q),V.apply(G||this,arguments)};J._eventEmitterGuid=V._eventEmitterGuid,this.on(K,J)}},{key:"emit",value:function(K,V){var G=this;if(this._listeners){V=V||{};var X=this._listeners["before*"]||[],J=this._listeners[K]||[],Q=this._listeners["after"+K]||[],Z=function(ce,oe){(ce=ce.slice()).forEach(function(fe){fe.call(G,{type:K},oe)})};Z(X,V),Z(J,V),Z(Q,V)}}}],M&&Y(P.prototype,M),N&&Y(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}(),q=ee;function re(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ae=function(){function F(K){var V=this;(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,K.on("playing",function(){V._playheadShouldBeProgressing=!0}),K.on("play",this._startPlaybackHeartbeatInterval.bind(this)),K.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),K.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),K.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),K.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("seeked",function(){K.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),K.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&K.emit("playbackheartbeat")}),K.on("devicesleep",function(G,X){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:X.viewer_time}),V._playbackHeartbeatInterval=null)})}var P,M,N;return P=F,(M=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&re(P.prototype,M),N&&re(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function ne(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function te(F,P,M){return P&&ne(F.prototype,P),M&&ne(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var he=te(function F(P){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),P.on("viewinit",function(){M.viewErrored=!1}),P.on("error",function(N,K){try{var V=P.errorTranslator({player_error_code:K.player_error_code,player_error_message:K.player_error_message,player_error_context:K.player_error_context});V?(P.data.player_error_code=V.player_error_code||K.player_error_code,P.data.player_error_message=V.player_error_message||K.player_error_message,P.data.player_error_context=V.player_error_context||K.player_error_context,M.viewErrored=!0):(delete P.data.player_error_code,delete P.data.player_error_message,delete P.data.player_error_context)}catch(G){P.mux.log.warn("Exception in error translator callback.",G),M.viewErrored=!0}})});function ve(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ie=function(){function F(K){(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._watchTimeTrackerLastCheckedTime=null,K.on("playbackheartbeat",this._updateWatchTime.bind(this)),K.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var P,M,N;return P=F,(M=[{key:"_updateWatchTime",value:function(K,V){var G=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=G),t(this.pm.data,"view_watch_time",G-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=G}},{key:"_clearWatchTimeState",value:function(K,V){this._updateWatchTime(K,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ve(P.prototype,M),N&&ve(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function Te(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var pe=function(){function F(K){(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._playbackTimeTrackerLastPlayheadPosition=-1,K.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),K.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),K.on("seeking",this._clearPlaybackTimeState.bind(this))}var P,M,N;return P=F,(M=[{key:"_updatePlaybackTime",value:function(){var K=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&K>this._playbackTimeTrackerLastPlayheadPosition){var V=K-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=K}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&Te(P.prototype,M),N&&Te(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function xe(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Me=function(){function F(K){(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K;var V=this._updatePlayheadTime.bind(this);K.on("playbackheartbeat",V),K.on("playbackheartbeatend",V),K.on("timeupdate",V),K.on("destroy",function(){K.off("timeupdate",V)})}var P,M,N;return P=F,(M=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(K,V){var G=this,X=function(){G.pm.currentFragmentPDT&&G.pm.currentFragmentStart&&(G.pm.data.player_program_time=G.pm.currentFragmentPDT+G.pm.data.player_playhead_time-G.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,X(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var J=this.pm.getPlayheadTime();J!==void 0&&(this.pm.data.player_playhead_time=J,X(),this._updateMaxPlayheadPosition())}}}])&&xe(P.prototype,M),N&&xe(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function Ae(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function We(F,P,M){return P&&Ae(F.prototype,P),M&&Ae(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ie=We(function F(P){if(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")}(this,F),!P.disableRebufferTracking){var M,N=function(V,G){K(G),M=void 0},K=function(V){if(M){var G=V.viewer_time-M;t(P.data,"view_rebuffer_duration",G),M=V.viewer_time}P.data.view_watch_time>=0&&P.data.view_rebuffer_count>0&&(P.data.view_rebuffer_frequency=P.data.view_rebuffer_count/P.data.view_watch_time,P.data.view_rebuffer_percentage=P.data.view_rebuffer_duration/P.data.view_watch_time)};P.on("playbackheartbeat",function(V,G){return K(G)}),P.on("rebufferstart",function(V,G){M||(t(P.data,"view_rebuffer_count",1),M=G.viewer_time,P.one("rebufferend",N))}),P.on("viewinit",function(){M=void 0,P.off("rebufferend",N)})}});function Be(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var be=function(){function F(K){var V=this;(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.disableRebufferTracking||K.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,K.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),K.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),K.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var P,M,N;return P=F,M=[{key:"_checkIfRebuffering",value:function(K,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(K,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var G=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&G>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(K,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(K){this._lastCheckedTime=K,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=K}},{key:"_cleanupRebufferTracker",value:function(K,V){var G=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var X=this.pm.data.player_playhead_time-this._lastPlayheadTime,J=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&X>0&&J-X>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+J-X}))}G?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],M&&Be(P.prototype,M),N&&Be(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}(),Ge=be;function He(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Qe=function(){function F(K){var V=this;(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.on("viewinit",function(){var G=K.data,X=G.view_id;if(!G.view_program_changed){var J=function(Q,Z){var ce=Z.viewer_time;Q.type==="playing"&&K.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(ce||h.now(),X):Q.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||h.now(),X)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var P,M,N;return P=F,(M=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(K,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:K}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&He(P.prototype,M),N&&He(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function Ue(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function it(F,P,M){return P&&Ue(F.prototype,P),M&&Ue(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var we=it(function F(P){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),P.on("viewinit",function(){M._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){P.on(N,function(){if(M._lastPlayheadPosition>=0&&P.data.player_playhead_time>=0&&M._lastPlayerWidth>=0&&M._lastSourceWidth>0&&M._lastPlayerHeight>=0&&M._lastSourceHeight>0){var K=P.data.player_playhead_time-M._lastPlayheadPosition;if(K<0)return void(M._lastPlayheadPosition=-1);var V=Math.min(M._lastPlayerWidth/M._lastSourceWidth,M._lastPlayerHeight/M._lastSourceHeight),G=Math.max(0,V-1),X=Math.max(0,1-V);P.data.view_max_upscale_percentage=Math.max(P.data.view_max_upscale_percentage||0,G),P.data.view_max_downscale_percentage=Math.max(P.data.view_max_downscale_percentage||0,X),t(P.data,"view_total_content_playback_time",K),t(P.data,"view_total_upscaling",G*K),t(P.data,"view_total_downscaling",X*K)}M._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){P.on(N,function(){M._lastPlayheadPosition=P.data.player_playhead_time,M._lastPlayerWidth=P.data.player_width,M._lastPlayerHeight=P.data.player_height,M._lastSourceWidth=P.data.video_source_width,M._lastSourceHeight=P.data.video_source_height})})});function nt(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Oe(F,P,M){return P&&nt(F.prototype,P),M&&nt(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ce=Oe(function F(P){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),this.isSeeking=!1,P.on("seeking",function(N,K){i()(P.data,K),M._lastSeekingTime=h.now(),M.isSeeking===!1&&(M.isSeeking=!0,P.send("seeking"))}),P.on("seeked",function(){M.isSeeking=!1;var N=M._lastSeekingTime||h.now(),K=h.now()-N;t(P.data,"view_seek_count",1),t(P.data,"view_seek_duration",K);var V=P.data.view_max_seek_time||0;P.data.view_max_seek_time=Math.max(V,K)}),P.on("viewend",function(){M.isSeeking=!1})});function Ye(F,P){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,X=[],J=!0,Q=!1;try{for(K=K.call(M);!(J=(V=K.next()).done)&&(X.push(V.value),!N||X.length!==N);J=!0);}catch(Z){Q=!0,G=Z}finally{try{J||K.return==null||K.return()}finally{if(Q)throw G}}return X}}(F,P)||function(M,N){if(M){if(typeof M=="string")return Re(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Re(M,N):void 0}}(F,P)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Re(F,P){(P==null||P>F.length)&&(P=F.length);for(var M=0,N=new Array(P);M<P;M++)N[M]=F[M];return N}function Le(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var at=function(F,P){F.push(P),F.sort(function(M,N){return M.viewer_time-N.viewer_time})},ze=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],pt=function(){function F(K){var V=this;(function(X,J){if(!(X instanceof J))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),ze.forEach(function(X){return K.on(X,V._updateAdData.bind(V))});var G=function(){V.isAdBreak=!1};K.on("adbreakstart",function(){V.isAdBreak=!0}),K.on("play",G),K.on("playing",G),K.on("viewend",G),K.on("adrequest",function(X,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},J),at(V._adRequests,J),t(K.data,"view_ad_request_count"),V.inPrerollPosition()&&(K.data.view_preroll_requested=!0,V._adHasPlayed||t(K.data,"view_preroll_request_count"))}),K.on("adresponse",function(X,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},J),at(V._adResponses,J);var Q=V.findAdRequest(J.ad_request_id);Q&&t(K.data,"view_ad_request_time",Math.max(0,J.viewer_time-Q.viewer_time))}),K.on("adplay",function(X,J){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(K.data,"view_ad_played_count")),V.inPrerollPosition()&&!K.data.view_preroll_played&&(K.data.view_preroll_played=!0,V._adRequests.length>0&&(K.data.view_preroll_request_time=Math.max(0,J.viewer_time-V._adRequests[0].viewer_time)),K.data.view_start&&(K.data.view_startup_preroll_request_time=Math.max(0,J.viewer_time-K.data.view_start)),V._prerollPlayTime=J.viewer_time)}),K.on("adplaying",function(X,J){V.inPrerollPosition()&&K.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(K.data.view_preroll_load_time=J.viewer_time-V._prerollPlayTime,K.data.view_startup_preroll_load_time=J.viewer_time-V._prerollPlayTime)}),K.on("adended",function(){V._wouldBeNewAdPlay=!0}),K.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var P,M,N;return P=F,(M=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(K){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===K)return this._adRequests[V]}},{key:"_updateAdData",value:function(K,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var G=Ye(o(V.ad_tag_url),2),X=G[0],J=G[1];this.pm.data.view_preroll_ad_tag_domain=J,this.pm.data.view_preroll_ad_tag_hostname=X}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var Q=Ye(o(V.ad_asset_url),2),Z=Q[0],ce=Q[1];this.pm.data.view_preroll_ad_asset_domain=ce,this.pm.data.view_preroll_ad_asset_hostname=Z}}}}])&&Le(P.prototype,M),N&&Le(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function xt(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function tt(F,P,M){return P&&xt(F.prototype,P),M&&xt(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ut=tt(function F(P){var M,N;(function(X,J){if(!(X instanceof J))throw new TypeError("Cannot call a class as a function")})(this,F);var K=function(){P.disableRebufferTracking||M&&(t(P.data,"view_waiting_rebuffer_duration",h.now()-M),M=!1,_().clearInterval(N))},V=!1,G=function(){V=!1,K()};P.on("waiting",function(){V&&(P.disableRebufferTracking||(t(P.data,"view_waiting_rebuffer_count",1),M=h.now(),N=_().setInterval(function(){if(M){var X=h.now();t(P.data,"view_waiting_rebuffer_duration",X-M),M=X}},250)))}),P.on("playing",function(){K(),V=!0}),P.on("pause",G),P.on("seeking",G)});function St(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ct(F,P,M){return P&&St(F.prototype,P),M&&St(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Et=ct(function F(P){var M=this;(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F);var N=function(){M.lastWallClockTime=h.now(),P.on("before*",K)},K=function(V){var G=h.now(),X=M.lastWallClockTime;M.lastWallClockTime=G,G-X>3e4&&(P.emit("devicesleep",{viewer_time:X}),i()(P.data,{viewer_time:X}),P.send("devicesleep"),P.emit("devicewake",{viewer_time:G}),i()(P.data,{viewer_time:G}),P.send("devicewake"))};P.one("playbackheartbeat",N),P.on("playbackheartbeatend",function(){P.off("before*",K),P.one("playbackheartbeat",N)})}),ut=O(375),Ot=O(655),yt=O.n(Ot),tr="muxData",Nt=function(){var F;try{F=ut.parse(yt().get(tr)||"")}catch{F={}}return F},Rt=function(F){try{yt().set(tr,ut.stringify(F),{expires:7300})}catch{}},rt=function(){var F=Nt();return F.mux_viewer_id=F.mux_viewer_id||y(),F.msn=F.msn||Math.random(),Rt(F),{mux_viewer_id:F.mux_viewer_id,mux_sample_number:F.msn}};function rr(F,P){var M=P.beaconCollectionDomain,N=P.beaconDomain;if(M)return"https://"+M;var K=N||"litix.io";return(F=F||"inferred").match(/^[a-z0-9]+$/)?"https://"+F+"."+K:"https://img.litix.io/a.gif"}var Kt=function(){var F;switch(ir()){case"cellular":F="cellular";break;case"ethernet":F="wired";break;case"wifi":F="wifi";break;case void 0:break;default:F="other"}return F},ir=function(){var F=_().navigator,P=F&&(F.connection||F.mozConnection||F.webkitConnection);return P&&P.type};Kt.getConnectionFromAPI=ir;var mr=Kt,pr=ar({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),nr=ar({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function ar(F){var P={};for(var M in F)F.hasOwnProperty(M)&&(P[F[M]]=M);return P}function Dt(F){var P={},M={};return Object.keys(F).forEach(function(N){var K=!1;if(F.hasOwnProperty(N)&&F[N]!==void 0){var V=N.split("_"),G=V[0],X=pr[G];X||(e.info("Data key word `"+V[0]+"` not expected in "+N),X=G+"_"),V.splice(1).forEach(function(J){J==="url"&&(K=!0),nr[J]?X+=nr[J]:Number(J)&&Math.floor(Number(J))===Number(J)?X+=J:(e.info("Data key word `"+J+"` not expected in "+N),X+="_"+J+"_")}),K?M[X]=F[N]:P[X]=F[N]}}),i()(P,M)}var sr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Er=["hb","requestcompleted","requestfailed","requestcanceled"],yr="https://img.litix.io",Tt=function(F){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=F||yr,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},sr,P)};Tt.prototype.queueEvent=function(F,P){var M=i()({},P);return(this._eventQueue.length<=this._options.maxQueueLength||F==="eventrateexceeded")&&(this._eventQueue.push(M),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Tt.prototype.flushEvents=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];F&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Tt.prototype.destroy=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,F?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},Tt.prototype._clearBeaconQueue=function(){var F=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,P=this._eventQueue.slice(F);F>0&&i()(P[P.length-1],Dt({mux_view_message:"event queue truncated"}));var M=this._createPayload(P);jr(this._beaconUrl,M,!0,function(){})},Tt.prototype._sendBeaconQueue=function(){var F=this;if(!this._postInFlight){var P=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var M=this._createPayload(P),N=h.now();jr(this._beaconUrl,M,!1,function(K,V){V?(F._eventQueue=P.concat(F._eventQueue),F._failureCount+=1,e.info("Error sending beacon: "+V)):F._failureCount=0,F._roundTripTime=h.now()-N,F._postInFlight=!1})}},Tt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var F=Math.pow(2,this._failureCount-1);return(1+(F*=Math.random()))*this._options.baseTimeBetweenBeacons},Tt.prototype._startBeaconSending=function(){var F=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){F._eventQueue.length&&F._sendBeaconQueue(),F._startBeaconSending()},this._getNextBeaconTime()))},Tt.prototype._createPayload=function(F){var P,M,N,K=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var G=function(){P=JSON.stringify({metadata:V,events:M||F}),N=P.length/1024},X=function(){return N<=K._options.maxPayloadKBSize};return G(),X()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),M=F.filter(function(J){return Er.indexOf(J.e)===-1}),G()),X()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),M.forEach(function(J){for(var Q in J){var Z=J[Q];typeof Z=="string"&&Z.length>51200&&(J[Q]=Z.substring(0,51200))}}),G()),P};var jr=function(F,P,M,N){if(M&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(F,P))N();else if(_().fetch)_().fetch(F,{method:"POST",body:P,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var K=new(_()).XMLHttpRequest;return K.onreadystatechange=function(){if(K.readyState===4)return N(null,K.status!==200?"error":void 0)},K.open("POST",F),K.setRequestHeader("Content-Type","text/plain"),void K.send(P)}N()}},Li=Tt;function _i(F,P){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,X=[],J=!0,Q=!1;try{for(K=K.call(M);!(J=(V=K.next()).done)&&(X.push(V.value),!N||X.length!==N);J=!0);}catch(Z){Q=!0,G=Z}finally{try{J||K.return==null||K.return()}finally{if(Q)throw G}}return X}}(F,P)||function(M,N){if(M){if(typeof M=="string")return Wr(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Wr(M,N):void 0}}(F,P)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Wr(F,P){(P==null||P>F.length)&&(P=F.length);for(var M=0,N=new Array(P);M<P;M++)N[M]=F[M];return N}function Gr(F,P){var M=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);P&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(F,K).enumerable})),M.push.apply(M,N)}return M}function It(F){for(var P=1;P<arguments.length;P++){var M=arguments[P]!=null?arguments[P]:{};P%2?Gr(Object(M),!0).forEach(function(N){or(F,N,M[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(M)):Gr(Object(M)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(M,N))})}return F}function jt(F){return jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(P){return typeof P}:function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},jt(F)}function bi(F,P){if(!(F instanceof P))throw new TypeError("Cannot call a class as a function")}function Hr(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function or(F,P,M){return P in F?Object.defineProperty(F,P,{value:M,enumerable:!0,configurable:!0,writable:!0}):F[P]=M,F}var Oi=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],Ri=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],Ii=["viewstart","error","ended","viewend"],Pi=function(){function F(K,V){var G,X,J,Q,Z,ce,oe,fe,se,de,Se,Ne,Ke,$e,Ee,je=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};bi(this,F),or(this,"previousBeaconData",null),or(this,"lastEventTime",0),or(this,"rateLimited",!1),this.mux=K,this.envKey=V,this.options=je,this.eventQueue=new Li(rr(this.envKey,this.options)),this.sampleRate=(G=this.options.sampleRate)!==null&&G!==void 0?G:1,this.disableCookies=(X=this.options.disableCookies)!==null&&X!==void 0&&X,this.respectDoNotTrack=(J=this.options.respectDoNotTrack)!==null&&J!==void 0&&J,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(Q=this.options.platform)===null||Q===void 0?void 0:Q.name,viewer_application_version:(Z=this.options.platform)===null||Z===void 0?void 0:Z.version,viewer_application_engine:(ce=this.options.platform)===null||ce===void 0?void 0:ce.layout,viewer_device_name:(oe=this.options.platform)===null||oe===void 0?void 0:oe.product,viewer_device_category:"",viewer_device_manufacturer:(fe=this.options.platform)===null||fe===void 0?void 0:fe.manufacturer,viewer_os_family:(se=this.options.platform)===null||se===void 0||(de=se.os)===null||de===void 0?void 0:de.family,viewer_os_architecture:(Se=this.options.platform)===null||Se===void 0||(Ne=Se.os)===null||Ne===void 0?void 0:Ne.architecture,viewer_os_version:(Ke=this.options.platform)===null||Ke===void 0||($e=Ke.os)===null||$e===void 0?void 0:$e.version,viewer_connection_type:mr(),page_url:_()===null||_()===void 0||(Ee=_().location)===null||Ee===void 0?void 0:Ee.href},this.viewerData=this.disableCookies?{}:rt()}var P,M,N;return P=F,(M=[{key:"send",value:function(K,V){var G;if(K){if(this.respectDoNotTrack&&s())return e.info("Not sending `"+K+"` because Do Not Track is enabled");if(!V||jt(V)!=="object")return e.error("A data object was expected in send() but was not provided");var X,J,Q=this.disableCookies?{}:(X=Nt(),J=h.now(),X.session_start&&(X.sst=X.session_start,delete X.session_start),X.session_id&&(X.sid=X.session_id,delete X.session_id),X.session_expires&&(X.sex=X.session_expires,delete X.session_expires),(!X.sex||X.sex<J)&&(X.sid=y(),X.sst=J),X.sex=J+15e5,Rt(X),{session_id:X.sid,session_start:X.sst,session_expires:X.sex}),Z=It(It(It(It(It({},this.pageLevelData),V),Q),this.viewerData),{},{event:K,env_key:this.envKey});Z.user_id&&(Z.viewer_user_id=Z.user_id,delete Z.user_id);var ce=((G=Z.mux_sample_number)!==null&&G!==void 0?G:0)>=this.sampleRate,oe=Dt(this._deduplicateBeaconData(K,Z));if(this.lastEventTime=this.mux.utils.now(),ce)return e.info("Not sending event due to sample rate restriction",K,Z,oe);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",K,Z,oe),!this.rateLimited){if(e.info("Sending event",K,Z,oe),this.rateLimited=!this.eventQueue.queueEvent(K,oe),this.mux.WINDOW_UNLOADING&&K==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&K==="hb"?this.eventQueue.flushEvents(!0):Ii.indexOf(K)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Z.event="eventrateexceeded",oe=Dt(Z),this.eventQueue.queueEvent(Z.event,oe),e.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(K,V){var G=this,X={},J=V.view_id;if(!J||K==="viewstart"||K==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)X=It({},V),J&&(this.previousBeaconData=X),J&&K==="viewend"&&(this.previousBeaconData=null);else{var Q=K.indexOf("request")===0;Object.entries(V).forEach(function(Z){var ce=_i(Z,2),oe=ce[0],fe=ce[1];G.previousBeaconData&&(fe!==G.previousBeaconData[oe]||Oi.indexOf(oe)>-1||G.objectHasChanged(Q,oe,fe,G.previousBeaconData[oe])||G.eventRequiresKey(K,oe))&&(X[oe]=fe,G.previousBeaconData[oe]=fe)})}return X}},{key:"objectHasChanged",value:function(K,V,G,X){return!(!K||V.indexOf("request_")!==0||V!=="request_response_headers"&&jt(G)==="object"&&jt(X)==="object"&&Object.keys(G||{}).length===Object.keys(X||{}).length)}},{key:"eventRequiresKey",value:function(K,V){return K==="renditionchange"&&V.indexOf("video_source_")===0||!(V.indexOf("ad_")!==0||!Ri.includes(K))}}])&&Hr(P.prototype,M),N&&Hr(P,N),Object.defineProperty(P,"prototype",{writable:!1}),F}();function Vr(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Ci(F,P,M){return P&&Vr(F.prototype,P),M&&Vr(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Mi=Ci(function F(P){(function(Q,Z){if(!(Q instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F);var M=0,N=0,K=0,V=0,G=0,X=0,J=0;P.on("requestcompleted",function(Q,Z){var ce,oe,fe=Z.request_start,se=Z.request_response_start,de=Z.request_response_end,Se=Z.request_bytes_loaded;if(V++,se?(ce=se-fe,oe=de-se):oe=de-fe,oe>0&&Se>0){var Ne=Se/oe*8e3;G++,N+=Se,K+=oe,P.data.view_min_request_throughput=Math.min(P.data.view_min_request_throughput||1/0,Ne),P.data.view_average_request_throughput=N/K*8e3,P.data.view_request_count=V,ce>0&&(M+=ce,P.data.view_max_request_latency=Math.max(P.data.view_max_request_latency||0,ce),P.data.view_average_request_latency=M/G)}}),P.on("requestfailed",function(Q,Z){V++,X++,P.data.view_request_count=V,P.data.view_request_failed_count=X}),P.on("requestcanceled",function(Q,Z){V++,J++,P.data.view_request_count=V,P.data.view_request_canceled_count=J})});function Yr(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function wi(F,P,M){return P&&Yr(F.prototype,P),M&&Yr(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Fi=wi(function F(P){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),P.on("before*",function(N,K){var V=K.viewer_time,G=h.now(),X=M._lastEventTime;if(M._lastEventTime=G,X&&G-X>36e5){var J=Object.keys(P.data).reduce(function(Q,Z){return Z.indexOf("video_")===0?i()(Q,function(ce,oe,fe){return oe in ce?Object.defineProperty(ce,oe,{value:fe,enumerable:!0,configurable:!0,writable:!0}):ce[oe]=fe,ce}({},Z,P.data[Z])):Q},{});P.mux.log.info("Received event after at least an hour inactivity, creating a new view"),P.emit("viewinit",i()({viewer_time:V},J)),P.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(P.emit("play",{viewer_time:V}),N.type!=="playing"&&P.emit("playing",{viewer_time:V}))}})});function Tr(F){return Tr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(P){return typeof P}:function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},Tr(F)}function ki(F,P){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,X=[],J=!0,Q=!1;try{for(K=K.call(M);!(J=(V=K.next()).done)&&(X.push(V.value),!N||X.length!==N);J=!0);}catch(Z){Q=!0,G=Z}finally{try{J||K.return==null||K.return()}finally{if(Q)throw G}}return X}}(F,P)||function(M,N){if(M){if(typeof M=="string")return zr(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?zr(M,N):void 0}}(F,P)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function zr(F,P){(P==null||P>F.length)&&(P=F.length);for(var M=0,N=new Array(P);M<P;M++)N[M]=F[M];return N}function Xr(F,P){for(var M=0;M<P.length;M++){var N=P[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function xr(F,P){return xr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(M,N){return M.__proto__=N,M},xr(F,P)}function Bi(F){var P=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var M,N=lr(F);if(P){var K=lr(this).constructor;M=Reflect.construct(N,arguments,K)}else M=N.apply(this,arguments);return Ui(this,M)}}function Ui(F,P){if(P&&(Tr(P)==="object"||typeof P=="function"))return P;if(P!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fe(F)}function Fe(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}function lr(F){return lr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(P){return P.__proto__||Object.getPrototypeOf(P)},lr(F)}var Ni=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Ki=function(F){(function(G,X){if(typeof X!="function"&&X!==null)throw new TypeError("Super expression must either be null or a function");G.prototype=Object.create(X&&X.prototype,{constructor:{value:G,writable:!0,configurable:!0}}),Object.defineProperty(G,"prototype",{writable:!1}),X&&xr(G,X)})(V,F);var P,M,N,K=Bi(V);function V(G,X,J){var Q;(function(se,de){if(!(se instanceof de))throw new TypeError("Cannot call a class as a function")})(this,V),(Q=K.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),Q.NAVIGATION_START=c.navigationStart(),Q.mux=G,Q.id=X,(J=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},J)).data=J.data||{},J.data.property_key&&(J.data.env_key=J.data.property_key,delete J.data.property_key),e.setLevel(J.debug?"debug":"warn"),Q.getPlayheadTime=J.getPlayheadTime,Q.getStateData=J.getStateData||function(){return{}},Q.getAdData=J.getAdData||function(){},Q.minimumRebufferDuration=J.minimumRebufferDuration,Q.sustainedRebufferThreshold=J.sustainedRebufferThreshold,Q.playbackHeartbeatTime=J.playbackHeartbeatTime,Q.disableRebufferTracking=J.disableRebufferTracking,Q.disableRebufferTracking&&Q.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Q.disablePlayheadRebufferTracking=J.disablePlayheadRebufferTracking,Q.errorTranslator=J.errorTranslator,Q.playbackEventDispatcher=new Pi(G,J.data.env_key,J),Q.data={player_instance_id:y(),mux_sample_rate:J.sampleRate,beacon_domain:J.beaconCollectionDomain?J.beaconCollectionDomain:J.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(se,de){de=i()({viewer_time:this.mux.utils.now()},de),this.oldEmit(se,de)};var Z=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Fe(Q));Q.on("viewinit",function(se,de){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,de),this._initializeViewData(),this.one("play",Z),this.one("adbreakstart",Z)});var ce=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(Fe(Q));if(Q.on("videochange",function(se,de){ce(de)}),Q.on("programchange",function(se,de){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),ce(i()(de,{view_program_changed:!0})),Z(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(se,de){this.currentFragmentPDT=de.currentFragmentPDT,this.currentFragmentStart=de.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var oe=function(){var se=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",oe,!1);var fe=function(se){se.persisted||Q.destroy()};window.addEventListener("pagehide",fe,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",fe)})}return Q.on("playerready",function(se,de){i()(this.data,de)}),Ni.forEach(function(se){Q.on(se,function(de,Se){se.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,Se),this._sanitizeData()}),Q.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),Q.on("viewend",function(se,de){i()(Q.data,de)}),Q.one("playerready",function(se){var de=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=de-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Q.longResumeTracker=new Fi(Fe(Q)),Q.errorTracker=new he(Fe(Q)),new Et(Fe(Q)),Q.seekingTracker=new Ce(Fe(Q)),Q.playheadTime=new Me(Fe(Q)),Q.playbackHeartbeat=new ae(Fe(Q)),new we(Fe(Q)),Q.watchTimeTracker=new ie(Fe(Q)),new pe(Fe(Q)),Q.adTracker=new pt(Fe(Q)),new Ge(Fe(Q)),new Ie(Fe(Q)),new Qe(Fe(Q)),new Ut(Fe(Q)),new Mi(Fe(Q)),J.hlsjs&&Q.addHLSJS(J),J.dashjs&&Q.addDashJS(J),Q.emit("viewinit",J.data),Q}return P=V,M=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(G){var X=i()({},this.data);if(X.video_source_is_live===void 0&&(X.player_source_duration===1/0||X.video_source_duration===1/0?X.video_source_is_live=!0:(X.player_source_duration>0||X.video_source_duration>0)&&(X.video_source_is_live=!1)),X.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(ce){X[ce]=void 0}),X.video_source_url=X.video_source_url||X.player_source_url,X.video_source_url){var J=ki(o(X.video_source_url),2),Q=J[0],Z=J[1];X.video_source_domain=Z,X.video_source_hostname=Q}delete X.ad_request_id,this.playbackEventDispatcher.send(G,X),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){i()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var G=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(X){var J=parseInt(G.data[X],10);G.data[X]=isNaN(J)?void 0:J}),["player_source_url","video_source_url"].forEach(function(X){if(G.data[X]){var J=G.data[X].toLowerCase();J.indexOf("data:")!==0&&J.indexOf("blob:")!==0||(G.data[X]="MSE style URL")}})}},{key:"_resetVideoData",value:function(G,X){var J=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete J.data[Q]})}},{key:"_resetViewData",value:function(){var G=this;Object.keys(this.data).forEach(function(X){X.indexOf("view_")===0&&delete G.data[X]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(G,X){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var G=this,X=this.data.view_id=y(),J=function(){X===G.data.view_id&&t(G.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",J):J()}},{key:"_restartHeartBeat",value:function(){var G=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){G.data.player_is_paused||G.emit("hb")},1e4))}},{key:"addHLSJS",value:function(G){G.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=G.hlsjs,function(X,J,Q){var Z=arguments.length>4?arguments[4]:void 0,ce=X.log,oe=X.utils.secondsToMs,fe=function(ye){var ue,ge=parseInt(Z.version);return ge===1&&ye.programDateTime!==null&&(ue=ye.programDateTime),ge===0&&ye.pdt!==null&&(ue=ye.pdt),ue};if(c.exists()){var se=function(ye,ue){return X.emit(J,ye,ue)},de=function(ye,ue){var ge=ue.levels,le=ue.audioTracks,me=ue.url,_e=ue.stats,Pe=ue.networkDetails,Je=ue.sessionData,Xe={},ot={};ge.forEach(function(vt,Ht){Xe[Ht]={width:vt.width,height:vt.height,bitrate:vt.bitrate,attrs:vt.attrs}}),le.forEach(function(vt,Ht){ot[Ht]={name:vt.name,language:vt.lang,bitrate:vt.bitrate}});var Ze=T(_e),ht=Ze.bytesLoaded,ke=Ze.requestStart,lt=Ze.responseStart,Lr=Ze.responseEnd;se("requestcompleted",v(v({},a(Je)),{},{request_event_type:ye,request_bytes_loaded:ht,request_start:ke,request_response_start:lt,request_response_end:Lr,request_type:"manifest",request_hostname:r(me),request_response_headers:I(Pe),request_rendition_lists:{media:Xe,audio:ot,video:{}}}))};Q.on(Z.Events.MANIFEST_LOADED,de);var Se=function(ye,ue){var ge=ue.details,le=ue.level,me=ue.networkDetails,_e=ue.stats,Pe=T(_e),Je=Pe.bytesLoaded,Xe=Pe.requestStart,ot=Pe.responseStart,Ze=Pe.responseEnd,ht=ge.fragments[ge.fragments.length-1],ke=fe(ht)+oe(ht.duration);se("requestcompleted",{request_event_type:ye,request_bytes_loaded:Je,request_start:Xe,request_response_start:ot,request_response_end:Ze,request_current_level:le,request_type:"manifest",request_hostname:r(ge.url),request_response_headers:I(me),video_holdback:ge.holdBack&&oe(ge.holdBack),video_part_holdback:ge.partHoldBack&&oe(ge.partHoldBack),video_part_target_duration:ge.partTarget&&oe(ge.partTarget),video_target_duration:ge.targetduration&&oe(ge.targetduration),video_source_is_live:ge.live,player_manifest_newest_program_time:isNaN(ke)?void 0:ke})};Q.on(Z.Events.LEVEL_LOADED,Se);var Ne=function(ye,ue){var ge=ue.details,le=ue.networkDetails,me=ue.stats,_e=T(me),Pe=_e.bytesLoaded,Je=_e.requestStart,Xe=_e.responseStart,ot=_e.responseEnd;se("requestcompleted",{request_event_type:ye,request_bytes_loaded:Pe,request_start:Je,request_response_start:Xe,request_response_end:ot,request_type:"manifest",request_hostname:r(ge.url),request_response_headers:I(le)})};Q.on(Z.Events.AUDIO_TRACK_LOADED,Ne);var Ke=function(ye,ue){var ge=ue.stats,le=ue.networkDetails,me=ue.frag;ge=ge||me.stats;var _e=T(ge),Pe=_e.bytesLoaded,Je=_e.requestStart,Xe=_e.responseStart,ot=_e.responseEnd,Ze=I(le),ht=Ze==null?void 0:Ze["x-request-id"],ke={request_event_type:ye,request_bytes_loaded:Pe,request_start:Je,request_response_start:Xe,request_response_end:ot,request_hostname:le?r(le.responseURL):void 0,request_id:ht,request_response_headers:Ze,request_media_duration:me.duration,request_url:le==null?void 0:le.responseURL};me.type==="main"?(ke.request_type="media",ke.request_current_level=me.level,ke.request_video_width=(Q.levels[me.level]||{}).width,ke.request_video_height=(Q.levels[me.level]||{}).height,ke.request_labeled_bitrate=(Q.levels[me.level]||{}).bitrate):ke.request_type=me.type,se("requestcompleted",ke)};Q.on(Z.Events.FRAG_LOADED,Ke);var $e=function(ye,ue){var ge=ue.frag,le=ge.start,me={currentFragmentPDT:fe(ge),currentFragmentStart:oe(le)};se("fragmentchange",me)};Q.on(Z.Events.FRAG_CHANGED,$e);var Ee=function(ye,ue){var ge=ue.type,le=ue.details,me=ue.response,_e=ue.fatal,Pe=ue.context,Je=ue.frag;if(le===Z.ErrorDetails.MANIFEST_LOAD_ERROR||le===Z.ErrorDetails.MANIFEST_LOAD_TIMEOUT||le===Z.ErrorDetails.FRAG_LOAD_ERROR||le===Z.ErrorDetails.FRAG_LOAD_TIMEOUT||le===Z.ErrorDetails.LEVEL_LOAD_ERROR||le===Z.ErrorDetails.LEVEL_LOAD_TIMEOUT){var Xe=Je&&Je.url||Pe&&Pe.url||"";se("requestfailed",{request_error:le,request_url:Xe,request_hostname:r(Xe),request_type:le===Z.ErrorDetails.FRAG_LOAD_ERROR||le===Z.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:me&&me.code,request_error_text:me&&me.text})}_e&&se("error",{player_error_code:ge,player_error_message:le})};Q.on(Z.Events.ERROR,Ee);var je=function(ye,ue){var ge=ue.frag,le=ge&&ge._url||"";se("requestcanceled",{request_event_type:ye,request_url:le,request_type:"media",request_hostname:r(le)})};Q.on(Z.Events.FRAG_LOAD_EMERGENCY_ABORTED,je);var Ve=function(ye,ue){var ge=ue.level,le=Q.levels[ge];if(le&&le.attrs&&le.attrs.BANDWIDTH){var me,_e=le.attrs.BANDWIDTH,Pe=parseFloat(le.attrs["FRAME-RATE"]);isNaN(Pe)||(me=Pe),_e?se("renditionchange",{video_source_fps:me,video_source_bitrate:_e,video_source_width:le.width,video_source_height:le.height,video_source_rendition_name:le.name,video_source_codec:le==null?void 0:le.videoCodec}):ce.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(Z.Events.LEVEL_SWITCHED,Ve),Q._stopMuxMonitor=function(){Q.off(Z.Events.MANIFEST_LOADED,de),Q.off(Z.Events.LEVEL_LOADED,Se),Q.off(Z.Events.AUDIO_TRACK_LOADED,Ne),Q.off(Z.Events.FRAG_LOADED,Ke),Q.off(Z.Events.FRAG_CHANGED,$e),Q.off(Z.Events.ERROR,Ee),Q.off(Z.Events.FRAG_LOAD_EMERGENCY_ABORTED,je),Q.off(Z.Events.LEVEL_SWITCHED,Ve),Q.off(Z.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(Z.Events.DESTROYING,Q._stopMuxMonitor)}else ce.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,G.hlsjs,{},G.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var G;this.hlsjs&&((G=this.hlsjs)&&typeof G._stopMuxMonitor=="function"&&G._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(G){G.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=G.dashjs,function(X,J,Q){var Z=X.log;if(Q&&Q.on){var ce=function(Ee,je){return X.emit(J,Ee,je)},oe=function(Ee){var je=Ee.type,Ve=(Ee.data||{}).url;ce("requestcompleted",{request_event_type:je,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(Ve),request_url:Ve})};Q.on("manifestLoaded",oe);var fe={},se=function(Ee){var je=Ee.type,Ve=Ee.fragmentModel,ye=(Ee.chunk||{}).mediaInfo||{},ue=ye.type,ge=ye.bitrateList,le={};(ge=ge||[]).forEach(function(ke,lt){le[lt]={},le[lt].width=ke.width,le[lt].height=ke.height,le[lt].bitrate=ke.bandwidth,le[lt].attrs={}}),ue==="video"?fe.video=le:ue==="audio"?fe.audio=le:fe.media=le;var me=W(Ve,Q),_e=me.requestStart,Pe=me.requestResponseStart,Je=me.requestResponseEnd,Xe=me.requestResponseHeaders,ot=me.requestMediaDuration,Ze=me.requestHostname,ht=me.requestUrl;ce("requestcompleted",{request_event_type:je,request_start:_e,request_response_start:Pe,request_response_end:Je,request_bytes_loaded:-1,request_type:ue+"_init",request_response_headers:Xe,request_hostname:Ze,request_url:ht,request_media_duration:ot,request_rendition_lists:fe})};Q.on("initFragmentLoaded",se);var de=function(Ee){var je=Ee.type,Ve=Ee.fragmentModel,ye=Ee.chunk||{},ue=ye.mediaInfo,ge=ye.start,le=(ue||{}).type,me=W(Ve,Q),_e=me.requestStart,Pe=me.requestResponseStart,Je=me.requestResponseEnd,Xe=me.requestBytesLoaded,ot=me.requestResponseHeaders,Ze=me.requestMediaDuration,ht=me.requestHostname,ke=me.requestUrl,lt=H(le,Q),Lr=lt.currentLevel,vt=lt.renditionWidth,Ht=lt.renditionHeight,fn=lt.renditionBitrate;ce("requestcompleted",{request_event_type:je,request_start:_e,request_response_start:Pe,request_response_end:Je,request_bytes_loaded:Xe,request_type:le,request_response_headers:ot,request_hostname:ht,request_url:ke,request_media_start_time:ge,request_media_duration:Ze,request_current_level:Lr,request_labeled_bitrate:fn,request_video_width:vt,request_video_height:Ht})};Q.on("mediaFragmentLoaded",de);var Se={video:void 0,audio:void 0,totalBitrate:void 0},Ne=function(){if(Se.video&&typeof Se.video.bitrate=="number"){if(Se.video.width&&Se.video.height){var Ee=Se.video.bitrate;return Se.audio&&typeof Se.audio.bitrate=="number"&&(Ee+=Se.audio.bitrate),Ee!==Se.totalBitrate?(Se.totalBitrate=Ee,{video_source_bitrate:Ee,video_source_height:Se.video.height,video_source_width:Se.video.width,video_source_codec:z(Se.video.codec)}):void 0}Z.warn("have bitrate info for video but missing width/height")}},Ke=function(Ee,je,Ve){if(typeof Ee.newQuality=="number"){var ye=Ee.mediaType;if(ye==="audio"||ye==="video"){var ue=Q.getBitrateInfoListFor(ye).find(function(le){return le.qualityIndex===Ee.newQuality});if(ue&&typeof ue.bitrate=="number"){Se[ye]=B(B({},ue),{},{codec:Q.getCurrentTrackFor(ye).codec});var ge=Ne();ge&&ce("renditionchange",ge)}else Z.warn("missing bitrate info for ".concat(ye))}}else Z.warn("missing evt.newQuality in qualityChangeRendered event",Ee)};Q.on("qualityChangeRendered",Ke);var $e=function(Ee){var je=Ee.error,Ve=Ee.event,ye=(Ve=Ve||{}).request||{},ue=_().event&&_().event.currentTarget||{};ce("requestfailed",{request_error:je+"_"+Ve.id+"_"+ye.type,request_url:Ve.url,request_hostname:r(Ve.url),request_type:ye.mediaType,request_error_code:ue.status,request_error_type:ue.statusText})};Q.on("error",$e),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",oe),Q.off("initFragmentLoaded",se),Q.off("mediaFragmentLoaded",de),Q.off("qualityChangeRendered",Ke),Q.off("error",$e),delete Q._stopMuxMonitor}}else Z.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,G.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var G;this.dashjs&&((G=this.dashjs)&&typeof G._stopMuxMonitor=="function"&&G._stopMuxMonitor(),this.dashjs=void 0)}}],M&&Xr(P.prototype,M),N&&Xr(P,N),Object.defineProperty(P,"prototype",{writable:!1}),V}(q),ji=Ki,Wi=O(153),Wt=O.n(Wi);function Sr(F){return Sr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(P){return typeof P}:function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},Sr(F)}function Qr(F,P){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,X=[],J=!0,Q=!1;try{for(K=K.call(M);!(J=(V=K.next()).done)&&(X.push(V.value),!N||X.length!==N);J=!0);}catch(Z){Q=!0,G=Z}finally{try{J||K.return==null||K.return()}finally{if(Q)throw G}}return X}}(F,P)||function(M,N){if(M){if(typeof M=="string")return $r(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?$r(M,N):void 0}}(F,P)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function $r(F,P){(P==null||P>F.length)&&(P=F.length);for(var M=0,N=new Array(P);M<P;M++)N[M]=F[M];return N}var Pt,Gi=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Hi={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};_()&&_().WeakMap&&(Pt=new WeakMap);var Vi="#EXT-X-TARGETDURATION",Yi="#EXT-X-PART-INF",zi="#EXT-X-SERVER-CONTROL",Xi="#EXTINF",Qi="#EXT-X-PROGRAM-DATE-TIME",$i="#EXT-X-VERSION",Ji="#EXT-X-SESSION-DATA",ur=function(F){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(F),this.manifest};ur.prototype.process=function(F){var P;for(this.buffer+=F,P=this.buffer.indexOf(`
|
|
6
|
+
`);P>-1;P=this.buffer.indexOf(`
|
|
7
|
+
`))this.processLine(this.buffer.substring(0,P)),this.buffer=this.buffer.substring(P+1)},ur.prototype.processLine=function(F){var P=F.indexOf(":"),M=tn(F,P),N=M[0],K=M.length===2?Ar(M[1]):void 0;if(N[0]!=="#")this.currentUri.uri=N,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(N){case Vi:if(!isFinite(K)||K<0)return;this.manifest.targetDuration=K,this.setHoldBack();break;case Yi:Dr(this.manifest,M),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case zi:Dr(this.manifest,M),this.setHoldBack();break;case Xi:K===0?this.currentUri.duration=.01:K>0&&(this.currentUri.duration=K);break;case Qi:var V=K,G=new Date(V);this.manifest.dateTimeString||(this.manifest.dateTimeString=V,this.manifest.dateTimeObject=G),this.currentUri.dateTimeString=V,this.currentUri.dateTimeObject=G;break;case $i:Dr(this.manifest,M);break;case Ji:var X=rn(M[1]),J=a(X);i()(this.manifest.sessionData,J)}},ur.prototype.setHoldBack=function(){var F=this.manifest,P=F.serverControl,M=F.targetDuration,N=F.partTargetDuration;if(P){var K="holdBack",V="partHoldBack",G=M&&3*M,X=N&&2*N;M&&!P.hasOwnProperty(K)&&(P[K]=G),G&&P[K]<G&&(P[K]=G),N&&!P.hasOwnProperty(V)&&(P[V]=3*N),N&&P[V]<X&&(P[V]=X)}};var Dr=function(F,P){var M,N=Jr(P[0].replace("#EXT-X-",""));en(P[1])?(M={},M=i()(qi(P[1]),M)):M=Ar(P[1]),F[N]=M},Jr=function(F){return F.toLowerCase().replace(/-(\w)/g,function(P){return P[1].toUpperCase()})},Ar=function(F){if(F.toLowerCase()==="yes"||F.toLowerCase()==="no")return F.toLowerCase()==="yes";var P=F.indexOf(":")!==-1?F:parseFloat(F);return isNaN(P)?F:P},Zi=function(F){var P={},M=F.split("=");return M.length>1&&(P[Jr(M[0])]=Ar(M[1])),P},qi=function(F){for(var P=F.split(","),M={},N=0;P.length>N;N++){var K=P[N],V=Zi(K);M=i()(V,M)}return M},en=function(F){return F.indexOf("=")>-1},tn=function(F,P){return P===-1?[F]:[F.substring(0,P),F.substring(P+1)]},rn=function(F){var P={};if(F){var M=F.search(",");return[F.slice(0,M),F.slice(M+1)].forEach(function(N,K){for(var V=N.replace(/['"]+/g,"").split("="),G=0;G<V.length;G++)V[G]==="DATA-ID"&&(P["DATA-ID"]=V[1-G]),V[G]==="VALUE"&&(P.VALUE=V[1-G])}),{data:P}}},nn=ur,an={safeCall:function(F,P,M,N){var K=N;if(F&&typeof F[P]=="function")try{K=F[P].apply(F,M)}catch(V){e.info("safeCall error",V)}return K},safeIncrement:t,getComputedStyle:function(F,P){var M;if(F&&P&&_()&&typeof _().getComputedStyle=="function")return Pt&&Pt.has(F)&&(M=Pt.get(F)),M||(M=_().getComputedStyle(F,null),Pt&&Pt.set(F,M)),M.getPropertyValue(P)},secondsToMs:function(F){return Math.floor(1e3*F)},assign:i(),headersStringToObject:u,extractHostnameAndDomain:o,extractHostname:r,manifestParser:nn,generateShortID:x,generateUUID:y,now:h.now},sn={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};function on(F,P){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,X=[],J=!0,Q=!1;try{for(K=K.call(M);!(J=(V=K.next()).done)&&(X.push(V.value),!N||X.length!==N);J=!0);}catch(Z){Q=!0,G=Z}finally{try{J||K.return==null||K.return()}finally{if(Q)throw G}}return X}}(F,P)||function(M,N){if(M){if(typeof M=="string")return Zr(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Zr(M,N):void 0}}(F,P)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Zr(F,P){(P==null||P>F.length)&&(P=F.length);for(var M=0,N=new Array(P);M<P;M++)N[M]=F[M];return N}var st={},Gt=function F(P){var M=arguments;typeof P=="string"?F.hasOwnProperty(P)?_().setTimeout(function(){M=Array.prototype.splice.call(M,1),F[P].apply(null,M)},0):e.warn("`"+P+"` is an unknown task"):typeof P=="function"?_().setTimeout(function(){P(F)},0):e.warn("`"+P+"` is invalid.")},ln={loaded:h.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(F,P){return function(M,N,K){var V=Qr(E(N),3),G=V[0],X=V[1],J=V[2],Q=M.log,Z=M.utils.getComputedStyle,ce=M.utils.secondsToMs;if(!G)return Q.error("No element was found with the `"+X+"` query selector.");if(J!=="video"&&J!=="audio")return Q.error("The element of `"+X+"` was not a media element.");G.mux&&(G.mux.destroy(),delete G.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(K=i()({automaticErrorTracking:!0},K)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:M.VERSION},K.data),K.getPlayheadTime=function(){return ce(G.currentTime)},K.getStateData=function(){var fe,se,de=this.hlsjs&&this.hlsjs.url,Se=this.dashjs&&Sr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ne={player_is_paused:G.paused,player_playhead_time:ce(G.currentTime),player_width:parseInt(Z(G,"width")),player_height:parseInt(Z(G,"height")),player_autoplay_on:G.autoplay,player_preload_on:G.preload,player_language_code:G.lang,player_is_fullscreen:Wt()&&!!(Wt().fullscreenElement||Wt().webkitFullscreenElement||Wt().mozFullScreenElement||Wt().msFullscreenElement),video_poster_url:G.poster,video_source_url:de||Se||G.currentSrc,video_source_duration:ce(G.duration),video_source_height:G.videoHeight,video_source_width:G.videoWidth,view_dropped_frame_count:(fe=G)===null||fe===void 0||(se=fe.getVideoPlaybackQuality)===null||se===void 0?void 0:se.call(fe).droppedVideoFrames},Ke=K.getPlayheadTime();if(G.getStartDate&&Ke>0){var $e=G.getStartDate();if($e&&typeof $e.getTime=="function"&&$e.getTime()){var Ee=$e.getTime();if(Ne.player_program_time=Ee+Ke,G.seekable.length>0){var je=Ee+G.seekable.end(G.seekable.length-1);Ne.player_live_edge_program_time=je}}}return Ne},G.mux=G.mux||{},G.mux.deleted=!1,G.mux.emit=function(fe,se){M.emit(X,fe,se)};var oe=function(){Q.error("The monitor for this video element has already been destroyed.")};G.mux.destroy=function(){Object.keys(G.mux.listeners).forEach(function(fe){G.removeEventListener(fe,G.mux.listeners[fe],!1)}),delete G.mux.listeners,G.mux.destroy=oe,G.mux.swapElement=oe,G.mux.emit=oe,G.mux.addHLSJS=oe,G.mux.addDashJS=oe,G.mux.removeHLSJS=oe,G.mux.removeDashJS=oe,G.mux.deleted=!0,M.emit(X,"destroy")},G.mux.swapElement=function(fe){var se=Qr(E(fe),3),de=se[0],Se=se[1],Ne=se[2];return de?Ne!=="video"&&Ne!=="audio"?M.log.error("The element of `"+Se+"` was not a media element."):(de.muxId=G.muxId,delete G.muxId,de.mux=de.mux||{},de.mux.listeners=i()({},G.mux.listeners),delete G.mux.listeners,Object.keys(de.mux.listeners).forEach(function(Ke){G.removeEventListener(Ke,de.mux.listeners[Ke],!1),de.addEventListener(Ke,de.mux.listeners[Ke],!1)}),de.mux.swapElement=G.mux.swapElement,de.mux.destroy=G.mux.destroy,delete G.mux,void(G=de)):M.log.error("No element was found with the `"+Se+"` query selector.")},G.mux.addHLSJS=function(fe){M.addHLSJS(X,fe)},G.mux.addDashJS=function(fe){M.addDashJS(X,fe)},G.mux.removeHLSJS=function(){M.removeHLSJS(X)},G.mux.removeDashJS=function(){M.removeDashJS(X)},M.init(X,K),M.emit(X,"playerready"),G.paused||(M.emit(X,"play"),G.readyState>2&&M.emit(X,"playing")),G.mux.listeners={},Gi.forEach(function(fe){(fe!=="error"||K.automaticErrorTracking)&&(G.mux.listeners[fe]=function(){var se={};if(fe==="error"){if(!G.error||G.error.code===1)return;se.player_error_code=G.error.code,se.player_error_message=Hi[G.error.code]||G.error.message}M.emit(X,fe,se)},G.addEventListener(fe,G.mux.listeners[fe],!1))})}(Gt,F,P)},destroyMonitor:function(F){var P=on(E(F),1)[0];P&&P.mux&&typeof P.mux.destroy=="function"?P.mux.destroy():e.error("A video element monitor for `"+F+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(F,P){var M=D(F);st[M]?st[M].addHLSJS(P):e.error("A monitor for `"+M+"` has not been initialized.")},addDashJS:function(F,P){var M=D(F);st[M]?st[M].addDashJS(P):e.error("A monitor for `"+M+"` has not been initialized.")},removeHLSJS:function(F){var P=D(F);st[P]?st[P].removeHLSJS():e.error("A monitor for `"+P+"` has not been initialized.")},removeDashJS:function(F){var P=D(F);st[P]?st[P].removeDashJS():e.error("A monitor for `"+P+"` has not been initialized.")},init:function(F,P){s()&&P&&P.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var M=D(F);st[M]=new ji(Gt,M,P)},emit:function(F,P,M){var N=D(F);st[N]?(st[N].emit(P,M),P==="destroy"&&delete st[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:an,events:sn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Gt,ln),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(F){F.persisted||(Gt.WINDOW_UNLOADING=!0)},!1);var un=Gt},655:function(A,w,O){var b,_;function y(x){return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},y(x);}(function(x){var D=!1;if((_=typeof(b=x)=="function"?b.call(w,O,w,A):b)===void 0||(A.exports=_),D=!0,y(w)==="object"&&(A.exports=x(),D=!0),!D){var E=window.Cookies,m=window.Cookies=x();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var x=function(){for(var D=0,E={};D<arguments.length;D++){var m=arguments[D];for(var p in m)E[p]=m[p]}return E};return function D(E){function m(p,f,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=x({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{s=JSON.stringify(f),/^[\{\[]/.test(s)&&(f=s)}catch{}return f=E.write?E.write(f,p):encodeURIComponent(String(f)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=(p=(p=encodeURIComponent(String(p))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[p,"=",f,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var o=g[r].split("="),c=o.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){s=c;break}p||(s[t]=c)}catch{}}return s}}return m.set=m,m.get=function(p){return m.call(m,p)},m.getJSON=function(){return m.apply({json:!0},[].slice.call(arguments))},m.defaults={},m.remove=function(p,f){m(p,"",x(f,{expires:-1}))},m.withConverter=D,m}(function(){})})},153:function(A,w,O){var b,_=O.g!==void 0?O.g:typeof window!="undefined"?window:{},y=O(558);typeof document!="undefined"?b=document:(b=_["__GLOBAL_DOCUMENT_CACHE@4"])||(b=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),A.exports=b},48:function(A,w,O){var b;b=typeof window!="undefined"?window:O.g!==void 0?O.g:typeof self!="undefined"?self:{},A.exports=b},678:function(A){var w=9007199254740991,O="[object Arguments]",b="[object Function]",_="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function x(S,T,I){switch(I.length){case 0:return S.call(T);case 1:return S.call(T,I[0]);case 2:return S.call(T,I[0],I[1]);case 3:return S.call(T,I[0],I[1],I[2])}return S.apply(T,I)}var D,E,m=Object.prototype,p=m.hasOwnProperty,f=m.toString,e=m.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,T){var I=n(S)||function(W){return function(H){return function(z){return!!z&&typeof z=="object"}(H)&&u(H)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||f.call(W)==O)}(S)?function(W,H){for(var z=-1,Y=Array(W);++z<W;)Y[z]=H(z);return Y}(S.length,String):[],k=I.length,B=!!k;for(var U in S)!T&&!p.call(S,U)||B&&(U=="length"||o(U,k))||I.push(U);return I}function r(S,T,I){var k=S[T];p.call(S,T)&&t(k,I)&&(I!==void 0||T in S)||(S[T]=I)}function o(S,T){return!!(T=T==null?w:T)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<T}function c(S){var T=S&&S.constructor;return S===(typeof T=="function"&&T.prototype||m)}function t(S,T){return S===T||S!=S&&T!=T}var n=Array.isArray;function u(S){return S!=null&&function(T){return typeof T=="number"&&T>-1&&T%1==0&&T<=w}(S.length)&&!function(T){var I=a(T)?f.call(T):"";return I==b||I==_}(S)}function a(S){var T=typeof S;return!!S&&(T=="object"||T=="function")}var d,v=(d=function(S,T){if(g||c(T)||u(T))(function(k,B,U,W){U||(U={});for(var H=-1,z=B.length;++H<z;){var Y=B[H],$=W?W(U[Y],k[Y],Y,U,k):void 0;r(U,Y,$===void 0?k[Y]:$)}})(T,function(k){return u(k)?i(k):function(B){if(!c(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(T),S);else for(var I in T)p.call(T,I)&&r(S,I,T[I])},function(S,T){return T=h(T===void 0?S.length-1:T,0),function(){for(var I=arguments,k=-1,B=h(I.length-T,0),U=Array(B);++k<B;)U[k]=I[T+k];k=-1;for(var W=Array(T+1);++k<T;)W[k]=I[k];return W[T]=U,x(S,this,W)}}(function(S,T){var I=-1,k=T.length,B=k>1?T[k-1]:void 0,U=k>2?T[2]:void 0;for(B=d.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(H,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?u(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],H)}(T[0],T[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++I<k;){var W=T[I];W&&d(S,W,I,B)}return S}));A.exports=v},640:function(A,w,O){var b,_;(function(y,x){"use strict";b=function(){var D=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function f(n,u){var a=n[u];if(typeof a.bind=="function")return a.bind(n);try{return Function.prototype.bind.call(a,n)}catch{return function(){return Function.prototype.apply.apply(a,[n,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(n){return n==="debug"&&(n="log"),typeof console!==E&&(n==="trace"&&m?e:console[n]!==void 0?f(console,n):console.log!==void 0?f(console,"log"):D)}function h(n,u){for(var a=0;a<p.length;a++){var d=p[a];this[d]=a<n?D:this.methodFactory(d,n,u)}this.log=this.debug}function g(n,u,a){return function(){typeof console!==E&&(h.call(this,u,a),this[n].apply(this,arguments))}}function i(n,u,a){return s(n)||g.apply(this,arguments)}function r(n,u,a){var d,v=this;u=u==null?"WARN":u;var S="loglevel";function T(U){var W=(p[U]||"silent").toUpperCase();if(typeof window!==E&&S){try{return void(window.localStorage[S]=W)}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+W+";"}catch{}}}function I(){var U;if(typeof window!==E&&S){try{U=window.localStorage[S]}catch{}if(typeof U===E)try{var W=window.document.cookie,H=W.indexOf(encodeURIComponent(S)+"=");H!==-1&&(U=/^([^;]+)/.exec(W.slice(H))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function k(){if(typeof window!==E&&S){try{return void window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof n=="string"?S+=":"+n:typeof n=="symbol"&&(S=void 0),v.name=n,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=a||i,v.getLevel=function(){return d},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(d=U,W!==!1&&T(U),h.call(v,U,n),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,I()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),k()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var B=I();B==null&&(B=u),v.setLevel(B,!1)}var o=new r,c={};o.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[n];return u||(u=c[n]=new r(n,o.getLevel(),o.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return o.noConflict=function(){return typeof window!==E&&window.log===o&&(window.log=t),o},o.getLoggers=function(){return c},o.default=o,o},(_=typeof b=="function"?b.call(w,O,w,A):b)===void 0||(A.exports=_)})()},375:function(A,w){"use strict";var O=Object.prototype.hasOwnProperty;function b(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}w.stringify=function(y,x){x=x||"";var D,E,m=[];for(E in typeof x!="string"&&(x="?"),y)if(O.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=_(E),D=_(D),E===null||D===null)continue;m.push(E+"="+D)}return m.length?x+m.join("&"):""},w.parse=function(y){for(var x,D=/([^=?#&]+)=?([^&]*)/g,E={};x=D.exec(y);){var m=b(x[1]),p=b(x[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},C={};function L(A){var w=C[A];if(w!==void 0)return w.exports;var O=C[A]={exports:{}};return l[A].call(O.exports,O,O.exports,L),O.exports}return L.n=function(A){var w=A&&A.__esModule?function(){return A.default}:function(){return A};return L.d(w,{a:w}),w},L.d=function(A,w){for(var O in w)L.o(w,O)&&!L.o(A,O)&&Object.defineProperty(A,O,{enumerable:!0,get:w[O]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(A,w){return Object.prototype.hasOwnProperty.call(A,w)},L(80)}()},typeof dr=="object"&&typeof Ir=="object"?Ir.exports=R():typeof dr=="object"?dr.mux=R():j.mux=R()})()});var cr=ei((zt,Pr)=>{typeof window!="undefined"&&function(R,l){typeof zt=="object"&&typeof Pr=="object"?Pr.exports=l():typeof define=="function"&&define.amd?define([],l):typeof zt=="object"?zt.Hls=l():R.Hls=l()}(zt,function(){return function(j){var R={};function l(C){if(R[C])return R[C].exports;var L=R[C]={i:C,l:!1,exports:{}};return j[C].call(L.exports,L,L.exports,l),L.l=!0,L.exports}return l.m=j,l.c=R,l.d=function(C,L,A){l.o(C,L)||Object.defineProperty(C,L,{enumerable:!0,get:A})},l.r=function(C){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(C,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(C,"__esModule",{value:!0})},l.t=function(C,L){if(L&1&&(C=l(C)),L&8||L&4&&typeof C=="object"&&C&&C.__esModule)return C;var A=Object.create(null);if(l.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:C}),L&2&&typeof C!="string")for(var w in C)l.d(A,w,function(O){return C[O]}.bind(null,w));return A},l.n=function(C){var L=C&&C.__esModule?function(){return C.default}:function(){return C};return l.d(L,"a",L),L},l.o=function(C,L){return Object.prototype.hasOwnProperty.call(C,L)},l.p="/dist/",l(l.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,l){"use strict";var C=Object.prototype.hasOwnProperty,L="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(L=!1));function w(y,x,D){this.fn=y,this.context=x,this.once=D||!1}function O(y,x,D,E,m){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new w(D,E||y,m),f=L?L+x:x;return y._events[f]?y._events[f].fn?y._events[f]=[y._events[f],p]:y._events[f].push(p):(y._events[f]=p,y._eventsCount++),y}function b(y,x){--y._eventsCount===0?y._events=new A:delete y._events[x]}function _(){this._events=new A,this._eventsCount=0}_.prototype.eventNames=function(){var x=[],D,E;if(this._eventsCount===0)return x;for(E in D=this._events)C.call(D,E)&&x.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(D)):x},_.prototype.listeners=function(x){var D=L?L+x:x,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,f=new Array(p);m<p;m++)f[m]=E[m].fn;return f},_.prototype.listenerCount=function(x){var D=L?L+x:x,E=this._events[D];return E?E.fn?1:E.length:0},_.prototype.emit=function(x,D,E,m,p,f){var e=L?L+x:x;if(!this._events[e])return!1;var s=this._events[e],h=arguments.length,g,i;if(s.fn){switch(s.once&&this.removeListener(x,s.fn,void 0,!0),h){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,D),!0;case 3:return s.fn.call(s.context,D,E),!0;case 4:return s.fn.call(s.context,D,E,m),!0;case 5:return s.fn.call(s.context,D,E,m,p),!0;case 6:return s.fn.call(s.context,D,E,m,p,f),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];s.fn.apply(s.context,g)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(x,s[i].fn,void 0,!0),h){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,D);break;case 3:s[i].fn.call(s[i].context,D,E);break;case 4:s[i].fn.call(s[i].context,D,E,m);break;default:if(!g)for(o=1,g=new Array(h-1);o<h;o++)g[o-1]=arguments[o];s[i].fn.apply(s[i].context,g)}}return!0},_.prototype.on=function(x,D,E){return O(this,x,D,E,!1)},_.prototype.once=function(x,D,E){return O(this,x,D,E,!0)},_.prototype.removeListener=function(x,D,E,m){var p=L?L+x:x;if(!this._events[p])return this;if(!D)return b(this,p),this;var f=this._events[p];if(f.fn)f.fn===D&&(!m||f.once)&&(!E||f.context===E)&&b(this,p);else{for(var e=0,s=[],h=f.length;e<h;e++)(f[e].fn!==D||m&&!f[e].once||E&&f[e].context!==E)&&s.push(f[e]);s.length?this._events[p]=s.length===1?s[0]:s:b(this,p)}return this},_.prototype.removeAllListeners=function(x){var D;return x?(D=L?L+x:x,this._events[D]&&b(this,D)):(this._events=new A,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,j.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,l){(function(C){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,A=/^(?=([^\/?#]*))\1([^]*)$/,w=/(?:\/|^)\.(?=\/)/g,O=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,b={buildAbsoluteURL:function(_,y,x){if(x=x||{},_=_.trim(),y=y.trim(),!y){if(!x.alwaysNormalize)return _;var D=b.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=b.normalizePath(D.path),b.buildURLFromParts(D)}var E=b.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=b.normalizePath(E.path),b.buildURLFromParts(E)):y;var m=b.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=A.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var f={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(f.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)f.path=m.path,E.params||(f.params=m.params,E.query||(f.query=m.query));else{var e=m.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;f.path=b.normalizePath(s)}return f.path===null&&(f.path=x.alwaysNormalize?b.normalizePath(E.path):E.path),b.buildURLFromParts(f)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(w,"");_.length!==(_=_.replace(O,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};j.exports=b})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,l){function C(x){var D={};function E(p){if(D[p])return D[p].exports;var f=D[p]={i:p,l:!1,exports:{}};return x[p].call(f.exports,f,f.exports,E),f.l=!0,f.exports}E.m=x,E.c=D,E.i=function(p){return p},E.d=function(p,f,e){E.o(p,f)||Object.defineProperty(p,f,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var f=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(f,"a",f),f},E.o=function(p,f){return Object.prototype.hasOwnProperty.call(p,f)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function w(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function O(x){return!isNaN(1*x)}function b(x,D,E){var m={};m[E]=[];var p=D.toString(),f=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!f)return m;for(var e=f[1],s=new RegExp("(\\\\n|\\W)"+w(e)+A,"g"),h;h=s.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(s=new RegExp("\\("+w(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+A,"g");h=s.exec(p);)x[h[2]]||(m[E].push(h[1]),x[h[2]]=l(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)O(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(x){var D=Object.keys(x);return D.reduce(function(E,m){return E||x[m].length>0},!1)}function y(x,D){for(var E={main:[D]},m={main:[]},p={main:{}};_(E);)for(var f=Object.keys(E),e=0;e<f.length;e++){var s=f[e],h=E[s],g=h.pop();if(p[s]=p[s]||{},!(p[s][g]||!x[s][g])){p[s][g]=!0,m[s]=m[s]||[],m[s].push(g);for(var i=b(x,x[s][g],s),r=Object.keys(i),o=0;o<r.length;o++)E[r[o]]=E[r[o]]||[],E[r[o]]=E[r[o]].concat(i[r[o]])}}return m}j.exports=function(x,D){D=D||{};var E={main:l.m},m=D.all?{main:Object.keys(E.main)}:y(E,x),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+C.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
|
|
9
|
+
`}),p=p+"new (("+C.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+m.main.map(function(g){return""+JSON.stringify(g)+": "+E.main[g].toString()}).join(",")+"}))(self);";var f=new window.Blob([p],{type:"text/javascript"});if(D.bare)return f;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(f),h=new window.Worker(s);return h.objectURL=s,h}},"./src/config.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"hlsDefaultConfig",function(){return o}),l.d(R,"mergeConfig",function(){return t}),l.d(R,"enableStreamingMode",function(){return n});var C=l("./src/controller/abr-controller.ts"),L=l("./src/controller/audio-stream-controller.ts"),A=l("./src/controller/audio-track-controller.ts"),w=l("./src/controller/subtitle-stream-controller.ts"),O=l("./src/controller/subtitle-track-controller.ts"),b=l("./src/controller/buffer-controller.ts"),_=l("./src/controller/timeline-controller.ts"),y=l("./src/controller/cap-level-controller.ts"),x=l("./src/controller/fps-controller.ts"),D=l("./src/controller/eme-controller.ts"),E=l("./src/controller/cmcd-controller.ts"),m=l("./src/utils/xhr-loader.ts"),p=l("./src/utils/fetch-loader.ts"),f=l("./src/utils/cues.ts"),e=l("./src/utils/mediakeys-helper.ts"),s=l("./src/utils/logger.ts");function h(){return h=Object.assign?Object.assign.bind():function(u){for(var a=1;a<arguments.length;a++){var d=arguments[a];for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&(u[v]=d[v])}return u},h.apply(this,arguments)}function g(u,a){var d=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),d.push.apply(d,v)}return d}function i(u){for(var a=1;a<arguments.length;a++){var d=arguments[a]!=null?arguments[a]:{};a%2?g(Object(d),!0).forEach(function(v){r(u,v,d[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)):g(Object(d)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(d,v))})}return u}function r(u,a,d){return a in u?Object.defineProperty(u,a,{value:d,enumerable:!0,configurable:!0,writable:!0}):u[a]=d,u}var o=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:m.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:C.default,bufferController:b.default,capLevelController:y.default,fpsController:x.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:w.SubtitleStreamController,subtitleTrackController:O.default,timelineController:_.TimelineController,audioStreamController:L.default,audioTrackController:A.default,emeController:D.default,cmcdController:E.default});function c(){return{cueHandler:f.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function t(u,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,a)}function n(u){var a=u.loader;if(a!==p.default&&a!==m.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var d=Object(p.fetchSupported)();d&&(u.loader=p.default,u.progressive=!0,u.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/utils/ewma-bandwidth-estimator.ts"),A=l("./src/events.ts"),w=l("./src/utils/buffer-helper.ts"),O=l("./src/errors.ts"),b=l("./src/types/loader.ts"),_=l("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function x(E,m,p){return m&&y(E.prototype,m),p&&y(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var D=function(){function E(p){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=p;var f=p.config;this.bwEstimator=new L.default(f.abrEwmaSlowVoD,f.abrEwmaFastVoD,f.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(A.Events.FRAG_LOADING,this.onFragLoading,this),f.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(A.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(A.Events.FRAG_LOADING,this.onFragLoading,this),f.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(A.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},m.onFragLoading=function(f,e){var s=e.frag;if(s.type===b.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=s,this.partCurrent=(h=e.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(f,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},m._abandonRulesCheck=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.autoLevelEnabled,g=s.config,i=s.media;if(!(!f||!i)){var r=e?e.stats:f.stats,o=e?e.duration:f.duration;if(r.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!h||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(c<=500*o/t)){var n=s.levels,u=s.minAutoLevel,a=n[f.level],d=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),v=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/c),S=(d-r.loaded)/v,T=i.currentTime,I=(w.BufferHelper.bufferInfo(i,T,g.maxBufferHole).end-T)/t;if(!(I>=2*o/t||S<=I)){var k=Number.POSITIVE_INFINITY,B;for(B=f.level-1;B>u;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*v),k<I)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+f.sn+(e?" part "+e.index:"")+" of level "+f.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
|
|
10
|
+
Current BW estimate: `+(Object(C.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
|
|
10
11
|
Estimated load time for current fragment: `+S.toFixed(3)+` s
|
|
11
12
|
Estimated load time for the next fragment: `+k.toFixed(3)+` s
|
|
12
|
-
Time to underbuffer: `+I.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),f.loader&&(this.fragCurrent=this.partCurrent=null,f.loader.abort()),s.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:f,part:e,stats:r})}}}}}},m.onFragLoaded=function(f,e){var s=e.frag,h=e.part;if(s.type===b.PlaylistLevelType.MAIN&&Object(P.isFiniteNumber)(s.sn)){var g=h?h.stats:s.stats,i=h?h.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[s.level],o=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:c},r.realBitrate=Math.round(8*o/c)}if(s.bitrateTest){var t={stats:g,frag:s,part:h,id:s.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(f,e){var s=e.frag,h=e.part,g=h?h.stats:s.stats;if(!g.aborted&&!(s.type!==b.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(f,e){switch(e.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.maxAutoLevel,g=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:f?f.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(M.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,a=this.findBestLevel(n,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(a>=0)return a;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=o?Math.min(o,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var T=this.bitrateTestDelay;if(T){var I=o?Math.min(o,g.maxLoadingDelay):g.maxLoadingDelay;d=I-T,_.logger.trace("bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),v=S=1}}return a=this.findBestLevel(n,i,h,u+d,v,S),Math.max(a,0)},m.findBestLevel=function(f,e,s,h,g,i){for(var r,o=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,u=n[t],a=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),d=u==null?void 0:u.codecSet,v=c?c.duration:o?o.duration:0,S=s;S>=e;S--){var T=n[S];if(!(!T||d&&T.codecSet!==d)){var I=T.details,k=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||v,B=void 0;S<=t?B=g*f:B=i*f;var U=n[S].maxBitrate,W=U*k/B;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+h+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<h))return S}}return-1},x(E,[{key:"nextAutoLevel",get:function(){var f=this._nextAutoLevel,e=this.bwEstimator;if(f!==-1&&!e.canEstimate())return f;var s=this.getNextABRAutoLevel();return f!==-1&&this.hls.levels[s].loadError?f:(f!==-1&&(s=Math.min(f,s)),s)},set:function(f){this._nextAutoLevel=f}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/events.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/controller/fragment-tracker.ts"),b=l("./src/types/level.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/chunk-cache.ts"),D=l("./src/demux/transmuxer-interface.ts"),E=l("./src/types/transmuxer.ts"),m=l("./src/controller/fragment-finders.ts"),p=l("./src/utils/discontinuities.ts"),f=l("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var c=arguments[o];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,h(r,o)}function h(r,o){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},h(r,o)}var g=100,i=function(r){s(o,r);function o(t,n){var u;return u=r.call(this,t,n,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=o.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var n=this.hls;n.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(A.Events.ERROR,this.onError,this),n.on(A.Events.BUFFER_RESET,this.onBufferReset,this),n.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var n=this.hls;n.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(A.Events.ERROR,this.onError,this),n.off(A.Events.BUFFER_RESET,this.onBufferReset,this),n.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(n,u){var a=u.frag,d=u.id,v=u.initPTS;if(d==="main"){var S=a.cc;this.initPTS[a.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),n=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var n,u=this.levels,a=this.trackId,d=u==null||(n=u[a])===null||n===void 0?void 0:n.details;if(d){if(this.waitForCdnTuneIn(d))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),T=this.retryDate;(!T||S>=T||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var I=this.waitingData;if(I){var k=I.frag,B=I.part,U=I.cache,W=I.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var G=U.flush(),z={frag:k,part:B,payload:G,networkDetails:null};this._handleFragmentLoadProgress(z),W&&r.prototype._handleFragmentLoadComplete.call(this,z)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+k.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),$=M.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),Z=Object(m.fragmentWithinToleranceTest)($.end,this.config.maxFragLookUpTolerance,k);Z<0&&(this.log("Waiting fragment cc ("+k.cc+") @ "+k.start+" cancelled because another fragment at "+$.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var u=this.mediaBuffer?this.mediaBuffer:n,a=u.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},c.doTickIdle=function(){var n,u,a=this.hls,d=this.levels,v=this.media,S=this.trackId,T=a.config;if(!(!d||!d[S])&&!(!v&&(this.startFragRequested||!T.startFragPrefetch))){var I=d[S],k=I.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=L.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),G=U.len,z=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(G>=z&&!Y)){if(!Y&&this._streamEnded(U,k)){a.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var $=k.fragments,Z=$[0].start,q=U.end;if(Y&&v){var ie=this.getLoadPosition();q=ie,k.PTSKnown&&ie<Z&&(U.end>Z||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=Z+.05)}if(!(W&&q>W.end+k.targetduration)&&!((!W||!W.len)&&U.len)){var ne=this.getNextFragment(q,k);if(!ne){this.bufferFlushed=!0;return}((n=ne.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((u=ne.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ne,k):this.loadFragment(ne,k,q)}}}}},c.getMaxBufferLength=function(n){var u=r.prototype.getMaxBufferLength.call(this);return n?Math.max(u,n):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(n,u){var a=u.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(d){return new b.Level(d)})},c.onAudioTrackSwitching=function(n,u){var a=!!u.url;this.trackId=u.id;var d=this.fragCurrent;d!=null&&d.loader&&d.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(g):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(n,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(A.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(n,u){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var d=this.levels,v=u.details,S=u.id;if(!d){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var T=d[S],I=0;if(v.live||(a=T.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!k)return;!T.details&&v.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,k),I=v.fragments[0].start):I=this.alignPlaylists(v,T.details)}T.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(T.details,I),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(n){var u,a=n.frag,d=n.part,v=n.payload,S=this.config,T=this.trackId,I=this.levels;if(!I){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var k=I[T];console.assert(k,"Audio track is defined on fragment load progress");var B=k.details;console.assert(B,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||k.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[a.cc],z=(u=a.initSegment)===null||u===void 0?void 0:u.data;if(G!==void 0){var Y=!1,$=d?d.index:-1,Z=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,$,Z);W.push(v,z,U,"",a,d,B.totalduration,Y,q,G)}else{this.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+T);var ie=this.waitingData=this.waitingData||{frag:a,part:d,cache:new x.default,complete:!1},ne=ie.cache;ne.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(n,u){var a=u.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(n,u){var a=u.frag,d=u.part;if(a.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(d?" p: "+d.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}a.sn!=="initSegment"&&(this.fragPrevious=a,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,d)}},c.onError=function(n,u){switch(u.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case f.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var a=!0,d=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);d&&d.len>.5&&(a=!this.reduceMaxBufferLength(d.len)),a&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(n,u){var a=u.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(n){var u,a="audio",d=this.hls,v=n.remuxResult,S=n.chunkMeta,T=this.getCurrentContext(S);if(!T){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(S.level);return}var I=T.frag,k=T.part,B=T.level.details,U=v.audio,W=v.text,G=v.id3,z=v.initSegment;if(!(this.fragContextChanged(I)||!B)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,I,S),d.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:a,tracks:z.tracks})),U){var Y=U.startPTS,$=U.endPTS,Z=U.startDTS,q=U.endDTS;k&&(k.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:$,startDTS:Z,endDTS:q}),I.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,Z,q),this.bufferFragmentData(U,I,k,S)}if(G!=null&&(u=G.samples)!==null&&u!==void 0&&u.length){var ie=e({id:a,frag:I,details:B},G);d.trigger(A.Events.FRAG_PARSING_METADATA,ie)}if(W){var ne=e({id:a,frag:I,details:B},W);d.trigger(A.Events.FRAG_PARSING_USERDATA,ne)}}},c._bufferInitSegment=function(n,u,a){if(this.state===L.State.PARSING){n.video&&delete n.video;var d=n.audio;if(!!d){d.levelCodec=d.codec,d.id="audio",this.log("Init audio buffer, container:"+d.container+", codecs[parsed]=["+d.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,n);var v=d.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:a,parent:u.type,data:v};this.hls.trigger(A.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(n,u,a){var d=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||d===O.FragmentState.NOT_LOADED||d===O.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):u.live&&!Object(P.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,u,a)))},c.completeAudioSwitch=function(){var n=this.hls,u=this.media,a=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(L.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/controller/base-playlist-controller.ts"),M=l("./src/types/loader.ts");function O(D,E){for(var m=0;m<E.length;m++){var p=E[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function b(D,E,m){return E&&O(D.prototype,E),m&&O(D,m),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,E){D.prototype=Object.create(E.prototype),D.prototype.constructor=D,y(D,E)}function y(D,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,f){return p.__proto__=f,p},y(D,E)}var x=function(D){_(E,D);function E(p){var f;return f=D.call(this,p,"[audio-track-controller]")||this,f.tracks=[],f.groupId=null,f.tracksInGroup=[],f.trackId=-1,f.trackName="",f.selectDefaultTrack=!0,f.registerListeners(),f}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.on(P.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),f.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.off(P.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},m.onManifestParsed=function(f,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(f,e){var s=e.id,h=e.details,g=this.tracksInGroup[s];if(!g){this.warn("Invalid audio track id "+s);return}var i=g.details;g.details=e.details,this.log("audioTrack "+s+" loaded ["+h.startSN+"-"+h.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},m.onLevelLoading=function(f,e){this.switchLevel(e.level)},m.onLevelSwitching=function(f,e){this.switchLevel(e.level)},m.switchLevel=function(f){var e=this.hls.levels[f];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var h=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(P.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(f,e){D.prototype.onError.call(this,f,e),!(e.fatal||!e.context)&&e.context.type===M.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(f){var e=this.tracksInGroup;if(f<0||f>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+f);var h=e[f],g=h.id,i=h.groupId,r=i===void 0?"":i,o=h.name,c=h.type,t=h.url;if(this.trackId=f,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:o,type:c,url:t}),!(h.details&&!h.details.live)){var n=this.switchParams(h.url,s==null?void 0:s.details);this.loadPlaylist(n)}},m.selectInitialTrack=function(){var f=this.tracksInGroup;console.assert(f.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(f){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var h=e[s];if((!this.selectDefaultTrack||h.default)&&(!f||f===h.name))return h.id}return-1},m.loadPlaylist=function(f){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,h=e.groupId,g=e.url;if(f)try{g=f.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(P.Events.AUDIO_TRACK_LOADING,{url:g,id:s,groupId:h,deliveryDirectives:f||null})}},b(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(f){this.selectDefaultTrack=!1,this.setAudioTrack(f)}}]),E}(A.default);R.default=x},"./src/controller/base-playlist-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/polyfills/number.ts"),L=l("./src/types/level.ts"),A=l("./src/controller/level-helper.ts"),M=l("./src/utils/logger.ts"),O=l("./src/errors.ts"),b=function(){function _(x,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,D+":"),this.warn=M.logger.warn.bind(M.logger,D+":"),this.hls=x}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===O.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(D,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var f=m[p],e=""+f.URI;if(e===D.slice(-e.length)){var s=parseInt(f["LAST-MSN"]),h=parseInt(f["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(P.isFiniteNumber)(s))return new L.HlsUrlParameters(s,Object(P.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(D){},y.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},y.playlistLoaded=function(D,E,m){var p=this,f=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(f.advancedDateTime=Date.now()-s,f.live||m!=null&&m.live){if(f.reloaded(m),m&&this.log("live playlist "+D+" "+(f.advanced?"REFRESHED "+f.lastPartSn+"-"+f.lastPartIndex:"MISSED")),m&&f.fragments.length>0&&Object(A.mergeDetails)(m,f),!this.canLoad||!f.live)return;var h,g=void 0,i=void 0;if(f.canBlockReload&&f.endSN&&f.advanced){var r=this.hls.config.lowLatencyMode,o=f.lastPartSn,c=f.endSN,t=f.lastPartIndex,n=t!==-1,u=o===c,a=r?0:t;n?(g=u?c+1:o,i=u?a:t+1):g=c+1;var d=f.age,v=d+f.ageHeader,S=Math.min(v-f.partTarget,f.targetduration*1.5);if(S>0){if(m&&S>m.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+m.tuneInGoal+" to: "+S+" with playlist age: "+f.age),S=0;else{var T=Math.floor(S/f.targetduration);if(g+=T,i!==void 0){var I=Math.round(S%f.targetduration/f.partTarget);i+=I}this.log("CDN Tune-in age: "+f.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+S+" skip sn "+T+" to part "+i)}f.tuneInGoal=S}if(h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i);var k=Object(A.computeReloadInterval)(f,e);g!==void 0&&f.canBlockReload&&(k-=f.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,m,p){var f=Object(L.getSkipValue)(D,m);return E!=null&&E.skip&&D.deltaUpdateFailed&&(m=E.msn,p=E.part,f=L.HlsSkip.No),new L.HlsUrlParameters(m,p,f)},y.retryLoadingOrFail=function(D){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var f;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(f=D.context)!==null&&f!==void 0&&f.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*m.levelLoadingRetryDelay,m.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"State",function(){return c}),l.d(R,"default",function(){return t});var P=l("./src/polyfills/number.ts"),L=l("./src/task-loop.ts"),A=l("./src/controller/fragment-tracker.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/utils/logger.ts"),b=l("./src/events.ts"),_=l("./src/errors.ts"),y=l("./src/types/transmuxer.ts"),x=l("./src/utils/mp4-tools.ts"),D=l("./src/utils/discontinuities.ts"),E=l("./src/controller/fragment-finders.ts"),m=l("./src/controller/level-helper.ts"),p=l("./src/loader/fragment-loader.ts"),f=l("./src/crypt/decrypter.ts"),e=l("./src/utils/time-ranges.ts"),s=l("./src/types/loader.ts");function h(n,u){for(var a=0;a<u.length;a++){var d=u[a];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(n,d.key,d)}}function g(n,u,a){return u&&h(n.prototype,u),a&&h(n,a),Object.defineProperty(n,"prototype",{writable:!1}),n}function i(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function r(n,u){n.prototype=Object.create(u.prototype),n.prototype.constructor=n,o(n,u)}function o(n,u){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,v){return d.__proto__=v,d},o(n,u)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},t=function(n){r(u,n);function u(d,v,S){var T;return T=n.call(this)||this,T.hls=void 0,T.fragPrevious=null,T.fragCurrent=null,T.fragmentTracker=void 0,T.transmuxer=null,T._state=c.STOPPED,T.media=null,T.mediaBuffer=null,T.config=void 0,T.bitrateTest=!1,T.lastCurrentTime=0,T.nextLoadPosition=0,T.startPosition=0,T.loadedmetadata=!1,T.fragLoadError=0,T.retryDate=0,T.levels=null,T.fragmentLoader=void 0,T.levelLastLoaded=null,T.startFragRequested=!1,T.decrypter=void 0,T.initPTS=[],T.onvseeking=null,T.onvended=null,T.logPrefix="",T.log=void 0,T.warn=void 0,T.logPrefix=S,T.log=O.logger.log.bind(O.logger,S+":"),T.warn=O.logger.warn.bind(O.logger,S+":"),T.hls=d,T.fragmentLoader=new p.default(d.config),T.fragmentTracker=v,T.config=d.config,T.decrypter=new f.default(d,d.config),d.on(b.Events.KEY_LOADED,T.onKeyLoaded,i(T)),d.on(b.Events.LEVEL_SWITCHING,T.onLevelSwitching,i(T)),T}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},a._streamEnded=function(v,S){var T=this.fragCurrent,I=this.fragmentTracker;if(!S.live&&T&&this.media&&T.sn>=S.endSN&&!v.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=M.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=I.getState(T);return W===A.FragmentState.PARTIAL||W===A.FragmentState.OK}return!1},a.onMediaAttached=function(v,S){var T=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),T.addEventListener("seeking",this.onvseeking),T.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,T=this.media,I=this.mediaBuffer,k=this.state,B=T?T.currentTime:0,U=M.BufferHelper.bufferInfo(I||T,B,v.maxBufferHole);if(this.log("media seeking to "+(Object(P.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,G=S.start-W,z=S.start+S.duration+W,Y=B>z;(B<G||Y)&&(Y&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}T&&(this.lastCurrentTime=B),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var T=this.levels[S.frag.level].details;T&&this.loadFragment(S.frag,T,S.frag.start)}},a.onLevelSwitching=function(v,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(b.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,n.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(b.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,S,T){this._loadFragForPlayback(v,S,T)},a._loadFragForPlayback=function(v,S,T){var I=this,k=function(U){if(I.fragContextChanged(v)){I.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),I.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,I._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,T,k).then(function(B){if(!!B){I.fragLoadError=0;var U=I.state;if(I.fragContextChanged(v)){(U===c.FRAG_LOADING||!I.fragCurrent&&U===c.PARSING)&&(I.fragmentTracker.removeFragment(v),I.state=c.IDLE);return}"payload"in B&&(I.log("Loaded fragment "+v.sn+" of level "+v.level),I.hls.trigger(b.Events.FRAG_LOADED,B)),I._handleFragmentLoadComplete(B)}}).catch(function(B){I.state===c.STOPPED||I.state===c.ERROR||(I.warn(B),I.resetFragmentLoading(v))})},a.flushMainBuffer=function(v,S,T){if(T===void 0&&(T=null),!!(v-S)){var I={startOffset:v,endOffset:S,type:T};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},a._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(T){if(!T||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return T}).then(function(T){var I=S.hls,k=T.payload,B=v.decryptdata;if(k&&k.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(k),B.key.buffer,B.iv.buffer).then(function(W){var G=self.performance.now();return I.trigger(b.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:G}}),T.payload=W,T})}return T}).then(function(T){var I=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(T.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),T.frag===I&&k.trigger(b.Events.FRAG_BUFFERED,{stats:W,frag:I,part:null,id:v.type}),S.tick()}).catch(function(T){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(T),S.resetFragmentLoading(v))})},a.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},a.fragBufferedComplete=function(v,S){var T=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(T?e.default.toString(M.BufferHelper.getBuffered(T)):"(detached)")),this.state=c.IDLE,T&&(!this.loadedmetadata&&T.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var T=v.frag,I=v.part,k=v.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(T.level,T.sn,T.stats.chunkCount+1,0,I?I.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,S,T,I){var k=this;if(T===void 0&&(T=null),!this.levels)throw new Error("frag load aborted, missing levels");if(T=Math.max(v.start,T||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&I){T>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(B,v,T);if(U>-1){var W=B[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,part:B[U],targetBufferTime:T}),this.doFragPartsLoad(v,B,U,I).catch(function(G){return k.handleFragLoadError(G)})}else if(!v.url||this.loadedEndOfParts(B,T))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),Object(P.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,targetBufferTime:T}),this.fragmentLoader.load(v,I).catch(function(G){return k.handleFragLoadError(G)})},a.doFragPartsLoad=function(v,S,T,I){var k=this;return new Promise(function(B,U){var W=[],G=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(v,$,I).then(function(Z){W[$.index]=Z;var q=Z.part;k.hls.trigger(b.Events.FRAG_LOADED,Z);var ie=S[Y+1];if(ie&&ie.fragment===v)z(Y+1);else return B({frag:v,part:q,partsLoaded:W})}).catch(U)};G(T)})},a.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(b.Events.ERROR,S),null},a._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var T=S.frag,I=S.part,k=S.level,B=self.performance.now();T.stats.parsing.end=B,I&&(I.stats.parsing.end=B),this.updateLevelTiming(T,I,k,v.partial)},a.getCurrentContext=function(v){var S=this.levels,T=v.level,I=v.sn,k=v.part;if(!S||!S[T])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+T+". The current chunk will not be buffered."),null;var B=S[T],U=k>-1?Object(m.getPartWith)(B,I,k):null,W=U?U.fragment:Object(m.getFragmentWithSN)(B,I,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(v,S,T,I){if(!(!v||this.state!==c.PARSING)){var k=v.data1,B=v.data2,U=k;if(k&&B&&(U=Object(x.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:v.type,frag:S,part:T,chunkMeta:I,parent:S.type,data:U};this.hls.trigger(b.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!T&&this.flushBufferGap(S)}}},a.flushBufferGap=function(v){var S=this.media;if(!!S){if(!M.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var T=S.currentTime,I=M.BufferHelper.bufferInfo(S,T,0),k=v.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(v.start-B,I.end-B),T+B);v.start-U>B&&this.flushMainBuffer(U,v.start)}},a.getFwdBufferInfo=function(v,S){var T=this.config,I=this.getLoadPosition();if(!Object(P.isFiniteNumber)(I))return null;var k=M.BufferHelper.bufferInfo(v,I,T.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(I,S);if(B&&k.nextStart<B.end)return M.BufferHelper.bufferInfo(v,I,Math.max(k.nextStart,T.maxBufferHole))}return k},a.getMaxBufferLength=function(v){var S=this.config,T;return v?T=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):T=S.maxBufferLength,Math.min(T,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var S=this.config,T=v||S.maxBufferLength;return S.maxMaxBufferLength>=T?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,S){var T=S.fragments,I=T.length;if(!I)return null;var k=this.config,B=T[0].start,U;if(S.live){var W=k.initialLiveManifestSize;if(I<W)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,T),this.startPosition=U?this.hls.liveSyncPosition||U.start:v)}else v<=B&&(U=T[0]);if(!U){var G=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,G,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},a.getNextPart=function(v,S,T){for(var I=-1,k=!1,B=!0,U=0,W=v.length;U<W;U++){var G=v[U];if(B=B&&!G.independent,I>-1&&T<G.start)break;var z=G.loaded;!z&&(k||G.independent||B)&&G.fragment===S&&(I=U),k=z}return I},a.loadedEndOfParts=function(v,S){var T=v[v.length-1];return T&&S>T.start&&T.loaded},a.getInitialLiveFragment=function(v,S){var T=this.fragPrevious,I=null;if(T){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+T.programDateTime),I=Object(E.findFragmentByPDT)(S,T.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=T.sn+1;if(k>=v.startSN&&k<=v.endSN){var B=S[k-v.startSN];T.cc===B.cc&&(I=B,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(S,T.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(I=this.getFragmentAtPosition(U,this.bitrateTest?v.fragmentEnd:v.edge,v))}return I},a.getFragmentAtPosition=function(v,S,T){var I=this.config,k=this.fragPrevious,B=T.fragments,U=T.endSN,W=T.fragmentHint,G=I.maxFragLookUpTolerance,z=!!(I.lowLatencyMode&&T.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(v<S){var $=v>S-G?0:G;Y=Object(E.findFragmentByPTS)(k,B,v,$)}else Y=B[B.length-1];if(Y){var Z=Y.sn-T.startSN;if(k&&Y.sn===k.sn&&!z){var q=k&&Y.level===k.level;if(q){var ie=B[Z+1];Y.sn<U&&this.fragmentTracker.getState(ie)!==A.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+ie.sn),Y=ie):Y=null}}}return Y},a.synchronizeToLiveEdge=function(v){var S=this.config,T=this.media;if(!!T){var I=this.hls.liveSyncPosition,k=T.currentTime,B=v.fragments[0].start,U=v.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(I!==null&&T.duration>I&&(k<I||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&T.readyState<4||k<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=I),T.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+I.toFixed(3)),T.currentTime=I))}}},a.alignPlaylists=function(v,S){var T=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,B=I!==null?T[I]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,G=!S,z=v.alignedSliding&&Object(P.isFiniteNumber)(W);if(G||!z&&!W){Object(D.alignStream)(k,B,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},a.setStartPosition=function(v,S){var T=this.startPosition;if(T<S&&(T=-1),T===-1||this.lastCurrentTime===-1){var I=v.startTimeOffset;Object(P.isFiniteNumber)(I)?(T=S+I,I<0&&(T+=v.totalduration),T=Math.min(Math.max(S,T),S+v.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+T),this.startPosition=T):v.live?T=this.hls.liveSyncPosition||S:this.startPosition=T=0,this.lastCurrentTime=T}this.nextLoadPosition=T},a.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},a.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var T=S.frag;if(!(!T||T.type!==v)){var I=this.fragCurrent;console.assert(I&&T.sn===I.sn&&T.level===I.level&&T.urlId===I.urlId,"Frag load error must match current frag to retry");var k=this.config;if(this.fragLoadError+1<=k.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var B=Math.min(Math.pow(2,this.fragLoadError)*k.fragLoadingRetryDelay,k.fragLoadingMaxRetryTimeout);this.warn("Fragment "+T.sn+" of "+v+" "+T.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(O.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},a.afterBufferFlushed=function(v,S,T){if(!!v){var I=M.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,I,T),this.state===c.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},a.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(v,S,T,I){var k=this,B=T.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,G){var z=v.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+v.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var $=I?0:Object(m.updateFragPTSDTS)(B,v,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:B,level:T,drift:$,type:G,frag:v,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+T.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:v,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),M=l("./src/errors.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/utils/mediasource-helper.ts"),_=l("./src/loader/fragment.ts"),y=l("./src/controller/buffer-operation-queue.ts"),x=Object(b.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(f){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,h=e.media,g=e.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),s.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.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=f,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,s){var h=2;(s.audio&&!s.video||!s.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var h=this.media=s.media;if(h&&x){var g=this.mediaSource=new x;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,h=this._objectUrl;if(s){if(A.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(g){A.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(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(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var h=e.sourceBuffer[s];try{h&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[s]=void 0)}catch(g){A.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var h=this,g=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],c=o.id,t=o.codec,n=o.levelCodec,u=o.container,a=o.metadata,d=(r.levelCodec||r.codec).replace(D,"$1"),v=(n||t).replace(D,"$1");if(d!==v){var S=u+";codecs="+(n||t);h.appendChangeType(i,S),A.logger.log("[buffer-controller]: switching codec "+d+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:n,metadata:a,id:c}}}}else h.pendingTracks[i]=s[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var h=this,g=this.operationQueue,i={execute:function(){var o=h.sourceBuffer[e];o&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};g.append(i,e)},p.onBufferAppending=function(e,s){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,c=s.type,t=s.frag,n=s.part,u=s.chunkMeta,a=u.buffering[c],d=self.performance.now();a.start=d;var v=t.stats.buffering,S=n?n.stats.buffering:null;v.start===0&&(v.start=d),S&&S.start===0&&(S.start=d);var T=r.audio,I=c==="audio"&&u.id===1&&(T==null?void 0:T.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),I){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(o,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,G={};for(var z in W)G[z]=O.BufferHelper.getBuffered(W[z]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:n,chunkMeta:u,parent:t.type,timeRanges:G})},onError:function(U){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:M.ErrorTypes.MEDIA_ERROR,parent:t.type,details:M.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=M.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=M.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(k,c)},p.onBufferFlushing=function(e,s){var h=this,g=this.operationQueue,i=function(o){return{execute:h.removeExecutor.bind(h,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){A.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?g.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,s){var h=this,g=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:g.elementaryStreams;o[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var n=self.performance.now();g.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var o=h.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,A.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var h=s.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(P.isFiniteNumber)(r)||r<0)){var o=h.currentTime,c=s.levelTargetDuration,t=Math.max(r,c),n=Math.floor(o/c)*c-t;i.forEach(function(u){var a=g[u];if(a){var d=O.BufferHelper.getBuffered(a);d.length>0&&n>d.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,o=Object(P.isFiniteNumber)(g.duration)?g.duration:0;e.live&&s.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(P.isFiniteNumber)(r))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){s.executeNext(r)})}},p.createSourceBuffers=function(e){var s=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!s[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var o=r.levelCodec||r.codec,c=r.container+";codecs="+o;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=s[i]=h.addSourceBuffer(c),n=i;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,h=s.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,h=s.current(e);h.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(s)},p.removeExecutor=function(e,s,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,c=o[e];if(!g||!i||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(P.isFiniteNumber)(g.duration)?g.duration:1/0,n=Object(P.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,s),a=Math.min(h,t,n);a>u?(A.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var h=this.operationQueue,g=this.sourceBuffer,i=g[s];if(!i){A.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,s){var h=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=s.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=h.sourceBuffer[r];(!o||!o.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:s,listener:i}),g.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(h){s.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return L});var P=l("./src/utils/logger.ts"),L=function(){function A(O){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=O}var M=A.prototype;return M.append=function(b,_){var y=this.queues[_];y.push(b),y.length===1&&this.buffers[_]&&this.executeNext(_)},M.insertAbort=function(b,_){var y=this.queues[_];y.unshift(b),this.executeNext(_)},M.appendBlocker=function(b){var _,y=new Promise(function(D){_=D}),x={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,b),y},M.executeNext=function(b){var _=this.buffers,y=this.queues,x=_[b],D=y[b];if(D.length){var E=D[0];try{E.execute()}catch(m){P.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!x||!x.updating)&&(D.shift(),this.executeNext(b))}}},M.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},M.current=function(b){return this.queues[b][0]},A}()},"./src/controller/cap-level-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts");function L(O,b){for(var _=0;_<b.length;_++){var y=b[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(O,y.key,y)}}function A(O,b,_){return b&&L(O.prototype,b),_&&L(O,_),Object.defineProperty(O,"prototype",{writable:!1}),O}var M=function(){function O(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var b=O.prototype;return b.setStreamController=function(y){this.streamController=y},b.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},b.registerListeners=function(){var y=this.hls;y.on(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.unregisterListener=function(){var y=this.hls;y.off(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.onFpsDropLevelCapping=function(y,x){O.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},b.onMediaAttaching=function(y,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},b.onManifestParsed=function(y,x){var D=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onBufferCodecs=function(y,x){var D=this.hls;D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onMediaDetaching=function(){this.stopCapping()},b.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(y.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},b.getMaxLevel=function(y){var x=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(m,p){return O.isLevelAllowed(p,x.restrictedLevels)&&p<=y});return this.clientRect=null,O.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},b.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())},b.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},b.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,x={width:0,height:0};if(y){var D=y.getBoundingClientRect();x.width=D.width,x.height=D.height,!x.width&&!x.height&&(x.width=D.right-D.left||y.width||0,x.height=D.bottom-D.top||y.height||0)}return this.clientRect=x,x},O.isLevelAllowed=function(y,x){return x===void 0&&(x=[]),x.indexOf(y)===-1},O.getMaxLevelByMediaSize=function(y,x,D){if(!y||!y.length)return-1;for(var E=function(s,h){return h?s.width!==h.width||s.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var f=y[p];if((f.width>=x||f.height>=D)&&E(f,y[p+1])){m=p;break}}return m},A(O,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),O}();R.default=M},"./src/controller/cmcd-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./src/events.ts"),L=l("./src/types/cmcd.ts"),A=l("./src/utils/buffer-helper.ts"),M=l("./src/utils/logger.ts");function O(m,p){for(var f=0;f<p.length;f++){var e=p[f];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function b(m,p,f){return p&&O(m.prototype,p),f&&O(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var f=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(f)return(f=f.call(m)).next.bind(f);if(Array.isArray(m)||(f=y(m))||p&&m&&typeof m.length=="number"){f&&(m=f);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
13
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return x(m,p);var f=Object.prototype.toString.call(m).slice(8,-1);if(f==="Object"&&m.constructor&&(f=m.constructor.name),f==="Map"||f==="Set")return Array.from(m);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return x(m,p)}}function x(m,p){(p==null||p>m.length)&&(p=m.length);for(var f=0,e=new Array(p);f<p;f++)e[f]=m[f];return e}function D(){return D=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var f=arguments[p];for(var e in f)Object.prototype.hasOwnProperty.call(f,e)&&(m[e]=f[e])}return m},D.apply(this,arguments)}var E=function(){function m(f){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){M.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),c={d:i.duration*1e3,ot:o};(o===L.CMCDObjectType.VIDEO||o===L.CMCDObjectType.AUDIO||o==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(o)/1e3,c.bl=e.getBufferLength(o)),e.apply(g,c)}catch(t){M.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=f;var s=this.config=f.config,h=s.cmcd;h!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,s){var h,g;this.audioBuffer=(h=s.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=s.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,s){s===void 0&&(s={}),D(s,this.createData());var h=s.ot===L.CMCDObjectType.INIT||s.ot===L.CMCDObjectType.VIDEO||s.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var g=m.toHeaders(s);if(!Object.keys(g).length)return;e.headers||(e.headers={}),D(e.headers,g)}else{var i=m.toQuery(s);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var s=e.type;if(s==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(s==="audio")return L.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var o=_(h),c;!(c=o()).done;){var t=c.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!s)return NaN;var g=A.BufferHelper.bufferInfo(h,s.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},m.serialize=function(e){for(var s=[],h=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},g=function(I){return Math.round(I)},i=function(I){return g(I/100)*100},r=function(I){return encodeURIComponent(I)},o={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),n;!(n=t()).done;){var u=n.value,a=e[u];if(!!h(a)&&!(u==="v"&&a===1)&&!(u=="pr"&&a===1)){var d=o[u];d&&(a=d(a));var v=typeof a,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+a:v==="boolean"?S=u:v==="number"?S=u+"="+a:S=u+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},m.toHeaders=function(e){for(var s=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,c=s;o<c.length;o++){var t=c[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var u=0;u<i.length;u++){var a=m.serialize(i[u]);a&&(h["CMCD-"+g[u]]=a)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,s){if(!s)return e;var h=e.includes("?")?"&":"?";return""+e+h+s},m}()},"./src/controller/eme-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),M=l("./src/utils/mediakeys-helper.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,f){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:f.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:f.videoRobustness||""})}),[e]},x=function(m,p,f,e){switch(m){case M.KeySystems.WIDEVINE:return y(p,f,e);default:throw new Error("Unknown key-system: "+m)}},D=function(){function E(p){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=p,this._config=p.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 m=E.prototype;return m.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},m._registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(f){switch(f){case M.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+f+'"')},m._attemptKeySystemAccess=function(f,e,s){var h=this,g=x(f,e,s,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(f,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(f,r)}),i.catch(function(r){A.logger.error('Failed to obtain key-system "'+f+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(f,e){var s=this;A.logger.log('Access for key-system "'+f+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:f};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,A.logger.log('Media-keys created for key-system "'+f+'"'),s._onMediaKeysCreated(),i});return g.catch(function(i){A.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var f=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),f._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(f){var e=this;A.logger.log("New key-system session "+f.sessionId),f.addEventListener("message",function(s){e._onKeySessionMessage(f,s.message)},!1)},m._onKeySessionMessage=function(f,e){A.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){A.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),f.update(s).catch(function(h){A.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(f){var e=this;if(A.logger.log('Media is encrypted using "'+f.initDataType+'" init data type'),!this.mediaKeysPromise){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(f.initDataType,f.initData))};this.mediaKeysPromise.then(s).catch(s)},m._attemptSetMediaKeys=function(f){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(f,e){var s=this,h=this._mediaKeysList[0];if(!h){A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){A.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){A.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){A.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}A.logger.log('Generating key-session request for "'+f+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(f,e).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(i){A.logger.error("Error generating key-session request:",i),s.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(f,e,s){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,f,e,s);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,f),g=void 0}catch(i){A.logger.error(i)}try{h.readyState||h.open("POST",f,!0),g&&g.call(this.hls,h,f)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(f,e,s,h){switch(f.readyState){case 4:if(f.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var g=f.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,f,e)}catch(o){A.logger.error(o)}h(g)}else{if(A.logger.error("License Request XHR failed ("+e+"). Status: "+f.status+" ("+f.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,h)}break}},m._generateLicenseRequestChallenge=function(f,e){switch(f.mediaKeySystemDomain){case M.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+f.mediaKeySystemDomain)},m._requestLicense=function(f,e){A.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(s.mediaKeySystemDomain),g=this._createLicenseXhr(h,f,e);A.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(s,f);g.send(i)}catch(r){A.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(f,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var f=this._media,e=this._mediaKeysList;!f||(f.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return f.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(f,e){if(!!this._emeEnabled){var s=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(M.KeySystems.WIDEVINE,s,h)}},b(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();R.default=D},"./src/controller/fps-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/utils/logger.ts"),A=function(){function M(b){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=b,this.registerListeners()}var O=M.prototype;return O.setStreamController=function(_){this.streamController=_},O.registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},O.unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching)},O.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},O.onMediaAttaching=function(_,y){var x=this.hls.config;if(x.capLevelOnFPSDrop){var D=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},O.checkFPS=function(_,y,x){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,m=x-this.lastDroppedFrames,p=y-this.lastDecodedFrames,f=1e3*m/E,e=this.hls;if(e.trigger(P.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:x}),f>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(P.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=x,this.lastDecodedFrames=y}},O.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},M}();R.default=A},"./src/controller/fragment-finders.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFragmentByPDT",function(){return A}),l.d(R,"findFragmentByPTS",function(){return M}),l.d(R,"fragmentWithinToleranceTest",function(){return O}),l.d(R,"pdtWithinToleranceTest",function(){return b}),l.d(R,"findFragWithCC",function(){return _});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/binary-search.ts");function A(y,x,D){if(x===null||!Array.isArray(y)||!y.length||!Object(P.isFiniteNumber)(x))return null;var E=y[0].programDateTime;if(x<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(x>=(m||0))return null;D=D||0;for(var p=0;p<y.length;++p){var f=y[p];if(b(x,D,f))return f}return null}function M(y,x,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var m=null;if(y?m=x[y.sn-x[0].sn+1]||null:D===0&&x[0].start===0&&(m=x[0]),m&&O(D,E,m)===0)return m;var p=L.default.search(x,O.bind(null,D,E));return p||m}function O(y,x,D){y===void 0&&(y=0),x===void 0&&(x=0);var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function b(y,x,D){var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,m=D.endProgramDateTime||0;return m-E>y}function _(y,x){return L.default.search(y,function(D){return D.cc<x?1:D.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"FragmentState",function(){return A}),l.d(R,"FragmentTracker",function(){return M});var P=l("./src/events.ts"),L=l("./src/types/loader.ts"),A;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(A||(A={}));var M=function(){function _(x){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=x,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var D=this.hls;D.on(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var f=p.length;f--;){var e=p[f],s=e?e.end:m.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return f>9&&(this.activeParts=p.slice(f-9)),e}else if(m.start<=D&&m.appendedPTS!==void 0&&D<=m.appendedPTS)return m}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var m=this.fragments,p=Object.keys(m),f=p.length;f--;){var e=m[p[f]];if((e==null?void 0:e.body.type)===E&&e.buffered){var s=e.body;if(s.start<=D&&D<=s.end)return s}}return null},y.detectEvictedFragments=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(D){var E=this,m=this.timeRanges,p=D.frag,f=D.part;if(!(!m||p.sn==="initSegment")){var e=b(p),s=this.fragments[e];!s||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=f!==null||g.partial===!0;s.range[h]=E.getBufferedTimes(p,f,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=b(D),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(D,E,m,p){for(var f={time:[],partial:m},e=E?E.start:D.start,s=E?E.end:D.end,h=D.minEndPTS||s,g=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(g>=r&&h<=o){f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)f.partial=!0,f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return f},y.getPartialFragment=function(D){var E=null,m,p,f,e=0,s=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||O(i)&&(p=i.body.start-s,f=i.body.end+s,D>=p&&D<=f&&(m=Math.min(D-p,f-D),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(D){var E=b(D),m=this.fragments[E];return m?m.buffered?O(m)?A.PARTIAL:A.OK:A.APPENDING:A.NOT_LOADED},y.isTimeBuffered=function(D,E,m){for(var p,f,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,f=m.end(e)+this.bufferPadding,D>=p&&E<=f)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var f=b(m);this.fragments[f]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var m=this,p=E.frag,f=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,f){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(f)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!f)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=b(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e&&e.buffered){var s=e.body;s.type===m&&s.start<E&&s.end>D&&p.removeFragment(s)}})},y.removeFragment=function(D){var E=b(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function O(_){var y,x;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((x=_.range.audio)===null||x===void 0?void 0:x.partial))}function b(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"STALL_MINIMUM_DURATION_MS",function(){return O}),l.d(R,"MAX_START_GAP_JUMP",function(){return b}),l.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),l.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),l.d(R,"default",function(){return x});var P=l("./src/utils/buffer-helper.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts"),M=l("./src/utils/logger.ts"),O=250,b=2,_=.1,y=.05,x=function(){function D(m,p,f,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=m,this.media=p,this.fragmentTracker=f,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,f){var e=this.config,s=this.media,h=this.stalled;if(s!==null){var g=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;M.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((o||r)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!P.BufferHelper.getBuffered(s).length)){var t=P.BufferHelper.bufferInfo(s,g,0),n=t.len>0,u=t.nextStart||0;if(!(!n&&!u)){if(i){var a=t.len>b,d=!u||f&&f.start<=g||u-g>b&&!this.fragmentTracker.getPartialFragment(g);if(a||d)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||(v=T.details)===null||v===void 0?void 0:v.live,k=I?T.details.targetduration*2:b;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(h===null){this.stalled=B;return}var U=B-h;if(!(!i&&U>=O&&(this._reportStall(t),!this.media))){var W=P.BufferHelper.bufferInfo(s,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,f){var e=this.config,s=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=s.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&f>e.highBufferWatchdogPeriod*1e3&&(M.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var f=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,M.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var f=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var h=s.currentTime,g=0,i=P.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(h+f.maxBufferHole>=g&&h<o){var c=Math.max(o+y,s.currentTime+_);return M.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,s.currentTime=c,p&&e.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,f=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var g=h+(s+1)*p.nudgeOffset;M.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else M.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/texttrack-utils.ts"),M=l("./src/demux/id3.ts"),O=l("./src/loader/date-range.ts"),b=l("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(m,p){return m.getTime()/1e3-p}function D(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(f){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=f,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(A.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},p.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var h=e[s];if(h.kind==="metadata"&&h.label==="id3")return Object(A.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=s.frag,o=s.samples,c=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,n=y(),u=!1,a={},d=0;d<o.length;d++){var v=o[d].type;if(!(v===b.MetadataSchema.emsg&&!g||!i)){var S=M.getID3Frames(o[d].data);if(S){var T=o[d].pts,I=t,k=I-T;k<=0&&(I=T+_);for(var B=0;B<S.length;B++){var U=S[B];if(!M.isTimeStampFrame(U)){var W=new n(T,I,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),a[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,h=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var c=e[o];c&&r.endTime!==c&&(r.endTime=c),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var h=s.startOffset,g=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var c=o.config,t=c.enableEmsgMetadataCues,n=c.enableID3MetadataCues;if(r&&(t||n)){var u;i==="audio"?u=function(d){return d.type===b.MetadataSchema.audioId3&&n}:i==="video"?u=function(d){return d.type===b.MetadataSchema.emsg&&t}:u=function(d){return d.type===b.MetadataSchema.audioId3&&n||d.type===b.MetadataSchema.emsg&&t},Object(A.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,s){var h=this,g=s.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=g.dateRanges,c=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!c.includes(k)}),n=function(B){var U=t[B];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)n(u);var a=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(P.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var d=a.programDateTime/1e3-a.start,v=g.edge||a.end,S=y(),T=function(B){var U=c[B],W=o[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,$=x(W.startDate,d),Z=v,q=W.endDate;if(q)Z=x(q,d),Y=!0;else if(W.endOnNext&&!Y){var ie=c.reduce(function(re,Ee){var me=o[Ee];return me.class===W.class&&me.id!==Ee&&me.startDate>W.startDate&&re.push(me),re},[]).sort(function(re,Ee){return re.startDate.getTime()-Ee.startDate.getTime()})[0];ie&&(Z=x(ie.startDate,d),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var te=ne[ae];if(!(te===O.DateRangeAttribute.ID||te===O.DateRangeAttribute.CLASS||te===O.DateRangeAttribute.START_DATE||te===O.DateRangeAttribute.DURATION||te===O.DateRangeAttribute.END_DATE||te===O.DateRangeAttribute.END_ON_NEXT)){var fe=z[te];if(fe)Y&&!G.durationKnown&&(fe.endTime=Z);else{var de=W.attr[te];fe=new S($,Z,""),(te===O.DateRangeAttribute.SCTE35_OUT||te===O.DateRangeAttribute.SCTE35_IN)&&(de=D(de)),fe.value={key:te,data:de},fe.type=b.MetadataSchema.dateRange,h.id3Track.addCue(fe),z[te]=fe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},I=0;I<c.length;I++)T(I)}}},m}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/errors.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts");function M(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function O(_,y,x){return y&&M(_.prototype,y),x&&M(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var b=function(){function _(x){var D=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 D.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(D,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(D,E){var m=E.details;this.levelDetails=m,m.advanced&&this.timeupdate(),!m.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===P.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var D=this.media,E=this.levelDetails;if(!(!D||!E)){this.currentTime=D.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,f=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!f||e===1)){var s=this.targetLatency;if(s!==null){var h=m-s,g=Math.min(this.maxLatency,s+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;D.playbackRate=Math.min(r,Math.max(1,o))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},y.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},O(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,E=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:E?D.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var E=D.holdBack,m=D.partHoldBack,p=D.targetduration,f=this.config,e=f.liveSyncDuration,s=f.liveSyncDurationCount,h=f.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*p);var r=p,o=1;return i+Math.min(this.stallCount*o,r)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(D===null||E===null||m===null)return null;var p=m.edge,f=D-E-this.edgeStalled,e=p-m.totalduration,s=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,f),s)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var E=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-E,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,E=this.levelDetails;if(!D||!E)return 0;var m=D.buffered.length;return(m?D.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return f});var P=l("./src/types/level.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),M=l("./src/utils/codecs.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/base-playlist-controller.ts"),_=l("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var h=arguments[s];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,m(e,s)}function m(e,s){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),f=function(e){E(s,e);function s(g){var i;return i=e.call(this,g,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var h=s.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var o=[],c=[],t=[],n,u={},a,d=!1,v=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;d=d||!!(B.width&&B.height),v=v||!!B.videoCodec,S=S||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var W=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;a=u[W],a?a.url.push(B.url):(a=new P.Level(B),u[W]=a,o.push(a)),U&&(U.AUDIO&&Object(O.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(O.addGroupId)(a,"text",U.SUBTITLES))}),(d||v)&&S&&(o=o.filter(function(B){var U=B.videoCodec,W=B.width,G=B.height;return!!U||!!(W&&G)})),o=o.filter(function(B){var U=B.audioCodec,W=B.videoCodec;return(!U||Object(M.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(M.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(B){return!B.audioCodec||Object(M.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(O.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(O.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var T=0;T<o.length;T++)if(o[T].bitrate===n){this._firstLevel=T,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var I=S&&!v,k={levels:o,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!I&&c.some(function(B){return!!B.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,u=!0,a;switch(r.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(r.frag){var d=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[d];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=d)):a=d}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),a=c.level),n=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,u)}},h.recoverLevel=function(i,r,o,c){var t=i.details,n=this._levels[r];if(n.loadError++,o){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var d=-1,v=this._levels,S=v.length;S--;){var T=(S+this.currentLevelIndex)%v.length;if(T!==this.currentLevelIndex&&v[T].loadError===0){d=T;break}}d>-1&&this.currentLevelIndex!==d&&(this.warn(t+": switch to "+d),i.levelRetry=!0,this.hls.nextAutoLevel=d)}}},h.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var c=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===_.PlaylistLevelType.MAIN){var c=this._levels[o.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var o,c=r.level,t=r.details,n=this._levels[c];if(!n){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){c=n;break}c!==o.urlId&&(o.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var c=o.urlId,t=o.url[c];if(i)try{t=i.addDirectives(t)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var o=function(n,u){return u!==r},c=this._levels.filter(function(t,n){return n!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(o),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(o)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(o)),t.urlId=0,!0):!1}).map(function(t,n){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=n}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},D(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,o=this._levels;if(o.length!==0&&!(this.currentLevelIndex===i&&(r=o[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=o.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],u=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,a);var d=u.details;if(!d||d.live){var v=this.switchParams(u.uri,n==null?void 0:n.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(b.default)},"./src/controller/level-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"addGroupId",function(){return O}),l.d(R,"assignTrackIdsByGroup",function(){return b}),l.d(R,"updatePTS",function(){return _}),l.d(R,"updateFragPTSDTS",function(){return x}),l.d(R,"mergeDetails",function(){return D}),l.d(R,"mapPartIntersection",function(){return m}),l.d(R,"mapFragmentIntersection",function(){return p}),l.d(R,"adjustSliding",function(){return f}),l.d(R,"addSliding",function(){return e}),l.d(R,"computeReloadInterval",function(){return s}),l.d(R,"getFragmentWithSN",function(){return h}),l.d(R,"getPartWith",function(){return g});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/loader/date-range.ts");function M(){return M=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(i[c]=o[c])}return i},M.apply(this,arguments)}function O(i,r,o){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(o);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(o);break}}function b(i){var r={};i.forEach(function(o){var c=o.groupId||"";o.id=r[c]=r[c]||0,r[c]++})}function _(i,r,o){var c=i[r],t=i[o];y(c,t)}function y(i,r){var o=r.startPTS;if(Object(P.isFiniteNumber)(o)){var c=0,t;r.sn>i.sn?(c=o-i.start,t=i):(c=i.start-o,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var n=i.cc===r.cc;n&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function x(i,r,o,c,t,n){var u=c-o;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=o+r.duration,n=t+r.duration);var a=o,d=c,v=r.startPTS,S=r.endPTS;if(Object(P.isFiniteNumber)(v)){var T=Math.abs(v-o);Object(P.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(T,r.deltaPTS):r.deltaPTS=T,a=Math.max(o,v),o=Math.min(o,v),t=Math.min(t,r.startDTS),d=Math.min(c,S),c=Math.max(c,S),n=Math.max(n,r.endDTS)}r.duration=c-o;var I=o-r.start;r.appendedPTS=c,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=c,r.minEndPTS=d,r.endDTS=n;var k=r.sn;if(!i||k<i.startSN||k>i.endSN)return 0;var B,U=k-i.startSN,W=i.fragments;for(W[U]=r,B=U;B>0;B--)y(W[B],W[B-1]);for(B=U;B<W.length-1;B++)y(W[B],W[B+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,I}function D(i,r){for(var o=null,c=i.fragments,t=c.length-1;t>=0;t--){var n=c[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,a;if(p(i,r,function(B,U){B.relurl&&(u=B.cc-U.cc),Object(P.isFiniteNumber)(B.startPTS)&&Object(P.isFiniteNumber)(B.endPTS)&&(U.start=U.startPTS=B.startPTS,U.startDTS=B.startDTS,U.appendedPTS=B.appendedPTS,U.maxStartPTS=B.maxStartPTS,U.endPTS=B.endPTS,U.endDTS=B.endDTS,U.minEndPTS=B.minEndPTS,U.duration=B.endPTS-B.startPTS,U.duration&&(a=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=B.elementaryStreams,U.loader=B.loader,U.stats=B.stats,U.urlId=B.urlId,B.initSegment&&(U.initSegment=B.initSegment,o=B.initSegment)}),o){var d=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;d.forEach(function(B){var U;(!B.initSegment||B.initSegment.relurl===((U=o)===null||U===void 0?void 0:U.relurl))&&(B.initSegment=o)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(B){return!B}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var T=0;T<S.length;T++)S[T].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),a?x(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):f(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var I=r.advancedDateTime;if(r.advanced&&I){var k=r.edge;r.driftStart||(r.driftStartTime=I,r.driftStart=k),r.driftEndTime=I,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var c=M({},i);return o&&o.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var n=new A.DateRange(r[t].attr,c[t]);n.isValid?c[t]=n:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,o){if(i&&r)for(var c=0,t=0,n=i.length;t<=n;t++){var u=i[t],a=r[t+c];u&&a&&u.index===a.index&&u.fragment.sn===a.fragment.sn?o(u,a):c--}}function p(i,r,o){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=n;v++){var S=d[u+v],T=a[v];c&&!T&&v<c&&(T=r.fragments[v]=S),S&&T&&o(S,T)}}function f(i,r){var o=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;o<0||o>=c.length||e(r,c[o].start)}function e(i,r){if(r){for(var o=i.fragments,c=i.skippedSegments;c<o.length;c++)o[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,c=o/2,t=i.age,n=t>0&&t<o*3,u=r.loading.end-r.loading.start,a,d=i.availabilityDelay;if(i.updated===!1)if(n){var v=333*i.misses;a=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=c;else n?(d=Math.min(d||o/2,t),i.availabilityDelay=d,a=d+o-t):a=o-u;return Math.round(a)}function h(i,r,o){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&o&&o.sn===r?o:null}function g(i,r,o){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var n=c[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return g});var P=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/is-supported.ts"),M=l("./src/events.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/transmuxer-interface.ts"),D=l("./src/types/transmuxer.ts"),E=l("./src/controller/gap-controller.ts"),m=l("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var c=r[o];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function f(i,r,o){return r&&p(i.prototype,r),o&&p(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,s(i,r)}function s(i,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},s(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var n;return n=i.call(this,c,t,"[stream-controller]")||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}var o=r.prototype;return o._registerListeners=function(){var t=this.hls;t.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(M.Events.ERROR,this.onError,this),t.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(M.Events.ERROR,this.onError,this),t.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=u.startLevel;a===-1&&(u.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=u.nextAutoLevel),this.level=u.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,n=this.levels,u=this.level,a=n==null||(t=n[u])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var d,v=self.performance.now(),S=this.retryDate;(!S||v>=S||(d=this.media)!==null&&d!==void 0&&d.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},o.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},o.doTickIdle=function(){var t,n,u=this.hls,a=this.levelLastLoaded,d=this.levels,v=this.media,S=u.config,T=u.nextLoadLevel;if(!(a===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!d||!d[T])){var I=d[T];this.level=u.nextLoadLevel=T;var k=I.details;if(!k||this.state===L.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==T){this.state=L.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(I.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(M.Events.BUFFER_EOS,G),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>B.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:B.end,Y=this.getNextFragment(z,k);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var $,Z=(($=this.backtrackFragment)!=null?$:Y).sn,q=Z-k.startSN,ie=k.fragments[q-1];ie&&Y.cc===ie.cc&&(Y=ie,this.fragmentTracker.removeFragment(ie))}else this.backtrackFragment&&B.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===b.FragmentState.OK&&this.nextLoadPosition>z){var ne=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;v&&this.afterBufferFlushed(v,ne,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,k)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((n=Y.decryptdata)!==null&&n!==void 0&&n.key)?this.loadKey(Y,k):this.loadFragment(Y,k,z))}}}},o.loadFragment=function(t,n,u){var a,d=this.fragmentTracker.getState(t);this.fragCurrent=t,d===b.FragmentState.NOT_LOADED?t.sn==="initSegment"?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,t,n,u)):d===b.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((a=this.media)===null||a===void 0?void 0:a.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},o.getAppendedFrag=function(t){var n=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},o.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},o.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},o.nextLevelSwitch=function(){var t=this.levels,n=this.media;if(n!=null&&n.readyState){var u,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var d=this.hls.nextLoadLevel,v=t[d],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var T=this.getBufferedFrag(n.currentTime+u);if(T){var I=this.followingBufferedFrag(T);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,B=I.duration,U=Math.max(T.end,k+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},o.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},o.flushMainBuffer=function(t,n){i.prototype.flushMainBuffer.call(this,t,n,this.altAudio?"video":null)},o.onMediaAttached=function(t,n){i.prototype.onMediaAttached.call(this,t,n);var u=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},o.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},o.onMediaPlaying=function(){this.tick()},o.onMediaSeeked=function(){var t=this.media,n=t?t.currentTime:null;Object(P.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},o.onManifestParsed=function(t,n){var u=!1,a=!1,d;n.levels.forEach(function(v){d=v.audioCodec,d&&(d.indexOf("mp4a.40.2")!==-1&&(u=!0),d.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=u&&a&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1},o.onLevelLoading=function(t,n){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var a=u[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=L.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var u,a=this.levels,d=n.level,v=n.details,S=v.totalduration;if(!a){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var T=this.fragCurrent;T&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&T.level!==n.level&&T.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,T.loader.abort());var I=a[d],k=0;if(v.live||(u=I.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;k=this.alignPlaylists(v,I.details)}if(I.details=v,this.levelLastLoaded=d,this.hls.trigger(M.Events.LEVEL_UPDATED,{details:v,level:d}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,u=t.frag,a=t.part,d=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],T=S.details;if(!T){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var I=S.videoCodec,k=T.PTSKnown||!T.live,B=(n=u.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new x.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=a?a.index:-1,z=G!==-1,Y=new D.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,d.byteLength,G,z),$=this.initPTS[u.cc];W.push(d,B,U,I,u,a,T.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var u=this.altAudio,a=!!n.url,d=n.id;if(!a){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:d})}},o.onAudioTrackSwitched=function(t,n){var u=n.id,a=!!this.hls.audioTracks[u].url;if(a){var d=this.videoBuffer;d&&this.mediaBuffer!==d&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=d)}this.altAudio=a,this.tick()},o.onBufferCreated=function(t,n){var u=n.tracks,a,d,v=!1;for(var S in u){var T=u[S];if(T.id==="main"){if(d=S,a=T,S==="video"){var I=u[S];I&&(this.videoBuffer=I.buffer)}}else v=!0}v&&a?(this.log("Alternate track found, use "+d+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var u=n.frag,a=n.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(a?" p: "+a.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var d=a?a.stats:u.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,a)}},o.onError=function(t,n){switch(n.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,n);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=L.State.ERROR):!n.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,a=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);a&&a.len>.5&&(u=!this.reduceMaxBufferLength(a.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},o.checkBuffer=function(){var t=this.media,n=this.gapController;if(!(!t||!n||!t.readyState)){if(this.loadedmetadata||!O.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var u=n.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,u,_.PlaylistLevelType.MAIN)}},o.onLevelsUpdated=function(t,n){this.levels=n.levels},o.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},o.seekToStartPos=function(){var t=this.media;if(!!t){var n=t.currentTime,u=this.startPosition;if(u>=0&&n<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+n);return}var a=O.BufferHelper.getBuffered(t),d=a.length?a.start(0):0,v=d-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+n),t.currentTime=u}}},o._getAudioCodec=function(t){var n=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n},o._loadBitrateTestFrag=function(t){var n=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var a=n.hls;if(!(!u||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=L.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),a.trigger(M.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,u="main",a=this.hls,d=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var T=S.frag,I=S.part,k=S.level,B=d.video,U=d.text,W=d.id3,G=d.initSegment,z=k.details,Y=this.altAudio?void 0:d.audio;if(!this.fragContextChanged(T)){if(this.state=L.State.PARSING,G){G.tracks&&(this._bufferInitSegment(k,G.tracks,T,v),a.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:u,tracks:G.tracks}));var $=G.initPTS,Z=G.timescale;Object(P.isFiniteNumber)($)&&(this.initPTS[T.cc]=$,a.trigger(M.Events.INIT_PTS_FOUND,{frag:T,id:u,initPTS:$,timescale:Z}))}if(B&&d.independent!==!1){if(z){var q=B.startPTS,ie=B.endPTS,ne=B.startDTS,ae=B.endDTS;if(I)I.elementaryStreams[B.type]={startPTS:q,endPTS:ie,startDTS:ne,endDTS:ae};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var te=this.getMainFwdBufferInfo(),fe=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,de=B.firstKeyFramePTS?B.firstKeyFramePTS:q;if(fe<de-this.config.maxBufferHole){this.backtrack(T);return}T.setElementaryStreamInfo(B.type,T.start,ie,T.start,ae,!0)}T.setElementaryStreamInfo(B.type,q,ie,ne,ae),this.backtrackFragment&&(this.backtrackFragment=T),this.bufferFragmentData(B,T,I,v)}}else if(d.independent===!1){this.backtrack(T);return}if(Y){var re=Y.startPTS,Ee=Y.endPTS,me=Y.startDTS,Te=Y.endDTS;I&&(I.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:Ee,startDTS:me,endDTS:Te}),T.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,Ee,me,Te),this.bufferFragmentData(Y,T,I,v)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:u,frag:T,details:z,samples:W.samples};a.trigger(M.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var _e={id:u,frag:T,details:z,samples:U.samples};a.trigger(M.Events.FRAG_PARSING_USERDATA,_e)}}},o._bufferInitSegment=function(t,n,u,a){var d=this;if(this.state===L.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var v=n.audio,S=n.video,T=n.audiovideo;if(v){var I=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),v.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),t.audioCodec&&t.audioCodec!==I&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+I+'"'),v.levelCodec=I,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),T&&this.log("Init audiovideo buffer, container:"+T.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+T.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&d.hls.trigger(M.Events.BUFFER_APPENDING,{type:B,data:W,frag:u,part:null,chunkMeta:a,parent:u.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},o.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(O.BufferHelper.isBuffered(t,u)?n=this.getAppendedFrag(u):O.BufferHelper.isBuffered(t,u+.1)&&(n=this.getAppendedFrag(u+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,d=n.level;(!a||n.sn!==a.sn||a.level!==d||n.urlId!==a.urlId)&&(this.hls.trigger(M.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==d)&&this.hls.trigger(M.Events.LEVEL_SWITCHED,{level:d}),this.fragPlaying=n)}}},f(r,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var n=t.currentTime,u=this.currentFrag;if(u&&Object(P.isFiniteNumber)(n)&&Object(P.isFiniteNumber)(u.programDateTime)){var a=u.programDateTime+(n-u.start)*1e3;return new Date(a)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"SubtitleStreamController",function(){return e});var P=l("./src/events.ts"),L=l("./src/utils/buffer-helper.ts"),A=l("./src/controller/fragment-finders.ts"),M=l("./src/utils/discontinuities.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/controller/base-stream-controller.ts"),y=l("./src/types/loader.ts"),x=l("./src/types/level.ts");function D(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&D(h.prototype,g),i&&D(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(h,g)}var f=500,e=function(h){m(g,h);function g(r,o){var c;return c=h.call(this,r,o,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(P.Events.ERROR,this.onError,this),o.on(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(P.Events.ERROR,this.onError,this),o.off(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(f),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(o,c){var t=c.frag,n=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!n){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var a,d=t.start,v=0;v<u.length;v++)if(d>=u[v].start&&d<=u[v].end){a=u[v];break}var S=t.start+t.duration;a?a.end=S:(a={start:d,end:S},u.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,c){var t=c.startOffset,n=c.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var d=a[u].details,v=d.targetduration,S=n-v;if(S<=0)return;c.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(T){for(var I=0;I<T.length;){if(T[I].end<=S){T.shift();continue}else if(T[I].start<S)T[I].start=S;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(o,c){var t,n=c.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(o,c){var t=this,n=c.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(u){return new x.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(f)},i.onSubtitleTrackLoaded=function(o,c){var t,n=c.details,u=c.id,a=this.currentTrackId,d=this.levels;if(!!d.length){var v=d[a];if(!(u>=d.length||u!==a||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var T=S.fragments[0];if(!v.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(n,S):T&&Object(O.addSliding)(n,T.start);else{var I=this.alignPlaylists(n,v.details);I===0&&T&&Object(O.addSliding)(n,T.start)}}if(v.details=n,this.levelLastLoaded=u,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var k=Object(A.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var c=o.frag,t=o.payload,n=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),n.key.buffer,n.iv.buffer).then(function(d){var v=performance.now();u.trigger(P.Events.FRAG_DECRYPTED,{frag:c,payload:d,stats:{tstart:a,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var o=this.currentTrackId,c=this.levels;if(!c.length||!c[o]||!c[o].details)return;var t=c[o].details,n=t.targetduration,u=this.config,a=this.media,d=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,u.maxBufferHole),v=d.end,S=d.len,T=this.getMaxBufferLength()+n;if(S>T)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var I=t.fragments,k=I.length,B=t.edge,U,W=this.fragPrevious;if(v<B){var G=u.maxFragLookUpTolerance;U=Object(A.findFragmentByPTS)(W,I,Math.max(I[0].start,v),G),!U&&W&&W.start<I[0].start&&(U=I[0])}else U=I[k-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==b.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,v)}},i.loadFragment=function(o,c,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):h.prototype.loadFragment.call(this,o,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),s=function(g){this.buffered=void 0;var i=function(o,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][o]};this.buffered={get length(){return g.length},end:function(o){return i("end",o,g.length)},start:function(o){return i("start",o,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/utils/texttrack-utils.ts"),A=l("./src/controller/base-playlist-controller.ts"),M=l("./src/types/loader.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,e){return f.__proto__=e,f},y(E,m)}var x=function(E){_(m,E);function m(f){var e;return e=E.call(this,f,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var p=m.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(P.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(P.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,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))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(s){Object(L.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},p.onSubtitleTrackLoaded=function(e,s){var h=s.id,g=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var o=r.details;r.details=s.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,s,o))},p.onLevelLoading=function(e,s){this.switchLevel(s.level)},p.onLevelSwitching=function(e,s){this.switchLevel(s.level)},p.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var h=s.textGroupIds[s.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(P.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,h=0;h<s.length;h++){var g=s[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===M.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},p.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var h=s.id,g=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(P.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,h=this.media,g=this.trackId;if(!!h){var i=D(h.textTracks),r=i.filter(function(t){return t.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var o=r[g];o&&(o.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,c=o===void 0?"":o,t=i.name,n=i.type,u=i.url;this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:n,url:u});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=D(this.media.textTracks),h=0;h<s.length;h++)if(s[h].mode==="hidden")e=h;else if(s[h].mode==="showing"){e=h;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},b(m,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),m}(A.default);function D(E){for(var m=[],p=0;p<E.length;p++){var f=E[p];f.kind==="subtitles"&&f.label&&m.push(E[p])}return m}R.default=x},"./src/controller/timeline-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"TimelineController",function(){return E});var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/cea-608-parser.ts"),M=l("./src/utils/output-filter.ts"),O=l("./src/utils/webvtt-parser.ts"),b=l("./src/utils/texttrack-utils.ts"),_=l("./src/utils/imsc1-ttml-parser.ts"),y=l("./src/utils/mp4-tools.ts"),x=l("./src/types/loader.ts"),D=l("./src/utils/logger.ts"),E=function(){function e(h){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.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.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 g=new M.default(this,"textTrack1"),i=new M.default(this,"textTrack2"),r=new M.default(this,"textTrack3"),o=new M.default(this,"textTrack4");this.cea608Parser1=new A.default(1,g,i),this.cea608Parser2=new A.default(3,r,o)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(g,i,r,o,c){for(var t=!1,n=c.length;n--;){var u=c[n],a=p(u[0],u[1],i,r);if(a>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,a/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var d=this.captionsTracks[g];this.Cues.newCue(d,i,r,o)}else{var v=this.Cues.newCue(null,i,r,o);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},s.onInitPtsFound=function(g,i){var r=this,o=i.frag,c=i.id,t=i.initPTS,n=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),u.length&&(this.unparsedVttFrags=[],u.forEach(function(a){r.onFragLoaded(L.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[g])return o}return null},s.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},s.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,c=i[g],t=c.label,n=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(b.clearCurrentCues)(r[g]),Object(b.sendAddTrackEvent)(r[g],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[g]=!0,r[g]=a)}}},s.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,o={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=o,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(g,i,r){var o=this.media;if(!!o)return o.addTextTrack(g,i,r)},s.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(b.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),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())},s._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(b.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],c=o.some(function(a){return a.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&o&&this.tracks.length===o.length;if(this.tracks=o||[],this.config.renderTextTracksNatively){var n=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,d){var v;if(d<n.length){for(var S=null,T=0;T<n.length;T++)if(m(n[T],a)){S=n[T];break}S&&(v=S)}if(v)Object(b.clearCurrentCues)(v);else{var I=r._captionsOrSubtitlesFromCharacteristics(a);v=r.createTextTrack(I,a.name,a.lang),v&&(v.mode="disabled")}v&&(v.groupId=a.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},s._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var c=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!c){var t="textTrack"+c[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===x.PlaylistLevelType.MAIN){var n,u,a=i.frag.sn,d=(n=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?n:-1;a===c+1||a===c&&d===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=d}},s.onFragLoaded=function(g,i){var r=i.frag,o=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===x.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(P.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,u="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||u){var a=this.tracks[r.level],d=this.vttCCs;d[r.cc]||(d[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,d)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(g,i){var r=this,o=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){D.logger.log("Failed to parse IMSC1: "+c),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},s._parseVTTs=function(g,i,r){var o,c=this,t=this.hls,n=(o=g.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(O.parseWebVTT)(n,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),D.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},s._fallbackToIMSC1=function(g,i){var r=this,o=this.tracks[g.level];o.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){o.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;g.forEach(function(n){return Object(b.addCueToTrack)(o,n)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},s.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===x.PlaylistLevelType.SUBTITLE){if(!Object(P.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[c].pts,n[0]),o.addData(i.samples[c].pts,n[1])}}},s.onBufferFlushing=function(g,i){var r=i.startOffset,o=i.endOffset,c=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(d){return Object(b.removeCuesInRange)(u[d],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(d){return Object(b.removeCuesInRange)(a[d],r,c)})}}},s.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,o=2,c=0;c<r;c++){var t=g[o++],n=127&g[o++],u=127&g[o++];if(!(n===0&&u===0)){var a=(4&t)!==0;if(a){var d=3&t;(d===0||d===1)&&(i[d].push(n),i[d].push(u))}}}return i},e}();function m(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,h,g){return Math.min(s,g)-Math.max(e,h)}function f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.subtle=void 0,this.aesIV=void 0,this.subtle=M,this.aesIV=O}var A=L.prototype;return A.decrypt=function(O,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,O)},L}()},"./src/crypt/aes-decryptor.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"removePadding",function(){return L}),l.d(R,"default",function(){return A});var P=l("./src/utils/typed-array.ts");function L(M){var O=M.byteLength,b=O&&new DataView(M.buffer).getUint8(O-1);return b?Object(P.sliceUint8)(M,0,O-b):M}var A=function(){function M(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var O=M.prototype;return O.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),x=new Uint32Array(4),D=0;D<4;D++)x[D]=y.getUint32(D*4);return x},O.initTable=function(){var _=this.sBox,y=this.invSBox,x=this.subMix,D=x[0],E=x[1],m=x[2],p=x[3],f=this.invSubMix,e=f[0],s=f[1],h=f[2],g=f[3],i=new Uint32Array(256),r=0,o=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var n=i[r],u=i[n],a=i[u],d=i[t]*257^t*16843008;D[r]=d<<24|d>>>8,E[r]=d<<16|d>>>16,m[r]=d<<8|d>>>24,p[r]=d,d=a*16843009^u*65537^n*257^r*16843008,e[t]=d<<24|d>>>8,s[t]=d<<16|d>>>16,h[t]=d<<8|d>>>24,g[t]=d,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},O.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),x=!0,D=0;D<y.length&&x;)x=y[D]===this.key[D],D++;if(!x){this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var m=this.ksRows=(E+6+1)*4,p,f,e=this.keySchedule=new Uint32Array(m),s=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],o=i[1],c=i[2],t=i[3],n,u;for(p=0;p<m;p++){if(p<E){n=e[p]=y[p];continue}u=n,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=n=(e[p-E]^u)>>>0}for(f=0;f<m;f++)p=m-f,f&3?u=e[p]:u=e[p-4],f<4||p<=4?s[f]=u:s[f]=r[h[u>>>24]]^o[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],s[f]=s[f]>>>0}},O.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},O.decrypt=function(_,y,x){for(var D=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,f=p[0],e=p[1],s=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(x),i=g[0],r=g[1],o=g[2],c=g[3],t=new Int32Array(_),n=new Int32Array(t.length),u,a,d,v,S,T,I,k,B,U,W,G,z,Y,$=this.networkToHostOrderSwap;y<t.length;){for(B=$(t[y]),U=$(t[y+1]),W=$(t[y+2]),G=$(t[y+3]),S=B^E[0],T=G^E[1],I=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)u=f[S>>>24]^e[T>>16&255]^s[I>>8&255]^h[k&255]^E[z],a=f[T>>>24]^e[I>>16&255]^s[k>>8&255]^h[S&255]^E[z+1],d=f[I>>>24]^e[k>>16&255]^s[S>>8&255]^h[T&255]^E[z+2],v=f[k>>>24]^e[S>>16&255]^s[T>>8&255]^h[I&255]^E[z+3],S=u,T=a,I=d,k=v,z=z+4;u=m[S>>>24]<<24^m[T>>16&255]<<16^m[I>>8&255]<<8^m[k&255]^E[z],a=m[T>>>24]<<24^m[I>>16&255]<<16^m[k>>8&255]<<8^m[S&255]^E[z+1],d=m[I>>>24]<<24^m[k>>16&255]<<16^m[S>>8&255]<<8^m[T&255]^E[z+2],v=m[k>>>24]<<24^m[S>>16&255]<<16^m[T>>8&255]<<8^m[I&255]^E[z+3],n[y]=$(u^i),n[y+1]=$(v^r),n[y+2]=$(d^o),n[y+3]=$(a^c),i=B,r=U,o=W,c=G,y=y+4}return n.buffer},M}()},"./src/crypt/decrypter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return y});var P=l("./src/crypt/aes-crypto.ts"),L=l("./src/crypt/fast-aes-key.ts"),A=l("./src/crypt/aes-decryptor.ts"),M=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=16,y=function(){function x(E,m,p){var f=p===void 0?{}:p,e=f.removePKCS7Padding,s=e===void 0?!0:e;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=E,this.config=m,this.removePKCS7Padding=s,s)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=x.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(m,p,f,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,f);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,f).then(e)},D.softwareDecrypt=function(m,p,f){var e=this.currentIV,s=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(O.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(f=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new A.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(g.buffer,0,f),this.currentIV=Object(b.sliceUint8)(g,-16).buffer,r||null},D.webCryptoDecrypt=function(m,p,f){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(s,p)),this.fastAesKey.expandKey().then(function(h){if(!s)return Promise.reject(new Error("web crypto not initialized"));var g=new P.default(s,f);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,f)})},D.onWebCryptoError=function(m,p,f,e){return M.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,f,e)},D.getValidChunk=function(m){var p=m,f=m.length-m.length%_;return f!==m.length&&(p=Object(b.sliceUint8)(m,0,f),this.remainderData=Object(b.sliceUint8)(m,f)),p},D.logOnce=function(m){!this.logEnabled||(M.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.subtle=void 0,this.key=void 0,this.subtle=M,this.key=O}var A=L.prototype;return A.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/adts.ts"),A=l("./src/utils/logger.ts"),M=l("./src/demux/id3.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(E,m){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=m,p}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=M.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(L.probe(m,f))return A.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(m,p){return L.canParse(m,p)},D.appendFrame=function(m,p,f){L.initTrackConfig(m,this.observer,p,f,m.manifestCodec);var e=L.appendFrame(m,p,f,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},x}(P.default);R.default=_},"./src/demux/adts.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getAudioConfig",function(){return M}),l.d(R,"isHeaderPattern",function(){return O}),l.d(R,"getHeaderLength",function(){return b}),l.d(R,"getFullFrameLength",function(){return _}),l.d(R,"canGetFrameLength",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E}),l.d(R,"initTrackConfig",function(){return m}),l.d(R,"getFrameDuration",function(){return p}),l.d(R,"parseFrameHeader",function(){return f}),l.d(R,"appendFrame",function(){return e});var P=l("./src/utils/logger.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts");function M(s,h,g,i){var r,o,c,t,n=navigator.userAgent.toLowerCase(),u=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var d=(h[g+2]&60)>>>2;if(d>a.length-1){s.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,P.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+d),/firefox/i.test(n)?d>=6?(r=5,t=new Array(4),o=d-3):(r=2,t=new Array(2),o=d):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=d):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?o=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&c===1||/vivaldi/i.test(n))||!i&&c===1)&&(r=2,t=new Array(2)),o=d)),t[0]=r<<3,t[0]|=(d&14)>>1,t[1]|=(d&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[d],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function O(s,h){return s[h]===255&&(s[h+1]&246)===240}function b(s,h){return s[h+1]&1?7:9}function _(s,h){return(s[h+3]&3)<<11|s[h+4]<<3|(s[h+5]&224)>>>5}function y(s,h){return h+5<s.length}function x(s,h){return h+1<s.length&&O(s,h)}function D(s,h){return y(s,h)&&O(s,h)&&_(s,h)<=s.length-h}function E(s,h){if(x(s,h)){var g=b(s,h);if(h+g>=s.length)return!1;var i=_(s,h);if(i<=g)return!1;var r=h+i;return r===s.length||x(s,r)}return!1}function m(s,h,g,i,r){if(!s.samplerate){var o=M(h,g,i,r);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,P.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function f(s,h){var g=b(s,h);if(h+g<=s.length){var i=_(s,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(s,h,g,i,r){var o=p(s.samplerate),c=i+r*o,t=f(h,g),n;if(t){var u=t.frameLength,a=t.headerLength,d=a+u,v=Math.max(0,g+d-h.length);v?(n=new Uint8Array(d-a),n.set(h.subarray(g+a,h.length),0)):n=h.subarray(g+a,g+d);var S={unit:n,pts:c};return v||s.samples.push(S),{sample:S,length:d,missing:v}}var T=h.length-g;n=new Uint8Array(T),n.set(h.subarray(g,h.length),0);var I={unit:n,pts:c};return{sample:I,length:T,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"initPTSFn",function(){return y});var P=l("./src/polyfills/number.ts"),L=l("./src/demux/id3.ts"),A=l("./src/types/demuxer.ts"),M=l("./src/demux/dummy-demuxed-track.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(m,p){return!1},D.appendFrame=function(m,p,f){},D.demux=function(m,p){this.cachedData&&(m=Object(O.appendUint8Array)(this.cachedData,m),this.cachedData=null);var f=L.getID3Data(m,0),e=f?f.length:0,s,h,g=this._audioTrack,i=this._id3Track,r=f?L.getTimeStamp(f):void 0,o=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(P.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),f&&f.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:f,type:A.MetadataSchema.audioId3}),h=this.basePTS;e<o;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,s=e):e=o}else L.canParse(m,e)?(f=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:f,type:A.MetadataSchema.audioId3}),e+=f.length,s=e):e++;if(e===o&&s!==o){var t=Object(b.sliceUint8)(m,s);this.cachedData?this.cachedData=Object(O.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(M.dummyTrack)(),id3Track:i,textTrack:Object(M.dummyTrack)()}},D.demuxSampleAes=function(m,p,f){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},D.destroy=function(){},x}(),y=function(D,E,m){return Object(P.isFiniteNumber)(D)?D*90:E*9e4+(m||0)};R.default=_},"./src/demux/chunk-cache.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function A(){this.chunks=[],this.dataLength=0}var M=A.prototype;return M.push=function(b){this.chunks.push(b),this.dataLength+=b.length},M.flush=function(){var b=this.chunks,_=this.dataLength,y;if(b.length)b.length===1?y=b[0]:y=L(b,_);else return new Uint8Array(0);return this.reset(),y},M.reset=function(){this.chunks.length=0,this.dataLength=0},A}();function L(A,M){for(var O=new Uint8Array(M),b=0,_=0;_<A.length;_++){var y=A[_];O.set(y,b),b+=y.length}return O}},"./src/demux/dummy-demuxed-track.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"dummyTrack",function(){return P});function P(L,A){return L===void 0&&(L=""),A===void 0&&(A=9e4),{type:L,id:-1,pid:-1,inputTimeScale:A,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/logger.ts"),L=function(){function A(O){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=O,this.bytesAvailable=O.byteLength,this.word=0,this.bitsAvailable=0}var M=A.prototype;return M.loadWord=function(){var b=this.data,_=this.bytesAvailable,y=b.byteLength-_,x=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");x.set(b.subarray(y,y+D)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},M.skipBits=function(b){var _;this.bitsAvailable>b?(this.word<<=b,this.bitsAvailable-=b):(b-=this.bitsAvailable,_=b>>3,b-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=b,this.bitsAvailable-=b)},M.readBits=function(b){var _=Math.min(this.bitsAvailable,b),y=this.word>>>32-_;return b>32&&P.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=b-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},M.skipLZ=function(){var b;for(b=0;b<this.bitsAvailable;++b)if((this.word&2147483648>>>b)!==0)return this.word<<=b,this.bitsAvailable-=b,b;return this.loadWord(),b+this.skipLZ()},M.skipUEG=function(){this.skipBits(1+this.skipLZ())},M.skipEG=function(){this.skipBits(1+this.skipLZ())},M.readUEG=function(){var b=this.skipLZ();return this.readBits(b+1)-1},M.readEG=function(){var b=this.readUEG();return 1&b?1+b>>>1:-1*(b>>>1)},M.readBoolean=function(){return this.readBits(1)===1},M.readUByte=function(){return this.readBits(8)},M.readUShort=function(){return this.readBits(16)},M.readUInt=function(){return this.readBits(32)},M.skipScalingList=function(b){for(var _=8,y=8,x,D=0;D<b;D++)y!==0&&(x=this.readEG(),y=(_+x+256)%256),_=y===0?_:y},M.readSPS=function(){var b=0,_=0,y=0,x=0,D,E,m,p=this.readUByte.bind(this),f=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(f(5),h(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var c=e();if(c===3&&h(1),i(),i(),h(1),s())for(E=c!==3?8:12,m=0;m<E;m++)s()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),D=e(),m=0;m<D;m++)g();i(),h(1);var n=e(),u=e(),a=f(1);a===0&&h(1),h(1),s()&&(b=e(),_=e(),y=e(),x=e());var d=[1,1];if(s()&&s()){var v=p();switch(v){case 1:d=[1,1];break;case 2:d=[12,11];break;case 3:d=[10,11];break;case 4:d=[16,11];break;case 5:d=[40,33];break;case 6:d=[24,11];break;case 7:d=[20,11];break;case 8:d=[32,11];break;case 9:d=[80,33];break;case 10:d=[18,11];break;case 11:d=[15,11];break;case 12:d=[64,33];break;case 13:d=[160,99];break;case 14:d=[4,3];break;case 15:d=[3,2];break;case 16:d=[2,1];break;case 255:{d=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((n+1)*16-b*2-_*2),height:(2-a)*(u+1)*16-(a?2:4)*(y+x),pixelRatio:d}},M.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();R.default=L},"./src/demux/id3.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isHeader",function(){return P}),l.d(R,"isFooter",function(){return L}),l.d(R,"getID3Data",function(){return A}),l.d(R,"canParse",function(){return O}),l.d(R,"getTimeStamp",function(){return b}),l.d(R,"isTimeStampFrame",function(){return _}),l.d(R,"getID3Frames",function(){return x}),l.d(R,"decodeFrame",function(){return D}),l.d(R,"utf8ArrayToStr",function(){return e}),l.d(R,"testables",function(){return s});var P=function(r,o){return o+10<=r.length&&r[o]===73&&r[o+1]===68&&r[o+2]===51&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},L=function(r,o){return o+10<=r.length&&r[o]===51&&r[o+1]===68&&r[o+2]===73&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},A=function(r,o){for(var c=o,t=0;P(r,o);){t+=10;var n=M(r,o+6);t+=n,L(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(c,c+t)},M=function(r,o){var c=0;return c=(r[o]&127)<<21,c|=(r[o+1]&127)<<14,c|=(r[o+2]&127)<<7,c|=r[o+3]&127,c},O=function(r,o){return P(r,o)&&M(r,o+6)+10<=r.length-o},b=function(r){for(var o=x(r),c=0;c<o.length;c++){var t=o[c];if(_(t))return f(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var o=String.fromCharCode(r[0],r[1],r[2],r[3]),c=M(r,4),t=10;return{type:o,size:c,data:r.subarray(t,t+c)}},x=function(r){for(var o=0,c=[];P(r,o);){var t=M(r,o+6);o+=10;for(var n=o+t;o+8<n;){var u=y(r.subarray(o)),a=D(u);a&&c.push(a),o+=u.size+10}L(r,o)&&(o+=10)}return c},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var o=e(r.data,!0),c=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data.subarray(1));return{key:r.type,data:n}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data);return{key:r.type,data:n}},f=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),c=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var c=g();if(c){var t=c.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var u=r.length,a,d,v,S="",T=0;T<u;){if(a=r[T++],a===0&&o)return S;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:d=r[T++],S+=String.fromCharCode((a&31)<<6|d&63);break;case 14:d=r[T++],v=r[T++],S+=String.fromCharCode((a&15)<<12|(d&63)<<6|(v&63)<<0);break;default:}}return S},s={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/id3.ts"),A=l("./src/utils/logger.ts"),M=l("./src/demux/mpegaudio.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(){return y.apply(this,arguments)||this}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=L.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(M.probe(m,f))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(m,p){return M.canParse(m,p)},D.appendFrame=function(m,p,f){if(this.basePTS!==null)return M.appendFrame(m,p,f,this.basePTS,this.frameIndex)},x}(P.default);R.default=_},"./src/demux/mp4demuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/types/demuxer.ts"),A=l("./src/utils/mp4-tools.ts"),M=l("./src/demux/dummy-demuxed-track.ts"),O=/\/emsg[-/]ID3/i,b=function(){function _(x,D){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=D}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,m,p){var f=Object(A.parseInitSegment)(D),e=this.videoTrack=Object(M.dummyTrack)("video",1),s=this.audioTrack=Object(M.dummyTrack)("audio",1),h=this.txtTrack=Object(M.dummyTrack)("text",1);if(this.id3Track=Object(M.dummyTrack)("id3",1),this.timeOffset=0,f.video){var g=f.video,i=g.id,r=g.timescale,o=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=o}if(f.audio){var c=f.audio,t=c.id,n=c.timescale,u=c.codec;s.id=t,s.timescale=n,s.codec=u}h.id=A.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(A.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var m=D,p=this.videoTrack,f=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(A.appendUint8Array)(this.remainderData,D));var e=Object(A.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var s=this.extractID3Track(p,E);return f.samples=Object(A.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,m=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return m.samples=Object(A.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(M.dummyTrack)(),id3Track:p,textTrack:Object(M.dummyTrack)()}},y.extractID3Track=function(D,E){var m=this.id3Track;if(D.samples.length){var p=Object(A.findBox)(D.samples,["emsg"]);p&&p.forEach(function(f){var e=Object(A.parseEmsg)(f);if(O.test(e.schemeIdUri)){var s=Object(P.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:s,pts:s,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(D,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();R.default=b},"./src/demux/mpegaudio.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"appendFrame",function(){return b}),l.d(R,"parseHeader",function(){return _}),l.d(R,"isHeaderPattern",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E});var P=null,L=[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],M=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],O=[0,1,1,4];function b(m,p,f,e,s){if(!(f+24>p.length)){var h=_(p,f);if(h&&f+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+s*g,r={unit:p.subarray(f,f+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var f=m[p+1]>>3&3,e=m[p+1]>>1&3,s=m[p+2]>>4&15,h=m[p+2]>>2&3;if(f!==1&&s!==0&&s!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=f===3?3-e:e===3?3:4,o=L[r*14+s-1]*1e3,c=f===3?0:f===2?1:2,t=A[c*3+h],n=i===3?1:2,u=M[f][e],a=O[e],d=u*8*a,v=Math.floor(u*o/t+g)*a;if(P===null){var S=navigator.userAgent||"",T=S.match(/Chrome\/(\d+)/i);P=T?parseInt(T[1]):0}var I=!!P&&P<=87;return I&&e===2&&o>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:n,frameLength:v,samplesPerFrame:d}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function x(m,p){return p+1<m.length&&y(m,p)}function D(m,p){var f=4;return y(m,p)&&f<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var f=4,e=_(m,p),s=f;e!=null&&e.frameLength&&(s=e.frameLength);var h=p+s;return h===m.length||x(m,h)}return!1}},"./src/demux/sample-aes.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/crypt/decrypter.ts"),L=l("./src/demux/tsdemuxer.ts"),A=function(){function M(b,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new P.default(b,_,{removePKCS7Padding:!1})}var O=M.prototype;return O.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},O.decryptAacSample=function(_,y,x,D){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),f=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||f.decryptAacSamples(_,y+1,x)})}},O.decryptAacSamples=function(_,y,x){for(;;y++){if(y>=_.length){x();return}if(!(_[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,y,x,D),!D)return}}},O.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,x=new Int8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)x.set(_.subarray(E,E+16),D);return x},O.getAvcDecryptedUnit=function(_,y){for(var x=new Uint8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)_.set(x.subarray(D,D+16),E);return _},O.decryptAvcSample=function(_,y,x,D,E,m){var p=Object(L.discardEPB)(E.data),f=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(f.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),m||e.decryptAvcSamples(_,y,x+1,D)})},O.decryptAvcSamples=function(_,y,x,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,x=0){if(y>=_.length){D();return}for(var E=_[y].units;!(x>=E.length);x++){var m=E[x];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,y,x,D,m,p),!p)return}}}},M}();R.default=A},"./src/demux/transmuxer-interface.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./node_modules/webworkify-webpack/index.js"),L=l.n(P),A=l("./src/events.ts"),M=l("./src/demux/transmuxer.ts"),O=l("./src/utils/logger.ts"),b=l("./src/errors.ts"),_=l("./src/utils/mediasource-helper.ts"),y=l("./node_modules/eventemitter3/index.js"),x=l.n(y),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(f,e,s,h){var g=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=f,this.id=e,this.onTransmuxComplete=s,this.onFlush=h;var i=f.config,r=function(u,a){a=a||{},a.frag=g.frag,a.id=g.id,f.trigger(u,a)};this.observer=new y.EventEmitter,this.observer.on(A.Events.FRAG_DECRYPTED,r),this.observer.on(A.Events.ERROR,r);var o={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){O.logger.log("demuxing in webworker");var t;try{t=this.worker=P("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){f.trigger(A.Events.ERROR,{type:b.ErrorTypes.OTHER_ERROR,details:b.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:c,id:e,config:JSON.stringify(i)})}catch(n){O.logger.warn("Error in worker:",n),O.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new M.default(this.observer,o,i,c,e),this.worker=null}}else this.transmuxer=new M.default(this.observer,o,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,h,g,i,r,o,c,t,n){var u,a,d=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,T=r?r.start:i.start,I=i.decryptdata,k=this.frag,B=!(k&&i.cc===k.cc),U=!(k&&t.level===k.level),W=k?t.sn-k.sn:-1,G=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(k==null?void 0:k.stats.chunkCount),Y=!U&&(W===1||W===0&&(G===1||z&&G<=0)),$=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=$),r&&(G||!Y)&&(r.stats.parsing.start=$);var Z=!(k&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new M.TransmuxState(B,Y,c,U,T,Z);if(!Y||B||Z){O.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
|
|
13
|
+
Time to underbuffer: `+I.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),f.loader&&(this.fragCurrent=this.partCurrent=null,f.loader.abort()),s.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:f,part:e,stats:r})}}}}}},m.onFragLoaded=function(f,e){var s=e.frag,h=e.part;if(s.type===b.PlaylistLevelType.MAIN&&Object(C.isFiniteNumber)(s.sn)){var g=h?h.stats:s.stats,i=h?h.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[s.level],o=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:c},r.realBitrate=Math.round(8*o/c)}if(s.bitrateTest){var t={stats:g,frag:s,part:h,id:s.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(f,e){var s=e.frag,h=e.part,g=h?h.stats:s.stats;if(!g.aborted&&!(s.type!==b.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(f,e){switch(e.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.maxAutoLevel,g=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:f?f.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(w.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,a=this.findBestLevel(n,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(a>=0)return a;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=o?Math.min(o,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var T=this.bitrateTestDelay;if(T){var I=o?Math.min(o,g.maxLoadingDelay):g.maxLoadingDelay;d=I-T,_.logger.trace("bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),v=S=1}}return a=this.findBestLevel(n,i,h,u+d,v,S),Math.max(a,0)},m.findBestLevel=function(f,e,s,h,g,i){for(var r,o=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,u=n[t],a=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),d=u==null?void 0:u.codecSet,v=c?c.duration:o?o.duration:0,S=s;S>=e;S--){var T=n[S];if(!(!T||d&&T.codecSet!==d)){var I=T.details,k=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||v,B=void 0;S<=t?B=g*f:B=i*f;var U=n[S].maxBitrate,W=U*k/B;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+h+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<h))return S}}return-1},x(E,[{key:"nextAutoLevel",get:function(){var f=this._nextAutoLevel,e=this.bwEstimator;if(f!==-1&&!e.canEstimate())return f;var s=this.getNextABRAutoLevel();return f!==-1&&this.hls.levels[s].loadError?f:(f!==-1&&(s=Math.min(f,s)),s)},set:function(f){this._nextAutoLevel=f}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/events.ts"),w=l("./src/utils/buffer-helper.ts"),O=l("./src/controller/fragment-tracker.ts"),b=l("./src/types/level.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/chunk-cache.ts"),D=l("./src/demux/transmuxer-interface.ts"),E=l("./src/types/transmuxer.ts"),m=l("./src/controller/fragment-finders.ts"),p=l("./src/utils/discontinuities.ts"),f=l("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var c=arguments[o];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,h(r,o)}function h(r,o){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},h(r,o)}var g=100,i=function(r){s(o,r);function o(t,n){var u;return u=r.call(this,t,n,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=o.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var n=this.hls;n.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(A.Events.ERROR,this.onError,this),n.on(A.Events.BUFFER_RESET,this.onBufferReset,this),n.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var n=this.hls;n.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(A.Events.ERROR,this.onError,this),n.off(A.Events.BUFFER_RESET,this.onBufferReset,this),n.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(n,u){var a=u.frag,d=u.id,v=u.initPTS;if(d==="main"){var S=a.cc;this.initPTS[a.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),n=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var n,u=this.levels,a=this.trackId,d=u==null||(n=u[a])===null||n===void 0?void 0:n.details;if(d){if(this.waitForCdnTuneIn(d))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),T=this.retryDate;(!T||S>=T||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var I=this.waitingData;if(I){var k=I.frag,B=I.part,U=I.cache,W=I.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var H=U.flush(),z={frag:k,part:B,payload:H,networkDetails:null};this._handleFragmentLoadProgress(z),W&&r.prototype._handleFragmentLoadComplete.call(this,z)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+k.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),$=w.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),ee=Object(m.fragmentWithinToleranceTest)($.end,this.config.maxFragLookUpTolerance,k);ee<0&&(this.log("Waiting fragment cc ("+k.cc+") @ "+k.start+" cancelled because another fragment at "+$.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var u=this.mediaBuffer?this.mediaBuffer:n,a=u.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},c.doTickIdle=function(){var n,u,a=this.hls,d=this.levels,v=this.media,S=this.trackId,T=a.config;if(!(!d||!d[S])&&!(!v&&(this.startFragRequested||!T.startFragPrefetch))){var I=d[S],k=I.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=L.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),H=U.len,z=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(H>=z&&!Y)){if(!Y&&this._streamEnded(U,k)){a.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var $=k.fragments,ee=$[0].start,q=U.end;if(Y&&v){var re=this.getLoadPosition();q=re,k.PTSKnown&&re<ee&&(U.end>ee||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=ee+.05)}if(!(W&&q>W.end+k.targetduration)&&!((!W||!W.len)&&U.len)){var ae=this.getNextFragment(q,k);if(!ae){this.bufferFlushed=!0;return}((n=ae.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((u=ae.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ae,k):this.loadFragment(ae,k,q)}}}}},c.getMaxBufferLength=function(n){var u=r.prototype.getMaxBufferLength.call(this);return n?Math.max(u,n):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(n,u){var a=u.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(d){return new b.Level(d)})},c.onAudioTrackSwitching=function(n,u){var a=!!u.url;this.trackId=u.id;var d=this.fragCurrent;d!=null&&d.loader&&d.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(g):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(n,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(A.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(n,u){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var d=this.levels,v=u.details,S=u.id;if(!d){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var T=d[S],I=0;if(v.live||(a=T.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!k)return;!T.details&&v.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,k),I=v.fragments[0].start):I=this.alignPlaylists(v,T.details)}T.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(T.details,I),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(n){var u,a=n.frag,d=n.part,v=n.payload,S=this.config,T=this.trackId,I=this.levels;if(!I){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var k=I[T];console.assert(k,"Audio track is defined on fragment load progress");var B=k.details;console.assert(B,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||k.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var H=this.initPTS[a.cc],z=(u=a.initSegment)===null||u===void 0?void 0:u.data;if(H!==void 0){var Y=!1,$=d?d.index:-1,ee=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,$,ee);W.push(v,z,U,"",a,d,B.totalduration,Y,q,H)}else{this.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+T);var re=this.waitingData=this.waitingData||{frag:a,part:d,cache:new x.default,complete:!1},ae=re.cache;ae.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(n,u){var a=u.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(n,u){var a=u.frag,d=u.part;if(a.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(d?" p: "+d.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}a.sn!=="initSegment"&&(this.fragPrevious=a,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,d)}},c.onError=function(n,u){switch(u.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case f.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var a=!0,d=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);d&&d.len>.5&&(a=!this.reduceMaxBufferLength(d.len)),a&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(n,u){var a=u.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(n){var u,a="audio",d=this.hls,v=n.remuxResult,S=n.chunkMeta,T=this.getCurrentContext(S);if(!T){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(S.level);return}var I=T.frag,k=T.part,B=T.level.details,U=v.audio,W=v.text,H=v.id3,z=v.initSegment;if(!(this.fragContextChanged(I)||!B)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,I,S),d.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:a,tracks:z.tracks})),U){var Y=U.startPTS,$=U.endPTS,ee=U.startDTS,q=U.endDTS;k&&(k.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:$,startDTS:ee,endDTS:q}),I.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,ee,q),this.bufferFragmentData(U,I,k,S)}if(H!=null&&(u=H.samples)!==null&&u!==void 0&&u.length){var re=e({id:a,frag:I,details:B},H);d.trigger(A.Events.FRAG_PARSING_METADATA,re)}if(W){var ae=e({id:a,frag:I,details:B},W);d.trigger(A.Events.FRAG_PARSING_USERDATA,ae)}}},c._bufferInitSegment=function(n,u,a){if(this.state===L.State.PARSING){n.video&&delete n.video;var d=n.audio;if(!!d){d.levelCodec=d.codec,d.id="audio",this.log("Init audio buffer, container:"+d.container+", codecs[parsed]=["+d.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,n);var v=d.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:a,parent:u.type,data:v};this.hls.trigger(A.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(n,u,a){var d=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||d===O.FragmentState.NOT_LOADED||d===O.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):u.live&&!Object(C.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,u,a)))},c.completeAudioSwitch=function(){var n=this.hls,u=this.media,a=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(L.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/controller/base-playlist-controller.ts"),w=l("./src/types/loader.ts");function O(D,E){for(var m=0;m<E.length;m++){var p=E[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function b(D,E,m){return E&&O(D.prototype,E),m&&O(D,m),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,E){D.prototype=Object.create(E.prototype),D.prototype.constructor=D,y(D,E)}function y(D,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,f){return p.__proto__=f,p},y(D,E)}var x=function(D){_(E,D);function E(p){var f;return f=D.call(this,p,"[audio-track-controller]")||this,f.tracks=[],f.groupId=null,f.tracksInGroup=[],f.trackId=-1,f.trackName="",f.selectDefaultTrack=!0,f.registerListeners(),f}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.on(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.on(C.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),f.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.off(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.off(C.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},m.onManifestParsed=function(f,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(f,e){var s=e.id,h=e.details,g=this.tracksInGroup[s];if(!g){this.warn("Invalid audio track id "+s);return}var i=g.details;g.details=e.details,this.log("audioTrack "+s+" loaded ["+h.startSN+"-"+h.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},m.onLevelLoading=function(f,e){this.switchLevel(e.level)},m.onLevelSwitching=function(f,e){this.switchLevel(e.level)},m.switchLevel=function(f){var e=this.hls.levels[f];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var h=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(C.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(f,e){D.prototype.onError.call(this,f,e),!(e.fatal||!e.context)&&e.context.type===w.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(f){var e=this.tracksInGroup;if(f<0||f>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+f);var h=e[f],g=h.id,i=h.groupId,r=i===void 0?"":i,o=h.name,c=h.type,t=h.url;if(this.trackId=f,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(C.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:o,type:c,url:t}),!(h.details&&!h.details.live)){var n=this.switchParams(h.url,s==null?void 0:s.details);this.loadPlaylist(n)}},m.selectInitialTrack=function(){var f=this.tracksInGroup;console.assert(f.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(f){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var h=e[s];if((!this.selectDefaultTrack||h.default)&&(!f||f===h.name))return h.id}return-1},m.loadPlaylist=function(f){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,h=e.groupId,g=e.url;if(f)try{g=f.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(C.Events.AUDIO_TRACK_LOADING,{url:g,id:s,groupId:h,deliveryDirectives:f||null})}},b(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(f){this.selectDefaultTrack=!1,this.setAudioTrack(f)}}]),E}(A.default);R.default=x},"./src/controller/base-playlist-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var C=l("./src/polyfills/number.ts"),L=l("./src/types/level.ts"),A=l("./src/controller/level-helper.ts"),w=l("./src/utils/logger.ts"),O=l("./src/errors.ts"),b=function(){function _(x,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=w.logger.log.bind(w.logger,D+":"),this.warn=w.logger.warn.bind(w.logger,D+":"),this.hls=x}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===O.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(D,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var f=m[p],e=""+f.URI;if(e===D.slice(-e.length)){var s=parseInt(f["LAST-MSN"]),h=parseInt(f["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(C.isFiniteNumber)(s))return new L.HlsUrlParameters(s,Object(C.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(D){},y.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},y.playlistLoaded=function(D,E,m){var p=this,f=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(f.advancedDateTime=Date.now()-s,f.live||m!=null&&m.live){if(f.reloaded(m),m&&this.log("live playlist "+D+" "+(f.advanced?"REFRESHED "+f.lastPartSn+"-"+f.lastPartIndex:"MISSED")),m&&f.fragments.length>0&&Object(A.mergeDetails)(m,f),!this.canLoad||!f.live)return;var h,g=void 0,i=void 0;if(f.canBlockReload&&f.endSN&&f.advanced){var r=this.hls.config.lowLatencyMode,o=f.lastPartSn,c=f.endSN,t=f.lastPartIndex,n=t!==-1,u=o===c,a=r?0:t;n?(g=u?c+1:o,i=u?a:t+1):g=c+1;var d=f.age,v=d+f.ageHeader,S=Math.min(v-f.partTarget,f.targetduration*1.5);if(S>0){if(m&&S>m.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+m.tuneInGoal+" to: "+S+" with playlist age: "+f.age),S=0;else{var T=Math.floor(S/f.targetduration);if(g+=T,i!==void 0){var I=Math.round(S%f.targetduration/f.partTarget);i+=I}this.log("CDN Tune-in age: "+f.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+S+" skip sn "+T+" to part "+i)}f.tuneInGoal=S}if(h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i);var k=Object(A.computeReloadInterval)(f,e);g!==void 0&&f.canBlockReload&&(k-=f.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,m,p){var f=Object(L.getSkipValue)(D,m);return E!=null&&E.skip&&D.deltaUpdateFailed&&(m=E.msn,p=E.part,f=L.HlsSkip.No),new L.HlsUrlParameters(m,p,f)},y.retryLoadingOrFail=function(D){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var f;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(f=D.context)!==null&&f!==void 0&&f.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*m.levelLoadingRetryDelay,m.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"State",function(){return c}),l.d(R,"default",function(){return t});var C=l("./src/polyfills/number.ts"),L=l("./src/task-loop.ts"),A=l("./src/controller/fragment-tracker.ts"),w=l("./src/utils/buffer-helper.ts"),O=l("./src/utils/logger.ts"),b=l("./src/events.ts"),_=l("./src/errors.ts"),y=l("./src/types/transmuxer.ts"),x=l("./src/utils/mp4-tools.ts"),D=l("./src/utils/discontinuities.ts"),E=l("./src/controller/fragment-finders.ts"),m=l("./src/controller/level-helper.ts"),p=l("./src/loader/fragment-loader.ts"),f=l("./src/crypt/decrypter.ts"),e=l("./src/utils/time-ranges.ts"),s=l("./src/types/loader.ts");function h(n,u){for(var a=0;a<u.length;a++){var d=u[a];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(n,d.key,d)}}function g(n,u,a){return u&&h(n.prototype,u),a&&h(n,a),Object.defineProperty(n,"prototype",{writable:!1}),n}function i(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function r(n,u){n.prototype=Object.create(u.prototype),n.prototype.constructor=n,o(n,u)}function o(n,u){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,v){return d.__proto__=v,d},o(n,u)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},t=function(n){r(u,n);function u(d,v,S){var T;return T=n.call(this)||this,T.hls=void 0,T.fragPrevious=null,T.fragCurrent=null,T.fragmentTracker=void 0,T.transmuxer=null,T._state=c.STOPPED,T.media=null,T.mediaBuffer=null,T.config=void 0,T.bitrateTest=!1,T.lastCurrentTime=0,T.nextLoadPosition=0,T.startPosition=0,T.loadedmetadata=!1,T.fragLoadError=0,T.retryDate=0,T.levels=null,T.fragmentLoader=void 0,T.levelLastLoaded=null,T.startFragRequested=!1,T.decrypter=void 0,T.initPTS=[],T.onvseeking=null,T.onvended=null,T.logPrefix="",T.log=void 0,T.warn=void 0,T.logPrefix=S,T.log=O.logger.log.bind(O.logger,S+":"),T.warn=O.logger.warn.bind(O.logger,S+":"),T.hls=d,T.fragmentLoader=new p.default(d.config),T.fragmentTracker=v,T.config=d.config,T.decrypter=new f.default(d,d.config),d.on(b.Events.KEY_LOADED,T.onKeyLoaded,i(T)),d.on(b.Events.LEVEL_SWITCHING,T.onLevelSwitching,i(T)),T}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},a._streamEnded=function(v,S){var T=this.fragCurrent,I=this.fragmentTracker;if(!S.live&&T&&this.media&&T.sn>=S.endSN&&!v.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=w.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=I.getState(T);return W===A.FragmentState.PARTIAL||W===A.FragmentState.OK}return!1},a.onMediaAttached=function(v,S){var T=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),T.addEventListener("seeking",this.onvseeking),T.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,T=this.media,I=this.mediaBuffer,k=this.state,B=T?T.currentTime:0,U=w.BufferHelper.bufferInfo(I||T,B,v.maxBufferHole);if(this.log("media seeking to "+(Object(C.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,H=S.start-W,z=S.start+S.duration+W,Y=B>z;(B<H||Y)&&(Y&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}T&&(this.lastCurrentTime=B),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var T=this.levels[S.frag.level].details;T&&this.loadFragment(S.frag,T,S.frag.start)}},a.onLevelSwitching=function(v,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(b.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,n.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(b.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,S,T){this._loadFragForPlayback(v,S,T)},a._loadFragForPlayback=function(v,S,T){var I=this,k=function(U){if(I.fragContextChanged(v)){I.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),I.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,I._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,T,k).then(function(B){if(!!B){I.fragLoadError=0;var U=I.state;if(I.fragContextChanged(v)){(U===c.FRAG_LOADING||!I.fragCurrent&&U===c.PARSING)&&(I.fragmentTracker.removeFragment(v),I.state=c.IDLE);return}"payload"in B&&(I.log("Loaded fragment "+v.sn+" of level "+v.level),I.hls.trigger(b.Events.FRAG_LOADED,B)),I._handleFragmentLoadComplete(B)}}).catch(function(B){I.state===c.STOPPED||I.state===c.ERROR||(I.warn(B),I.resetFragmentLoading(v))})},a.flushMainBuffer=function(v,S,T){if(T===void 0&&(T=null),!!(v-S)){var I={startOffset:v,endOffset:S,type:T};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},a._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(T){if(!T||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return T}).then(function(T){var I=S.hls,k=T.payload,B=v.decryptdata;if(k&&k.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(k),B.key.buffer,B.iv.buffer).then(function(W){var H=self.performance.now();return I.trigger(b.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:H}}),T.payload=W,T})}return T}).then(function(T){var I=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(T.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),T.frag===I&&k.trigger(b.Events.FRAG_BUFFERED,{stats:W,frag:I,part:null,id:v.type}),S.tick()}).catch(function(T){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(T),S.resetFragmentLoading(v))})},a.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},a.fragBufferedComplete=function(v,S){var T=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(T?e.default.toString(w.BufferHelper.getBuffered(T)):"(detached)")),this.state=c.IDLE,T&&(!this.loadedmetadata&&T.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var T=v.frag,I=v.part,k=v.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(T.level,T.sn,T.stats.chunkCount+1,0,I?I.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,S,T,I){var k=this;if(T===void 0&&(T=null),!this.levels)throw new Error("frag load aborted, missing levels");if(T=Math.max(v.start,T||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&I){T>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(B,v,T);if(U>-1){var W=B[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,part:B[U],targetBufferTime:T}),this.doFragPartsLoad(v,B,U,I).catch(function(H){return k.handleFragLoadError(H)})}else if(!v.url||this.loadedEndOfParts(B,T))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),Object(C.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,targetBufferTime:T}),this.fragmentLoader.load(v,I).catch(function(H){return k.handleFragLoadError(H)})},a.doFragPartsLoad=function(v,S,T,I){var k=this;return new Promise(function(B,U){var W=[],H=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(v,$,I).then(function(ee){W[$.index]=ee;var q=ee.part;k.hls.trigger(b.Events.FRAG_LOADED,ee);var re=S[Y+1];if(re&&re.fragment===v)z(Y+1);else return B({frag:v,part:q,partsLoaded:W})}).catch(U)};H(T)})},a.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(b.Events.ERROR,S),null},a._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var T=S.frag,I=S.part,k=S.level,B=self.performance.now();T.stats.parsing.end=B,I&&(I.stats.parsing.end=B),this.updateLevelTiming(T,I,k,v.partial)},a.getCurrentContext=function(v){var S=this.levels,T=v.level,I=v.sn,k=v.part;if(!S||!S[T])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+T+". The current chunk will not be buffered."),null;var B=S[T],U=k>-1?Object(m.getPartWith)(B,I,k):null,W=U?U.fragment:Object(m.getFragmentWithSN)(B,I,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(v,S,T,I){if(!(!v||this.state!==c.PARSING)){var k=v.data1,B=v.data2,U=k;if(k&&B&&(U=Object(x.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:v.type,frag:S,part:T,chunkMeta:I,parent:S.type,data:U};this.hls.trigger(b.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!T&&this.flushBufferGap(S)}}},a.flushBufferGap=function(v){var S=this.media;if(!!S){if(!w.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var T=S.currentTime,I=w.BufferHelper.bufferInfo(S,T,0),k=v.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(v.start-B,I.end-B),T+B);v.start-U>B&&this.flushMainBuffer(U,v.start)}},a.getFwdBufferInfo=function(v,S){var T=this.config,I=this.getLoadPosition();if(!Object(C.isFiniteNumber)(I))return null;var k=w.BufferHelper.bufferInfo(v,I,T.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(I,S);if(B&&k.nextStart<B.end)return w.BufferHelper.bufferInfo(v,I,Math.max(k.nextStart,T.maxBufferHole))}return k},a.getMaxBufferLength=function(v){var S=this.config,T;return v?T=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):T=S.maxBufferLength,Math.min(T,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var S=this.config,T=v||S.maxBufferLength;return S.maxMaxBufferLength>=T?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,S){var T=S.fragments,I=T.length;if(!I)return null;var k=this.config,B=T[0].start,U;if(S.live){var W=k.initialLiveManifestSize;if(I<W)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,T),this.startPosition=U?this.hls.liveSyncPosition||U.start:v)}else v<=B&&(U=T[0]);if(!U){var H=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,H,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},a.getNextPart=function(v,S,T){for(var I=-1,k=!1,B=!0,U=0,W=v.length;U<W;U++){var H=v[U];if(B=B&&!H.independent,I>-1&&T<H.start)break;var z=H.loaded;!z&&(k||H.independent||B)&&H.fragment===S&&(I=U),k=z}return I},a.loadedEndOfParts=function(v,S){var T=v[v.length-1];return T&&S>T.start&&T.loaded},a.getInitialLiveFragment=function(v,S){var T=this.fragPrevious,I=null;if(T){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+T.programDateTime),I=Object(E.findFragmentByPDT)(S,T.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=T.sn+1;if(k>=v.startSN&&k<=v.endSN){var B=S[k-v.startSN];T.cc===B.cc&&(I=B,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(S,T.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(I=this.getFragmentAtPosition(U,this.bitrateTest?v.fragmentEnd:v.edge,v))}return I},a.getFragmentAtPosition=function(v,S,T){var I=this.config,k=this.fragPrevious,B=T.fragments,U=T.endSN,W=T.fragmentHint,H=I.maxFragLookUpTolerance,z=!!(I.lowLatencyMode&&T.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(v<S){var $=v>S-H?0:H;Y=Object(E.findFragmentByPTS)(k,B,v,$)}else Y=B[B.length-1];if(Y){var ee=Y.sn-T.startSN;if(k&&Y.sn===k.sn&&!z){var q=k&&Y.level===k.level;if(q){var re=B[ee+1];Y.sn<U&&this.fragmentTracker.getState(re)!==A.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+re.sn),Y=re):Y=null}}}return Y},a.synchronizeToLiveEdge=function(v){var S=this.config,T=this.media;if(!!T){var I=this.hls.liveSyncPosition,k=T.currentTime,B=v.fragments[0].start,U=v.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(I!==null&&T.duration>I&&(k<I||!W)){var H=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&T.readyState<4||k<U-H)&&(this.loadedmetadata||(this.nextLoadPosition=I),T.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+I.toFixed(3)),T.currentTime=I))}}},a.alignPlaylists=function(v,S){var T=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,B=I!==null?T[I]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,H=!S,z=v.alignedSliding&&Object(C.isFiniteNumber)(W);if(H||!z&&!W){Object(D.alignStream)(k,B,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},a.setStartPosition=function(v,S){var T=this.startPosition;if(T<S&&(T=-1),T===-1||this.lastCurrentTime===-1){var I=v.startTimeOffset;Object(C.isFiniteNumber)(I)?(T=S+I,I<0&&(T+=v.totalduration),T=Math.min(Math.max(S,T),S+v.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+T),this.startPosition=T):v.live?T=this.hls.liveSyncPosition||S:this.startPosition=T=0,this.lastCurrentTime=T}this.nextLoadPosition=T},a.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},a.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var T=S.frag;if(!(!T||T.type!==v)){var I=this.fragCurrent;console.assert(I&&T.sn===I.sn&&T.level===I.level&&T.urlId===I.urlId,"Frag load error must match current frag to retry");var k=this.config;if(this.fragLoadError+1<=k.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var B=Math.min(Math.pow(2,this.fragLoadError)*k.fragLoadingRetryDelay,k.fragLoadingMaxRetryTimeout);this.warn("Fragment "+T.sn+" of "+v+" "+T.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(O.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},a.afterBufferFlushed=function(v,S,T){if(!!v){var I=w.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,I,T),this.state===c.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},a.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(v,S,T,I){var k=this,B=T.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,H){var z=v.elementaryStreams[H];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+v.sn+" "+H+" duration reliably ("+Y+")"),W||!1;var $=I?0:Object(m.updateFragPTSDTS)(B,v,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:B,level:T,drift:$,type:H,frag:v,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+T.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:v,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var C=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),w=l("./src/errors.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/utils/mediasource-helper.ts"),_=l("./src/loader/fragment.ts"),y=l("./src/controller/buffer-operation-queue.ts"),x=Object(b.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(f){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,h=e.media,g=e.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),s.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.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=f,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,s){var h=2;(s.audio&&!s.video||!s.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var h=this.media=s.media;if(h&&x){var g=this.mediaSource=new x;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,h=this._objectUrl;if(s){if(A.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(g){A.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(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(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var h=e.sourceBuffer[s];try{h&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[s]=void 0)}catch(g){A.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var h=this,g=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],c=o.id,t=o.codec,n=o.levelCodec,u=o.container,a=o.metadata,d=(r.levelCodec||r.codec).replace(D,"$1"),v=(n||t).replace(D,"$1");if(d!==v){var S=u+";codecs="+(n||t);h.appendChangeType(i,S),A.logger.log("[buffer-controller]: switching codec "+d+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:n,metadata:a,id:c}}}}else h.pendingTracks[i]=s[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var h=this,g=this.operationQueue,i={execute:function(){var o=h.sourceBuffer[e];o&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};g.append(i,e)},p.onBufferAppending=function(e,s){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,c=s.type,t=s.frag,n=s.part,u=s.chunkMeta,a=u.buffering[c],d=self.performance.now();a.start=d;var v=t.stats.buffering,S=n?n.stats.buffering:null;v.start===0&&(v.start=d),S&&S.start===0&&(S.start=d);var T=r.audio,I=c==="audio"&&u.id===1&&(T==null?void 0:T.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),I){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(o,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,H={};for(var z in W)H[z]=O.BufferHelper.getBuffered(W[z]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:n,chunkMeta:u,parent:t.type,timeRanges:H})},onError:function(U){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:w.ErrorTypes.MEDIA_ERROR,parent:t.type,details:w.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=w.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=w.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(k,c)},p.onBufferFlushing=function(e,s){var h=this,g=this.operationQueue,i=function(o){return{execute:h.removeExecutor.bind(h,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){A.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?g.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,s){var h=this,g=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:g.elementaryStreams;o[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var n=self.performance.now();g.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var o=h.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,A.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var h=s.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(C.isFiniteNumber)(r)||r<0)){var o=h.currentTime,c=s.levelTargetDuration,t=Math.max(r,c),n=Math.floor(o/c)*c-t;i.forEach(function(u){var a=g[u];if(a){var d=O.BufferHelper.getBuffered(a);d.length>0&&n>d.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,o=Object(C.isFiniteNumber)(g.duration)?g.duration:0;e.live&&s.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(C.isFiniteNumber)(r))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){s.executeNext(r)})}},p.createSourceBuffers=function(e){var s=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!s[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var o=r.levelCodec||r.codec,c=r.container+";codecs="+o;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=s[i]=h.addSourceBuffer(c),n=i;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,h=s.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,h=s.current(e);h.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(s)},p.removeExecutor=function(e,s,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,c=o[e];if(!g||!i||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(C.isFiniteNumber)(g.duration)?g.duration:1/0,n=Object(C.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,s),a=Math.min(h,t,n);a>u?(A.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var h=this.operationQueue,g=this.sourceBuffer,i=g[s];if(!i){A.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,s){var h=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=s.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=h.sourceBuffer[r];(!o||!o.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:s,listener:i}),g.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(h){s.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return L});var C=l("./src/utils/logger.ts"),L=function(){function A(O){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=O}var w=A.prototype;return w.append=function(b,_){var y=this.queues[_];y.push(b),y.length===1&&this.buffers[_]&&this.executeNext(_)},w.insertAbort=function(b,_){var y=this.queues[_];y.unshift(b),this.executeNext(_)},w.appendBlocker=function(b){var _,y=new Promise(function(D){_=D}),x={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,b),y},w.executeNext=function(b){var _=this.buffers,y=this.queues,x=_[b],D=y[b];if(D.length){var E=D[0];try{E.execute()}catch(m){C.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!x||!x.updating)&&(D.shift(),this.executeNext(b))}}},w.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},w.current=function(b){return this.queues[b][0]},A}()},"./src/controller/cap-level-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/events.ts");function L(O,b){for(var _=0;_<b.length;_++){var y=b[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(O,y.key,y)}}function A(O,b,_){return b&&L(O.prototype,b),_&&L(O,_),Object.defineProperty(O,"prototype",{writable:!1}),O}var w=function(){function O(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var b=O.prototype;return b.setStreamController=function(y){this.streamController=y},b.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},b.registerListeners=function(){var y=this.hls;y.on(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.unregisterListener=function(){var y=this.hls;y.off(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.onFpsDropLevelCapping=function(y,x){O.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},b.onMediaAttaching=function(y,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},b.onManifestParsed=function(y,x){var D=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onBufferCodecs=function(y,x){var D=this.hls;D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onMediaDetaching=function(){this.stopCapping()},b.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(y.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},b.getMaxLevel=function(y){var x=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(m,p){return O.isLevelAllowed(p,x.restrictedLevels)&&p<=y});return this.clientRect=null,O.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},b.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())},b.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},b.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,x={width:0,height:0};if(y){var D=y.getBoundingClientRect();x.width=D.width,x.height=D.height,!x.width&&!x.height&&(x.width=D.right-D.left||y.width||0,x.height=D.bottom-D.top||y.height||0)}return this.clientRect=x,x},O.isLevelAllowed=function(y,x){return x===void 0&&(x=[]),x.indexOf(y)===-1},O.getMaxLevelByMediaSize=function(y,x,D){if(!y||!y.length)return-1;for(var E=function(s,h){return h?s.width!==h.width||s.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var f=y[p];if((f.width>=x||f.height>=D)&&E(f,y[p+1])){m=p;break}}return m},A(O,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),O}();R.default=w},"./src/controller/cmcd-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var C=l("./src/events.ts"),L=l("./src/types/cmcd.ts"),A=l("./src/utils/buffer-helper.ts"),w=l("./src/utils/logger.ts");function O(m,p){for(var f=0;f<p.length;f++){var e=p[f];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function b(m,p,f){return p&&O(m.prototype,p),f&&O(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var f=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(f)return(f=f.call(m)).next.bind(f);if(Array.isArray(m)||(f=y(m))||p&&m&&typeof m.length=="number"){f&&(m=f);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
14
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return x(m,p);var f=Object.prototype.toString.call(m).slice(8,-1);if(f==="Object"&&m.constructor&&(f=m.constructor.name),f==="Map"||f==="Set")return Array.from(m);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return x(m,p)}}function x(m,p){(p==null||p>m.length)&&(p=m.length);for(var f=0,e=new Array(p);f<p;f++)e[f]=m[f];return e}function D(){return D=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var f=arguments[p];for(var e in f)Object.prototype.hasOwnProperty.call(f,e)&&(m[e]=f[e])}return m},D.apply(this,arguments)}var E=function(){function m(f){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){w.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),c={d:i.duration*1e3,ot:o};(o===L.CMCDObjectType.VIDEO||o===L.CMCDObjectType.AUDIO||o==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(o)/1e3,c.bl=e.getBufferLength(o)),e.apply(g,c)}catch(t){w.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=f;var s=this.config=f.config,h=s.cmcd;h!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(C.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,s){var h,g;this.audioBuffer=(h=s.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=s.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,s){s===void 0&&(s={}),D(s,this.createData());var h=s.ot===L.CMCDObjectType.INIT||s.ot===L.CMCDObjectType.VIDEO||s.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var g=m.toHeaders(s);if(!Object.keys(g).length)return;e.headers||(e.headers={}),D(e.headers,g)}else{var i=m.toQuery(s);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var s=e.type;if(s==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(s==="audio")return L.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var o=_(h),c;!(c=o()).done;){var t=c.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!s)return NaN;var g=A.BufferHelper.bufferInfo(h,s.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},m.serialize=function(e){for(var s=[],h=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},g=function(I){return Math.round(I)},i=function(I){return g(I/100)*100},r=function(I){return encodeURIComponent(I)},o={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),n;!(n=t()).done;){var u=n.value,a=e[u];if(!!h(a)&&!(u==="v"&&a===1)&&!(u=="pr"&&a===1)){var d=o[u];d&&(a=d(a));var v=typeof a,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+a:v==="boolean"?S=u:v==="number"?S=u+"="+a:S=u+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},m.toHeaders=function(e){for(var s=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,c=s;o<c.length;o++){var t=c[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var u=0;u<i.length;u++){var a=m.serialize(i[u]);a&&(h["CMCD-"+g[u]]=a)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,s){if(!s)return e;var h=e.includes("?")?"&":"?";return""+e+h+s},m}()},"./src/controller/eme-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),w=l("./src/utils/mediakeys-helper.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,f){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:f.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:f.videoRobustness||""})}),[e]},x=function(m,p,f,e){switch(m){case w.KeySystems.WIDEVINE:return y(p,f,e);default:throw new Error("Unknown key-system: "+m)}},D=function(){function E(p){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=p,this._config=p.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 m=E.prototype;return m.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},m._registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(f){switch(f){case w.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+f+'"')},m._attemptKeySystemAccess=function(f,e,s){var h=this,g=x(f,e,s,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(f,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(f,r)}),i.catch(function(r){A.logger.error('Failed to obtain key-system "'+f+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(f,e){var s=this;A.logger.log('Access for key-system "'+f+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:f};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,A.logger.log('Media-keys created for key-system "'+f+'"'),s._onMediaKeysCreated(),i});return g.catch(function(i){A.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var f=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),f._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(f){var e=this;A.logger.log("New key-system session "+f.sessionId),f.addEventListener("message",function(s){e._onKeySessionMessage(f,s.message)},!1)},m._onKeySessionMessage=function(f,e){A.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){A.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),f.update(s).catch(function(h){A.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(f){var e=this;if(A.logger.log('Media is encrypted using "'+f.initDataType+'" init data type'),!this.mediaKeysPromise){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(f.initDataType,f.initData))};this.mediaKeysPromise.then(s).catch(s)},m._attemptSetMediaKeys=function(f){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(f,e){var s=this,h=this._mediaKeysList[0];if(!h){A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){A.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){A.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){A.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}A.logger.log('Generating key-session request for "'+f+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(f,e).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(i){A.logger.error("Error generating key-session request:",i),s.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(f,e,s){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,f,e,s);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,f),g=void 0}catch(i){A.logger.error(i)}try{h.readyState||h.open("POST",f,!0),g&&g.call(this.hls,h,f)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(f,e,s,h){switch(f.readyState){case 4:if(f.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var g=f.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,f,e)}catch(o){A.logger.error(o)}h(g)}else{if(A.logger.error("License Request XHR failed ("+e+"). Status: "+f.status+" ("+f.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,h)}break}},m._generateLicenseRequestChallenge=function(f,e){switch(f.mediaKeySystemDomain){case w.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+f.mediaKeySystemDomain)},m._requestLicense=function(f,e){A.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(s.mediaKeySystemDomain),g=this._createLicenseXhr(h,f,e);A.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(s,f);g.send(i)}catch(r){A.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(f,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var f=this._media,e=this._mediaKeysList;!f||(f.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return f.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(f,e){if(!!this._emeEnabled){var s=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(w.KeySystems.WIDEVINE,s,h)}},b(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();R.default=D},"./src/controller/fps-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/events.ts"),L=l("./src/utils/logger.ts"),A=function(){function w(b){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=b,this.registerListeners()}var O=w.prototype;return O.setStreamController=function(_){this.streamController=_},O.registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},O.unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching)},O.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},O.onMediaAttaching=function(_,y){var x=this.hls.config;if(x.capLevelOnFPSDrop){var D=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},O.checkFPS=function(_,y,x){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,m=x-this.lastDroppedFrames,p=y-this.lastDecodedFrames,f=1e3*m/E,e=this.hls;if(e.trigger(C.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:x}),f>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(C.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=x,this.lastDecodedFrames=y}},O.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},w}();R.default=A},"./src/controller/fragment-finders.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFragmentByPDT",function(){return A}),l.d(R,"findFragmentByPTS",function(){return w}),l.d(R,"fragmentWithinToleranceTest",function(){return O}),l.d(R,"pdtWithinToleranceTest",function(){return b}),l.d(R,"findFragWithCC",function(){return _});var C=l("./src/polyfills/number.ts"),L=l("./src/utils/binary-search.ts");function A(y,x,D){if(x===null||!Array.isArray(y)||!y.length||!Object(C.isFiniteNumber)(x))return null;var E=y[0].programDateTime;if(x<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(x>=(m||0))return null;D=D||0;for(var p=0;p<y.length;++p){var f=y[p];if(b(x,D,f))return f}return null}function w(y,x,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var m=null;if(y?m=x[y.sn-x[0].sn+1]||null:D===0&&x[0].start===0&&(m=x[0]),m&&O(D,E,m)===0)return m;var p=L.default.search(x,O.bind(null,D,E));return p||m}function O(y,x,D){y===void 0&&(y=0),x===void 0&&(x=0);var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function b(y,x,D){var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,m=D.endProgramDateTime||0;return m-E>y}function _(y,x){return L.default.search(y,function(D){return D.cc<x?1:D.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"FragmentState",function(){return A}),l.d(R,"FragmentTracker",function(){return w});var C=l("./src/events.ts"),L=l("./src/types/loader.ts"),A;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(A||(A={}));var w=function(){function _(x){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=x,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var D=this.hls;D.on(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(C.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(C.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var f=p.length;f--;){var e=p[f],s=e?e.end:m.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return f>9&&(this.activeParts=p.slice(f-9)),e}else if(m.start<=D&&m.appendedPTS!==void 0&&D<=m.appendedPTS)return m}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var m=this.fragments,p=Object.keys(m),f=p.length;f--;){var e=m[p[f]];if((e==null?void 0:e.body.type)===E&&e.buffered){var s=e.body;if(s.start<=D&&D<=s.end)return s}}return null},y.detectEvictedFragments=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(D){var E=this,m=this.timeRanges,p=D.frag,f=D.part;if(!(!m||p.sn==="initSegment")){var e=b(p),s=this.fragments[e];!s||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=f!==null||g.partial===!0;s.range[h]=E.getBufferedTimes(p,f,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=b(D),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(D,E,m,p){for(var f={time:[],partial:m},e=E?E.start:D.start,s=E?E.end:D.end,h=D.minEndPTS||s,g=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(g>=r&&h<=o){f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)f.partial=!0,f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return f},y.getPartialFragment=function(D){var E=null,m,p,f,e=0,s=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||O(i)&&(p=i.body.start-s,f=i.body.end+s,D>=p&&D<=f&&(m=Math.min(D-p,f-D),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(D){var E=b(D),m=this.fragments[E];return m?m.buffered?O(m)?A.PARTIAL:A.OK:A.APPENDING:A.NOT_LOADED},y.isTimeBuffered=function(D,E,m){for(var p,f,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,f=m.end(e)+this.bufferPadding,D>=p&&E<=f)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var f=b(m);this.fragments[f]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var m=this,p=E.frag,f=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,f){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(f)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!f)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=b(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e&&e.buffered){var s=e.body;s.type===m&&s.start<E&&s.end>D&&p.removeFragment(s)}})},y.removeFragment=function(D){var E=b(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function O(_){var y,x;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((x=_.range.audio)===null||x===void 0?void 0:x.partial))}function b(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"STALL_MINIMUM_DURATION_MS",function(){return O}),l.d(R,"MAX_START_GAP_JUMP",function(){return b}),l.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),l.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),l.d(R,"default",function(){return x});var C=l("./src/utils/buffer-helper.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts"),w=l("./src/utils/logger.ts"),O=250,b=2,_=.1,y=.05,x=function(){function D(m,p,f,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=m,this.media=p,this.fragmentTracker=f,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,f){var e=this.config,s=this.media,h=this.stalled;if(s!==null){var g=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;w.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((o||r)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!C.BufferHelper.getBuffered(s).length)){var t=C.BufferHelper.bufferInfo(s,g,0),n=t.len>0,u=t.nextStart||0;if(!(!n&&!u)){if(i){var a=t.len>b,d=!u||f&&f.start<=g||u-g>b&&!this.fragmentTracker.getPartialFragment(g);if(a||d)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||(v=T.details)===null||v===void 0?void 0:v.live,k=I?T.details.targetduration*2:b;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(h===null){this.stalled=B;return}var U=B-h;if(!(!i&&U>=O&&(this._reportStall(t),!this.media))){var W=C.BufferHelper.bufferInfo(s,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,f){var e=this.config,s=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=s.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&f>e.highBufferWatchdogPeriod*1e3&&(w.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var f=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,w.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var f=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var h=s.currentTime,g=0,i=C.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(h+f.maxBufferHole>=g&&h<o){var c=Math.max(o+y,s.currentTime+_);return w.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,s.currentTime=c,p&&e.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,f=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var g=h+(s+1)*p.nudgeOffset;w.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else w.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/texttrack-utils.ts"),w=l("./src/demux/id3.ts"),O=l("./src/loader/date-range.ts"),b=l("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(m,p){return m.getTime()/1e3-p}function D(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(f){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=f,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(A.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},p.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var h=e[s];if(h.kind==="metadata"&&h.label==="id3")return Object(A.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=s.frag,o=s.samples,c=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,n=y(),u=!1,a={},d=0;d<o.length;d++){var v=o[d].type;if(!(v===b.MetadataSchema.emsg&&!g||!i)){var S=w.getID3Frames(o[d].data);if(S){var T=o[d].pts,I=t,k=I-T;k<=0&&(I=T+_);for(var B=0;B<S.length;B++){var U=S[B];if(!w.isTimeStampFrame(U)){var W=new n(T,I,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),a[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,h=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var c=e[o];c&&r.endTime!==c&&(r.endTime=c),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var h=s.startOffset,g=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var c=o.config,t=c.enableEmsgMetadataCues,n=c.enableID3MetadataCues;if(r&&(t||n)){var u;i==="audio"?u=function(d){return d.type===b.MetadataSchema.audioId3&&n}:i==="video"?u=function(d){return d.type===b.MetadataSchema.emsg&&t}:u=function(d){return d.type===b.MetadataSchema.audioId3&&n||d.type===b.MetadataSchema.emsg&&t},Object(A.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,s){var h=this,g=s.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=g.dateRanges,c=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!c.includes(k)}),n=function(B){var U=t[B];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)n(u);var a=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(C.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var d=a.programDateTime/1e3-a.start,v=g.edge||a.end,S=y(),T=function(B){var U=c[B],W=o[U],H=i[U],z=(H==null?void 0:H.cues)||{},Y=(H==null?void 0:H.durationKnown)||!1,$=x(W.startDate,d),ee=v,q=W.endDate;if(q)ee=x(q,d),Y=!0;else if(W.endOnNext&&!Y){var re=c.reduce(function(ie,Te){var pe=o[Te];return pe.class===W.class&&pe.id!==Te&&pe.startDate>W.startDate&&ie.push(pe),ie},[]).sort(function(ie,Te){return ie.startDate.getTime()-Te.startDate.getTime()})[0];re&&(ee=x(re.startDate,d),Y=!0)}for(var ae=Object.keys(W.attr),ne=0;ne<ae.length;ne++){var te=ae[ne];if(!(te===O.DateRangeAttribute.ID||te===O.DateRangeAttribute.CLASS||te===O.DateRangeAttribute.START_DATE||te===O.DateRangeAttribute.DURATION||te===O.DateRangeAttribute.END_DATE||te===O.DateRangeAttribute.END_ON_NEXT)){var he=z[te];if(he)Y&&!H.durationKnown&&(he.endTime=ee);else{var ve=W.attr[te];he=new S($,ee,""),(te===O.DateRangeAttribute.SCTE35_OUT||te===O.DateRangeAttribute.SCTE35_IN)&&(ve=D(ve)),he.value={key:te,data:ve},he.type=b.MetadataSchema.dateRange,h.id3Track.addCue(he),z[te]=he}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},I=0;I<c.length;I++)T(I)}}},m}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var C=l("./src/errors.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts");function w(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function O(_,y,x){return y&&w(_.prototype,y),x&&w(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var b=function(){function _(x){var D=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 D.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(D,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(D,E){var m=E.details;this.levelDetails=m,m.advanced&&this.timeupdate(),!m.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===C.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var D=this.media,E=this.levelDetails;if(!(!D||!E)){this.currentTime=D.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,f=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!f||e===1)){var s=this.targetLatency;if(s!==null){var h=m-s,g=Math.min(this.maxLatency,s+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;D.playbackRate=Math.min(r,Math.max(1,o))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},y.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},O(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,E=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:E?D.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var E=D.holdBack,m=D.partHoldBack,p=D.targetduration,f=this.config,e=f.liveSyncDuration,s=f.liveSyncDurationCount,h=f.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*p);var r=p,o=1;return i+Math.min(this.stallCount*o,r)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(D===null||E===null||m===null)return null;var p=m.edge,f=D-E-this.edgeStalled,e=p-m.totalduration,s=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,f),s)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var E=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-E,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,E=this.levelDetails;if(!D||!E)return 0;var m=D.buffered.length;return(m?D.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return f});var C=l("./src/types/level.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),w=l("./src/utils/codecs.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/base-playlist-controller.ts"),_=l("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var h=arguments[s];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,m(e,s)}function m(e,s){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),f=function(e){E(s,e);function s(g){var i;return i=e.call(this,g,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var h=s.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var o=[],c=[],t=[],n,u={},a,d=!1,v=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;d=d||!!(B.width&&B.height),v=v||!!B.videoCodec,S=S||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var W=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;a=u[W],a?a.url.push(B.url):(a=new C.Level(B),u[W]=a,o.push(a)),U&&(U.AUDIO&&Object(O.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(O.addGroupId)(a,"text",U.SUBTITLES))}),(d||v)&&S&&(o=o.filter(function(B){var U=B.videoCodec,W=B.width,H=B.height;return!!U||!!(W&&H)})),o=o.filter(function(B){var U=B.audioCodec,W=B.videoCodec;return(!U||Object(w.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(w.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(B){return!B.audioCodec||Object(w.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(O.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(O.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var T=0;T<o.length;T++)if(o[T].bitrate===n){this._firstLevel=T,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var I=S&&!v,k={levels:o,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!I&&c.some(function(B){return!!B.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,u=!0,a;switch(r.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(r.frag){var d=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[d];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=d)):a=d}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),a=c.level),n=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,u)}},h.recoverLevel=function(i,r,o,c){var t=i.details,n=this._levels[r];if(n.loadError++,o){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var d=-1,v=this._levels,S=v.length;S--;){var T=(S+this.currentLevelIndex)%v.length;if(T!==this.currentLevelIndex&&v[T].loadError===0){d=T;break}}d>-1&&this.currentLevelIndex!==d&&(this.warn(t+": switch to "+d),i.levelRetry=!0,this.hls.nextAutoLevel=d)}}},h.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var c=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===_.PlaylistLevelType.MAIN){var c=this._levels[o.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var o,c=r.level,t=r.details,n=this._levels[c];if(!n){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){c=n;break}c!==o.urlId&&(o.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var c=o.urlId,t=o.url[c];if(i)try{t=i.addDirectives(t)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var o=function(n,u){return u!==r},c=this._levels.filter(function(t,n){return n!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(o),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(o)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(o)),t.urlId=0,!0):!1}).map(function(t,n){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=n}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},D(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,o=this._levels;if(o.length!==0&&!(this.currentLevelIndex===i&&(r=o[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=o.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],u=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,a);var d=u.details;if(!d||d.live){var v=this.switchParams(u.uri,n==null?void 0:n.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(b.default)},"./src/controller/level-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"addGroupId",function(){return O}),l.d(R,"assignTrackIdsByGroup",function(){return b}),l.d(R,"updatePTS",function(){return _}),l.d(R,"updateFragPTSDTS",function(){return x}),l.d(R,"mergeDetails",function(){return D}),l.d(R,"mapPartIntersection",function(){return m}),l.d(R,"mapFragmentIntersection",function(){return p}),l.d(R,"adjustSliding",function(){return f}),l.d(R,"addSliding",function(){return e}),l.d(R,"computeReloadInterval",function(){return s}),l.d(R,"getFragmentWithSN",function(){return h}),l.d(R,"getPartWith",function(){return g});var C=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/loader/date-range.ts");function w(){return w=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(i[c]=o[c])}return i},w.apply(this,arguments)}function O(i,r,o){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(o);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(o);break}}function b(i){var r={};i.forEach(function(o){var c=o.groupId||"";o.id=r[c]=r[c]||0,r[c]++})}function _(i,r,o){var c=i[r],t=i[o];y(c,t)}function y(i,r){var o=r.startPTS;if(Object(C.isFiniteNumber)(o)){var c=0,t;r.sn>i.sn?(c=o-i.start,t=i):(c=i.start-o,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var n=i.cc===r.cc;n&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function x(i,r,o,c,t,n){var u=c-o;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=o+r.duration,n=t+r.duration);var a=o,d=c,v=r.startPTS,S=r.endPTS;if(Object(C.isFiniteNumber)(v)){var T=Math.abs(v-o);Object(C.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(T,r.deltaPTS):r.deltaPTS=T,a=Math.max(o,v),o=Math.min(o,v),t=Math.min(t,r.startDTS),d=Math.min(c,S),c=Math.max(c,S),n=Math.max(n,r.endDTS)}r.duration=c-o;var I=o-r.start;r.appendedPTS=c,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=c,r.minEndPTS=d,r.endDTS=n;var k=r.sn;if(!i||k<i.startSN||k>i.endSN)return 0;var B,U=k-i.startSN,W=i.fragments;for(W[U]=r,B=U;B>0;B--)y(W[B],W[B-1]);for(B=U;B<W.length-1;B++)y(W[B],W[B+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,I}function D(i,r){for(var o=null,c=i.fragments,t=c.length-1;t>=0;t--){var n=c[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,a;if(p(i,r,function(B,U){B.relurl&&(u=B.cc-U.cc),Object(C.isFiniteNumber)(B.startPTS)&&Object(C.isFiniteNumber)(B.endPTS)&&(U.start=U.startPTS=B.startPTS,U.startDTS=B.startDTS,U.appendedPTS=B.appendedPTS,U.maxStartPTS=B.maxStartPTS,U.endPTS=B.endPTS,U.endDTS=B.endDTS,U.minEndPTS=B.minEndPTS,U.duration=B.endPTS-B.startPTS,U.duration&&(a=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=B.elementaryStreams,U.loader=B.loader,U.stats=B.stats,U.urlId=B.urlId,B.initSegment&&(U.initSegment=B.initSegment,o=B.initSegment)}),o){var d=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;d.forEach(function(B){var U;(!B.initSegment||B.initSegment.relurl===((U=o)===null||U===void 0?void 0:U.relurl))&&(B.initSegment=o)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(B){return!B}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var T=0;T<S.length;T++)S[T].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),a?x(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):f(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var I=r.advancedDateTime;if(r.advanced&&I){var k=r.edge;r.driftStart||(r.driftStartTime=I,r.driftStart=k),r.driftEndTime=I,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var c=w({},i);return o&&o.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var n=new A.DateRange(r[t].attr,c[t]);n.isValid?c[t]=n:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,o){if(i&&r)for(var c=0,t=0,n=i.length;t<=n;t++){var u=i[t],a=r[t+c];u&&a&&u.index===a.index&&u.fragment.sn===a.fragment.sn?o(u,a):c--}}function p(i,r,o){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=n;v++){var S=d[u+v],T=a[v];c&&!T&&v<c&&(T=r.fragments[v]=S),S&&T&&o(S,T)}}function f(i,r){var o=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;o<0||o>=c.length||e(r,c[o].start)}function e(i,r){if(r){for(var o=i.fragments,c=i.skippedSegments;c<o.length;c++)o[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,c=o/2,t=i.age,n=t>0&&t<o*3,u=r.loading.end-r.loading.start,a,d=i.availabilityDelay;if(i.updated===!1)if(n){var v=333*i.misses;a=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=c;else n?(d=Math.min(d||o/2,t),i.availabilityDelay=d,a=d+o-t):a=o-u;return Math.round(a)}function h(i,r,o){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&o&&o.sn===r?o:null}function g(i,r,o){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var n=c[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return g});var C=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/is-supported.ts"),w=l("./src/events.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/transmuxer-interface.ts"),D=l("./src/types/transmuxer.ts"),E=l("./src/controller/gap-controller.ts"),m=l("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var c=r[o];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function f(i,r,o){return r&&p(i.prototype,r),o&&p(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,s(i,r)}function s(i,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},s(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var n;return n=i.call(this,c,t,"[stream-controller]")||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}var o=r.prototype;return o._registerListeners=function(){var t=this.hls;t.on(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(w.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(w.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(w.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(w.Events.ERROR,this.onError,this),t.on(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(w.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(w.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(w.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(w.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(w.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(w.Events.ERROR,this.onError,this),t.off(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(w.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(w.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(w.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=u.startLevel;a===-1&&(u.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=u.nextAutoLevel),this.level=u.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,n=this.levels,u=this.level,a=n==null||(t=n[u])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var d,v=self.performance.now(),S=this.retryDate;(!S||v>=S||(d=this.media)!==null&&d!==void 0&&d.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},o.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},o.doTickIdle=function(){var t,n,u=this.hls,a=this.levelLastLoaded,d=this.levels,v=this.media,S=u.config,T=u.nextLoadLevel;if(!(a===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!d||!d[T])){var I=d[T];this.level=u.nextLoadLevel=T;var k=I.details;if(!k||this.state===L.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==T){this.state=L.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(I.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var H={};this.altAudio&&(H.type="video"),this.hls.trigger(w.Events.BUFFER_EOS,H),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>B.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:B.end,Y=this.getNextFragment(z,k);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var $,ee=(($=this.backtrackFragment)!=null?$:Y).sn,q=ee-k.startSN,re=k.fragments[q-1];re&&Y.cc===re.cc&&(Y=re,this.fragmentTracker.removeFragment(re))}else this.backtrackFragment&&B.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===b.FragmentState.OK&&this.nextLoadPosition>z){var ae=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;v&&this.afterBufferFlushed(v,ae,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,k)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((n=Y.decryptdata)!==null&&n!==void 0&&n.key)?this.loadKey(Y,k):this.loadFragment(Y,k,z))}}}},o.loadFragment=function(t,n,u){var a,d=this.fragmentTracker.getState(t);this.fragCurrent=t,d===b.FragmentState.NOT_LOADED?t.sn==="initSegment"?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,t,n,u)):d===b.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((a=this.media)===null||a===void 0?void 0:a.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},o.getAppendedFrag=function(t){var n=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},o.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},o.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},o.nextLevelSwitch=function(){var t=this.levels,n=this.media;if(n!=null&&n.readyState){var u,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var d=this.hls.nextLoadLevel,v=t[d],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var T=this.getBufferedFrag(n.currentTime+u);if(T){var I=this.followingBufferedFrag(T);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,B=I.duration,U=Math.max(T.end,k+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},o.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},o.flushMainBuffer=function(t,n){i.prototype.flushMainBuffer.call(this,t,n,this.altAudio?"video":null)},o.onMediaAttached=function(t,n){i.prototype.onMediaAttached.call(this,t,n);var u=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},o.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},o.onMediaPlaying=function(){this.tick()},o.onMediaSeeked=function(){var t=this.media,n=t?t.currentTime:null;Object(C.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(w.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},o.onManifestParsed=function(t,n){var u=!1,a=!1,d;n.levels.forEach(function(v){d=v.audioCodec,d&&(d.indexOf("mp4a.40.2")!==-1&&(u=!0),d.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=u&&a&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1},o.onLevelLoading=function(t,n){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var a=u[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=L.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var u,a=this.levels,d=n.level,v=n.details,S=v.totalduration;if(!a){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var T=this.fragCurrent;T&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&T.level!==n.level&&T.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,T.loader.abort());var I=a[d],k=0;if(v.live||(u=I.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;k=this.alignPlaylists(v,I.details)}if(I.details=v,this.levelLastLoaded=d,this.hls.trigger(w.Events.LEVEL_UPDATED,{details:v,level:d}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,u=t.frag,a=t.part,d=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],T=S.details;if(!T){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var I=S.videoCodec,k=T.PTSKnown||!T.live,B=(n=u.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new x.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),H=a?a.index:-1,z=H!==-1,Y=new D.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,d.byteLength,H,z),$=this.initPTS[u.cc];W.push(d,B,U,I,u,a,T.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var u=this.altAudio,a=!!n.url,d=n.id;if(!a){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(w.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(w.Events.AUDIO_TRACK_SWITCHED,{id:d})}},o.onAudioTrackSwitched=function(t,n){var u=n.id,a=!!this.hls.audioTracks[u].url;if(a){var d=this.videoBuffer;d&&this.mediaBuffer!==d&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=d)}this.altAudio=a,this.tick()},o.onBufferCreated=function(t,n){var u=n.tracks,a,d,v=!1;for(var S in u){var T=u[S];if(T.id==="main"){if(d=S,a=T,S==="video"){var I=u[S];I&&(this.videoBuffer=I.buffer)}}else v=!0}v&&a?(this.log("Alternate track found, use "+d+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var u=n.frag,a=n.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(a?" p: "+a.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var d=a?a.stats:u.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,a)}},o.onError=function(t,n){switch(n.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,n);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=L.State.ERROR):!n.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,a=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);a&&a.len>.5&&(u=!this.reduceMaxBufferLength(a.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},o.checkBuffer=function(){var t=this.media,n=this.gapController;if(!(!t||!n||!t.readyState)){if(this.loadedmetadata||!O.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var u=n.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,u,_.PlaylistLevelType.MAIN)}},o.onLevelsUpdated=function(t,n){this.levels=n.levels},o.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},o.seekToStartPos=function(){var t=this.media;if(!!t){var n=t.currentTime,u=this.startPosition;if(u>=0&&n<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+n);return}var a=O.BufferHelper.getBuffered(t),d=a.length?a.start(0):0,v=d-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+n),t.currentTime=u}}},o._getAudioCodec=function(t){var n=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n},o._loadBitrateTestFrag=function(t){var n=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var a=n.hls;if(!(!u||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=L.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),a.trigger(w.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,u="main",a=this.hls,d=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var T=S.frag,I=S.part,k=S.level,B=d.video,U=d.text,W=d.id3,H=d.initSegment,z=k.details,Y=this.altAudio?void 0:d.audio;if(!this.fragContextChanged(T)){if(this.state=L.State.PARSING,H){H.tracks&&(this._bufferInitSegment(k,H.tracks,T,v),a.trigger(w.Events.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:u,tracks:H.tracks}));var $=H.initPTS,ee=H.timescale;Object(C.isFiniteNumber)($)&&(this.initPTS[T.cc]=$,a.trigger(w.Events.INIT_PTS_FOUND,{frag:T,id:u,initPTS:$,timescale:ee}))}if(B&&d.independent!==!1){if(z){var q=B.startPTS,re=B.endPTS,ae=B.startDTS,ne=B.endDTS;if(I)I.elementaryStreams[B.type]={startPTS:q,endPTS:re,startDTS:ae,endDTS:ne};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var te=this.getMainFwdBufferInfo(),he=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,ve=B.firstKeyFramePTS?B.firstKeyFramePTS:q;if(he<ve-this.config.maxBufferHole){this.backtrack(T);return}T.setElementaryStreamInfo(B.type,T.start,re,T.start,ne,!0)}T.setElementaryStreamInfo(B.type,q,re,ae,ne),this.backtrackFragment&&(this.backtrackFragment=T),this.bufferFragmentData(B,T,I,v)}}else if(d.independent===!1){this.backtrack(T);return}if(Y){var ie=Y.startPTS,Te=Y.endPTS,pe=Y.startDTS,xe=Y.endDTS;I&&(I.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:ie,endPTS:Te,startDTS:pe,endDTS:xe}),T.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,ie,Te,pe,xe),this.bufferFragmentData(Y,T,I,v)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:u,frag:T,details:z,samples:W.samples};a.trigger(w.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Ae={id:u,frag:T,details:z,samples:U.samples};a.trigger(w.Events.FRAG_PARSING_USERDATA,Ae)}}},o._bufferInitSegment=function(t,n,u,a){var d=this;if(this.state===L.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var v=n.audio,S=n.video,T=n.audiovideo;if(v){var I=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),v.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),t.audioCodec&&t.audioCodec!==I&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+I+'"'),v.levelCodec=I,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),T&&this.log("Init audiovideo buffer, container:"+T.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+T.codec+"]"),this.hls.trigger(w.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&d.hls.trigger(w.Events.BUFFER_APPENDING,{type:B,data:W,frag:u,part:null,chunkMeta:a,parent:u.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},o.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(O.BufferHelper.isBuffered(t,u)?n=this.getAppendedFrag(u):O.BufferHelper.isBuffered(t,u+.1)&&(n=this.getAppendedFrag(u+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,d=n.level;(!a||n.sn!==a.sn||a.level!==d||n.urlId!==a.urlId)&&(this.hls.trigger(w.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==d)&&this.hls.trigger(w.Events.LEVEL_SWITCHED,{level:d}),this.fragPlaying=n)}}},f(r,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var n=t.currentTime,u=this.currentFrag;if(u&&Object(C.isFiniteNumber)(n)&&Object(C.isFiniteNumber)(u.programDateTime)){var a=u.programDateTime+(n-u.start)*1e3;return new Date(a)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"SubtitleStreamController",function(){return e});var C=l("./src/events.ts"),L=l("./src/utils/buffer-helper.ts"),A=l("./src/controller/fragment-finders.ts"),w=l("./src/utils/discontinuities.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/controller/base-stream-controller.ts"),y=l("./src/types/loader.ts"),x=l("./src/types/level.ts");function D(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&D(h.prototype,g),i&&D(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(h,g)}var f=500,e=function(h){m(g,h);function g(r,o){var c;return c=h.call(this,r,o,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(C.Events.ERROR,this.onError,this),o.on(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(C.Events.ERROR,this.onError,this),o.off(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(f),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(o,c){var t=c.frag,n=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!n){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var a,d=t.start,v=0;v<u.length;v++)if(d>=u[v].start&&d<=u[v].end){a=u[v];break}var S=t.start+t.duration;a?a.end=S:(a={start:d,end:S},u.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,c){var t=c.startOffset,n=c.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var d=a[u].details,v=d.targetduration,S=n-v;if(S<=0)return;c.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(T){for(var I=0;I<T.length;){if(T[I].end<=S){T.shift();continue}else if(T[I].start<S)T[I].start=S;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(o,c){var t,n=c.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(o,c){var t=this,n=c.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(u){return new x.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(f)},i.onSubtitleTrackLoaded=function(o,c){var t,n=c.details,u=c.id,a=this.currentTrackId,d=this.levels;if(!!d.length){var v=d[a];if(!(u>=d.length||u!==a||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var T=S.fragments[0];if(!v.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(w.alignMediaPlaylistByPDT)(n,S):T&&Object(O.addSliding)(n,T.start);else{var I=this.alignPlaylists(n,v.details);I===0&&T&&Object(O.addSliding)(n,T.start)}}if(v.details=n,this.levelLastLoaded=u,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var k=Object(A.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var c=o.frag,t=o.payload,n=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),n.key.buffer,n.iv.buffer).then(function(d){var v=performance.now();u.trigger(C.Events.FRAG_DECRYPTED,{frag:c,payload:d,stats:{tstart:a,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var o=this.currentTrackId,c=this.levels;if(!c.length||!c[o]||!c[o].details)return;var t=c[o].details,n=t.targetduration,u=this.config,a=this.media,d=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,u.maxBufferHole),v=d.end,S=d.len,T=this.getMaxBufferLength()+n;if(S>T)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var I=t.fragments,k=I.length,B=t.edge,U,W=this.fragPrevious;if(v<B){var H=u.maxFragLookUpTolerance;U=Object(A.findFragmentByPTS)(W,I,Math.max(I[0].start,v),H),!U&&W&&W.start<I[0].start&&(U=I[0])}else U=I[k-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==b.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,v)}},i.loadFragment=function(o,c,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):h.prototype.loadFragment.call(this,o,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),s=function(g){this.buffered=void 0;var i=function(o,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][o]};this.buffered={get length(){return g.length},end:function(o){return i("end",o,g.length)},start:function(o){return i("start",o,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/events.ts"),L=l("./src/utils/texttrack-utils.ts"),A=l("./src/controller/base-playlist-controller.ts"),w=l("./src/types/loader.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,e){return f.__proto__=e,f},y(E,m)}var x=function(E){_(m,E);function m(f){var e;return e=E.call(this,f,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var p=m.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(C.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(C.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,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))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(s){Object(L.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},p.onSubtitleTrackLoaded=function(e,s){var h=s.id,g=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var o=r.details;r.details=s.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,s,o))},p.onLevelLoading=function(e,s){this.switchLevel(s.level)},p.onLevelSwitching=function(e,s){this.switchLevel(s.level)},p.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var h=s.textGroupIds[s.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(C.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,h=0;h<s.length;h++){var g=s[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===w.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},p.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var h=s.id,g=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(C.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,h=this.media,g=this.trackId;if(!!h){var i=D(h.textTracks),r=i.filter(function(t){return t.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var o=r[g];o&&(o.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,c=o===void 0?"":o,t=i.name,n=i.type,u=i.url;this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:n,url:u});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=D(this.media.textTracks),h=0;h<s.length;h++)if(s[h].mode==="hidden")e=h;else if(s[h].mode==="showing"){e=h;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},b(m,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),m}(A.default);function D(E){for(var m=[],p=0;p<E.length;p++){var f=E[p];f.kind==="subtitles"&&f.label&&m.push(E[p])}return m}R.default=x},"./src/controller/timeline-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"TimelineController",function(){return E});var C=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/cea-608-parser.ts"),w=l("./src/utils/output-filter.ts"),O=l("./src/utils/webvtt-parser.ts"),b=l("./src/utils/texttrack-utils.ts"),_=l("./src/utils/imsc1-ttml-parser.ts"),y=l("./src/utils/mp4-tools.ts"),x=l("./src/types/loader.ts"),D=l("./src/utils/logger.ts"),E=function(){function e(h){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.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.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 g=new w.default(this,"textTrack1"),i=new w.default(this,"textTrack2"),r=new w.default(this,"textTrack3"),o=new w.default(this,"textTrack4");this.cea608Parser1=new A.default(1,g,i),this.cea608Parser2=new A.default(3,r,o)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(g,i,r,o,c){for(var t=!1,n=c.length;n--;){var u=c[n],a=p(u[0],u[1],i,r);if(a>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,a/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var d=this.captionsTracks[g];this.Cues.newCue(d,i,r,o)}else{var v=this.Cues.newCue(null,i,r,o);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},s.onInitPtsFound=function(g,i){var r=this,o=i.frag,c=i.id,t=i.initPTS,n=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),u.length&&(this.unparsedVttFrags=[],u.forEach(function(a){r.onFragLoaded(L.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[g])return o}return null},s.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},s.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,c=i[g],t=c.label,n=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(b.clearCurrentCues)(r[g]),Object(b.sendAddTrackEvent)(r[g],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[g]=!0,r[g]=a)}}},s.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,o={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=o,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(g,i,r){var o=this.media;if(!!o)return o.addTextTrack(g,i,r)},s.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(b.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),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())},s._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(b.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],c=o.some(function(a){return a.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&o&&this.tracks.length===o.length;if(this.tracks=o||[],this.config.renderTextTracksNatively){var n=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,d){var v;if(d<n.length){for(var S=null,T=0;T<n.length;T++)if(m(n[T],a)){S=n[T];break}S&&(v=S)}if(v)Object(b.clearCurrentCues)(v);else{var I=r._captionsOrSubtitlesFromCharacteristics(a);v=r.createTextTrack(I,a.name,a.lang),v&&(v.mode="disabled")}v&&(v.groupId=a.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},s._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var c=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!c){var t="textTrack"+c[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===x.PlaylistLevelType.MAIN){var n,u,a=i.frag.sn,d=(n=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?n:-1;a===c+1||a===c&&d===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=d}},s.onFragLoaded=function(g,i){var r=i.frag,o=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===x.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(C.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,u="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||u){var a=this.tracks[r.level],d=this.vttCCs;d[r.cc]||(d[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,d)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(g,i){var r=this,o=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){D.logger.log("Failed to parse IMSC1: "+c),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},s._parseVTTs=function(g,i,r){var o,c=this,t=this.hls,n=(o=g.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(O.parseWebVTT)(n,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),D.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},s._fallbackToIMSC1=function(g,i){var r=this,o=this.tracks[g.level];o.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){o.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;g.forEach(function(n){return Object(b.addCueToTrack)(o,n)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},s.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===x.PlaylistLevelType.SUBTITLE){if(!Object(C.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[c].pts,n[0]),o.addData(i.samples[c].pts,n[1])}}},s.onBufferFlushing=function(g,i){var r=i.startOffset,o=i.endOffset,c=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(d){return Object(b.removeCuesInRange)(u[d],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(d){return Object(b.removeCuesInRange)(a[d],r,c)})}}},s.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,o=2,c=0;c<r;c++){var t=g[o++],n=127&g[o++],u=127&g[o++];if(!(n===0&&u===0)){var a=(4&t)!==0;if(a){var d=3&t;(d===0||d===1)&&(i[d].push(n),i[d].push(u))}}}return i},e}();function m(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,h,g){return Math.min(s,g)-Math.max(e,h)}function f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return C});var C=function(){function L(w,O){this.subtle=void 0,this.aesIV=void 0,this.subtle=w,this.aesIV=O}var A=L.prototype;return A.decrypt=function(O,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,O)},L}()},"./src/crypt/aes-decryptor.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"removePadding",function(){return L}),l.d(R,"default",function(){return A});var C=l("./src/utils/typed-array.ts");function L(w){var O=w.byteLength,b=O&&new DataView(w.buffer).getUint8(O-1);return b?Object(C.sliceUint8)(w,0,O-b):w}var A=function(){function w(){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 O=w.prototype;return O.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),x=new Uint32Array(4),D=0;D<4;D++)x[D]=y.getUint32(D*4);return x},O.initTable=function(){var _=this.sBox,y=this.invSBox,x=this.subMix,D=x[0],E=x[1],m=x[2],p=x[3],f=this.invSubMix,e=f[0],s=f[1],h=f[2],g=f[3],i=new Uint32Array(256),r=0,o=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var n=i[r],u=i[n],a=i[u],d=i[t]*257^t*16843008;D[r]=d<<24|d>>>8,E[r]=d<<16|d>>>16,m[r]=d<<8|d>>>24,p[r]=d,d=a*16843009^u*65537^n*257^r*16843008,e[t]=d<<24|d>>>8,s[t]=d<<16|d>>>16,h[t]=d<<8|d>>>24,g[t]=d,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},O.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),x=!0,D=0;D<y.length&&x;)x=y[D]===this.key[D],D++;if(!x){this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var m=this.ksRows=(E+6+1)*4,p,f,e=this.keySchedule=new Uint32Array(m),s=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],o=i[1],c=i[2],t=i[3],n,u;for(p=0;p<m;p++){if(p<E){n=e[p]=y[p];continue}u=n,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=n=(e[p-E]^u)>>>0}for(f=0;f<m;f++)p=m-f,f&3?u=e[p]:u=e[p-4],f<4||p<=4?s[f]=u:s[f]=r[h[u>>>24]]^o[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],s[f]=s[f]>>>0}},O.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},O.decrypt=function(_,y,x){for(var D=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,f=p[0],e=p[1],s=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(x),i=g[0],r=g[1],o=g[2],c=g[3],t=new Int32Array(_),n=new Int32Array(t.length),u,a,d,v,S,T,I,k,B,U,W,H,z,Y,$=this.networkToHostOrderSwap;y<t.length;){for(B=$(t[y]),U=$(t[y+1]),W=$(t[y+2]),H=$(t[y+3]),S=B^E[0],T=H^E[1],I=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)u=f[S>>>24]^e[T>>16&255]^s[I>>8&255]^h[k&255]^E[z],a=f[T>>>24]^e[I>>16&255]^s[k>>8&255]^h[S&255]^E[z+1],d=f[I>>>24]^e[k>>16&255]^s[S>>8&255]^h[T&255]^E[z+2],v=f[k>>>24]^e[S>>16&255]^s[T>>8&255]^h[I&255]^E[z+3],S=u,T=a,I=d,k=v,z=z+4;u=m[S>>>24]<<24^m[T>>16&255]<<16^m[I>>8&255]<<8^m[k&255]^E[z],a=m[T>>>24]<<24^m[I>>16&255]<<16^m[k>>8&255]<<8^m[S&255]^E[z+1],d=m[I>>>24]<<24^m[k>>16&255]<<16^m[S>>8&255]<<8^m[T&255]^E[z+2],v=m[k>>>24]<<24^m[S>>16&255]<<16^m[T>>8&255]<<8^m[I&255]^E[z+3],n[y]=$(u^i),n[y+1]=$(v^r),n[y+2]=$(d^o),n[y+3]=$(a^c),i=B,r=U,o=W,c=H,y=y+4}return n.buffer},w}()},"./src/crypt/decrypter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return y});var C=l("./src/crypt/aes-crypto.ts"),L=l("./src/crypt/fast-aes-key.ts"),A=l("./src/crypt/aes-decryptor.ts"),w=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=16,y=function(){function x(E,m,p){var f=p===void 0?{}:p,e=f.removePKCS7Padding,s=e===void 0?!0:e;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=E,this.config=m,this.removePKCS7Padding=s,s)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=x.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(m,p,f,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,f);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,f).then(e)},D.softwareDecrypt=function(m,p,f){var e=this.currentIV,s=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(O.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(f=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new A.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(g.buffer,0,f),this.currentIV=Object(b.sliceUint8)(g,-16).buffer,r||null},D.webCryptoDecrypt=function(m,p,f){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(s,p)),this.fastAesKey.expandKey().then(function(h){if(!s)return Promise.reject(new Error("web crypto not initialized"));var g=new C.default(s,f);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,f)})},D.onWebCryptoError=function(m,p,f,e){return w.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,f,e)},D.getValidChunk=function(m){var p=m,f=m.length-m.length%_;return f!==m.length&&(p=Object(b.sliceUint8)(m,0,f),this.remainderData=Object(b.sliceUint8)(m,f)),p},D.logOnce=function(m){!this.logEnabled||(w.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return C});var C=function(){function L(w,O){this.subtle=void 0,this.key=void 0,this.subtle=w,this.key=O}var A=L.prototype;return A.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/adts.ts"),A=l("./src/utils/logger.ts"),w=l("./src/demux/id3.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(E,m){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=m,p}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=w.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(L.probe(m,f))return A.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(m,p){return L.canParse(m,p)},D.appendFrame=function(m,p,f){L.initTrackConfig(m,this.observer,p,f,m.manifestCodec);var e=L.appendFrame(m,p,f,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},x}(C.default);R.default=_},"./src/demux/adts.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getAudioConfig",function(){return w}),l.d(R,"isHeaderPattern",function(){return O}),l.d(R,"getHeaderLength",function(){return b}),l.d(R,"getFullFrameLength",function(){return _}),l.d(R,"canGetFrameLength",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E}),l.d(R,"initTrackConfig",function(){return m}),l.d(R,"getFrameDuration",function(){return p}),l.d(R,"parseFrameHeader",function(){return f}),l.d(R,"appendFrame",function(){return e});var C=l("./src/utils/logger.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts");function w(s,h,g,i){var r,o,c,t,n=navigator.userAgent.toLowerCase(),u=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var d=(h[g+2]&60)>>>2;if(d>a.length-1){s.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,C.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+d),/firefox/i.test(n)?d>=6?(r=5,t=new Array(4),o=d-3):(r=2,t=new Array(2),o=d):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=d):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?o=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&c===1||/vivaldi/i.test(n))||!i&&c===1)&&(r=2,t=new Array(2)),o=d)),t[0]=r<<3,t[0]|=(d&14)>>1,t[1]|=(d&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[d],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function O(s,h){return s[h]===255&&(s[h+1]&246)===240}function b(s,h){return s[h+1]&1?7:9}function _(s,h){return(s[h+3]&3)<<11|s[h+4]<<3|(s[h+5]&224)>>>5}function y(s,h){return h+5<s.length}function x(s,h){return h+1<s.length&&O(s,h)}function D(s,h){return y(s,h)&&O(s,h)&&_(s,h)<=s.length-h}function E(s,h){if(x(s,h)){var g=b(s,h);if(h+g>=s.length)return!1;var i=_(s,h);if(i<=g)return!1;var r=h+i;return r===s.length||x(s,r)}return!1}function m(s,h,g,i,r){if(!s.samplerate){var o=w(h,g,i,r);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,C.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function f(s,h){var g=b(s,h);if(h+g<=s.length){var i=_(s,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(s,h,g,i,r){var o=p(s.samplerate),c=i+r*o,t=f(h,g),n;if(t){var u=t.frameLength,a=t.headerLength,d=a+u,v=Math.max(0,g+d-h.length);v?(n=new Uint8Array(d-a),n.set(h.subarray(g+a,h.length),0)):n=h.subarray(g+a,g+d);var S={unit:n,pts:c};return v||s.samples.push(S),{sample:S,length:d,missing:v}}var T=h.length-g;n=new Uint8Array(T),n.set(h.subarray(g,h.length),0);var I={unit:n,pts:c};return{sample:I,length:T,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"initPTSFn",function(){return y});var C=l("./src/polyfills/number.ts"),L=l("./src/demux/id3.ts"),A=l("./src/types/demuxer.ts"),w=l("./src/demux/dummy-demuxed-track.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(m,p){return!1},D.appendFrame=function(m,p,f){},D.demux=function(m,p){this.cachedData&&(m=Object(O.appendUint8Array)(this.cachedData,m),this.cachedData=null);var f=L.getID3Data(m,0),e=f?f.length:0,s,h,g=this._audioTrack,i=this._id3Track,r=f?L.getTimeStamp(f):void 0,o=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(C.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),f&&f.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:f,type:A.MetadataSchema.audioId3}),h=this.basePTS;e<o;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,s=e):e=o}else L.canParse(m,e)?(f=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:f,type:A.MetadataSchema.audioId3}),e+=f.length,s=e):e++;if(e===o&&s!==o){var t=Object(b.sliceUint8)(m,s);this.cachedData?this.cachedData=Object(O.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(w.dummyTrack)(),id3Track:i,textTrack:Object(w.dummyTrack)()}},D.demuxSampleAes=function(m,p,f){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(w.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(w.dummyTrack)()}},D.destroy=function(){},x}(),y=function(D,E,m){return Object(C.isFiniteNumber)(D)?D*90:E*9e4+(m||0)};R.default=_},"./src/demux/chunk-cache.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return C});var C=function(){function A(){this.chunks=[],this.dataLength=0}var w=A.prototype;return w.push=function(b){this.chunks.push(b),this.dataLength+=b.length},w.flush=function(){var b=this.chunks,_=this.dataLength,y;if(b.length)b.length===1?y=b[0]:y=L(b,_);else return new Uint8Array(0);return this.reset(),y},w.reset=function(){this.chunks.length=0,this.dataLength=0},A}();function L(A,w){for(var O=new Uint8Array(w),b=0,_=0;_<A.length;_++){var y=A[_];O.set(y,b),b+=y.length}return O}},"./src/demux/dummy-demuxed-track.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"dummyTrack",function(){return C});function C(L,A){return L===void 0&&(L=""),A===void 0&&(A=9e4),{type:L,id:-1,pid:-1,inputTimeScale:A,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/utils/logger.ts"),L=function(){function A(O){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=O,this.bytesAvailable=O.byteLength,this.word=0,this.bitsAvailable=0}var w=A.prototype;return w.loadWord=function(){var b=this.data,_=this.bytesAvailable,y=b.byteLength-_,x=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");x.set(b.subarray(y,y+D)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},w.skipBits=function(b){var _;this.bitsAvailable>b?(this.word<<=b,this.bitsAvailable-=b):(b-=this.bitsAvailable,_=b>>3,b-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=b,this.bitsAvailable-=b)},w.readBits=function(b){var _=Math.min(this.bitsAvailable,b),y=this.word>>>32-_;return b>32&&C.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=b-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},w.skipLZ=function(){var b;for(b=0;b<this.bitsAvailable;++b)if((this.word&2147483648>>>b)!==0)return this.word<<=b,this.bitsAvailable-=b,b;return this.loadWord(),b+this.skipLZ()},w.skipUEG=function(){this.skipBits(1+this.skipLZ())},w.skipEG=function(){this.skipBits(1+this.skipLZ())},w.readUEG=function(){var b=this.skipLZ();return this.readBits(b+1)-1},w.readEG=function(){var b=this.readUEG();return 1&b?1+b>>>1:-1*(b>>>1)},w.readBoolean=function(){return this.readBits(1)===1},w.readUByte=function(){return this.readBits(8)},w.readUShort=function(){return this.readBits(16)},w.readUInt=function(){return this.readBits(32)},w.skipScalingList=function(b){for(var _=8,y=8,x,D=0;D<b;D++)y!==0&&(x=this.readEG(),y=(_+x+256)%256),_=y===0?_:y},w.readSPS=function(){var b=0,_=0,y=0,x=0,D,E,m,p=this.readUByte.bind(this),f=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(f(5),h(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var c=e();if(c===3&&h(1),i(),i(),h(1),s())for(E=c!==3?8:12,m=0;m<E;m++)s()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),D=e(),m=0;m<D;m++)g();i(),h(1);var n=e(),u=e(),a=f(1);a===0&&h(1),h(1),s()&&(b=e(),_=e(),y=e(),x=e());var d=[1,1];if(s()&&s()){var v=p();switch(v){case 1:d=[1,1];break;case 2:d=[12,11];break;case 3:d=[10,11];break;case 4:d=[16,11];break;case 5:d=[40,33];break;case 6:d=[24,11];break;case 7:d=[20,11];break;case 8:d=[32,11];break;case 9:d=[80,33];break;case 10:d=[18,11];break;case 11:d=[15,11];break;case 12:d=[64,33];break;case 13:d=[160,99];break;case 14:d=[4,3];break;case 15:d=[3,2];break;case 16:d=[2,1];break;case 255:{d=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((n+1)*16-b*2-_*2),height:(2-a)*(u+1)*16-(a?2:4)*(y+x),pixelRatio:d}},w.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();R.default=L},"./src/demux/id3.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isHeader",function(){return C}),l.d(R,"isFooter",function(){return L}),l.d(R,"getID3Data",function(){return A}),l.d(R,"canParse",function(){return O}),l.d(R,"getTimeStamp",function(){return b}),l.d(R,"isTimeStampFrame",function(){return _}),l.d(R,"getID3Frames",function(){return x}),l.d(R,"decodeFrame",function(){return D}),l.d(R,"utf8ArrayToStr",function(){return e}),l.d(R,"testables",function(){return s});var C=function(r,o){return o+10<=r.length&&r[o]===73&&r[o+1]===68&&r[o+2]===51&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},L=function(r,o){return o+10<=r.length&&r[o]===51&&r[o+1]===68&&r[o+2]===73&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},A=function(r,o){for(var c=o,t=0;C(r,o);){t+=10;var n=w(r,o+6);t+=n,L(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(c,c+t)},w=function(r,o){var c=0;return c=(r[o]&127)<<21,c|=(r[o+1]&127)<<14,c|=(r[o+2]&127)<<7,c|=r[o+3]&127,c},O=function(r,o){return C(r,o)&&w(r,o+6)+10<=r.length-o},b=function(r){for(var o=x(r),c=0;c<o.length;c++){var t=o[c];if(_(t))return f(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var o=String.fromCharCode(r[0],r[1],r[2],r[3]),c=w(r,4),t=10;return{type:o,size:c,data:r.subarray(t,t+c)}},x=function(r){for(var o=0,c=[];C(r,o);){var t=w(r,o+6);o+=10;for(var n=o+t;o+8<n;){var u=y(r.subarray(o)),a=D(u);a&&c.push(a),o+=u.size+10}L(r,o)&&(o+=10)}return c},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var o=e(r.data,!0),c=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data.subarray(1));return{key:r.type,data:n}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data);return{key:r.type,data:n}},f=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),c=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var c=g();if(c){var t=c.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var u=r.length,a,d,v,S="",T=0;T<u;){if(a=r[T++],a===0&&o)return S;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:d=r[T++],S+=String.fromCharCode((a&31)<<6|d&63);break;case 14:d=r[T++],v=r[T++],S+=String.fromCharCode((a&15)<<12|(d&63)<<6|(v&63)<<0);break;default:}}return S},s={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/id3.ts"),A=l("./src/utils/logger.ts"),w=l("./src/demux/mpegaudio.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(){return y.apply(this,arguments)||this}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=L.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(w.probe(m,f))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(m,p){return w.canParse(m,p)},D.appendFrame=function(m,p,f){if(this.basePTS!==null)return w.appendFrame(m,p,f,this.basePTS,this.frameIndex)},x}(C.default);R.default=_},"./src/demux/mp4demuxer.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/types/demuxer.ts"),A=l("./src/utils/mp4-tools.ts"),w=l("./src/demux/dummy-demuxed-track.ts"),O=/\/emsg[-/]ID3/i,b=function(){function _(x,D){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=D}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,m,p){var f=Object(A.parseInitSegment)(D),e=this.videoTrack=Object(w.dummyTrack)("video",1),s=this.audioTrack=Object(w.dummyTrack)("audio",1),h=this.txtTrack=Object(w.dummyTrack)("text",1);if(this.id3Track=Object(w.dummyTrack)("id3",1),this.timeOffset=0,f.video){var g=f.video,i=g.id,r=g.timescale,o=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=o}if(f.audio){var c=f.audio,t=c.id,n=c.timescale,u=c.codec;s.id=t,s.timescale=n,s.codec=u}h.id=A.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(A.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var m=D,p=this.videoTrack,f=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(A.appendUint8Array)(this.remainderData,D));var e=Object(A.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var s=this.extractID3Track(p,E);return f.samples=Object(A.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,m=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return m.samples=Object(A.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(w.dummyTrack)(),id3Track:p,textTrack:Object(w.dummyTrack)()}},y.extractID3Track=function(D,E){var m=this.id3Track;if(D.samples.length){var p=Object(A.findBox)(D.samples,["emsg"]);p&&p.forEach(function(f){var e=Object(A.parseEmsg)(f);if(O.test(e.schemeIdUri)){var s=Object(C.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:s,pts:s,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(D,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();R.default=b},"./src/demux/mpegaudio.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"appendFrame",function(){return b}),l.d(R,"parseHeader",function(){return _}),l.d(R,"isHeaderPattern",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E});var C=null,L=[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],w=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],O=[0,1,1,4];function b(m,p,f,e,s){if(!(f+24>p.length)){var h=_(p,f);if(h&&f+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+s*g,r={unit:p.subarray(f,f+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var f=m[p+1]>>3&3,e=m[p+1]>>1&3,s=m[p+2]>>4&15,h=m[p+2]>>2&3;if(f!==1&&s!==0&&s!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=f===3?3-e:e===3?3:4,o=L[r*14+s-1]*1e3,c=f===3?0:f===2?1:2,t=A[c*3+h],n=i===3?1:2,u=w[f][e],a=O[e],d=u*8*a,v=Math.floor(u*o/t+g)*a;if(C===null){var S=navigator.userAgent||"",T=S.match(/Chrome\/(\d+)/i);C=T?parseInt(T[1]):0}var I=!!C&&C<=87;return I&&e===2&&o>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:n,frameLength:v,samplesPerFrame:d}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function x(m,p){return p+1<m.length&&y(m,p)}function D(m,p){var f=4;return y(m,p)&&f<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var f=4,e=_(m,p),s=f;e!=null&&e.frameLength&&(s=e.frameLength);var h=p+s;return h===m.length||x(m,h)}return!1}},"./src/demux/sample-aes.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/crypt/decrypter.ts"),L=l("./src/demux/tsdemuxer.ts"),A=function(){function w(b,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new C.default(b,_,{removePKCS7Padding:!1})}var O=w.prototype;return O.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},O.decryptAacSample=function(_,y,x,D){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),f=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||f.decryptAacSamples(_,y+1,x)})}},O.decryptAacSamples=function(_,y,x){for(;;y++){if(y>=_.length){x();return}if(!(_[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,y,x,D),!D)return}}},O.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,x=new Int8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)x.set(_.subarray(E,E+16),D);return x},O.getAvcDecryptedUnit=function(_,y){for(var x=new Uint8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)_.set(x.subarray(D,D+16),E);return _},O.decryptAvcSample=function(_,y,x,D,E,m){var p=Object(L.discardEPB)(E.data),f=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(f.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),m||e.decryptAvcSamples(_,y,x+1,D)})},O.decryptAvcSamples=function(_,y,x,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,x=0){if(y>=_.length){D();return}for(var E=_[y].units;!(x>=E.length);x++){var m=E[x];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,y,x,D,m,p),!p)return}}}},w}();R.default=A},"./src/demux/transmuxer-interface.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var C=l("./node_modules/webworkify-webpack/index.js"),L=l.n(C),A=l("./src/events.ts"),w=l("./src/demux/transmuxer.ts"),O=l("./src/utils/logger.ts"),b=l("./src/errors.ts"),_=l("./src/utils/mediasource-helper.ts"),y=l("./node_modules/eventemitter3/index.js"),x=l.n(y),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(f,e,s,h){var g=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=f,this.id=e,this.onTransmuxComplete=s,this.onFlush=h;var i=f.config,r=function(u,a){a=a||{},a.frag=g.frag,a.id=g.id,f.trigger(u,a)};this.observer=new y.EventEmitter,this.observer.on(A.Events.FRAG_DECRYPTED,r),this.observer.on(A.Events.ERROR,r);var o={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){O.logger.log("demuxing in webworker");var t;try{t=this.worker=C("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){f.trigger(A.Events.ERROR,{type:b.ErrorTypes.OTHER_ERROR,details:b.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:c,id:e,config:JSON.stringify(i)})}catch(n){O.logger.warn("Error in worker:",n),O.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new w.default(this.observer,o,i,c,e),this.worker=null}}else this.transmuxer=new w.default(this.observer,o,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,h,g,i,r,o,c,t,n){var u,a,d=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,T=r?r.start:i.start,I=i.decryptdata,k=this.frag,B=!(k&&i.cc===k.cc),U=!(k&&t.level===k.level),W=k?t.sn-k.sn:-1,H=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(k==null?void 0:k.stats.chunkCount),Y=!U&&(W===1||W===0&&(H===1||z&&H<=0)),$=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=$),r&&(H||!Y)&&(r.stats.parsing.start=$);var ee=!(k&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new w.TransmuxState(B,Y,c,U,T,ee);if(!Y||B||ee){O.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
|
|
14
15
|
discontinuity: `+B+`
|
|
15
16
|
trackSwitch: `+U+`
|
|
16
17
|
contiguous: `+Y+`
|
|
17
18
|
accurateTimeOffset: `+c+`
|
|
18
19
|
timeOffset: `+T+`
|
|
19
|
-
initSegmentChange: `+Z);var ie=new M.TransmuxConfig(h,g,s,o,n);this.configureTransmuxer(ie)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:I,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(v){var ne=v.push(e,I,t,q);Object(M.isPromise)(ne)?ne.then(function(ae){d.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(M.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,h=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":O.logger[s.data.logType]&&O.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,h.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,h=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/demux/transmuxer.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),M=l("./node_modules/eventemitter3/index.js"),O=l.n(M);function b(E){var m=new M.EventEmitter,p=function(s,h){E.postMessage({event:s,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var f=function(){var s=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};A.logger[i]=r};for(var h in A.logger)s(h)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var h=JSON.parse(s.config);E.transmuxer=new P.default(m,s.typeSupported,h,s.vendor,s.id),Object(A.enableLogs)(h.debug),f(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var g=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(P.isPromise)(g)?g.then(function(o){_(E,o)}):_(E,g);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(P.isPromise)(r)?r.then(function(o){x(E,o,i)}):x(E,r,i);break}default:break}})}function _(E,m){if(D(m.remuxResult))return!1;var p=[],f=m.remuxResult,e=f.audio,s=f.video;return e&&y(p,e),s&&y(p,s),E.postMessage({event:"transmuxComplete",data:m},p),!0}function y(E,m){m.data1&&E.push(m.data1.buffer),m.data2&&E.push(m.data2.buffer)}function x(E,m,p){var f=m.reduce(function(e,s){return _(E,s)||e},!1);f||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function D(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return p}),l.d(R,"isPromise",function(){return s}),l.d(R,"TransmuxConfig",function(){return h}),l.d(R,"TransmuxState",function(){return g});var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/crypt/decrypter.ts"),M=l("./src/demux/aacdemuxer.ts"),O=l("./src/demux/mp4demuxer.ts"),b=l("./src/demux/tsdemuxer.ts"),_=l("./src/demux/mp3demuxer.ts"),y=l("./src/remux/mp4-remuxer.ts"),x=l("./src/remux/passthrough-remuxer.ts"),D=l("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:b.default,remux:y.default},{demux:O.default,remux:x.default},{demux:M.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(o,c,t,n,u){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=o,this.typeSupported=c,this.config=t,this.vendor=n,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,n,u){var a=this,d=n.transmuxing;d.executeStart=E();var v=new Uint8Array(c),S=this.config,T=this.currentTransmuxState,I=this.transmuxConfig;u&&(this.currentTransmuxState=u);var k=u||T,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,G=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=I.audioCodec,Z=I.videoCodec,q=I.defaultInitPts,ie=I.duration,ne=I.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,$,Z,ie),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ae=f(v,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var fe=te.softwareDecrypt(v,ae.key.buffer,ae.iv.buffer);if(!fe)return d.executeEnd=E(),e(n);v=new Uint8Array(fe)}else return this.decryptionPromise=te.webCryptoDecrypt(v,ae.key.buffer,ae.iv.buffer).then(function(Ee){var me=a.push(Ee,null,n);return a.decryptionPromise=null,me}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,I);var de=this.transmux(v,ae,z,G,n),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,d.executeEnd=E(),de},r.flush=function(c){var t=this,n=c.transmuxing;n.executeStart=E();var u=this.decrypter,a=this.currentTransmuxState,d=this.decryptionPromise;if(d)return d.then(function(){return t.flush(c)});var v=[],S=a.timeOffset;if(u){var T=u.flush();T&&v.push(this.push(T,null,c))}var I=this.demuxer,k=this.remuxer;if(!I||!k)return this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(c)];var B=I.flush(S);return s(B)?B.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,B,c),v)},r.flushRemux=function(c,t,n){var u=t.audioTrack,a=t.videoTrack,d=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,T=S.accurateTimeOffset,I=S.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var k=this.remuxer.remux(u,a,d,v,I,T,!0,this.id);c.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(c),n.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,n,u){var a=this.demuxer,d=this.remuxer;!a||!d||(a.resetInitSegment(c,t,n,u),d.resetInitSegment(c,t,n))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,n,u,a){var d;return t&&t.method==="SAMPLE-AES"?d=this.transmuxSampleAes(c,t,n,u,a):d=this.transmuxUnencrypted(c,n,u,a),d},r.transmuxUnencrypted=function(c,t,n,u){var a=this.demuxer.demux(c,t,!1,!this.config.progressive),d=a.audioTrack,v=a.videoTrack,S=a.id3Track,T=a.textTrack,I=this.remuxer.remux(d,v,S,T,t,n,!1,this.id);return{remuxResult:I,chunkMeta:u}},r.transmuxSampleAes=function(c,t,n,u,a){var d=this;return this.demuxer.demuxSampleAes(c,t,n).then(function(v){var S=d.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,n,u,!1,d.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(c,t){for(var n=this.config,u=this.observer,a=this.typeSupported,d=this.vendor,v=t.audioCodec,S=t.defaultInitPts,T=t.duration,I=t.initSegmentData,k=t.videoCodec,B,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){B=m[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:O.default,remux:x.default});var G=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(u,n,a,d)),(!G||!(G instanceof $))&&(this.demuxer=new $(u,n,a),this.probe=$.probe),this.resetInitSegment(I,v,k,T),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new A.default(this.observer,this.config)),c},i}();function f(i,r){var o=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(o=r),o}var e=function(r){return{remuxResult:{},chunkMeta:r}};function s(i){return"then"in i&&i.then instanceof Function}var h=function(r,o,c,t,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=o,this.initSegmentData=c,this.duration=t,this.defaultInitPts=n},g=function(r,o,c,t,n,u){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=o,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"discardEPB",function(){return h});var P=l("./src/demux/adts.ts"),L=l("./src/demux/mpegaudio.ts"),A=l("./src/demux/exp-golomb.ts"),M=l("./src/demux/sample-aes.ts"),O=l("./src/events.ts"),b=l("./src/utils/mp4-tools.ts"),_=l("./src/utils/logger.ts"),y=l("./src/errors.ts"),x=l("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(g[o]=r[o])}return g},D.apply(this,arguments)}var E=function(){function g(r,o,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._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=r,this.config=o,this.typeSupported=c}g.probe=function(o){return o[0]===71&&o[188]===71},g.createTrack=function(o,c){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:b.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(o,c,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",n),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,c=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,c,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var u,a=this._avcTrack,d=this._audioTrack,v=this._id3Track,S=this._txtTrack,T=a.pid,I=a.pesData,k=d.pid,B=v.pid,U=d.pesData,W=v.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(b.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};$-=$%188,$<o.byteLength&&!n&&(this.remainderData=new Uint8Array(o.buffer,$,o.buffer.byteLength-$));for(var Z=0,q=0;q<$;q+=188)if(o[q]===71){var ie=!!(o[q+1]&64),ne=((o[q+1]&31)<<8)+o[q+2],ae=(o[q+3]&48)>>4,te=void 0;if(ae>1){if(te=q+5+o[q+4],te===q+188)continue}else te=q+4;switch(ne){case T:ie&&(I&&(u=e(I))&&this.parseAVCPES(a,S,u,!1),I={data:[],size:0}),I&&(I.data.push(o.subarray(te,q+188)),I.size+=q+188-te);break;case k:if(ie){if(U&&(u=e(U)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:ie&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(o.subarray(te,q+188)),W.size+=q+188-te);break;case 0:ie&&(te+=o[te]+1),Y=this._pmtId=p(o,te);break;case Y:{ie&&(te+=o[te]+1);var fe=f(o,te,this.typeSupported,t);T=fe.avc,T>0&&(a.pid=T),k=fe.audio,k>0&&(d.pid=k,d.segmentCodec=fe.segmentCodec),B=fe.id3,B>0&&(v.pid=B),G!==null&&!z&&(_.logger.log("unknown PID '"+G+"' in TS found"),G=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=ne;break}}else Z++;Z>0&&this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Z+" TS packet/s that do not start with 0x47"}),a.pesData=I,d.pesData=U,v.pesData=W;var de={audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};return n&&this.extractRemainingSamples(de),de},i.flush=function(){var o=this.remainderData;this.remainderData=null;var c;return o?c=this.demux(o,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(o){var c=o.audioTrack,t=o.videoTrack,n=o.id3Track,u=o.textTrack,a=t.pesData,d=c.pesData,v=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=a,d&&(S=e(d))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else d!=null&&d.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=d;v&&(S=e(v))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=v},i.demuxSampleAes=function(o,c,t){var n=this.demux(o,t,!0,!this.config.progressive),u=this.sampleAes=new M.default(this.observer,this.config,c);return this.decrypt(n,u)},i.decrypt=function(o,c){return new Promise(function(t){var n=o.audioTrack,u=o.videoTrack;n.samples&&n.segmentCodec==="aac"?c.decryptAacSamples(n.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(o)}):t(o)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,c,t,n){var u=this,a=this.parseAVCNALu(o,t.data),d=!1,v=this.avcSample,S,T=!1;t.data=null,v&&a.length&&!o.audFound&&(s(v,o),v=this.avcSample=m(!1,t.pts,t.dts,"")),a.forEach(function(I){switch(I.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="NDR "),v.frame=!0;var k=I.data;if(T&&k.length>4){var B=new A.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,d&&v&&(v.debug+="SEI "),Object(b.parseSEIMessageFromNALu)(h(I.data),t.pts,c.samples);break}case 7:if(S=!0,T=!0,d&&v&&(v.debug+="SPS "),!o.sps){var U=new A.default(I.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[I.data],o.duration=u._duration;for(var G=I.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var $=G[Y].toString(16);$.length<2&&($="0"+$),z+=$}o.codec=z}break;case 8:S=!0,d&&v&&(v.debug+="PPS "),o.pps||(o.pps=[I.data]);break;case 9:S=!1,o.audFound=!0,v&&s(v,o),v=u.avcSample=m(!1,t.pts,t.dts,d?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+I.type+" ");break}if(v&&S){var Z=v.units;Z.push(I)}}),n&&v&&(s(v,o),this.avcSample=null)},i.getLastNalUnit=function(o){var c,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;n=u[u.length-1]}return n},i.parseAVCNALu=function(o,c){var t=c.byteLength,n=o.naluState||0,u=n,a=[],d=0,v,S,T,I=-1,k=0;for(n===-1&&(I=0,k=c[0]&31,n=0,d=1);d<t;){if(v=c[d++],!n){n=v?0:1;continue}if(n===1){n=v?0:2;continue}if(!v)n=3;else if(v===1){if(I>=0){var B={data:c.subarray(I,d-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(u&&d<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=d-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}d<t?(T=c[d]&31,I=d,k=T,n=0):n=-1}else n=0}if(I>=0&&n>=0){var G={data:c.subarray(I,t),type:k,state:n};a.push(G)}if(a.length===0){var z=this.getLastNalUnit(o.samples);if(z){var Y=new Uint8Array(z.data.byteLength+c.byteLength);Y.set(z.data,0),Y.set(c,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,c){var t=0,n=this.aacOverFlow,u=c.data;if(n){this.aacOverFlow=null;var a=n.missing,d=n.sample.unit.byteLength;if(a===-1){var v=new Uint8Array(d+u.byteLength);v.set(n.sample.unit,0),v.set(u,d),u=v}else{var S=d-a;n.sample.unit.set(u.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var T,I;for(T=t,I=u.length;T<I-1&&!P.isHeader(u,T);T++);if(T!==t){var k,B;if(T<I-1?(k="AAC PES did not start with ADTS header,offset:"+T,B=!1):(k="no ADTS header found in AAC PES",B=!0),_.logger.warn("parsing error:"+k),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}P.initTrackConfig(o,this.observer,u,T,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(n){var W=P.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;T<I;)if(z=P.appendFrame(o,u,T,U,G),T+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;T<I-1&&!P.isHeader(u,T);T++);},i.parseMPEGPES=function(o,c){var t=c.data,n=t.length,u=0,a=0,d=c.pts;if(d===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(L.isHeader(t,a)){var v=L.appendFrame(o,t,a,d,u);if(v)a+=v.length,u++;else break}else a++},i.parseID3PES=function(o,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},c,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});o.samples.push(t)},g}();function m(g,i,r,o){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function f(g,i,r,o){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],n=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<n;){var a=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!o){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=a);break;case 21:c.id3===-1&&(c.id3=a);break;case 219:if(!o){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=a,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,o,c,t,n,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var a=new Uint8Array(u[0].length+u[1].length);a.set(u[0]),a.set(u[1],u[0].length),u[0]=a,u.splice(1,1)}r=u[0];var d=(r[0]<<16)+(r[1]<<8)+r[2];if(d===1){if(o=(r[4]<<8)+r[5],o&&o>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(n=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-n>60*9e4&&(_.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var T=new Uint8Array(g.size),I=0,k=u.length;I<k;I++){r=u[I];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;T.set(r,i),i+=B}return o&&(o-=c+3),{data:T,pts:t,dts:n,len:o}}return null}function s(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,o=r.length;if(o){var c=r[o-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],o=1;o<i-2;)g[o]===0&&g[o+1]===0&&g[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),n=0;for(o=0;o<c;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=g[n];return t}R.default=E},"./src/errors.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ErrorTypes",function(){return P}),l.d(R,"ErrorDetails",function(){return L});var P;(function(A){A.NETWORK_ERROR="networkError",A.MEDIA_ERROR="mediaError",A.KEY_SYSTEM_ERROR="keySystemError",A.MUX_ERROR="muxError",A.OTHER_ERROR="otherError"})(P||(P={}));var L;(function(A){A.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",A.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",A.KEY_SYSTEM_NO_SESSION="keySystemNoSession",A.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",A.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",A.MANIFEST_LOAD_ERROR="manifestLoadError",A.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",A.MANIFEST_PARSING_ERROR="manifestParsingError",A.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",A.LEVEL_EMPTY_ERROR="levelEmptyError",A.LEVEL_LOAD_ERROR="levelLoadError",A.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",A.LEVEL_SWITCH_ERROR="levelSwitchError",A.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",A.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",A.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",A.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",A.FRAG_LOAD_ERROR="fragLoadError",A.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",A.FRAG_DECRYPT_ERROR="fragDecryptError",A.FRAG_PARSING_ERROR="fragParsingError",A.REMUX_ALLOC_ERROR="remuxAllocError",A.KEY_LOAD_ERROR="keyLoadError",A.KEY_LOAD_TIMEOUT="keyLoadTimeOut",A.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",A.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",A.BUFFER_APPEND_ERROR="bufferAppendError",A.BUFFER_APPENDING_ERROR="bufferAppendingError",A.BUFFER_STALLED_ERROR="bufferStalledError",A.BUFFER_FULL_ERROR="bufferFullError",A.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",A.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",A.INTERNAL_EXCEPTION="internalException",A.INTERNAL_ABORTED="aborted",A.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Events",function(){return P});var P;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(P||(P={}))},"./src/hls.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return i});var P=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(P),A=l("./src/loader/playlist-loader.ts"),M=l("./src/loader/key-loader.ts"),O=l("./src/controller/id3-track-controller.ts"),b=l("./src/controller/latency-controller.ts"),_=l("./src/controller/level-controller.ts"),y=l("./src/controller/fragment-tracker.ts"),x=l("./src/controller/stream-controller.ts"),D=l("./src/is-supported.ts"),E=l("./src/utils/logger.ts"),m=l("./src/config.ts"),p=l("./node_modules/eventemitter3/index.js"),f=l.n(p),e=l("./src/events.ts"),s=l("./src/errors.ts");function h(r,o){for(var c=0;c<o.length;c++){var t=o[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,o,c){return o&&h(r.prototype,o),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var n=t.abrController,u=t.bufferController,a=t.capLevelController,d=t.fpsController,v=this.abrController=new n(this),S=this.bufferController=new u(this),T=this.capLevelController=new a(this),I=new d(this),k=new A.default(this),B=new M.default(this),U=new O.default(this),W=this.levelController=new _.default(this),G=new y.FragmentTracker(this),z=this.streamController=new x.default(this,G);T.setStreamController(z),I.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[v,S,T,I,U,G];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,G,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,G,Y),this.createController(t.timelineController,null,$),this.emeController=this.createController(t.emeController,null,$),this.cmcdController=this.createController(t.cmcdController,null,$),this.latencyController=this.createController(b.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,u){if(t){var a=n?new t(this,n):new t(this);return u&&u.push(a),a}return null},o.on=function(t,n,u){u===void 0&&(u=this),this._emitter.on(t,n,u)},o.once=function(t,n,u){u===void 0&&(u=this),this._emitter.once(t,n,u)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,u,a){u===void 0&&(u=this),this._emitter.off(t,n,u,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,u){return this._emitter.emit(t,n,u)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},o.listenerCount=function(t){return this._emitter.listenerCount(t)},o.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},o.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},o.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},o.loadSource=function(t){this.stopLoad();var n=this.media,u=this.url,a=this.url=P.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(n)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},o.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(n){n.startLoad(t)})},o.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},o.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},o.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},o.removeLevel=function(t,n){n===void 0&&(n=0),this.levelController.removeLevel(t,n)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var n=!!t;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(E.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,n=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,a=0;a<u;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,u;return n===-1&&t&&t.length?u=t.length-1:u=n,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var n=this.audioTrackController;n&&(n.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:m.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isSupported",function(){return A}),l.d(R,"changeTypeSupported",function(){return M});var P=l("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var O=Object(P.getMediaSource)();if(!O)return!1;var b=L(),_=O&&typeof O.isTypeSupported=="function"&&O.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!_&&!!y}function M(){var O,b=L();return typeof(b==null||(O=b.prototype)===null||O===void 0?void 0:O.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"DateRangeAttribute",function(){return _}),l.d(R,"DateRange",function(){return y});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/attr-list.ts"),A=l("./src/utils/logger.ts");function M(){return M=Object.assign?Object.assign.bind():function(x){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(x[m]=E[m])}return x},M.apply(this,arguments)}function O(x,D){for(var E=0;E<D.length;E++){var m=D[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(x,m.key,m)}}function b(x,D,E){return D&&O(x.prototype,D),E&&O(x,E),Object.defineProperty(x,"prototype",{writable:!1}),x}var _;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function x(D,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var m=E.attr;for(var p in m)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==m[p]){A.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=M(new L.AttrList({}),m,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var f=new Date(this.attr[_.END_DATE]);Object(P.isFiniteNumber)(f.getTime())&&(this._endDate=f)}}return b(x,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var E=this.duration;return E!==null?new Date(this._startDate.getTime()+E*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(P.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(P.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E}),l.d(R,"LoadError",function(){return p});var P=l("./src/polyfills/number.ts"),L=l("./src/errors.ts");function A(f,e){f.prototype=Object.create(e.prototype),f.prototype.constructor=f,y(f,e)}function M(f){var e=typeof Map=="function"?new Map:void 0;return M=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return O(h,arguments,x(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},M(f)}function O(f,e,s){return b()?O=Reflect.construct.bind():O=function(g,i,r){var o=[null];o.push.apply(o,i);var c=Function.bind.apply(g,o),t=new c;return r&&y(t,r.prototype),t},O.apply(null,arguments)}function b(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function y(f,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(f,e)}function x(f){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},x(f)}var D=Math.pow(2,17),E=function(){function f(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=f.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){i.loader&&i.loader.destroy();var a=i.loader=h.loader=c?new c(o):new t(o),d=m(h),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:D};h.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){i.resetLoader(h,a),n({frag:h,part:null,payload:T.data,networkDetails:B})},onError:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:T,networkDetails:k}))},onAbort:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:k}))},onTimeout:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:k}))},onProgress:function(T,I,k,B){g&&g({frag:h,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){r.loader&&r.loader.destroy();var a=r.loader=h.loader=c?new c(o):new t(o),d=m(h,g),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};g.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){r.resetLoader(h,a),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:T.data,networkDetails:B};i(U),n(U)},onError:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:T,networkDetails:k}))},onAbort:function(T,I,k){h.stats.aborted=g.stats.aborted,r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:k}))},onTimeout:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:k}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,o=r.total;if(i.loaded+=r.loaded,o){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/o),c),n=c-t,u=n*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var a=i.loading,d=r.loading;a.start?a.first+=d.first-d.start:(a.start=d.start,a.first=d.first),a.end=d.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},f}();function m(f,e){e===void 0&&(e=null);var s=e||f,h={frag:f,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},g=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(P.isFiniteNumber)(g)&&Object(P.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(f){A(e,f);function e(s){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=f.call.apply(f,[this].concat(i))||this,h.data=void 0,h.data=s,h}return e}(M(Error))},"./src/loader/fragment.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ElementaryStreamTypes",function(){return E}),l.d(R,"BaseSegment",function(){return m}),l.d(R,"Fragment",function(){return p}),l.d(R,"Part",function(){return f});var P=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),M=l("./src/utils/logger.ts"),O=l("./src/loader/level-key.ts"),b=l("./src/loader/load-stats.ts");function _(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,s)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var s=e.prototype;return s.setByteRange=function(g,i){var r=g.split("@",2),o=[];r.length===1?o[0]=i?i.byteRangeEndOffset:0:o[0]=parseInt(r[1]),o[1]=parseInt(r[0])+o[0],this._byteRange=o},D(e,[{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(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(s,e);function s(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new b.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=s.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=O.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},h.setElementaryStreamInfo=function(i,r,o,c,t,n){n===void 0&&(n=!1);var u=this.elementaryStreams,a=u[i];if(!a){u[i]={startPTS:r,endPTS:o,startDTS:c,endDTS:t,partial:n};return}a.startPTS=Math.min(a.startPTS,r),a.endPTS=Math.max(a.endPTS,o),a.startDTS=Math.min(a.startDTS,c),a.endDTS=Math.max(a.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},D(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&M.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(P.isFiniteNumber)(this.programDateTime))return null;var i=Object(P.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(m),f=function(e){_(s,e);function s(h,g,i,r,o){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new b.LoadStats,c.duration=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,o),o&&(c.fragOffset=o.fragOffset+o.duration),c}return D(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),s}(m)},"./src/loader/key-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return M});var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),M=function(){function O(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var b=O.prototype;return b.startLoad=function(y){},b.stopLoad=function(){this.destroyInternalLoaders()},b.registerListeners=function(){this.hls.on(P.Events.KEY_LOADING,this.onKeyLoading,this)},b.unregisterListeners=function(){this.hls.off(P.Events.KEY_LOADING,this.onKeyLoading)},b.destroyInternalLoaders=function(){for(var y in this.loaders){var x=this.loaders[y];x&&x.destroy()}this.loaders={}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onKeyLoading=function(y,x){var D=x.frag,E=D.type,m=this.loaders[E];if(!D.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var f=this.hls.config;if(m&&(A.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){A.logger.warn("key uri is falsy");return}var e=f.loader,s=D.loader=this.loaders[E]=new e(f);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:D,responseType:"arraybuffer"},g={timeout:f.fragLoadingTimeOut,maxRetry:0,retryDelay:f.fragLoadingRetryDelay,maxRetryDelay:f.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(h,g,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(P.Events.KEY_LOADED,{frag:D}))},b.loadsuccess=function(y,x,D){var E=D.frag;if(!E.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(P.Events.KEY_LOADED,{frag:E})},b.loaderror=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},b.loadtimeout=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},O}()},"./src/loader/level-details.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelDetails",function(){return O});var P=l("./src/polyfills/number.ts");function L(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function A(b,_,y){return _&&L(b.prototype,_),y&&L(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var M=10,O=function(){function b(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.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.dateRanges={},this.url=y}var _=b.prototype;return _.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!D,this.advanced=this.endSN>x.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},A(b,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(P.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||M}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var D=this.driftEnd-this.driftStart;return D*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),b}()},"./src/loader/level-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelKey",function(){return O});var P=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(P);function A(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function M(b,_,y){return _&&A(b.prototype,_),y&&A(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var O=function(){b.fromURL=function(y,x){return new b(y,x)},b.fromURI=function(y){return new b(y)};function b(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(P.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return M(b,[{key:"uri",get:function(){return this._uri}}]),b}()},"./src/loader/load-stats.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LoadStats",function(){return P});var P=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(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return h});var P=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),M=l("./src/loader/date-range.ts"),O=l("./src/loader/fragment.ts"),b=l("./src/loader/level-details.ts"),_=l("./src/loader/level-key.ts"),y=l("./src/utils/attr-list.ts"),x=l("./src/utils/logger.ts"),D=l("./src/utils/codecs.ts"),E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),f=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(t){var n,u;return e.test((n=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?n:"")}var h=function(){function t(){}return t.findGroup=function(u,a){for(var d=0;d<u.length;d++){var v=u[d];if(v.id===a)return v}},t.convertAVC1ToAVCOTI=function(u){var a=u.split(".");if(a.length>2){var d=a.shift()+".";return d+=parseInt(a.shift()).toString(16),d+=("000"+parseInt(a.shift()).toString(16)).slice(-4),d}return u},t.resolve=function(u,a){return L.buildAbsoluteURL(a,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,a){var d=[],v={},S=!1;E.lastIndex=0;for(var T;(T=E.exec(u))!=null;)if(T[1]){var I=new y.AttrList(T[1]),k={attrs:I,bitrate:I.decimalInteger("AVERAGE-BANDWIDTH")||I.decimalInteger("BANDWIDTH"),name:I.NAME,url:t.resolve(T[2],a)},B=I.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),g((I.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),d.push(k)}else if(T[3]){var U=new y.AttrList(T[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:d,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,a,d,v){v===void 0&&(v=[]);var S,T=[],I=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===d){var B={attrs:k,bitrate:0,id:I++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:d,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(v.length){var U=t.findGroup(v,B.groupId)||v[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}T.push(B)}}return T},t.parseLevelPlaylist=function(u,a,d,v,S){var T=new b.LevelDetails(a),I=T.fragments,k=null,B=0,U=0,W=0,G=0,z=null,Y=new O.Fragment(v,a),$,Z,q,ie=-1,ne=!1;for(p.lastIndex=0,T.m3u8=u;($=p.exec(u))!==null;){ne&&(ne=!1,Y=new O.Fragment(v,a),Y.start=W,Y.sn=B,Y.cc=G,Y.level=d,k&&(Y.initSegment=k,Y.rawProgramDateTime=k.rawProgramDateTime,k.rawProgramDateTime=null));var ae=$[1];if(ae){Y.duration=parseFloat(ae);var te=(" "+$[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ae,te]:["INF",ae])}else if($[3])Object(P.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=d,Y.cc=G,Y.urlId=S,I.push(Y),Y.relurl=(" "+$[3]).slice(1),o(Y,z),z=Y,W+=Y.duration,B++,U=0,ne=!0);else if($[4]){var fe=(" "+$[4]).slice(1);z?Y.setByteRange(fe,z):Y.setByteRange(fe)}else if($[5])Y.rawProgramDateTime=(" "+$[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),ie===-1&&(ie=I.length);else{if($=$[0].match(f),!$){x.logger.warn("No matches on slow regex match for level playlist!");continue}for(Z=1;Z<$.length&&typeof $[Z]=="undefined";Z++);var de=(" "+$[Z]).slice(1),re=(" "+$[Z+1]).slice(1),Ee=$[Z+2]?(" "+$[Z+2]).slice(1):"";switch(de){case"PLAYLIST-TYPE":T.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":B=T.startSN=parseInt(re);break;case"SKIP":{var me=new y.AttrList(re),Te=me.decimalInteger("SKIPPED-SEGMENTS");if(Object(P.isFiniteNumber)(Te)){T.skippedSegments=Te;for(var Me=Te;Me--;)I.unshift(null);B+=Te}var _e=me.enumeratedString("RECENTLY-REMOVED-DATERANGES");_e&&(T.recentlyRemovedDateranges=_e.split(" "));break}case"TARGETDURATION":T.targetduration=parseFloat(re);break;case"VERSION":T.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":T.live=!1;break;case"#":(re||Ee)&&Y.tagList.push(Ee?[re,Ee]:[re]);break;case"DISCONTINUITY":G++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([de]);break;case"BITRATE":Y.tagList.push([de,re]);break;case"DATERANGE":{var ke=new y.AttrList(re),Ie=new M.DateRange(ke,T.dateRanges[ke.ID]);Ie.isValid||T.skippedSegments?T.dateRanges[Ie.id]=Ie:x.logger.warn('Ignoring invalid DATERANGE tag: "'+re+'"'),Y.tagList.push(["EXT-X-DATERANGE",re]);break}case"DISCONTINUITY-SEQUENCE":G=parseInt(re);break;case"KEY":{var Be,be=new y.AttrList(re),Ue=be.enumeratedString("METHOD"),Ke=be.URI,je=be.hexadecimalInteger("IV"),Ne=be.enumeratedString("KEYFORMATVERSIONS"),et=be.enumeratedString("KEYID"),Fe=(Be=be.enumeratedString("KEYFORMAT"))!=null?Be:"identity",tt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(tt.indexOf(Fe)>-1){x.logger.warn("Keyformat "+Fe+" is not supported from the manifest");continue}else if(Fe!=="identity")continue;Ue&&(q=_.LevelKey.fromURL(a,Ke),Ke&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ue)>=0&&(q.method=Ue,q.keyFormat=Fe,et&&(q.keyID=et),Ne&&(q.keyFormatVersions=Ne),q.iv=je));break}case"START":{var Oe=new y.AttrList(re),Pe=Oe.decimalFloatingPoint("TIME-OFFSET");Object(P.isFiniteNumber)(Pe)&&(T.startTimeOffset=Pe);break}case"MAP":{var Ve=new y.AttrList(re);if(Y.duration){var Ce=new O.Fragment(v,a);c(Ce,Ve,d,q),k=Ce,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else c(Y,Ve,d,q),k=Y,ne=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(re);T.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),T.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),T.canSkipDateRanges=T.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),T.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),T.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var nt=new y.AttrList(re);T.partTarget=nt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var We=T.partList;We||(We=T.partList=[]);var ft=U>0?We[We.length-1]:void 0,yt=U++,Qe=new O.Part(new y.AttrList(re),Y,a,yt,ft);We.push(Qe),Y.duration+=Qe.duration;break}case"PRELOAD-HINT":{var Ot=new y.AttrList(re);T.preloadHint=Ot;break}case"RENDITION-REPORT":{var Tt=new y.AttrList(re);T.renditionReports=T.renditionReports||[],T.renditionReports.push(Tt);break}default:x.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(I.pop(),W-=z.duration,T.partList&&(T.fragmentHint=z)):T.partList&&(o(Y,z),Y.cc=G,T.fragmentHint=Y);var at=I.length,dt=I[0],st=I[at-1];if(W+=T.skippedSegments*T.targetduration,W>0&&at&&st){T.averagetargetduration=W/at;var xt=st.sn;T.endSN=xt!=="initSegment"?xt:0,dt&&(T.startCC=dt.cc,dt.initSegment||T.fragments.every(function(Et){return Et.relurl&&s(Et.relurl)})&&(x.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new O.Fragment(v,a),Y.relurl=st.relurl,Y.level=d,Y.sn="initSegment",dt.initSegment=Y,T.needSidxRanges=!0))}else T.endSN=0,T.startCC=0;return T.fragmentHint&&(W+=T.fragmentHint.duration),T.totalduration=W,T.endCC=G,ie>0&&r(I,ie),T},t}();function g(t,n){["video","audio","text"].forEach(function(u){var a=t.filter(function(v){return Object(D.isCodecType)(v,u)});if(a.length){var d=a.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[u+"Codec"]=d.length>0?d[0]:a[0],t=t.filter(function(v){return a.indexOf(v)===-1})}}),n.unknownCodecs=t}function i(t,n,u){var a=n[u];a&&(t[u]=a)}function r(t,n){for(var u=t[n],a=n;a--;){var d=t[a];if(!d)return;d.programDateTime=u.programDateTime-d.duration*1e3,u=d}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(P.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,n,u,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=u,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),M=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/loader/m3u8-parser.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/attr-list.ts");function x(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(m,p){var f=m.url;return(f===void 0||f.indexOf("data:")===0)&&(f=p.url),f}var E=function(){function m(f){this.hls=void 0,this.loaders=Object.create(null),this.hls=f,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,h=s.pLoader,g=s.loader,i=h||g,r=new i(s);return e.loader=r,this.loaders[e.type]=r,r},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,s){var h=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var h=s.id,g=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){M.logger.trace("[playlist-loader]: playlist request ongoing");return}M.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,o,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,o=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,o=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,o=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var u=n.partTarget,a=n.targetduration;u&&a&&(o=Math.min(Math.max(u*3,a*.8)*1e3,o))}}var d={timeout:o,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,d,v)},p.loadsuccess=function(e,s,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,s,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,h,g):this.handleMasterPlaylist(e,s,h,g)},p.loaderror=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!1,e)},p.loadtimeout=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!0)},p.handleMasterPlaylist=function(e,s,h,g){var i=this.hls,r=e.data,o=D(e,h),c=b.default.parseMasterPlaylist(r,o),t=c.levels,n=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),a=t.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),d=b.default.parseMasterPlaylistMedia(r,o,"AUDIO",u),v=b.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=b.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(d.length){var T=d.some(function(I){return!I.url});!T&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(M.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:d,subtitles:v,captions:S,url:o,stats:s,networkDetails:g,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,h,g){var i=this.hls,r=h.id,o=h.level,c=h.type,t=D(e,h),n=Object(P.isFiniteNumber)(r)?r:0,u=Object(P.isFiniteNumber)(o)?o:n,a=x(h),d=b.default.parseLevelPlaylist(e.data,t,u,a,n);if(!d.fragments.length){i.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:d,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:s,networkDetails:g,sessionData:null})}if(s.parsing.end=performance.now(),d.needSidxRanges){var S,T=(S=d.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:T,isSidxRequest:!0,type:c,level:o,levelDetails:d,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=d,this.handlePlaylistLoaded(e,s,h,g)},p.handleSidxRequest=function(e,s){var h=new Uint8Array(e.data),g=Object(O.findBox)(h,["sidx"])[0];if(!!g){var i=Object(O.parseSegmentIndex)(g);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(c,t){var n=c.info,u=o.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),u.initSegment){var a=Object(O.findBox)(h,["moov"])[0],d=a?a.length:null;u.initSegment.setByteRange(String(d)+"@0")}})}}},p.handleManifestParsingError=function(e,s,h,g){this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:s,networkDetails:g})},p.handleNetworkError=function(e,s,h,g){h===void 0&&(h=!1),M.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=A.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,s,h,g){var i=h.type,r=h.level,o=h.id,c=h.groupId,t=h.loader,n=h.levelDetails,u=h.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break}},m}();R.default=E},"./src/polyfills/number.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isFiniteNumber",function(){return P}),l.d(R,"MAX_SAFE_INTEGER",function(){return L});var P=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,l){"use strict";l.r(R);var P=function(){function L(){}return L.getSilentFrame=function(M,O){switch(M){case"mp4a.40.2":if(O===1)return new Uint8Array([0,200,0,128,35,128]);if(O===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(O===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(O===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(O===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(O===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(O===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(O===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(O===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},L}();R.default=P},"./src/remux/mp4-generator.ts":function(j,R,l){"use strict";l.r(R);var P=Math.pow(2,32)-1,L=function(){function A(){}return A.init=function(){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:[]};var O;for(O in A.types)A.types.hasOwnProperty(O)&&(A.types[O]=[O.charCodeAt(0),O.charCodeAt(1),O.charCodeAt(2),O.charCodeAt(3)]);var b=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:b,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=x,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 D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,D,m,D,E),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,y))},A.box=function(O){for(var b=8,_=arguments.length,y=new Array(_>1?_-1:0),x=1;x<_;x++)y[x-1]=arguments[x];for(var D=y.length,E=D;D--;)b+=y[D].byteLength;var m=new Uint8Array(b);for(m[0]=b>>24&255,m[1]=b>>16&255,m[2]=b>>8&255,m[3]=b&255,m.set(O,4),D=0,b=8;D<E;D++)m.set(y[D],b),b+=y[D].byteLength;return m},A.hdlr=function(O){return A.box(A.types.hdlr,A.HDLR_TYPES[O])},A.mdat=function(O){return A.box(A.types.mdat,O)},A.mdhd=function(O,b){b*=O;var _=Math.floor(b/(P+1)),y=Math.floor(b%(P+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,O>>24&255,O>>16&255,O>>8&255,O&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},A.mdia=function(O){return A.box(A.types.mdia,A.mdhd(O.timescale,O.duration),A.hdlr(O.type),A.minf(O))},A.mfhd=function(O){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]))},A.minf=function(O){return O.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(O)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(O))},A.moof=function(O,b,_){return A.box(A.types.moof,A.mfhd(O),A.traf(_,b))},A.moov=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trak(O[b]);return A.box.apply(null,[A.types.moov,A.mvhd(O[0].timescale,O[0].duration)].concat(_).concat(A.mvex(O)))},A.mvex=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trex(O[b]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(O,b){b*=O;var _=Math.floor(b/(P+1)),y=Math.floor(b%(P+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,x)},A.sdtp=function(O){var b=O.samples||[],_=new Uint8Array(4+b.length),y,x;for(y=0;y<b.length;y++)x=b[y].flags,_[y+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return A.box(A.types.sdtp,_)},A.stbl=function(O){return A.box(A.types.stbl,A.stsd(O),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(O){var b=[],_=[],y,x,D;for(y=0;y<O.sps.length;y++)x=O.sps[y],D=x.byteLength,b.push(D>>>8&255),b.push(D&255),b=b.concat(Array.prototype.slice.call(x));for(y=0;y<O.pps.length;y++)x=O.pps[y],D=x.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(x));var E=A.box(A.types.avcC,new Uint8Array([1,b[3],b[4],b[5],255,224|O.sps.length].concat(b).concat([O.pps.length]).concat(_))),m=O.width,p=O.height,f=O.pixelRatio[0],e=O.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,m>>8&255,m&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,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([f>>24,f>>16&255,f>>8&255,f&255,e>>24,e>>16&255,e>>8&255,e&255])))},A.esds=function(O){var b=O.config.length;return new Uint8Array([0,0,0,0,3,23+b,0,1,0,4,15+b,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([b]).concat(O.config).concat([6,1,2]))},A.mp4a=function(O){var b=O.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,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]),A.box(A.types.esds,A.esds(O)))},A.mp3=function(O){var b=O.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,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]))},A.stsd=function(O){return O.type==="audio"?O.segmentCodec==="mp3"&&O.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(O)):A.box(A.types.stsd,A.STSD,A.mp4a(O)):A.box(A.types.stsd,A.STSD,A.avc1(O))},A.tkhd=function(O){var b=O.id,_=O.duration*O.timescale,y=O.width,x=O.height,D=Math.floor(_/(P+1)),E=Math.floor(_%(P+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,b>>24&255,b>>16&255,b>>8&255,b&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,x>>8&255,x&255,0,0]))},A.traf=function(O,b){var _=A.sdtp(O),y=O.id,x=Math.floor(b/(P+1)),D=Math.floor(b%(P+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,D>>24,D>>16&255,D>>8&255,D&255])),A.trun(O,_.length+16+20+8+16+8+8),_)},A.trak=function(O){return O.duration=O.duration||4294967295,A.box(A.types.trak,A.tkhd(O),A.mdia(O))},A.trex=function(O){var b=O.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(O,b){var _=O.samples||[],y=_.length,x=12+16*y,D=new Uint8Array(x),E,m,p,f,e,s;for(b+=8+x,D.set([O.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255],0),E=0;E<y;E++)m=_[E],p=m.duration,f=m.size,e=m.flags,s=m.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*E);return A.box(A.types.trun,D)},A.initSegment=function(O){A.types||A.init();var b=A.moov(O),_=new Uint8Array(A.FTYP.byteLength+b.byteLength);return _.set(A.FTYP),_.set(b,A.FTYP.byteLength),_},A}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,R.default=L},"./src/remux/mp4-remuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return e}),l.d(R,"normalizePts",function(){return s}),l.d(R,"flushTextTrackMetadataCueSamples",function(){return g}),l.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var P=l("./src/polyfills/number.ts"),L=l("./src/remux/aac-helper.ts"),A=l("./src/remux/mp4-generator.ts"),M=l("./src/events.ts"),O=l("./src/errors.ts"),b=l("./src/utils/logger.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(c[u]=n[u])}return c},x.apply(this,arguments)}var D=10*1e3,E=1024,m=1152,p=null,f=null,e=function(){function c(n,u,a,d){if(d===void 0&&(d=""),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.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=n,this.config=u,this.typeSupported=a,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(f===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);f=T?parseInt(T[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},t.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(u){var a=!1,d=u.reduce(function(v,S){var T=S.pts-v;return T<-4294967296?(a=!0,s(v,S.pts)):T>0?v:S.pts},u[0].pts);return a&&b.logger.debug("PTS rollover detected"),d},t.remux=function(u,a,d,v,S,T,I,k){var B,U,W,G,z,Y,$=S,Z=S,q=u.pid>-1,ie=a.pid>-1,ne=a.samples.length,ae=u.samples.length>0,te=I&&ne>0||ne>1,fe=(!q||ae)&&(!ie||te)||this.ISGenerated||I;if(fe){this.ISGenerated||(W=this.generateIS(u,a,S));var de=this.isVideoContiguous,re=-1,Ee;if(te&&(re=h(a.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){b.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+ne+" video samples due to a missing keyframe");var me=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(re),a.dropped+=re,Z+=(a.samples[0].pts-me)/a.inputTimeScale,Ee=Z}else re===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+ne+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&te){var Te=this.getVideoStartPts(a.samples),Me=s(u.samples[0].pts,Te)-Te,_e=Me/a.inputTimeScale;$+=Math.max(0,_e),Z+=Math.max(0,-_e)}if(ae){if(u.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,a,S)),U=this.remuxAudio(u,$,this.isAudioContiguous,T,ie||te||k===_.PlaylistLevelType.AUDIO?Z:void 0),te){var ke=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,a,S)),B=this.remuxVideo(a,Z,de,ke)}}else te&&(B=this.remuxVideo(a,Z,de,0));B&&(B.firstKeyFrame=re,B.independent=re!==-1,B.firstKeyFramePTS=Ee)}}return this.ISGenerated&&(d.samples.length&&(z=g(d,S,this._initPTS,this._initDTS)),v.samples.length&&(G=i(v,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(u,a,d){var v=u.samples,S=a.samples,T=this.typeSupported,I={},k=!Object(P.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,G;if(k&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":T.mpeg?(B="audio/mpeg",u.codec=""):T.mp3&&(u.codec="mp3");break}I.audio={id:"audio",container:B,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&T.mpeg?new Uint8Array(0):A.default.initSegment([u]),metadata:{channelCount:u.channelCount}},k&&(G=u.inputTimeScale,U=W=v[0].pts-Math.round(G*d))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:A.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){G=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*d);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(I).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:I,initPTS:U,timescale:G}},t.remuxVideo=function(u,a,d,v){var S=u.inputTimeScale,T=u.samples,I=[],k=T.length,B=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,q=!1;if(!d||U===null){var ie=a*S,ne=T[0].pts-s(T[0].dts,T[0].pts);U=ie-ne}for(var ae=0;ae<k;ae++){var te=T[ae];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<T[ae>0?ae-1:ae].dts&&(q=!0)}q&&T.sort(function(It,rr){var St=It.dts-rr.dts,gr=It.pts-rr.pts;return St||gr}),z=T[0].dts,Y=T[T.length-1].dts;var fe=Y-z,de=fe?Math.round(fe/(k-1)):G||u.inputTimeScale/30;if(d){var re=z-U,Ee=re>de,me=re<-1;if(Ee||me){Ee?b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),z=U;var Te=T[0].pts-re;T[0].dts=z,T[0].pts=Te,b.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Te,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,_e=0,ke=0;ke<k;ke++){for(var Ie=T[ke],Be=Ie.units,be=Be.length,Ue=0,Ke=0;Ke<be;Ke++)Ue+=Be[Ke].data.length;_e+=Ue,Me+=be,Ie.length=Ue,Ie.dts=Math.max(Ie.dts,z),$=Math.min(Ie.pts,$),Z=Math.max(Ie.pts,Z)}Y=T[k-1].dts;var je=_e+4*Me+8,Ne;try{Ne=new Uint8Array(je)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating video mdat "+je});return}var et=new DataView(Ne.buffer);et.setUint32(0,je),Ne.set(A.default.types.mdat,4);for(var Fe=!1,tt=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,Ce=0;Ce<k;Ce++){for(var Le=T[Ce],nt=Le.units,We=0,ft=0,yt=nt.length;ft<yt;ft++){var Qe=nt[ft],Ot=Qe.data,Tt=Qe.data.byteLength;et.setUint32(W,Tt),W+=4,Ne.set(Ot,W),W+=Tt,We+=4+Tt}var at=void 0;if(Ce<k-1)G=T[Ce+1].dts-Le.dts,at=T[Ce+1].pts-Le.pts;else{var dt=this.config,st=Ce>0?Le.dts-T[Ce-1].dts:de;if(at=Ce>0?Le.pts-T[Ce-1].pts:de,dt.stretchShortVideoTrack&&this.nextAudioPts!==null){var xt=Math.floor(dt.maxBufferHole*S),Et=(v?$+v*S:this.nextAudioPts)-Le.pts;Et>xt?(G=Et-st,G<0?G=st:Fe=!0,b.logger.log("[mp4-remuxer]: It is approximately "+Et/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=st}else G=st}var cr=Math.round(Le.pts-Le.dts);tt=Math.min(tt,G),Pe=Math.max(Pe,G),Oe=Math.min(Oe,at),Ve=Math.max(Ve,at),I.push(new r(Le.key,G,We,cr))}if(I.length){if(p){if(p<70){var Ut=I[0].flags;Ut.dependsOn=2,Ut.isNonSync=0}}else if(f&&Ve-Oe<Pe-tt&&de/Pe<.025&&I[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Rt=z,$e=0,er=I.length;$e<er;$e++){var Nt=Rt+I[$e].duration,tr=Rt+I[$e].cts;if($e<er-1){var Kt=Nt+I[$e+1].cts;I[$e].duration=Kt-tr}else I[$e].duration=$e?I[$e-1].duration:de;I[$e].cts=0,Rt=Nt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Fe||!G?de:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var hr=A.default.moof(u.sequenceNumber++,z,x({},u,{samples:I})),vr="video",ot={data1:hr,data2:Ne,startPTS:$/S,endPTS:(Z+G)/S,startDTS:z/S,endDTS:U/S,type:vr,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(Ne.length,"MDAT length must not be zero"),ot},t.remuxAudio=function(u,a,d,v,S){var T=u.inputTimeScale,I=u.samplerate?u.samplerate:T,k=T/I,B=u.segmentCodec==="aac"?E:m,U=B*k,W=this._initPTS,G=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=u.samples,Z=G?0:8,q=this.nextAudioPts||-1,ie=a*T;if(this.isAudioContiguous=d=d||$.length&&q>0&&(v&&Math.abs(ie-q)<9e3||Math.abs(s($[0].pts-W,ie)-q)<20*U),$.forEach(function(Qe){Qe.pts=s(Qe.pts-W,ie)}),!d||q<0){if($=$.filter(function(Qe){return Qe.pts>=0}),!$.length)return;S===0?q=0:v&&!Y?q=Math.max(0,ie):q=$[0].pts}if(u.segmentCodec==="aac")for(var ne=this.config.maxAudioFramesDrift,ae=0,te=q;ae<$.length;ae++){var fe=$[ae],de=fe.pts,re=de-te,Ee=Math.abs(1e3*re/T);if(re<=-ne*U&&Y)ae===0&&(b.logger.warn("Audio frame @ "+(de/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/T)+" ms."),this.nextAudioPts=q=te=de);else if(re>=ne*U&&Ee<D&&Y){var me=Math.round(re/U);te=de-me*U,te<0&&(me--,te+=U),ae===0&&(this.nextAudioPts=q=te),b.logger.warn("[mp4-remuxer]: Injecting "+me+" audio frame @ "+(te/T).toFixed(3)+"s due to "+Math.round(1e3*re/T)+" ms gap.");for(var Te=0;Te<me;Te++){var Me=Math.max(te,0),_e=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);_e||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),_e=fe.unit.subarray()),$.splice(ae,0,{unit:_e,pts:Me}),te+=U,ae++}}fe.pts=te,te+=U}for(var ke=null,Ie=null,Be,be=0,Ue=$.length;Ue--;)be+=$[Ue].unit.byteLength;for(var Ke=0,je=$.length;Ke<je;Ke++){var Ne=$[Ke],et=Ne.unit,Fe=Ne.pts;if(Ie!==null){var tt=z[Ke-1];tt.duration=Math.round((Fe-Ie)/k)}else if(d&&u.segmentCodec==="aac"&&(Fe=q),ke=Fe,be>0){be+=Z;try{Be=new Uint8Array(be)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:be,reason:"fail allocating audio mdat "+be});return}if(!G){var Oe=new DataView(Be.buffer);Oe.setUint32(0,be),Be.set(A.default.types.mdat,4)}}else return;Be.set(et,Z);var Pe=et.byteLength;Z+=Pe,z.push(new r(!0,B,Pe,0)),Ie=Fe}var Ve=z.length;if(!!Ve){var Ce=z[z.length-1];this.nextAudioPts=q=Ie+k*Ce.duration;var Le=G?new Uint8Array(0):A.default.moof(u.sequenceNumber++,ke/k,x({},u,{samples:z}));u.samples=[];var nt=ke/T,We=q/T,ft="audio",yt={data1:Le,data2:Be,startPTS:nt,endPTS:We,startDTS:nt,endDTS:We,type:ft,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,console.assert(Be.length,"MDAT length must not be zero"),yt}},t.remuxEmptyAudio=function(u,a,d,v){var S=u.inputTimeScale,T=u.samplerate?u.samplerate:S,I=S/T,k=this.nextAudioPts,B=(k!==null?k:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=I*E,G=Math.ceil((U-B)/W),z=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Y=[],$=0;$<G;$++){var Z=B+$*W;Y.push({unit:z,pts:Z,dts:Z})}return u.samples=Y,this.remuxAudio(u,a,d,!1)},c}();function s(c,t){var n;if(t===null)return c;for(t<c?n=-8589934592:n=8589934592;Math.abs(c-t)>4294967296;)c+=n;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,n,u){var a=c.samples.length;if(!!a){for(var d=c.inputTimeScale,v=0;v<a;v++){var S=c.samples[v];S.pts=s(S.pts-n,t*d)/d,S.dts=s(S.dts-u,t*d)/d}var T=c.samples;return c.samples=[],{samples:T}}}function i(c,t,n){var u=c.samples.length;if(!!u){for(var a=c.inputTimeScale,d=0;d<u;d++){var v=c.samples[d];v.pts=s(v.pts-n,t*a)/a}c.samples.sort(function(T,I){return T.pts-I.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,n,u,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=u,this.cts=a,this.flags=new o(t)},o=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/remux/mp4-remuxer.ts"),A=l("./src/utils/mp4-tools.ts"),M=l("./src/loader/fragment.ts"),O=l("./src/utils/logger.ts"),b=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var x=y.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var f=this.initData=Object(A.parseInitSegment)(E);m||(m=_(f.audio,M.ElementaryStreamTypes.AUDIO)),p||(p=_(f.video,M.ElementaryStreamTypes.VIDEO));var e={};f.audio&&f.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:f.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:f.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:O.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},x.remux=function(E,m,p,f,e){var s,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:f,id3:p,initSegment:void 0};Object(P.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return O.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(A.getStartDTS)(c,r);Object(P.isFiniteNumber)(h)||(this.initPTS=o.initPTS=h=t-e);var n=Object(A.getDuration)(r,c),u=E?t-h:g,a=u+n;Object(A.offsetStartDTS)(c,r,h),n>0?this.lastEndTime=a:(O.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!c.audio,v=!!c.video,S="";d&&(S+="audio"),v&&(S+="video");var T={data1:r,startPTS:u,startDTS:u,endPTS:a,endDTS:a,type:S,hasAudio:d,hasVideo:v,nb:1,dropped:0};i.audio=T.type==="audio"?T:void 0,i.video=T.type!=="audio"?T:void 0,i.initSegment=o;var I=(s=this.initPTS)!=null?s:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,I,I),f.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(f,e,I)),i},y}();function _(y,x){var D=y==null?void 0:y.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||x===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=b},"./src/task-loop.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=L.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(O){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,O),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},L}()},"./src/types/cmcd.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"CMCDVersion",function(){return P}),l.d(R,"CMCDObjectType",function(){return L}),l.d(R,"CMCDStreamingFormat",function(){return A}),l.d(R,"CMCDStreamType",function(){return M});var P=1,L;(function(O){O.MANIFEST="m",O.AUDIO="a",O.VIDEO="v",O.MUXED="av",O.INIT="i",O.CAPTION="c",O.TIMED_TEXT="tt",O.KEY="k",O.OTHER="o"})(L||(L={}));var A;(function(O){O.DASH="d",O.HLS="h",O.SMOOTH="s",O.OTHER="o"})(A||(A={}));var M;(function(O){O.VOD="v",O.LIVE="l"})(M||(M={}))},"./src/types/demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"MetadataSchema",function(){return P});var P;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(P||(P={}))},"./src/types/level.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"HlsSkip",function(){return A}),l.d(R,"getSkipValue",function(){return M}),l.d(R,"HlsUrlParameters",function(){return O}),l.d(R,"Level",function(){return b});function P(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function L(_,y,x){return y&&P(_.prototype,y),x&&P(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var A;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(A||(A={}));function M(_,y){var x=_.canSkipUntil,D=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return x&&m<x?D?A.v2:A.Yes:A.No}var O=function(){function _(x,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=D,this.skip=E}var y=_.prototype;return y.addDirectives=function(D){var E=new self.URL(D);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},_}(),b=function(){function _(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{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(x){var D=x%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"PlaylistContextType",function(){return P}),l.d(R,"PlaylistLevelType",function(){return L});var P;(function(A){A.MANIFEST="manifest",A.LEVEL="level",A.AUDIO_TRACK="audioTrack",A.SUBTITLE_TRACK="subtitleTrack"})(P||(P={}));var L;(function(A){A.MAIN="main",A.AUDIO="audio",A.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ChunkMetadata",function(){return P});var P=function(M,O,b,_,y,x){_===void 0&&(_=0),y===void 0&&(y=-1),x===void 0&&(x=!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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=M,this.sn=O,this.id=b,this.size=_,this.part=y,this.partial=x};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"AttrList",function(){return A});var P=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function M(b){typeof b=="string"&&(b=M.parseAttrList(b));for(var _ in b)b.hasOwnProperty(_)&&(this[_]=b[_])}var O=M.prototype;return O.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var x=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)x[D]=parseInt(y.slice(D*2,D*2+2),16);return x}else return null},O.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.decimalFloatingPoint=function(_){return parseFloat(this[_])},O.optionalFloat=function(_,y){var x=this[_];return x?parseFloat(x):y},O.enumeratedString=function(_){return this[_]},O.bool=function(_){return this[_]==="YES"},O.decimalResolution=function(_){var y=P.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},M.parseAttrList=function(_){var y,x={},D='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),x[y[1]]=E}return x},M}()},"./src/utils/binary-search.ts":function(j,R,l){"use strict";l.r(R);var P={search:function(A,M){for(var O=0,b=A.length-1,_=null,y=null;O<=b;){_=(O+b)/2|0,y=A[_];var x=M(y);if(x>0)O=_+1;else if(x<0)b=_-1;else return y}return null}};R.default=P},"./src/utils/buffer-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"BufferHelper",function(){return A});var P=l("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function M(){}return M.isBuffered=function(b,_){try{if(b){for(var y=M.getBuffered(b),x=0;x<y.length;x++)if(_>=y.start(x)&&_<=y.end(x))return!0}}catch{}return!1},M.bufferInfo=function(b,_,y){try{if(b){var x=M.getBuffered(b),D=[],E;for(E=0;E<x.length;E++)D.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(D,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},M.bufferedInfo=function(b,_,y){_=Math.max(0,_),b.sort(function(r,o){var c=r.start-o.start;return c||o.end-r.end});var x=[];if(y)for(var D=0;D<b.length;D++){var E=x.length;if(E){var m=x[E-1].end;b[D].start-m<y?b[D].end>m&&(x[E-1].end=b[D].end):x.push(b[D])}else x.push(b[D])}else x=b;for(var p=0,f,e=_,s=_,h=0;h<x.length;h++){var g=x[h].start,i=x[h].end;if(_+y>=g&&_<i)e=g,s=i,p=s-_;else if(_+y<g){f=g;break}}return{len:p,start:e||0,end:s||0,nextStart:f}},M.getBuffered=function(b){try{return b.buffered}catch(_){return P.logger.log("failed to get media.buffered",_),L}},M}()},"./src/utils/cea-608-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Row",function(){return s}),l.d(R,"CaptionScreen",function(){return h});var P=l("./src/utils/logger.ts"),L={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},A=function(n){var u=n;return L.hasOwnProperty(n)&&(u=L[n]),String.fromCharCode(u)},M=15,O=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(t){t[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"})(E||(E={}));var m=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var n=t.prototype;return n.log=function(a,d){this.verboseLevel>=a&&P.logger.log(this.time+" ["+a+"] "+d)},t}(),p=function(n){for(var u=[],a=0;a<n.length;a++)u.push(n[a].toString(16));return u},f=function(){function t(u,a,d,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=a||!1,this.italics=d||!1,this.background=v||"black",this.flash=S||!1}var n=t.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(a){for(var d=["foreground","underline","italics","background","flash"],v=0;v<d.length;v++){var S=d[v];a.hasOwnProperty(S)&&(this[S]=a[S])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},n.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,a,d,v,S,T){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new f(a,d,v,S,T)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,d){this.uchar=a,this.penState.copy(d)},n.setPenState=function(a){this.penState.copy(a)},n.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},n.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),s=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<O;a++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new f}var n=t.prototype;return n.equals=function(a){for(var d=!0,v=0;v<O;v++)if(!this.chars[v].equals(a.chars[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<O;d++)this.chars[d].copy(a.chars[d])},n.isEmpty=function(){for(var a=!0,d=0;d<O;d++)if(!this.chars[d].isEmpty()){a=!1;break}return a},n.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>O&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=O)},n.moveCursor=function(a){var d=this.pos+a;if(a>1)for(var v=this.pos+1;v<d+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(d)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var d=A(a);if(this.pos>=O){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+d+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(d,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var d;for(d=a;d<O;d++)this.chars[d].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var a=[],d=!0,v=0;v<O;v++){var S=this.chars[v].uchar;S!==" "&&(d=!1),a.push(S)}return d?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var d=this.chars[this.pos];d.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<M;a++)this.rows.push(new s(u));this.logger=u,this.currRow=M-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<M;a++)this.rows[a].clear();this.currRow=M-1},n.equals=function(a){for(var d=!0,v=0;v<M;v++)if(!this.rows[v].equals(a.rows[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<M;d++)this.rows[d].copy(a.rows[d])},n.isEmpty=function(){for(var a=!0,d=0;d<M;d++)if(!this.rows[d].isEmpty()){a=!1;break}return a},n.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},n.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},n.insertChar=function(a){var d=this.rows[this.currRow];d.insertChar(a)},n.setPen=function(a){var d=this.rows[this.currRow];d.setPenStyles(a)},n.moveCursor=function(a){var d=this.rows[this.currRow];d.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var d=this.rows[this.currRow];d.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var d=a.row-1;if(this.nrRollUpRows&&d<this.nrRollUpRows-1&&(d=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==d){for(var v=0;v<M;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,T=this.lastOutputScreen;if(T){var I=T.rows[S].cueStartTime,k=this.logger.time;if(I&&k!==null&&I<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[d-this.nrRollUpRows+B+1].copy(T.rows[S+B])}}this.currRow=d;var U=this.rows[this.currRow];if(a.indent!==null){var W=a.indent,G=Math.max(W-1,0);U.setCursor(a.indent),a.color=U.chars[G].penState.foreground}var z={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(z)},n.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},n.setRollUpRows=function(a){this.nrRollUpRows=a},n.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,d=this.rows.splice(a,1)[0];d.clear(),this.rows.splice(this.currRow,0,d),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var d=[],v="",S=-1,T=0;T<M;T++){var I=this.rows[T].getTextString();I&&(S=T+1,a?d.push("Row "+S+": '"+I+"'"):d.push(I.trim()))}return d.length>0&&(a?v="["+d.join(" | ")+"]":v=d.join(`
|
|
20
|
-
`)),v},n.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,a,d){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=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(d),this.nonDisplayedMemory=new h(d),this.lastOutputScreen=new h(d),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=d}var n=t.prototype;return n.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(a){this.outputFilter=a},n.setPAC=function(a){this.writeScreen.setPAC(a)},n.setBkgData=function(a){this.writeScreen.setBkgData(a)},n.setMode=function(a){a!==this.mode&&(this.mode=a,this.logger.log(E.INFO,"MODE="+a),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=a)},n.insertChars=function(a){for(var d=0;d<a.length;d++)this.writeScreen.insertChar(a[d]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},n.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},n.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},n.ccMIDROW=function(a){var d={flash:!1};if(d.underline=a%2===1,d.italics=a>=46,d.italics)d.foreground="white";else{var v=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];d.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(d)),this.writeScreen.setPen(d)},n.outputDataUpdate=function(a){a===void 0&&(a=!1);var d=this.logger.time;d!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=d:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,d,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:d),this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},t}(),i=function(){function t(u,a,d){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,a,v),new g(u+1,d,v)],this.cmdHistory=c(),this.logger=v}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,d){this.channels[a].setHandler(d)},n.addData=function(a,d){var v,S,T,I=!1;this.logger.time=a;for(var k=0;k<d.length;k+=2)if(S=d[k]&127,T=d[k+1]&127,!(S===0&&T===0)){if(this.logger.log(E.DATA,"["+p([d[k],d[k+1]])+"] -> ("+p([S,T])+")"),v=this.parseCmd(S,T),v||(v=this.parseMidrow(S,T)),v||(v=this.parsePAC(S,T)),v||(v=this.parseBackgroundAttributes(S,T)),!v&&(I=this.parseChars(S,T),I)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,T])+" orig: "+p([d[k],d[k+1]]))}},n.parseCmd=function(a,d){var v=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&d>=32&&d<=47,T=(a===23||a===31)&&d>=33&&d<=35;if(!(S||T))return!1;if(o(a,d,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([a,d])+") is dropped"),!0;var I=a===20||a===21||a===23?1:2,k=this.channels[I];return a===20||a===21||a===28||a===29?d===32?k.ccRCL():d===33?k.ccBS():d===34?k.ccAOF():d===35?k.ccAON():d===36?k.ccDER():d===37?k.ccRU(2):d===38?k.ccRU(3):d===39?k.ccRU(4):d===40?k.ccFON():d===41?k.ccRDC():d===42?k.ccTR():d===43?k.ccRTD():d===44?k.ccEDM():d===45?k.ccCR():d===46?k.ccENM():d===47&&k.ccEOC():k.ccTO(d-32),r(a,d,v),this.currentChannel=I,!0},n.parseMidrow=function(a,d){var v=0;if((a===17||a===25)&&d>=32&&d<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(d),this.logger.log(E.DEBUG,"MIDROW ("+p([a,d])+")"),!0):!1}return!1},n.parsePAC=function(a,d){var v,S=this.cmdHistory,T=(a>=17&&a<=23||a>=25&&a<=31)&&d>=64&&d<=127,I=(a===16||a===24)&&d>=64&&d<=95;if(!(T||I))return!1;if(o(a,d,S))return r(null,null,S),!0;var k=a<=23?1:2;d>=64&&d<=95?v=k===1?b[a]:y[a]:v=k===1?_[a]:x[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(v,d)),r(a,d,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,d){var v,S={color:null,italics:!1,indent:null,underline:!1,row:a};return d>95?v=d-96:v=d-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},n.parseChars=function(a,d){var v,S=null,T=null;if(a>=25?(v=2,T=a-8):(v=1,T=a),T>=17&&T<=19){var I;T===17?I=d+80:T===18?I=d+112:I=d+144,this.logger.log(E.INFO,"Special char '"+A(I)+"' in channel "+v),S=[I]}else a>=32&&a<=127&&(S=d===0?[a]:[a,d]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,d,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,d){var v=(a===16||a===24)&&d>=32&&d<=47,S=(a===23||a===31)&&d>=45&&d<=47;if(!(v||S))return!1;var T,I={};a===16||a===24?(T=Math.floor((d-32)/2),I.background=D[T],d%2===1&&(I.background=I.background+"_semi")):d===45?I.background="transparent":(I.foreground="black",d===47&&(I.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(I),r(a,d,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var d=this.channels[a];d&&d.reset()}this.cmdHistory=c()},n.cueSplitAtTime=function(a){for(var d=0;d<this.channels.length;d++){var v=this.channels[d];v&&v.cueSplitAtTime(a)}},t}();function r(t,n,u){u.a=t,u.b=n}function o(t,n,u){return u.a===t&&u.b===n}function c(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isCodecType",function(){return L}),l.d(R,"isCodecSupportedInMp4",function(){return A});var P={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 L(M,O){var b=P[O];return!!b&&b[M.slice(0,4)]===!0}function A(M,O){return MediaSource.isTypeSupported((O||"video")+'/mp4;codecs="'+M+'"')}},"./src/utils/cues.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/vttparser.ts"),L=l("./src/utils/webvtt-parser.ts"),A=l("./src/utils/texttrack-utils.ts"),M=/\s/,O={newCue:function(_,y,x,D){for(var E=[],m,p,f,e,s,h=self.VTTCue||self.TextTrackCue,g=0;g<D.rows.length;g++)if(m=D.rows[g],f=!0,e=0,s="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)M.test(m.chars[i].uchar)&&f?e++:(s+=m.chars[i].uchar,f=!1);m.cueStartTime=y,y===x&&(x+=1e-4),e>=16?e--:e++;var r=Object(P.fixLineBreaks)(s.trim()),o=Object(L.generateCueId)(y,x,r);(!_||!_.cues||!_.cues.getCueById(o))&&(p=new h(y,x,r),p.id=o,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(A.addCueToTrack)(_,c)})),E}};R.default=O},"./src/utils/discontinuities.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFirstFragWithCC",function(){return M}),l.d(R,"shouldAlignOnDiscontinuities",function(){return O}),l.d(R,"findDiscontinuousReferenceFrag",function(){return b}),l.d(R,"adjustSlidingStart",function(){return y}),l.d(R,"alignStream",function(){return x}),l.d(R,"alignPDT",function(){return E}),l.d(R,"alignFragmentByPDTDelta",function(){return m}),l.d(R,"alignMediaPlaylistByPDT",function(){return p});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/controller/level-helper.ts");function M(f,e){for(var s=null,h=0,g=f.length;h<g;h++){var i=f[h];if(i&&i.cc===e){s=i;break}}return s}function O(f,e,s){return!!(e.details&&(s.endCC>s.startCC||f&&f.cc<s.startCC))}function b(f,e){var s=f.fragments,h=e.fragments;if(!h.length||!s.length){L.logger.log("No fragments to align");return}var g=M(s,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(f,e){if(f){var s=f.start+e;f.start=f.startPTS=s,f.endPTS=s+f.duration}}function y(f,e){for(var s=e.fragments,h=0,g=s.length;h<g;h++)_(s[h],f);e.fragmentHint&&_(e.fragmentHint,f),e.alignedSliding=!0}function x(f,e,s){!e||(D(f,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(A.adjustSliding)(e.details,s))}function D(f,e,s){if(O(f,s,e)){var h=b(s.details,e);h&&Object(P.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=f.fragments[0].programDateTime,g=(h-s)/1e3+e.fragments[0].start;g&&Object(P.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-s)+"ms, sliding:"+g.toFixed(3)+" "+f.url+" "),y(g,f))}}function m(f,e){var s=f.programDateTime;if(!!s){var h=(s-e)/1e3;f.start=f.startPTS=h,f.endPTS=h+f.duration}}function p(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=e.fragments[0].start,g=s-h*1e3;f.fragments.forEach(function(i){m(i,g)}),f.fragmentHint&&m(f.fragmentHint,g),f.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/ewma.ts"),L=function(){function A(O,b,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new P.default(O),this.fast_=new P.default(b)}var M=A.prototype;return M.update=function(b,_){var y=this.slow_,x=this.fast_;this.slow_.halfLife!==b&&(this.slow_=new P.default(b,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new P.default(_,x.getEstimate(),x.getTotalWeight()))},M.sample=function(b,_){b=Math.max(b,this.minDelayMs_);var y=8*_,x=b/1e3,D=y/x;this.fast_.sample(x,D),this.slow_.sample(x,D)},M.canEstimate=function(){var b=this.fast_;return b&&b.getTotalWeight()>=this.minWeight_},M.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},M.destroy=function(){},A}();R.default=L},"./src/utils/ewma.ts":function(j,R,l){"use strict";l.r(R);var P=function(){function L(M,O,b){O===void 0&&(O=0),b===void 0&&(b=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=M,this.alpha_=M?Math.exp(Math.log(.5)/M):0,this.estimate_=O,this.totalWeight_=b}var A=L.prototype;return A.sample=function(O,b){var _=Math.pow(this.alpha_,O);this.estimate_=b*(1-_)+_*this.estimate_,this.totalWeight_+=O},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var O=1-Math.pow(this.alpha_,this.totalWeight_);if(O)return this.estimate_/O}return this.estimate_},L}();R.default=P},"./src/utils/fetch-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"fetchSupported",function(){return m});var P=l("./src/polyfills/number.ts"),L=l("./src/loader/load-stats.ts"),A=l("./src/demux/chunk-cache.ts");function M(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,x(h,g)}function O(h){var g=typeof Map=="function"?new Map:void 0;return O=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,o)}function o(){return b(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),x(o,r)},O(h)}function b(h,g,i){return _()?b=Reflect.construct.bind():b=function(o,c,t){var n=[null];n.push.apply(n,c);var u=Function.bind.apply(o,n),a=new u;return t&&x(a,t.prototype),a},b.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,g){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},x(h,g)}function D(h){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(i){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=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,o,c){var t=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var u=f(r,this.controller.signal),a=c.onProgress,d=r.responseType==="arraybuffer",v=d?"byteLength":"length";this.context=r,this.config=o,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(n,r,t.response)},o.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var T=S.status,I=S.statusText;throw new s(I||"fetch, bad network response",T,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(P.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):d?S.arrayBuffer():S.text()}).then(function(S){var T=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[v];var I={url:T.url,data:S};a&&!Object(P.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,T),c.onSuccess(I,n,r,T)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var T=S&&S.code||0,I=S?S.message:null;c.onError({code:T,text:I},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},g.loadProgressively=function(r,o,c,t,n){t===void 0&&(t=0);var u=new A.default,a=r.body.getReader(),d=function v(){return a.read().then(function(S){if(S.done)return u.dataLength&&n(o,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var T=S.value,I=T.length;return o.loaded+=I,I<t||u.dataLength?(u.push(T),u.dataLength>=t&&n(o,c,u.flush(),r)):n(o,c,T,r),v()}).catch(function(){return Promise.reject()})};return d()},h}();function f(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var s=function(h){M(g,h);function g(i,r,o){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=o,c}return g}(O(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"IMSC1_CODEC",function(){return y}),l.d(R,"parseIMSC1",function(){return m});var P=l("./src/utils/mp4-tools.ts"),L=l("./src/utils/vttparser.ts"),A=l("./src/utils/vttcue.ts"),M=l("./src/demux/id3.ts"),O=l("./src/utils/timescale-conversion.ts"),b=l("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var u=arguments[n];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(t[a]=u[a])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,n,u,a,d){var v=Object(P.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){d(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(I){return Object(M.utf8ArrayToStr)(I)}),T=Object(O.toTimescaleFromScale)(n,1,u);try{S.forEach(function(I){return a(p(I,T))})}catch(I){d(I)}}function p(t,n){var u=new DOMParser,a=u.parseFromString(t,"text/xml"),d=a.getElementsByTagName("tt")[0];if(!d)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=d.getAttribute("ttp:"+W)||v[W],U},{}),T=d.getAttribute("xml:space")!=="preserve",I=e(f(d,"styling","style")),k=e(f(d,"layout","region")),B=f(d,"body","[begin]");return[].map.call(B,function(U){var W=s(U,T);if(!W||!U.hasAttribute("begin"))return null;var G=r(U.getAttribute("begin"),S),z=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(G===null)throw i(U);if(Y===null){if(z===null)throw i(U);Y=G+z}var $=new A.default(G-n,Y-n,W);$.id=Object(b.generateCueId)($.startTime,$.endTime,$.text);var Z=k[U.getAttribute("region")],q=I[U.getAttribute("style")];$.position=10,$.size=80;var ie=h(Z,q,I),ne=ie.textAlign;if(ne){var ae=E[ne];ae&&($.lineAlign=ae),$.align=ne}return _($,ie),$}).filter(function(U){return U!==null})}function f(t,n,u){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function e(t){return t.reduce(function(n,u){var a=u.getAttribute("xml:id");return a&&(n[a]=u),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(u,a,d){var v;return a.nodeName==="br"&&d?u+`
|
|
21
|
-
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?s(a,n):n?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function h(t,n,u){var a="http://www.w3.org/ns/ttml#styling",d=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(d=u[S]),v.reduce(function(T,I){var k=g(n,a,I)||g(t,a,I)||g(d,a,I);return k&&(T[I]=k),T},{})}function g(t,n,u){return t&&t.hasAttributeNS(n,u)?t.getAttributeNS(n,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(x.test(t)?u=o(t,n):D.test(t)&&(u=c(t,n))),u}function o(t,n){var u=x.exec(t),a=(u[4]|0)+(u[5]|0)/n.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/n.frameRate}function c(t,n){var u=D.exec(t),a=Number(u[1]),d=u[2];switch(d){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/n.frameRate;case"t":return a/n.tickRate}return a}},"./src/utils/logger.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"enableLogs",function(){return b}),l.d(R,"logger",function(){return _});var P=function(){},L={trace:P,debug:P,log:P,warn:P,info:P,error:P},A=L;function M(y){var x=self.console[y];return x?x.bind(self.console,"["+y+"] >"):P}function O(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];D.forEach(function(m){A[m]=y[m]?y[m].bind(y):M(m)})}function b(y){if(self.console&&y===!0||typeof y=="object"){O(y,"debug","log","info","warn","error");try{A.log()}catch{A=L}}else A=L}var _=A},"./src/utils/mediakeys-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"KeySystems",function(){return P}),l.d(R,"requestMediaKeySystemAccess",function(){return L});var P;(function(A){A.WIDEVINE="com.widevine.alpha",A.PLAYREADY="com.microsoft.playready"})(P||(P={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getMediaSource",function(){return P});function P(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"RemuxerTrackIdConfig",function(){return b}),l.d(R,"bin2str",function(){return _}),l.d(R,"readUint16",function(){return y}),l.d(R,"readUint32",function(){return x}),l.d(R,"readSint32",function(){return D}),l.d(R,"writeUint32",function(){return E}),l.d(R,"findBox",function(){return m}),l.d(R,"parseSegmentIndex",function(){return p}),l.d(R,"parseInitSegment",function(){return f}),l.d(R,"getStartDTS",function(){return e}),l.d(R,"getDuration",function(){return s}),l.d(R,"computeRawDurationFromSamples",function(){return h}),l.d(R,"offsetStartDTS",function(){return g}),l.d(R,"segmentValidRange",function(){return i}),l.d(R,"appendUint8Array",function(){return r}),l.d(R,"parseSamples",function(){return o}),l.d(R,"parseSEIMessageFromNALu",function(){return n}),l.d(R,"parseEmsg",function(){return a});var P=l("./src/utils/typed-array.ts"),L=l("./src/loader/fragment.ts"),A=l("./src/demux/id3.ts"),M=Math.pow(2,32)-1,O=[].push,b={video:1,audio:2,id3:3,text:4};function _(d){return String.fromCharCode.apply(null,d)}function y(d,v){var S=d[v]<<8|d[v+1];return S<0?65536+S:S}function x(d,v){var S=D(d,v);return S<0?4294967296+S:S}function D(d,v){return d[v]<<24|d[v+1]<<16|d[v+2]<<8|d[v+3]}function E(d,v,S){d[v]=S>>24,d[v+1]=S>>16&255,d[v+2]=S>>8&255,d[v+3]=S&255}function m(d,v){var S=[];if(!v.length)return S;for(var T=d.byteLength,I=0;I<T;){var k=x(d,I),B=_(d.subarray(I+4,I+8)),U=k>1?I+k:T;if(B===v[0])if(v.length===1)S.push(d.subarray(I+8,U));else{var W=m(d.subarray(I+8,U),v.slice(1));W.length&&O.apply(S,W)}I=U}return S}function p(d){var v=[],S=d[0],T=8,I=x(d,T);T+=4;var k=0,B=0;S===0?T+=8:T+=16,T+=2;var U=d.length+B,W=y(d,T);T+=2;for(var G=0;G<W;G++){var z=T,Y=x(d,z);z+=4;var $=Y&2147483647,Z=(Y&2147483648)>>>31;if(Z===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var q=x(d,z);z+=4,v.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/I,start:U,end:U+$-1}}),U+=$,z+=4,T=z}return{earliestPresentationTime:k,timescale:I,version:S,referencesCount:W,references:v}}function f(d){for(var v=[],S=m(d,["moov","trak"]),T=0;T<S.length;T++){var I=S[T],k=m(I,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=x(k,U),G=m(I,["mdia","mdhd"])[0];if(G){B=G[0],U=B===0?12:20;var z=x(G,U),Y=m(I,["mdia","hdlr"])[0];if(Y){var $=_(Y.subarray(8,12)),Z={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[$];if(Z){var q=m(I,["mdia","minf","stbl","stsd"])[0],ie=void 0;q&&(ie=_(q.subarray(12,16))),v[W]={timescale:z,type:Z},v[Z]={timescale:z,id:W,codec:ie}}}}}}var ne=m(d,["moov","mvex","trex"]);return ne.forEach(function(ae){var te=x(ae,4),fe=v[te];fe&&(fe.default={duration:x(ae,12),flags:x(ae,20)})}),v}function e(d,v){return m(v,["moof","traf"]).reduce(function(S,T){var I=m(T,["tfdt"])[0],k=I[0],B=m(T,["tfhd"]).reduce(function(U,W){var G=x(W,4),z=d[G];if(z){var Y=x(I,4);k===1&&(Y*=Math.pow(2,32),Y+=x(I,8));var $=z.timescale||9e4,Z=Y/$;if(isFinite(Z)&&(U===null||Z<U))return Z}return U},null);return B!==null&&isFinite(B)&&(S===null||B<S)?B:S},null)||0}function s(d,v){for(var S=0,T=0,I=0,k=m(d,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=m(U,["tfhd"])[0],G=x(W,4),z=v[G];if(!!z){var Y=z.default,$=x(W,0)|(Y==null?void 0:Y.flags),Z=Y==null?void 0:Y.duration;$&8&&($&2?Z=x(W,12):Z=x(W,8));for(var q=z.timescale||9e4,ie=m(U,["trun"]),ne=0;ne<ie.length;ne++){if(S=h(ie[ne]),!S&&Z){var ae=x(ie[ne],4);S=Z*ae}z.type===L.ElementaryStreamTypes.VIDEO?T+=S/q:z.type===L.ElementaryStreamTypes.AUDIO&&(I+=S/q)}}}if(T===0&&I===0){for(var te=0,fe=m(d,["sidx"]),de=0;de<fe.length;de++){var re=p(fe[de]);re!=null&&re.references&&(te+=re.references.reduce(function(Ee,me){return Ee+me.info.duration||0},0))}return te}return T||I}function h(d){var v=x(d,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var T=0,I=x(d,4),k=0;k<I;k++){if(v&256){var B=x(d,S);T+=B,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return T}function g(d,v,S){m(v,["moof","traf"]).forEach(function(T){m(T,["tfhd"]).forEach(function(I){var k=x(I,4),B=d[k];if(!!B){var U=B.timescale||9e4;m(T,["tfdt"]).forEach(function(W){var G=W[0],z=x(W,4);if(G===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=x(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(M+1)),$=Math.floor(z%(M+1));E(W,4,Y),E(W,8,$)}})}})})}function i(d){var v={valid:null,remainder:null},S=m(d,["moof"]);if(S){if(S.length<2)return v.remainder=d,v}else return v;var T=S[S.length-1];return v.valid=Object(P.sliceUint8)(d,0,T.byteOffset-8),v.remainder=Object(P.sliceUint8)(d,T.byteOffset-8),v}function r(d,v){var S=new Uint8Array(d.length+v.length);return S.set(d),S.set(v,d.length),S}function o(d,v){var S=[],T=v.samples,I=v.timescale,k=v.id,B=!1,U=m(T,["moof"]);return U.map(function(W){var G=W.byteOffset-8,z=m(W,["traf"]);z.map(function(Y){var $=m(Y,["tfdt"]).map(function(Z){var q=Z[0],ie=x(Z,4);return q===1&&(ie*=Math.pow(2,32),ie+=x(Z,8)),ie/I})[0];return $!==void 0&&(d=$),m(Y,["tfhd"]).map(function(Z){var q=x(Z,4),ie=x(Z,0)&16777215,ne=(ie&1)!==0,ae=(ie&2)!==0,te=(ie&8)!==0,fe=0,de=(ie&16)!==0,re=0,Ee=(ie&32)!==0,me=8;q===k&&(ne&&(me+=8),ae&&(me+=4),te&&(fe=x(Z,me),me+=4),de&&(re=x(Z,me),me+=4),Ee&&(me+=4),v.type==="video"&&(B=c(v.codec)),m(Y,["trun"]).map(function(Te){var Me=Te[0],_e=x(Te,0)&16777215,ke=(_e&1)!==0,Ie=0,Be=(_e&4)!==0,be=(_e&256)!==0,Ue=0,Ke=(_e&512)!==0,je=0,Ne=(_e&1024)!==0,et=(_e&2048)!==0,Fe=0,tt=x(Te,4),Oe=8;ke&&(Ie=x(Te,Oe),Oe+=4),Be&&(Oe+=4);for(var Pe=Ie+G,Ve=0;Ve<tt;Ve++){if(be?(Ue=x(Te,Oe),Oe+=4):Ue=fe,Ke?(je=x(Te,Oe),Oe+=4):je=re,Ne&&(Oe+=4),et&&(Me===0?Fe=x(Te,Oe):Fe=D(Te,Oe),Oe+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var Ce=0;Ce<je;){var Le=x(T,Pe);Pe+=4;var nt=T[Pe]&31;if(t(B,nt)){var We=T.subarray(Pe,Pe+Le);n(We,d+Fe/I,S)}Pe+=Le,Ce+=Le+4}d+=Ue/I}}))})})}),S}function c(d){if(!d)return!1;var v=d.indexOf("."),S=v<0?d:d.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(d,v){return d?v===39||v===40:v===6}function n(d,v,S){var T=u(d),I=0;I++;for(var k=0,B=0,U=!1,W=0;I<T.length;){k=0;do{if(I>=T.length)break;W=T[I++],k+=W}while(W===255);B=0;do{if(I>=T.length)break;W=T[I++],B+=W}while(W===255);var G=T.length-I;if(!U&&k===4&&I<T.length){U=!0;var z=T[I++];if(z===181){var Y=y(T,I);if(I+=2,Y===49){var $=x(T,I);if(I+=4,$===1195456820){var Z=T[I++];if(Z===3){var q=T[I++],ie=31&q,ne=64&q,ae=ne?2+ie*3:0,te=new Uint8Array(ae);if(ne){te[0]=q;for(var fe=1;fe<ae;fe++)te[fe]=T[I++]}S.push({type:Z,payloadType:k,pts:v,bytes:te})}}}}}else if(k===5&&B<G){if(U=!0,B>16){for(var de=[],re=0;re<16;re++){var Ee=T[I++].toString(16);de.push(Ee.length==1?"0"+Ee:Ee),(re===3||re===5||re===7||re===9)&&de.push("-")}for(var me=B-16,Te=new Uint8Array(me),Me=0;Me<me;Me++)Te[Me]=T[I++];S.push({payloadType:k,pts:v,uuid:de.join(""),userData:Object(A.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(B<G)I+=B;else if(B>G)break}}function u(d){for(var v=d.byteLength,S=[],T=1;T<v-2;)d[T]===0&&d[T+1]===0&&d[T+2]===3?(S.push(T+2),T+=2):T++;if(S.length===0)return d;var I=v-S.length,k=new Uint8Array(I),B=0;for(T=0;T<I;B++,T++)B===S[0]&&(B++,S.shift()),k[T]=d[B];return k}function a(d){var v=d[0],S="",T="",I=0,k=0,B=0,U=0,W=0,G=0;if(v===0){for(;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)T+=_(d.subarray(G,G+1)),G+=1;T+=_(d.subarray(G,G+1)),G+=1,I=x(d,12),k=x(d,16),U=x(d,20),W=x(d,24),G=28}else if(v===1){G+=4,I=x(d,G),G+=4;var z=x(d,G);G+=4;var Y=x(d,G);for(G+=4,B=Math.pow(2,32)*z+Y,Number.isSafeInteger(B)||(B=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),U=x(d,G),G+=4,W=x(d,G),G+=4;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)T+=_(d.subarray(G,G+1)),G+=1;T+=_(d.subarray(G,G+1)),G+=1}var $=d.subarray(G,d.byteLength);return{schemeIdUri:S,value:T,timeScale:I,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=M,this.trackName=O}var A=L.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(O,b,_){(this.startTime===null||this.startTime>O)&&(this.startTime=O),this.endTime=b,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sendAddTrackEvent",function(){return L}),l.d(R,"addCueToTrack",function(){return A}),l.d(R,"clearCurrentCues",function(){return M}),l.d(R,"removeCuesInRange",function(){return O}),l.d(R,"getCuesInRange",function(){return _});var P=l("./src/utils/logger.ts");function L(y,x){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,x.dispatchEvent(D)}function A(y,x){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(x.id))try{if(y.addCue(x),!y.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(m){P.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function M(y){var x=y.mode;if(x==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);x==="disabled"&&(y.mode=x)}function O(y,x,D,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,x,D),f=0;f<p.length;f++)(!E||E(p[f]))&&y.removeCue(p[f]);m==="disabled"&&(y.mode=m)}function b(y,x){if(x<y[0].startTime)return 0;var D=y.length-1;if(x>y[D].endTime)return-1;for(var E=0,m=D;E<=m;){var p=Math.floor((m+E)/2);if(x<y[p].startTime)m=p-1;else if(x>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-x<x-y[m].startTime?E:m}function _(y,x,D){var E=[],m=b(y,x);if(m>-1)for(var p=m,f=y.length;p<f;p++){var e=y[p];if(e.startTime>=x&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(j,R,l){"use strict";l.r(R);var P={toString:function(A){for(var M="",O=A.length,b=0;b<O;b++)M+="["+A.start(b).toFixed(3)+","+A.end(b).toFixed(3)+"]";return M}};R.default=P},"./src/utils/timescale-conversion.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"toTimescaleFromBase",function(){return L}),l.d(R,"toTimescaleFromScale",function(){return A}),l.d(R,"toMsFromMpegTsClock",function(){return M}),l.d(R,"toMpegTsClockFromTimescale",function(){return O});var P=9e4;function L(b,_,y,x){y===void 0&&(y=1),x===void 0&&(x=!1);var D=b*_*y;return x?Math.round(D):D}function A(b,_,y,x){return y===void 0&&(y=1),x===void 0&&(x=!1),L(b,_,1/y,x)}function M(b,_){return _===void 0&&(_=!1),L(b,1e3,1/P,_)}function O(b,_){return _===void 0&&(_=1),L(b,P,1/_)}},"./src/utils/typed-array.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sliceUint8",function(){return P});function P(L,A,M){return Uint8Array.prototype.slice?L.slice(A,M):new Uint8Array(Array.prototype.slice.call(L,A,M))}},"./src/utils/vttcue.ts":function(j,R,l){"use strict";l.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var P=["","lr","rl"],L=["start","middle","end","left","right"];function A(y,x){if(typeof x!="string"||!Array.isArray(y))return!1;var D=x.toLowerCase();return~y.indexOf(D)?D:!1}function M(y){return A(P,y)}function O(y){return A(L,y)}function b(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var f in p)y[f]=p[f]}return y}function _(y,x,D){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",f=!1,e=y,s=x,h=D,g=null,i="",r=!0,o="auto",c="start",t=50,n="middle",u=50,a="middle";Object.defineProperty(E,"id",b({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",b({},m,{get:function(){return f},set:function(v){f=!!v}})),Object.defineProperty(E,"startTime",b({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",b({},m,{get:function(){return s},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",b({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",b({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",b({},m,{get:function(){return i},set:function(v){var S=M(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",b({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",b({},m,{get:function(){return o},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",b({},m,{get:function(){return c},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",b({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",b({},m,{get:function(){return n},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",b({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",b({},m,{get:function(){return a},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"parseTimeStamp",function(){return A}),l.d(R,"fixLineBreaks",function(){return x}),l.d(R,"VTTParser",function(){return D});var P=l("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(f,e){if(!f)return"";if(typeof f!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(f))},E}();function A(E){function m(f,e,s,h){return(f|0)*3600+(e|0)*60+(s|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var M=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(f,e){!this.get(f)&&e!==""&&(this.values[f]=e)},m.get=function(f,e,s){return s?this.has(f)?this.values[f]:e[s]:this.has(f)?this.values[f]:e},m.has=function(f){return f in this.values},m.alt=function(f,e,s){for(var h=0;h<s.length;++h)if(e===s[h]){this.set(f,e);break}},m.integer=function(f,e){/^-?\d+$/.test(e)&&this.set(f,parseInt(e,10))},m.percent=function(f,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(f,s),!0}return!1},E}();function O(E,m,p,f){var e=f?E.split(f):[E];for(var s in e)if(typeof e[s]=="string"){var h=e[s].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var b=new P.default(0,0,""),_=b.align==="middle"?"middle":"center";function y(E,m,p){var f=E;function e(){var g=A(E);if(g===null)throw new Error("Malformed timestamp: "+f);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function s(g,i){var r=new M;O(g,function(t,n){var u;switch(t){case"region":for(var a=p.length-1;a>=0;a--)if(p[a].id===n){r.set(t,p[a].region);break}break;case"vertical":r.alt(t,n,["rl","lr"]);break;case"line":u=n.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=n.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&b.line===-1&&(o=-1),i.line=o,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.get("position","auto");c==="auto"&&b.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+f);E=E.slice(3),h(),m.endTime=e(),h(),s(E,m)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
20
|
+
initSegmentChange: `+ee);var re=new w.TransmuxConfig(h,g,s,o,n);this.configureTransmuxer(re)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:I,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(v){var ae=v.push(e,I,t,q);Object(w.isPromise)(ae)?ae.then(function(ne){d.handleTransmuxComplete(ne)}):this.handleTransmuxComplete(ae)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(w.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,h=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":O.logger[s.data.logType]&&O.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,h.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,h=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var C=l("./src/demux/transmuxer.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),w=l("./node_modules/eventemitter3/index.js"),O=l.n(w);function b(E){var m=new w.EventEmitter,p=function(s,h){E.postMessage({event:s,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var f=function(){var s=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};A.logger[i]=r};for(var h in A.logger)s(h)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var h=JSON.parse(s.config);E.transmuxer=new C.default(m,s.typeSupported,h,s.vendor,s.id),Object(A.enableLogs)(h.debug),f(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var g=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(C.isPromise)(g)?g.then(function(o){_(E,o)}):_(E,g);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(C.isPromise)(r)?r.then(function(o){x(E,o,i)}):x(E,r,i);break}default:break}})}function _(E,m){if(D(m.remuxResult))return!1;var p=[],f=m.remuxResult,e=f.audio,s=f.video;return e&&y(p,e),s&&y(p,s),E.postMessage({event:"transmuxComplete",data:m},p),!0}function y(E,m){m.data1&&E.push(m.data1.buffer),m.data2&&E.push(m.data2.buffer)}function x(E,m,p){var f=m.reduce(function(e,s){return _(E,s)||e},!1);f||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function D(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return p}),l.d(R,"isPromise",function(){return s}),l.d(R,"TransmuxConfig",function(){return h}),l.d(R,"TransmuxState",function(){return g});var C=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/crypt/decrypter.ts"),w=l("./src/demux/aacdemuxer.ts"),O=l("./src/demux/mp4demuxer.ts"),b=l("./src/demux/tsdemuxer.ts"),_=l("./src/demux/mp3demuxer.ts"),y=l("./src/remux/mp4-remuxer.ts"),x=l("./src/remux/passthrough-remuxer.ts"),D=l("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:b.default,remux:y.default},{demux:O.default,remux:x.default},{demux:w.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(o,c,t,n,u){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=o,this.typeSupported=c,this.config=t,this.vendor=n,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,n,u){var a=this,d=n.transmuxing;d.executeStart=E();var v=new Uint8Array(c),S=this.config,T=this.currentTransmuxState,I=this.transmuxConfig;u&&(this.currentTransmuxState=u);var k=u||T,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,H=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=I.audioCodec,ee=I.videoCodec,q=I.defaultInitPts,re=I.duration,ae=I.initSegmentData;(U||W||Y)&&this.resetInitSegment(ae,$,ee,re),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ne=f(v,t);if(ne&&ne.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var he=te.softwareDecrypt(v,ne.key.buffer,ne.iv.buffer);if(!he)return d.executeEnd=E(),e(n);v=new Uint8Array(he)}else return this.decryptionPromise=te.webCryptoDecrypt(v,ne.key.buffer,ne.iv.buffer).then(function(Te){var pe=a.push(Te,null,n);return a.decryptionPromise=null,pe}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,I);var ve=this.transmux(v,ne,z,H,n),ie=this.currentTransmuxState;return ie.contiguous=!0,ie.discontinuity=!1,ie.trackSwitch=!1,d.executeEnd=E(),ve},r.flush=function(c){var t=this,n=c.transmuxing;n.executeStart=E();var u=this.decrypter,a=this.currentTransmuxState,d=this.decryptionPromise;if(d)return d.then(function(){return t.flush(c)});var v=[],S=a.timeOffset;if(u){var T=u.flush();T&&v.push(this.push(T,null,c))}var I=this.demuxer,k=this.remuxer;if(!I||!k)return this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(c)];var B=I.flush(S);return s(B)?B.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,B,c),v)},r.flushRemux=function(c,t,n){var u=t.audioTrack,a=t.videoTrack,d=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,T=S.accurateTimeOffset,I=S.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var k=this.remuxer.remux(u,a,d,v,I,T,!0,this.id);c.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(c),n.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,n,u){var a=this.demuxer,d=this.remuxer;!a||!d||(a.resetInitSegment(c,t,n,u),d.resetInitSegment(c,t,n))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,n,u,a){var d;return t&&t.method==="SAMPLE-AES"?d=this.transmuxSampleAes(c,t,n,u,a):d=this.transmuxUnencrypted(c,n,u,a),d},r.transmuxUnencrypted=function(c,t,n,u){var a=this.demuxer.demux(c,t,!1,!this.config.progressive),d=a.audioTrack,v=a.videoTrack,S=a.id3Track,T=a.textTrack,I=this.remuxer.remux(d,v,S,T,t,n,!1,this.id);return{remuxResult:I,chunkMeta:u}},r.transmuxSampleAes=function(c,t,n,u,a){var d=this;return this.demuxer.demuxSampleAes(c,t,n).then(function(v){var S=d.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,n,u,!1,d.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(c,t){for(var n=this.config,u=this.observer,a=this.typeSupported,d=this.vendor,v=t.audioCodec,S=t.defaultInitPts,T=t.duration,I=t.initSegmentData,k=t.videoCodec,B,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){B=m[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:O.default,remux:x.default});var H=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(u,n,a,d)),(!H||!(H instanceof $))&&(this.demuxer=new $(u,n,a),this.probe=$.probe),this.resetInitSegment(I,v,k,T),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new A.default(this.observer,this.config)),c},i}();function f(i,r){var o=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(o=r),o}var e=function(r){return{remuxResult:{},chunkMeta:r}};function s(i){return"then"in i&&i.then instanceof Function}var h=function(r,o,c,t,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=o,this.initSegmentData=c,this.duration=t,this.defaultInitPts=n},g=function(r,o,c,t,n,u){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=o,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"discardEPB",function(){return h});var C=l("./src/demux/adts.ts"),L=l("./src/demux/mpegaudio.ts"),A=l("./src/demux/exp-golomb.ts"),w=l("./src/demux/sample-aes.ts"),O=l("./src/events.ts"),b=l("./src/utils/mp4-tools.ts"),_=l("./src/utils/logger.ts"),y=l("./src/errors.ts"),x=l("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(g[o]=r[o])}return g},D.apply(this,arguments)}var E=function(){function g(r,o,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._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=r,this.config=o,this.typeSupported=c}g.probe=function(o){return o[0]===71&&o[188]===71},g.createTrack=function(o,c){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:b.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(o,c,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",n),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,c=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,c,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var u,a=this._avcTrack,d=this._audioTrack,v=this._id3Track,S=this._txtTrack,T=a.pid,I=a.pesData,k=d.pid,B=v.pid,U=d.pesData,W=v.pesData,H=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(b.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};$-=$%188,$<o.byteLength&&!n&&(this.remainderData=new Uint8Array(o.buffer,$,o.buffer.byteLength-$));for(var ee=0,q=0;q<$;q+=188)if(o[q]===71){var re=!!(o[q+1]&64),ae=((o[q+1]&31)<<8)+o[q+2],ne=(o[q+3]&48)>>4,te=void 0;if(ne>1){if(te=q+5+o[q+4],te===q+188)continue}else te=q+4;switch(ae){case T:re&&(I&&(u=e(I))&&this.parseAVCPES(a,S,u,!1),I={data:[],size:0}),I&&(I.data.push(o.subarray(te,q+188)),I.size+=q+188-te);break;case k:if(re){if(U&&(u=e(U)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:re&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(o.subarray(te,q+188)),W.size+=q+188-te);break;case 0:re&&(te+=o[te]+1),Y=this._pmtId=p(o,te);break;case Y:{re&&(te+=o[te]+1);var he=f(o,te,this.typeSupported,t);T=he.avc,T>0&&(a.pid=T),k=he.audio,k>0&&(d.pid=k,d.segmentCodec=he.segmentCodec),B=he.id3,B>0&&(v.pid=B),H!==null&&!z&&(_.logger.log("unknown PID '"+H+"' in TS found"),H=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=ae;break}}else ee++;ee>0&&this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ee+" TS packet/s that do not start with 0x47"}),a.pesData=I,d.pesData=U,v.pesData=W;var ve={audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};return n&&this.extractRemainingSamples(ve),ve},i.flush=function(){var o=this.remainderData;this.remainderData=null;var c;return o?c=this.demux(o,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(o){var c=o.audioTrack,t=o.videoTrack,n=o.id3Track,u=o.textTrack,a=t.pesData,d=c.pesData,v=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=a,d&&(S=e(d))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else d!=null&&d.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=d;v&&(S=e(v))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=v},i.demuxSampleAes=function(o,c,t){var n=this.demux(o,t,!0,!this.config.progressive),u=this.sampleAes=new w.default(this.observer,this.config,c);return this.decrypt(n,u)},i.decrypt=function(o,c){return new Promise(function(t){var n=o.audioTrack,u=o.videoTrack;n.samples&&n.segmentCodec==="aac"?c.decryptAacSamples(n.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(o)}):t(o)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,c,t,n){var u=this,a=this.parseAVCNALu(o,t.data),d=!1,v=this.avcSample,S,T=!1;t.data=null,v&&a.length&&!o.audFound&&(s(v,o),v=this.avcSample=m(!1,t.pts,t.dts,"")),a.forEach(function(I){switch(I.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="NDR "),v.frame=!0;var k=I.data;if(T&&k.length>4){var B=new A.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,d&&v&&(v.debug+="SEI "),Object(b.parseSEIMessageFromNALu)(h(I.data),t.pts,c.samples);break}case 7:if(S=!0,T=!0,d&&v&&(v.debug+="SPS "),!o.sps){var U=new A.default(I.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[I.data],o.duration=u._duration;for(var H=I.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var $=H[Y].toString(16);$.length<2&&($="0"+$),z+=$}o.codec=z}break;case 8:S=!0,d&&v&&(v.debug+="PPS "),o.pps||(o.pps=[I.data]);break;case 9:S=!1,o.audFound=!0,v&&s(v,o),v=u.avcSample=m(!1,t.pts,t.dts,d?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+I.type+" ");break}if(v&&S){var ee=v.units;ee.push(I)}}),n&&v&&(s(v,o),this.avcSample=null)},i.getLastNalUnit=function(o){var c,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;n=u[u.length-1]}return n},i.parseAVCNALu=function(o,c){var t=c.byteLength,n=o.naluState||0,u=n,a=[],d=0,v,S,T,I=-1,k=0;for(n===-1&&(I=0,k=c[0]&31,n=0,d=1);d<t;){if(v=c[d++],!n){n=v?0:1;continue}if(n===1){n=v?0:2;continue}if(!v)n=3;else if(v===1){if(I>=0){var B={data:c.subarray(I,d-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(u&&d<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=d-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}d<t?(T=c[d]&31,I=d,k=T,n=0):n=-1}else n=0}if(I>=0&&n>=0){var H={data:c.subarray(I,t),type:k,state:n};a.push(H)}if(a.length===0){var z=this.getLastNalUnit(o.samples);if(z){var Y=new Uint8Array(z.data.byteLength+c.byteLength);Y.set(z.data,0),Y.set(c,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,c){var t=0,n=this.aacOverFlow,u=c.data;if(n){this.aacOverFlow=null;var a=n.missing,d=n.sample.unit.byteLength;if(a===-1){var v=new Uint8Array(d+u.byteLength);v.set(n.sample.unit,0),v.set(u,d),u=v}else{var S=d-a;n.sample.unit.set(u.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var T,I;for(T=t,I=u.length;T<I-1&&!C.isHeader(u,T);T++);if(T!==t){var k,B;if(T<I-1?(k="AAC PES did not start with ADTS header,offset:"+T,B=!1):(k="no ADTS header found in AAC PES",B=!0),_.logger.warn("parsing error:"+k),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}C.initTrackConfig(o,this.observer,u,T,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(n){var W=C.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0,z;T<I;)if(z=C.appendFrame(o,u,T,U,H),T+=z.length,z.missing){this.aacOverFlow=z;break}else for(H++;T<I-1&&!C.isHeader(u,T);T++);},i.parseMPEGPES=function(o,c){var t=c.data,n=t.length,u=0,a=0,d=c.pts;if(d===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(L.isHeader(t,a)){var v=L.appendFrame(o,t,a,d,u);if(v)a+=v.length,u++;else break}else a++},i.parseID3PES=function(o,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},c,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});o.samples.push(t)},g}();function m(g,i,r,o){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function f(g,i,r,o){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],n=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<n;){var a=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!o){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=a);break;case 21:c.id3===-1&&(c.id3=a);break;case 219:if(!o){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=a,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,o,c,t,n,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var a=new Uint8Array(u[0].length+u[1].length);a.set(u[0]),a.set(u[1],u[0].length),u[0]=a,u.splice(1,1)}r=u[0];var d=(r[0]<<16)+(r[1]<<8)+r[2];if(d===1){if(o=(r[4]<<8)+r[5],o&&o>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(n=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-n>60*9e4&&(_.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var T=new Uint8Array(g.size),I=0,k=u.length;I<k;I++){r=u[I];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;T.set(r,i),i+=B}return o&&(o-=c+3),{data:T,pts:t,dts:n,len:o}}return null}function s(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,o=r.length;if(o){var c=r[o-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],o=1;o<i-2;)g[o]===0&&g[o+1]===0&&g[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),n=0;for(o=0;o<c;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=g[n];return t}R.default=E},"./src/errors.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ErrorTypes",function(){return C}),l.d(R,"ErrorDetails",function(){return L});var C;(function(A){A.NETWORK_ERROR="networkError",A.MEDIA_ERROR="mediaError",A.KEY_SYSTEM_ERROR="keySystemError",A.MUX_ERROR="muxError",A.OTHER_ERROR="otherError"})(C||(C={}));var L;(function(A){A.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",A.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",A.KEY_SYSTEM_NO_SESSION="keySystemNoSession",A.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",A.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",A.MANIFEST_LOAD_ERROR="manifestLoadError",A.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",A.MANIFEST_PARSING_ERROR="manifestParsingError",A.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",A.LEVEL_EMPTY_ERROR="levelEmptyError",A.LEVEL_LOAD_ERROR="levelLoadError",A.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",A.LEVEL_SWITCH_ERROR="levelSwitchError",A.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",A.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",A.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",A.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",A.FRAG_LOAD_ERROR="fragLoadError",A.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",A.FRAG_DECRYPT_ERROR="fragDecryptError",A.FRAG_PARSING_ERROR="fragParsingError",A.REMUX_ALLOC_ERROR="remuxAllocError",A.KEY_LOAD_ERROR="keyLoadError",A.KEY_LOAD_TIMEOUT="keyLoadTimeOut",A.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",A.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",A.BUFFER_APPEND_ERROR="bufferAppendError",A.BUFFER_APPENDING_ERROR="bufferAppendingError",A.BUFFER_STALLED_ERROR="bufferStalledError",A.BUFFER_FULL_ERROR="bufferFullError",A.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",A.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",A.INTERNAL_EXCEPTION="internalException",A.INTERNAL_ABORTED="aborted",A.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Events",function(){return C});var C;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(C||(C={}))},"./src/hls.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return i});var C=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(C),A=l("./src/loader/playlist-loader.ts"),w=l("./src/loader/key-loader.ts"),O=l("./src/controller/id3-track-controller.ts"),b=l("./src/controller/latency-controller.ts"),_=l("./src/controller/level-controller.ts"),y=l("./src/controller/fragment-tracker.ts"),x=l("./src/controller/stream-controller.ts"),D=l("./src/is-supported.ts"),E=l("./src/utils/logger.ts"),m=l("./src/config.ts"),p=l("./node_modules/eventemitter3/index.js"),f=l.n(p),e=l("./src/events.ts"),s=l("./src/errors.ts");function h(r,o){for(var c=0;c<o.length;c++){var t=o[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,o,c){return o&&h(r.prototype,o),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var n=t.abrController,u=t.bufferController,a=t.capLevelController,d=t.fpsController,v=this.abrController=new n(this),S=this.bufferController=new u(this),T=this.capLevelController=new a(this),I=new d(this),k=new A.default(this),B=new w.default(this),U=new O.default(this),W=this.levelController=new _.default(this),H=new y.FragmentTracker(this),z=this.streamController=new x.default(this,H);T.setStreamController(z),I.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[v,S,T,I,U,H];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,H,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,H,Y),this.createController(t.timelineController,null,$),this.emeController=this.createController(t.emeController,null,$),this.cmcdController=this.createController(t.cmcdController,null,$),this.latencyController=this.createController(b.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,u){if(t){var a=n?new t(this,n):new t(this);return u&&u.push(a),a}return null},o.on=function(t,n,u){u===void 0&&(u=this),this._emitter.on(t,n,u)},o.once=function(t,n,u){u===void 0&&(u=this),this._emitter.once(t,n,u)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,u,a){u===void 0&&(u=this),this._emitter.off(t,n,u,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,u){return this._emitter.emit(t,n,u)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},o.listenerCount=function(t){return this._emitter.listenerCount(t)},o.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},o.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},o.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},o.loadSource=function(t){this.stopLoad();var n=this.media,u=this.url,a=this.url=C.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(n)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},o.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(n){n.startLoad(t)})},o.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},o.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},o.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},o.removeLevel=function(t,n){n===void 0&&(n=0),this.levelController.removeLevel(t,n)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var n=!!t;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(E.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,n=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,a=0;a<u;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,u;return n===-1&&t&&t.length?u=t.length-1:u=n,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var n=this.audioTrackController;n&&(n.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:m.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isSupported",function(){return A}),l.d(R,"changeTypeSupported",function(){return w});var C=l("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var O=Object(C.getMediaSource)();if(!O)return!1;var b=L(),_=O&&typeof O.isTypeSupported=="function"&&O.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!_&&!!y}function w(){var O,b=L();return typeof(b==null||(O=b.prototype)===null||O===void 0?void 0:O.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"DateRangeAttribute",function(){return _}),l.d(R,"DateRange",function(){return y});var C=l("./src/polyfills/number.ts"),L=l("./src/utils/attr-list.ts"),A=l("./src/utils/logger.ts");function w(){return w=Object.assign?Object.assign.bind():function(x){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(x[m]=E[m])}return x},w.apply(this,arguments)}function O(x,D){for(var E=0;E<D.length;E++){var m=D[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(x,m.key,m)}}function b(x,D,E){return D&&O(x.prototype,D),E&&O(x,E),Object.defineProperty(x,"prototype",{writable:!1}),x}var _;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function x(D,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var m=E.attr;for(var p in m)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==m[p]){A.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=w(new L.AttrList({}),m,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var f=new Date(this.attr[_.END_DATE]);Object(C.isFiniteNumber)(f.getTime())&&(this._endDate=f)}}return b(x,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var E=this.duration;return E!==null?new Date(this._startDate.getTime()+E*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(C.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(C.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E}),l.d(R,"LoadError",function(){return p});var C=l("./src/polyfills/number.ts"),L=l("./src/errors.ts");function A(f,e){f.prototype=Object.create(e.prototype),f.prototype.constructor=f,y(f,e)}function w(f){var e=typeof Map=="function"?new Map:void 0;return w=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return O(h,arguments,x(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},w(f)}function O(f,e,s){return b()?O=Reflect.construct.bind():O=function(g,i,r){var o=[null];o.push.apply(o,i);var c=Function.bind.apply(g,o),t=new c;return r&&y(t,r.prototype),t},O.apply(null,arguments)}function b(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function y(f,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(f,e)}function x(f){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},x(f)}var D=Math.pow(2,17),E=function(){function f(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=f.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){i.loader&&i.loader.destroy();var a=i.loader=h.loader=c?new c(o):new t(o),d=m(h),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:D};h.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){i.resetLoader(h,a),n({frag:h,part:null,payload:T.data,networkDetails:B})},onError:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:T,networkDetails:k}))},onAbort:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:k}))},onTimeout:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:k}))},onProgress:function(T,I,k,B){g&&g({frag:h,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){r.loader&&r.loader.destroy();var a=r.loader=h.loader=c?new c(o):new t(o),d=m(h,g),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};g.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){r.resetLoader(h,a),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:T.data,networkDetails:B};i(U),n(U)},onError:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:T,networkDetails:k}))},onAbort:function(T,I,k){h.stats.aborted=g.stats.aborted,r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:k}))},onTimeout:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:k}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,o=r.total;if(i.loaded+=r.loaded,o){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/o),c),n=c-t,u=n*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var a=i.loading,d=r.loading;a.start?a.first+=d.first-d.start:(a.start=d.start,a.first=d.first),a.end=d.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},f}();function m(f,e){e===void 0&&(e=null);var s=e||f,h={frag:f,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},g=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(C.isFiniteNumber)(g)&&Object(C.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(f){A(e,f);function e(s){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=f.call.apply(f,[this].concat(i))||this,h.data=void 0,h.data=s,h}return e}(w(Error))},"./src/loader/fragment.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ElementaryStreamTypes",function(){return E}),l.d(R,"BaseSegment",function(){return m}),l.d(R,"Fragment",function(){return p}),l.d(R,"Part",function(){return f});var C=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),w=l("./src/utils/logger.ts"),O=l("./src/loader/level-key.ts"),b=l("./src/loader/load-stats.ts");function _(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,s)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var s=e.prototype;return s.setByteRange=function(g,i){var r=g.split("@",2),o=[];r.length===1?o[0]=i?i.byteRangeEndOffset:0:o[0]=parseInt(r[1]),o[1]=parseInt(r[0])+o[0],this._byteRange=o},D(e,[{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(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(s,e);function s(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new b.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=s.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=O.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},h.setElementaryStreamInfo=function(i,r,o,c,t,n){n===void 0&&(n=!1);var u=this.elementaryStreams,a=u[i];if(!a){u[i]={startPTS:r,endPTS:o,startDTS:c,endDTS:t,partial:n};return}a.startPTS=Math.min(a.startPTS,r),a.endPTS=Math.max(a.endPTS,o),a.startDTS=Math.min(a.startDTS,c),a.endDTS=Math.max(a.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},D(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&w.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(C.isFiniteNumber)(this.programDateTime))return null;var i=Object(C.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(m),f=function(e){_(s,e);function s(h,g,i,r,o){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new b.LoadStats,c.duration=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,o),o&&(c.fragOffset=o.fragOffset+o.duration),c}return D(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),s}(m)},"./src/loader/key-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return w});var C=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),w=function(){function O(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var b=O.prototype;return b.startLoad=function(y){},b.stopLoad=function(){this.destroyInternalLoaders()},b.registerListeners=function(){this.hls.on(C.Events.KEY_LOADING,this.onKeyLoading,this)},b.unregisterListeners=function(){this.hls.off(C.Events.KEY_LOADING,this.onKeyLoading)},b.destroyInternalLoaders=function(){for(var y in this.loaders){var x=this.loaders[y];x&&x.destroy()}this.loaders={}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onKeyLoading=function(y,x){var D=x.frag,E=D.type,m=this.loaders[E];if(!D.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var f=this.hls.config;if(m&&(A.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){A.logger.warn("key uri is falsy");return}var e=f.loader,s=D.loader=this.loaders[E]=new e(f);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:D,responseType:"arraybuffer"},g={timeout:f.fragLoadingTimeOut,maxRetry:0,retryDelay:f.fragLoadingRetryDelay,maxRetryDelay:f.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(h,g,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(C.Events.KEY_LOADED,{frag:D}))},b.loadsuccess=function(y,x,D){var E=D.frag;if(!E.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(C.Events.KEY_LOADED,{frag:E})},b.loaderror=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},b.loadtimeout=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(C.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},O}()},"./src/loader/level-details.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelDetails",function(){return O});var C=l("./src/polyfills/number.ts");function L(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function A(b,_,y){return _&&L(b.prototype,_),y&&L(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var w=10,O=function(){function b(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.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.dateRanges={},this.url=y}var _=b.prototype;return _.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!D,this.advanced=this.endSN>x.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},A(b,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(C.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||w}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var D=this.driftEnd-this.driftStart;return D*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),b}()},"./src/loader/level-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelKey",function(){return O});var C=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(C);function A(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function w(b,_,y){return _&&A(b.prototype,_),y&&A(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var O=function(){b.fromURL=function(y,x){return new b(y,x)},b.fromURI=function(y){return new b(y)};function b(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(C.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return w(b,[{key:"uri",get:function(){return this._uri}}]),b}()},"./src/loader/load-stats.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LoadStats",function(){return C});var C=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(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return h});var C=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),w=l("./src/loader/date-range.ts"),O=l("./src/loader/fragment.ts"),b=l("./src/loader/level-details.ts"),_=l("./src/loader/level-key.ts"),y=l("./src/utils/attr-list.ts"),x=l("./src/utils/logger.ts"),D=l("./src/utils/codecs.ts"),E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),f=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(t){var n,u;return e.test((n=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?n:"")}var h=function(){function t(){}return t.findGroup=function(u,a){for(var d=0;d<u.length;d++){var v=u[d];if(v.id===a)return v}},t.convertAVC1ToAVCOTI=function(u){var a=u.split(".");if(a.length>2){var d=a.shift()+".";return d+=parseInt(a.shift()).toString(16),d+=("000"+parseInt(a.shift()).toString(16)).slice(-4),d}return u},t.resolve=function(u,a){return L.buildAbsoluteURL(a,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,a){var d=[],v={},S=!1;E.lastIndex=0;for(var T;(T=E.exec(u))!=null;)if(T[1]){var I=new y.AttrList(T[1]),k={attrs:I,bitrate:I.decimalInteger("AVERAGE-BANDWIDTH")||I.decimalInteger("BANDWIDTH"),name:I.NAME,url:t.resolve(T[2],a)},B=I.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),g((I.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),d.push(k)}else if(T[3]){var U=new y.AttrList(T[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:d,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,a,d,v){v===void 0&&(v=[]);var S,T=[],I=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===d){var B={attrs:k,bitrate:0,id:I++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:d,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(v.length){var U=t.findGroup(v,B.groupId)||v[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}T.push(B)}}return T},t.parseLevelPlaylist=function(u,a,d,v,S){var T=new b.LevelDetails(a),I=T.fragments,k=null,B=0,U=0,W=0,H=0,z=null,Y=new O.Fragment(v,a),$,ee,q,re=-1,ae=!1;for(p.lastIndex=0,T.m3u8=u;($=p.exec(u))!==null;){ae&&(ae=!1,Y=new O.Fragment(v,a),Y.start=W,Y.sn=B,Y.cc=H,Y.level=d,k&&(Y.initSegment=k,Y.rawProgramDateTime=k.rawProgramDateTime,k.rawProgramDateTime=null));var ne=$[1];if(ne){Y.duration=parseFloat(ne);var te=(" "+$[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ne,te]:["INF",ne])}else if($[3])Object(C.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=d,Y.cc=H,Y.urlId=S,I.push(Y),Y.relurl=(" "+$[3]).slice(1),o(Y,z),z=Y,W+=Y.duration,B++,U=0,ae=!0);else if($[4]){var he=(" "+$[4]).slice(1);z?Y.setByteRange(he,z):Y.setByteRange(he)}else if($[5])Y.rawProgramDateTime=(" "+$[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),re===-1&&(re=I.length);else{if($=$[0].match(f),!$){x.logger.warn("No matches on slow regex match for level playlist!");continue}for(ee=1;ee<$.length&&typeof $[ee]=="undefined";ee++);var ve=(" "+$[ee]).slice(1),ie=(" "+$[ee+1]).slice(1),Te=$[ee+2]?(" "+$[ee+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":T.type=ie.toUpperCase();break;case"MEDIA-SEQUENCE":B=T.startSN=parseInt(ie);break;case"SKIP":{var pe=new y.AttrList(ie),xe=pe.decimalInteger("SKIPPED-SEGMENTS");if(Object(C.isFiniteNumber)(xe)){T.skippedSegments=xe;for(var Me=xe;Me--;)I.unshift(null);B+=xe}var Ae=pe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ae&&(T.recentlyRemovedDateranges=Ae.split(" "));break}case"TARGETDURATION":T.targetduration=parseFloat(ie);break;case"VERSION":T.version=parseInt(ie);break;case"EXTM3U":break;case"ENDLIST":T.live=!1;break;case"#":(ie||Te)&&Y.tagList.push(Te?[ie,Te]:[ie]);break;case"DISCONTINUITY":H++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([ve]);break;case"BITRATE":Y.tagList.push([ve,ie]);break;case"DATERANGE":{var We=new y.AttrList(ie),Ie=new w.DateRange(We,T.dateRanges[We.ID]);Ie.isValid||T.skippedSegments?T.dateRanges[Ie.id]=Ie:x.logger.warn('Ignoring invalid DATERANGE tag: "'+ie+'"'),Y.tagList.push(["EXT-X-DATERANGE",ie]);break}case"DISCONTINUITY-SEQUENCE":H=parseInt(ie);break;case"KEY":{var Be,be=new y.AttrList(ie),Ge=be.enumeratedString("METHOD"),He=be.URI,Qe=be.hexadecimalInteger("IV"),Ue=be.enumeratedString("KEYFORMATVERSIONS"),it=be.enumeratedString("KEYID"),we=(Be=be.enumeratedString("KEYFORMAT"))!=null?Be:"identity",nt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(nt.indexOf(we)>-1){x.logger.warn("Keyformat "+we+" is not supported from the manifest");continue}else if(we!=="identity")continue;Ge&&(q=_.LevelKey.fromURL(a,He),He&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ge)>=0&&(q.method=Ge,q.keyFormat=we,it&&(q.keyID=it),Ue&&(q.keyFormatVersions=Ue),q.iv=Qe));break}case"START":{var Oe=new y.AttrList(ie),Ce=Oe.decimalFloatingPoint("TIME-OFFSET");Object(C.isFiniteNumber)(Ce)&&(T.startTimeOffset=Ce);break}case"MAP":{var Ye=new y.AttrList(ie);if(Y.duration){var Re=new O.Fragment(v,a);c(Re,Ye,d,q),k=Re,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else c(Y,Ye,d,q),k=Y,ae=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(ie);T.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),T.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),T.canSkipDateRanges=T.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),T.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),T.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var at=new y.AttrList(ie);T.partTarget=at.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ze=T.partList;ze||(ze=T.partList=[]);var pt=U>0?ze[ze.length-1]:void 0,xt=U++,tt=new O.Part(new y.AttrList(ie),Y,a,xt,pt);ze.push(tt),Y.duration+=tt.duration;break}case"PRELOAD-HINT":{var Ut=new y.AttrList(ie);T.preloadHint=Ut;break}case"RENDITION-REPORT":{var St=new y.AttrList(ie);T.renditionReports=T.renditionReports||[],T.renditionReports.push(St);break}default:x.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(I.pop(),W-=z.duration,T.partList&&(T.fragmentHint=z)):T.partList&&(o(Y,z),Y.cc=H,T.fragmentHint=Y);var ct=I.length,Et=I[0],ut=I[ct-1];if(W+=T.skippedSegments*T.targetduration,W>0&&ct&&ut){T.averagetargetduration=W/ct;var Ot=ut.sn;T.endSN=Ot!=="initSegment"?Ot:0,Et&&(T.startCC=Et.cc,Et.initSegment||T.fragments.every(function(yt){return yt.relurl&&s(yt.relurl)})&&(x.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new O.Fragment(v,a),Y.relurl=ut.relurl,Y.level=d,Y.sn="initSegment",Et.initSegment=Y,T.needSidxRanges=!0))}else T.endSN=0,T.startCC=0;return T.fragmentHint&&(W+=T.fragmentHint.duration),T.totalduration=W,T.endCC=H,re>0&&r(I,re),T},t}();function g(t,n){["video","audio","text"].forEach(function(u){var a=t.filter(function(v){return Object(D.isCodecType)(v,u)});if(a.length){var d=a.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[u+"Codec"]=d.length>0?d[0]:a[0],t=t.filter(function(v){return a.indexOf(v)===-1})}}),n.unknownCodecs=t}function i(t,n,u){var a=n[u];a&&(t[u]=a)}function r(t,n){for(var u=t[n],a=n;a--;){var d=t[a];if(!d)return;d.programDateTime=u.programDateTime-d.duration*1e3,u=d}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(C.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,n,u,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=u,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),w=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/loader/m3u8-parser.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/attr-list.ts");function x(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(m,p){var f=m.url;return(f===void 0||f.indexOf("data:")===0)&&(f=p.url),f}var E=function(){function m(f){this.hls=void 0,this.loaders=Object.create(null),this.hls=f,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,h=s.pLoader,g=s.loader,i=h||g,r=new i(s);return e.loader=r,this.loaders[e.type]=r,r},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,s){var h=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var h=s.id,g=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){w.logger.trace("[playlist-loader]: playlist request ongoing");return}w.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,o,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,o=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,o=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,o=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var u=n.partTarget,a=n.targetduration;u&&a&&(o=Math.min(Math.max(u*3,a*.8)*1e3,o))}}var d={timeout:o,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,d,v)},p.loadsuccess=function(e,s,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,s,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,h,g):this.handleMasterPlaylist(e,s,h,g)},p.loaderror=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!1,e)},p.loadtimeout=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!0)},p.handleMasterPlaylist=function(e,s,h,g){var i=this.hls,r=e.data,o=D(e,h),c=b.default.parseMasterPlaylist(r,o),t=c.levels,n=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),a=t.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),d=b.default.parseMasterPlaylistMedia(r,o,"AUDIO",u),v=b.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=b.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(d.length){var T=d.some(function(I){return!I.url});!T&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(w.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:d,subtitles:v,captions:S,url:o,stats:s,networkDetails:g,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,h,g){var i=this.hls,r=h.id,o=h.level,c=h.type,t=D(e,h),n=Object(C.isFiniteNumber)(r)?r:0,u=Object(C.isFiniteNumber)(o)?o:n,a=x(h),d=b.default.parseLevelPlaylist(e.data,t,u,a,n);if(!d.fragments.length){i.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:d,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:s,networkDetails:g,sessionData:null})}if(s.parsing.end=performance.now(),d.needSidxRanges){var S,T=(S=d.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:T,isSidxRequest:!0,type:c,level:o,levelDetails:d,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=d,this.handlePlaylistLoaded(e,s,h,g)},p.handleSidxRequest=function(e,s){var h=new Uint8Array(e.data),g=Object(O.findBox)(h,["sidx"])[0];if(!!g){var i=Object(O.parseSegmentIndex)(g);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(c,t){var n=c.info,u=o.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),u.initSegment){var a=Object(O.findBox)(h,["moov"])[0],d=a?a.length:null;u.initSegment.setByteRange(String(d)+"@0")}})}}},p.handleManifestParsingError=function(e,s,h,g){this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:s,networkDetails:g})},p.handleNetworkError=function(e,s,h,g){h===void 0&&(h=!1),w.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=A.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,s,h,g){var i=h.type,r=h.level,o=h.id,c=h.groupId,t=h.loader,n=h.levelDetails,u=h.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break}},m}();R.default=E},"./src/polyfills/number.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isFiniteNumber",function(){return C}),l.d(R,"MAX_SAFE_INTEGER",function(){return L});var C=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,l){"use strict";l.r(R);var C=function(){function L(){}return L.getSilentFrame=function(w,O){switch(w){case"mp4a.40.2":if(O===1)return new Uint8Array([0,200,0,128,35,128]);if(O===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(O===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(O===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(O===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(O===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(O===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(O===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(O===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},L}();R.default=C},"./src/remux/mp4-generator.ts":function(j,R,l){"use strict";l.r(R);var C=Math.pow(2,32)-1,L=function(){function A(){}return A.init=function(){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:[]};var O;for(O in A.types)A.types.hasOwnProperty(O)&&(A.types[O]=[O.charCodeAt(0),O.charCodeAt(1),O.charCodeAt(2),O.charCodeAt(3)]);var b=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:b,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=x,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 D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,D,m,D,E),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,y))},A.box=function(O){for(var b=8,_=arguments.length,y=new Array(_>1?_-1:0),x=1;x<_;x++)y[x-1]=arguments[x];for(var D=y.length,E=D;D--;)b+=y[D].byteLength;var m=new Uint8Array(b);for(m[0]=b>>24&255,m[1]=b>>16&255,m[2]=b>>8&255,m[3]=b&255,m.set(O,4),D=0,b=8;D<E;D++)m.set(y[D],b),b+=y[D].byteLength;return m},A.hdlr=function(O){return A.box(A.types.hdlr,A.HDLR_TYPES[O])},A.mdat=function(O){return A.box(A.types.mdat,O)},A.mdhd=function(O,b){b*=O;var _=Math.floor(b/(C+1)),y=Math.floor(b%(C+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,O>>24&255,O>>16&255,O>>8&255,O&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},A.mdia=function(O){return A.box(A.types.mdia,A.mdhd(O.timescale,O.duration),A.hdlr(O.type),A.minf(O))},A.mfhd=function(O){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]))},A.minf=function(O){return O.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(O)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(O))},A.moof=function(O,b,_){return A.box(A.types.moof,A.mfhd(O),A.traf(_,b))},A.moov=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trak(O[b]);return A.box.apply(null,[A.types.moov,A.mvhd(O[0].timescale,O[0].duration)].concat(_).concat(A.mvex(O)))},A.mvex=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trex(O[b]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(O,b){b*=O;var _=Math.floor(b/(C+1)),y=Math.floor(b%(C+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,x)},A.sdtp=function(O){var b=O.samples||[],_=new Uint8Array(4+b.length),y,x;for(y=0;y<b.length;y++)x=b[y].flags,_[y+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return A.box(A.types.sdtp,_)},A.stbl=function(O){return A.box(A.types.stbl,A.stsd(O),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(O){var b=[],_=[],y,x,D;for(y=0;y<O.sps.length;y++)x=O.sps[y],D=x.byteLength,b.push(D>>>8&255),b.push(D&255),b=b.concat(Array.prototype.slice.call(x));for(y=0;y<O.pps.length;y++)x=O.pps[y],D=x.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(x));var E=A.box(A.types.avcC,new Uint8Array([1,b[3],b[4],b[5],255,224|O.sps.length].concat(b).concat([O.pps.length]).concat(_))),m=O.width,p=O.height,f=O.pixelRatio[0],e=O.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,m>>8&255,m&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,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([f>>24,f>>16&255,f>>8&255,f&255,e>>24,e>>16&255,e>>8&255,e&255])))},A.esds=function(O){var b=O.config.length;return new Uint8Array([0,0,0,0,3,23+b,0,1,0,4,15+b,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([b]).concat(O.config).concat([6,1,2]))},A.mp4a=function(O){var b=O.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,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]),A.box(A.types.esds,A.esds(O)))},A.mp3=function(O){var b=O.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,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]))},A.stsd=function(O){return O.type==="audio"?O.segmentCodec==="mp3"&&O.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(O)):A.box(A.types.stsd,A.STSD,A.mp4a(O)):A.box(A.types.stsd,A.STSD,A.avc1(O))},A.tkhd=function(O){var b=O.id,_=O.duration*O.timescale,y=O.width,x=O.height,D=Math.floor(_/(C+1)),E=Math.floor(_%(C+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,b>>24&255,b>>16&255,b>>8&255,b&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,x>>8&255,x&255,0,0]))},A.traf=function(O,b){var _=A.sdtp(O),y=O.id,x=Math.floor(b/(C+1)),D=Math.floor(b%(C+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,D>>24,D>>16&255,D>>8&255,D&255])),A.trun(O,_.length+16+20+8+16+8+8),_)},A.trak=function(O){return O.duration=O.duration||4294967295,A.box(A.types.trak,A.tkhd(O),A.mdia(O))},A.trex=function(O){var b=O.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(O,b){var _=O.samples||[],y=_.length,x=12+16*y,D=new Uint8Array(x),E,m,p,f,e,s;for(b+=8+x,D.set([O.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255],0),E=0;E<y;E++)m=_[E],p=m.duration,f=m.size,e=m.flags,s=m.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*E);return A.box(A.types.trun,D)},A.initSegment=function(O){A.types||A.init();var b=A.moov(O),_=new Uint8Array(A.FTYP.byteLength+b.byteLength);return _.set(A.FTYP),_.set(b,A.FTYP.byteLength),_},A}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,R.default=L},"./src/remux/mp4-remuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return e}),l.d(R,"normalizePts",function(){return s}),l.d(R,"flushTextTrackMetadataCueSamples",function(){return g}),l.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var C=l("./src/polyfills/number.ts"),L=l("./src/remux/aac-helper.ts"),A=l("./src/remux/mp4-generator.ts"),w=l("./src/events.ts"),O=l("./src/errors.ts"),b=l("./src/utils/logger.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(c[u]=n[u])}return c},x.apply(this,arguments)}var D=10*1e3,E=1024,m=1152,p=null,f=null,e=function(){function c(n,u,a,d){if(d===void 0&&(d=""),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.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=n,this.config=u,this.typeSupported=a,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(f===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);f=T?parseInt(T[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},t.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(u){var a=!1,d=u.reduce(function(v,S){var T=S.pts-v;return T<-4294967296?(a=!0,s(v,S.pts)):T>0?v:S.pts},u[0].pts);return a&&b.logger.debug("PTS rollover detected"),d},t.remux=function(u,a,d,v,S,T,I,k){var B,U,W,H,z,Y,$=S,ee=S,q=u.pid>-1,re=a.pid>-1,ae=a.samples.length,ne=u.samples.length>0,te=I&&ae>0||ae>1,he=(!q||ne)&&(!re||te)||this.ISGenerated||I;if(he){this.ISGenerated||(W=this.generateIS(u,a,S));var ve=this.isVideoContiguous,ie=-1,Te;if(te&&(ie=h(a.samples),!ve&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,ie>0){b.logger.warn("[mp4-remuxer]: Dropped "+ie+" out of "+ae+" video samples due to a missing keyframe");var pe=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(ie),a.dropped+=ie,ee+=(a.samples[0].pts-pe)/a.inputTimeScale,Te=ee}else ie===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+ae+" video samples"),Y=!1);if(this.ISGenerated){if(ne&&te){var xe=this.getVideoStartPts(a.samples),Me=s(u.samples[0].pts,xe)-xe,Ae=Me/a.inputTimeScale;$+=Math.max(0,Ae),ee+=Math.max(0,-Ae)}if(ne){if(u.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,a,S)),U=this.remuxAudio(u,$,this.isAudioContiguous,T,re||te||k===_.PlaylistLevelType.AUDIO?ee:void 0),te){var We=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,a,S)),B=this.remuxVideo(a,ee,ve,We)}}else te&&(B=this.remuxVideo(a,ee,ve,0));B&&(B.firstKeyFrame=ie,B.independent=ie!==-1,B.firstKeyFramePTS=Te)}}return this.ISGenerated&&(d.samples.length&&(z=g(d,S,this._initPTS,this._initDTS)),v.samples.length&&(H=i(v,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:H,id3:z}},t.generateIS=function(u,a,d){var v=u.samples,S=a.samples,T=this.typeSupported,I={},k=!Object(C.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,H;if(k&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":T.mpeg?(B="audio/mpeg",u.codec=""):T.mp3&&(u.codec="mp3");break}I.audio={id:"audio",container:B,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&T.mpeg?new Uint8Array(0):A.default.initSegment([u]),metadata:{channelCount:u.channelCount}},k&&(H=u.inputTimeScale,U=W=v[0].pts-Math.round(H*d))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:A.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){H=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(H*d);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(I).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:I,initPTS:U,timescale:H}},t.remuxVideo=function(u,a,d,v){var S=u.inputTimeScale,T=u.samples,I=[],k=T.length,B=this._initPTS,U=this.nextAvcDts,W=8,H=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,q=!1;if(!d||U===null){var re=a*S,ae=T[0].pts-s(T[0].dts,T[0].pts);U=re-ae}for(var ne=0;ne<k;ne++){var te=T[ne];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<T[ne>0?ne-1:ne].dts&&(q=!0)}q&&T.sort(function(Dt,sr){var Er=Dt.dts-sr.dts,yr=Dt.pts-sr.pts;return Er||yr}),z=T[0].dts,Y=T[T.length-1].dts;var he=Y-z,ve=he?Math.round(he/(k-1)):H||u.inputTimeScale/30;if(d){var ie=z-U,Te=ie>ve,pe=ie<-1;if(Te||pe){Te?b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(ie,!0)+" ms ("+ie+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-ie,!0)+" ms ("+ie+"dts) overlapping between fragments detected"),z=U;var xe=T[0].pts-ie;T[0].dts=z,T[0].pts=xe,b.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(xe,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(ie,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,Ae=0,We=0;We<k;We++){for(var Ie=T[We],Be=Ie.units,be=Be.length,Ge=0,He=0;He<be;He++)Ge+=Be[He].data.length;Ae+=Ge,Me+=be,Ie.length=Ge,Ie.dts=Math.max(Ie.dts,z),$=Math.min(Ie.pts,$),ee=Math.max(Ie.pts,ee)}Y=T[k-1].dts;var Qe=Ae+4*Me+8,Ue;try{Ue=new Uint8Array(Qe)}catch{this.observer.emit(w.Events.ERROR,w.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Qe,reason:"fail allocating video mdat "+Qe});return}var it=new DataView(Ue.buffer);it.setUint32(0,Qe),Ue.set(A.default.types.mdat,4);for(var we=!1,nt=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Ce=Number.NEGATIVE_INFINITY,Ye=Number.NEGATIVE_INFINITY,Re=0;Re<k;Re++){for(var Le=T[Re],at=Le.units,ze=0,pt=0,xt=at.length;pt<xt;pt++){var tt=at[pt],Ut=tt.data,St=tt.data.byteLength;it.setUint32(W,St),W+=4,Ue.set(Ut,W),W+=St,ze+=4+St}var ct=void 0;if(Re<k-1)H=T[Re+1].dts-Le.dts,ct=T[Re+1].pts-Le.pts;else{var Et=this.config,ut=Re>0?Le.dts-T[Re-1].dts:ve;if(ct=Re>0?Le.pts-T[Re-1].pts:ve,Et.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ot=Math.floor(Et.maxBufferHole*S),yt=(v?$+v*S:this.nextAudioPts)-Le.pts;yt>Ot?(H=yt-ut,H<0?H=ut:we=!0,b.logger.log("[mp4-remuxer]: It is approximately "+yt/90+" ms to the next segment; using duration "+H/90+" ms for the last video frame.")):H=ut}else H=ut}var tr=Math.round(Le.pts-Le.dts);nt=Math.min(nt,H),Ce=Math.max(Ce,H),Oe=Math.min(Oe,ct),Ye=Math.max(Ye,ct),I.push(new r(Le.key,H,ze,tr))}if(I.length){if(p){if(p<70){var Nt=I[0].flags;Nt.dependsOn=2,Nt.isNonSync=0}}else if(f&&Ye-Oe<Ce-nt&&ve/Ce<.025&&I[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Rt=z,rt=0,rr=I.length;rt<rr;rt++){var Kt=Rt+I[rt].duration,ir=Rt+I[rt].cts;if(rt<rr-1){var mr=Kt+I[rt+1].cts;I[rt].duration=mr-ir}else I[rt].duration=rt?I[rt-1].duration:ve;I[rt].cts=0,Rt=Kt}}}console.assert(H!==null,"mp4SampleDuration must be computed"),H=we||!H?ve:H,this.nextAvcDts=U=Y+H,this.videoSampleDuration=H,this.isVideoContiguous=!0;var pr=A.default.moof(u.sequenceNumber++,z,x({},u,{samples:I})),nr="video",ar={data1:pr,data2:Ue,startPTS:$/S,endPTS:(ee+H)/S,startDTS:z/S,endDTS:U/S,type:nr,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(Ue.length,"MDAT length must not be zero"),ar},t.remuxAudio=function(u,a,d,v,S){var T=u.inputTimeScale,I=u.samplerate?u.samplerate:T,k=T/I,B=u.segmentCodec==="aac"?E:m,U=B*k,W=this._initPTS,H=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=u.samples,ee=H?0:8,q=this.nextAudioPts||-1,re=a*T;if(this.isAudioContiguous=d=d||$.length&&q>0&&(v&&Math.abs(re-q)<9e3||Math.abs(s($[0].pts-W,re)-q)<20*U),$.forEach(function(tt){tt.pts=s(tt.pts-W,re)}),!d||q<0){if($=$.filter(function(tt){return tt.pts>=0}),!$.length)return;S===0?q=0:v&&!Y?q=Math.max(0,re):q=$[0].pts}if(u.segmentCodec==="aac")for(var ae=this.config.maxAudioFramesDrift,ne=0,te=q;ne<$.length;ne++){var he=$[ne],ve=he.pts,ie=ve-te,Te=Math.abs(1e3*ie/T);if(ie<=-ae*U&&Y)ne===0&&(b.logger.warn("Audio frame @ "+(ve/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ie/T)+" ms."),this.nextAudioPts=q=te=ve);else if(ie>=ae*U&&Te<D&&Y){var pe=Math.round(ie/U);te=ve-pe*U,te<0&&(pe--,te+=U),ne===0&&(this.nextAudioPts=q=te),b.logger.warn("[mp4-remuxer]: Injecting "+pe+" audio frame @ "+(te/T).toFixed(3)+"s due to "+Math.round(1e3*ie/T)+" ms gap.");for(var xe=0;xe<pe;xe++){var Me=Math.max(te,0),Ae=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);Ae||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=he.unit.subarray()),$.splice(ne,0,{unit:Ae,pts:Me}),te+=U,ne++}}he.pts=te,te+=U}for(var We=null,Ie=null,Be,be=0,Ge=$.length;Ge--;)be+=$[Ge].unit.byteLength;for(var He=0,Qe=$.length;He<Qe;He++){var Ue=$[He],it=Ue.unit,we=Ue.pts;if(Ie!==null){var nt=z[He-1];nt.duration=Math.round((we-Ie)/k)}else if(d&&u.segmentCodec==="aac"&&(we=q),We=we,be>0){be+=ee;try{Be=new Uint8Array(be)}catch{this.observer.emit(w.Events.ERROR,w.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:be,reason:"fail allocating audio mdat "+be});return}if(!H){var Oe=new DataView(Be.buffer);Oe.setUint32(0,be),Be.set(A.default.types.mdat,4)}}else return;Be.set(it,ee);var Ce=it.byteLength;ee+=Ce,z.push(new r(!0,B,Ce,0)),Ie=we}var Ye=z.length;if(!!Ye){var Re=z[z.length-1];this.nextAudioPts=q=Ie+k*Re.duration;var Le=H?new Uint8Array(0):A.default.moof(u.sequenceNumber++,We/k,x({},u,{samples:z}));u.samples=[];var at=We/T,ze=q/T,pt="audio",xt={data1:Le,data2:Be,startPTS:at,endPTS:ze,startDTS:at,endDTS:ze,type:pt,hasAudio:!0,hasVideo:!1,nb:Ye};return this.isAudioContiguous=!0,console.assert(Be.length,"MDAT length must not be zero"),xt}},t.remuxEmptyAudio=function(u,a,d,v){var S=u.inputTimeScale,T=u.samplerate?u.samplerate:S,I=S/T,k=this.nextAudioPts,B=(k!==null?k:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=I*E,H=Math.ceil((U-B)/W),z=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Y=[],$=0;$<H;$++){var ee=B+$*W;Y.push({unit:z,pts:ee,dts:ee})}return u.samples=Y,this.remuxAudio(u,a,d,!1)},c}();function s(c,t){var n;if(t===null)return c;for(t<c?n=-8589934592:n=8589934592;Math.abs(c-t)>4294967296;)c+=n;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,n,u){var a=c.samples.length;if(!!a){for(var d=c.inputTimeScale,v=0;v<a;v++){var S=c.samples[v];S.pts=s(S.pts-n,t*d)/d,S.dts=s(S.dts-u,t*d)/d}var T=c.samples;return c.samples=[],{samples:T}}}function i(c,t,n){var u=c.samples.length;if(!!u){for(var a=c.inputTimeScale,d=0;d<u;d++){var v=c.samples[d];v.pts=s(v.pts-n,t*a)/a}c.samples.sort(function(T,I){return T.pts-I.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,n,u,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=u,this.cts=a,this.flags=new o(t)},o=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/polyfills/number.ts"),L=l("./src/remux/mp4-remuxer.ts"),A=l("./src/utils/mp4-tools.ts"),w=l("./src/loader/fragment.ts"),O=l("./src/utils/logger.ts"),b=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var x=y.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var f=this.initData=Object(A.parseInitSegment)(E);m||(m=_(f.audio,w.ElementaryStreamTypes.AUDIO)),p||(p=_(f.video,w.ElementaryStreamTypes.VIDEO));var e={};f.audio&&f.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:f.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:f.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:O.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},x.remux=function(E,m,p,f,e){var s,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:f,id3:p,initSegment:void 0};Object(C.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return O.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(A.getStartDTS)(c,r);Object(C.isFiniteNumber)(h)||(this.initPTS=o.initPTS=h=t-e);var n=Object(A.getDuration)(r,c),u=E?t-h:g,a=u+n;Object(A.offsetStartDTS)(c,r,h),n>0?this.lastEndTime=a:(O.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!c.audio,v=!!c.video,S="";d&&(S+="audio"),v&&(S+="video");var T={data1:r,startPTS:u,startDTS:u,endPTS:a,endDTS:a,type:S,hasAudio:d,hasVideo:v,nb:1,dropped:0};i.audio=T.type==="audio"?T:void 0,i.video=T.type!=="audio"?T:void 0,i.initSegment=o;var I=(s=this.initPTS)!=null?s:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,I,I),f.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(f,e,I)),i},y}();function _(y,x){var D=y==null?void 0:y.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||x===w.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=b},"./src/task-loop.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return C});var C=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=L.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(O){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,O),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},L}()},"./src/types/cmcd.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"CMCDVersion",function(){return C}),l.d(R,"CMCDObjectType",function(){return L}),l.d(R,"CMCDStreamingFormat",function(){return A}),l.d(R,"CMCDStreamType",function(){return w});var C=1,L;(function(O){O.MANIFEST="m",O.AUDIO="a",O.VIDEO="v",O.MUXED="av",O.INIT="i",O.CAPTION="c",O.TIMED_TEXT="tt",O.KEY="k",O.OTHER="o"})(L||(L={}));var A;(function(O){O.DASH="d",O.HLS="h",O.SMOOTH="s",O.OTHER="o"})(A||(A={}));var w;(function(O){O.VOD="v",O.LIVE="l"})(w||(w={}))},"./src/types/demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"MetadataSchema",function(){return C});var C;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(C||(C={}))},"./src/types/level.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"HlsSkip",function(){return A}),l.d(R,"getSkipValue",function(){return w}),l.d(R,"HlsUrlParameters",function(){return O}),l.d(R,"Level",function(){return b});function C(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function L(_,y,x){return y&&C(_.prototype,y),x&&C(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var A;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(A||(A={}));function w(_,y){var x=_.canSkipUntil,D=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return x&&m<x?D?A.v2:A.Yes:A.No}var O=function(){function _(x,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=D,this.skip=E}var y=_.prototype;return y.addDirectives=function(D){var E=new self.URL(D);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},_}(),b=function(){function _(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{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(x){var D=x%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"PlaylistContextType",function(){return C}),l.d(R,"PlaylistLevelType",function(){return L});var C;(function(A){A.MANIFEST="manifest",A.LEVEL="level",A.AUDIO_TRACK="audioTrack",A.SUBTITLE_TRACK="subtitleTrack"})(C||(C={}));var L;(function(A){A.MAIN="main",A.AUDIO="audio",A.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ChunkMetadata",function(){return C});var C=function(w,O,b,_,y,x){_===void 0&&(_=0),y===void 0&&(y=-1),x===void 0&&(x=!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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=w,this.sn=O,this.id=b,this.size=_,this.part=y,this.partial=x};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"AttrList",function(){return A});var C=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function w(b){typeof b=="string"&&(b=w.parseAttrList(b));for(var _ in b)b.hasOwnProperty(_)&&(this[_]=b[_])}var O=w.prototype;return O.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var x=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)x[D]=parseInt(y.slice(D*2,D*2+2),16);return x}else return null},O.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.decimalFloatingPoint=function(_){return parseFloat(this[_])},O.optionalFloat=function(_,y){var x=this[_];return x?parseFloat(x):y},O.enumeratedString=function(_){return this[_]},O.bool=function(_){return this[_]==="YES"},O.decimalResolution=function(_){var y=C.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},w.parseAttrList=function(_){var y,x={},D='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),x[y[1]]=E}return x},w}()},"./src/utils/binary-search.ts":function(j,R,l){"use strict";l.r(R);var C={search:function(A,w){for(var O=0,b=A.length-1,_=null,y=null;O<=b;){_=(O+b)/2|0,y=A[_];var x=w(y);if(x>0)O=_+1;else if(x<0)b=_-1;else return y}return null}};R.default=C},"./src/utils/buffer-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"BufferHelper",function(){return A});var C=l("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function w(){}return w.isBuffered=function(b,_){try{if(b){for(var y=w.getBuffered(b),x=0;x<y.length;x++)if(_>=y.start(x)&&_<=y.end(x))return!0}}catch{}return!1},w.bufferInfo=function(b,_,y){try{if(b){var x=w.getBuffered(b),D=[],E;for(E=0;E<x.length;E++)D.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(D,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},w.bufferedInfo=function(b,_,y){_=Math.max(0,_),b.sort(function(r,o){var c=r.start-o.start;return c||o.end-r.end});var x=[];if(y)for(var D=0;D<b.length;D++){var E=x.length;if(E){var m=x[E-1].end;b[D].start-m<y?b[D].end>m&&(x[E-1].end=b[D].end):x.push(b[D])}else x.push(b[D])}else x=b;for(var p=0,f,e=_,s=_,h=0;h<x.length;h++){var g=x[h].start,i=x[h].end;if(_+y>=g&&_<i)e=g,s=i,p=s-_;else if(_+y<g){f=g;break}}return{len:p,start:e||0,end:s||0,nextStart:f}},w.getBuffered=function(b){try{return b.buffered}catch(_){return C.logger.log("failed to get media.buffered",_),L}},w}()},"./src/utils/cea-608-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Row",function(){return s}),l.d(R,"CaptionScreen",function(){return h});var C=l("./src/utils/logger.ts"),L={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},A=function(n){var u=n;return L.hasOwnProperty(n)&&(u=L[n]),String.fromCharCode(u)},w=15,O=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(t){t[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"})(E||(E={}));var m=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var n=t.prototype;return n.log=function(a,d){this.verboseLevel>=a&&C.logger.log(this.time+" ["+a+"] "+d)},t}(),p=function(n){for(var u=[],a=0;a<n.length;a++)u.push(n[a].toString(16));return u},f=function(){function t(u,a,d,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=a||!1,this.italics=d||!1,this.background=v||"black",this.flash=S||!1}var n=t.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(a){for(var d=["foreground","underline","italics","background","flash"],v=0;v<d.length;v++){var S=d[v];a.hasOwnProperty(S)&&(this[S]=a[S])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},n.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,a,d,v,S,T){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new f(a,d,v,S,T)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,d){this.uchar=a,this.penState.copy(d)},n.setPenState=function(a){this.penState.copy(a)},n.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},n.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),s=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<O;a++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new f}var n=t.prototype;return n.equals=function(a){for(var d=!0,v=0;v<O;v++)if(!this.chars[v].equals(a.chars[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<O;d++)this.chars[d].copy(a.chars[d])},n.isEmpty=function(){for(var a=!0,d=0;d<O;d++)if(!this.chars[d].isEmpty()){a=!1;break}return a},n.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>O&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=O)},n.moveCursor=function(a){var d=this.pos+a;if(a>1)for(var v=this.pos+1;v<d+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(d)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var d=A(a);if(this.pos>=O){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+d+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(d,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var d;for(d=a;d<O;d++)this.chars[d].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var a=[],d=!0,v=0;v<O;v++){var S=this.chars[v].uchar;S!==" "&&(d=!1),a.push(S)}return d?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var d=this.chars[this.pos];d.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<w;a++)this.rows.push(new s(u));this.logger=u,this.currRow=w-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<w;a++)this.rows[a].clear();this.currRow=w-1},n.equals=function(a){for(var d=!0,v=0;v<w;v++)if(!this.rows[v].equals(a.rows[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<w;d++)this.rows[d].copy(a.rows[d])},n.isEmpty=function(){for(var a=!0,d=0;d<w;d++)if(!this.rows[d].isEmpty()){a=!1;break}return a},n.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},n.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},n.insertChar=function(a){var d=this.rows[this.currRow];d.insertChar(a)},n.setPen=function(a){var d=this.rows[this.currRow];d.setPenStyles(a)},n.moveCursor=function(a){var d=this.rows[this.currRow];d.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var d=this.rows[this.currRow];d.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var d=a.row-1;if(this.nrRollUpRows&&d<this.nrRollUpRows-1&&(d=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==d){for(var v=0;v<w;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,T=this.lastOutputScreen;if(T){var I=T.rows[S].cueStartTime,k=this.logger.time;if(I&&k!==null&&I<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[d-this.nrRollUpRows+B+1].copy(T.rows[S+B])}}this.currRow=d;var U=this.rows[this.currRow];if(a.indent!==null){var W=a.indent,H=Math.max(W-1,0);U.setCursor(a.indent),a.color=U.chars[H].penState.foreground}var z={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(z)},n.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},n.setRollUpRows=function(a){this.nrRollUpRows=a},n.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,d=this.rows.splice(a,1)[0];d.clear(),this.rows.splice(this.currRow,0,d),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var d=[],v="",S=-1,T=0;T<w;T++){var I=this.rows[T].getTextString();I&&(S=T+1,a?d.push("Row "+S+": '"+I+"'"):d.push(I.trim()))}return d.length>0&&(a?v="["+d.join(" | ")+"]":v=d.join(`
|
|
21
|
+
`)),v},n.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,a,d){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=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(d),this.nonDisplayedMemory=new h(d),this.lastOutputScreen=new h(d),this.currRollUpRow=this.displayedMemory.rows[w-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=d}var n=t.prototype;return n.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[w-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(a){this.outputFilter=a},n.setPAC=function(a){this.writeScreen.setPAC(a)},n.setBkgData=function(a){this.writeScreen.setBkgData(a)},n.setMode=function(a){a!==this.mode&&(this.mode=a,this.logger.log(E.INFO,"MODE="+a),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=a)},n.insertChars=function(a){for(var d=0;d<a.length;d++)this.writeScreen.insertChar(a[d]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},n.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},n.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},n.ccMIDROW=function(a){var d={flash:!1};if(d.underline=a%2===1,d.italics=a>=46,d.italics)d.foreground="white";else{var v=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];d.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(d)),this.writeScreen.setPen(d)},n.outputDataUpdate=function(a){a===void 0&&(a=!1);var d=this.logger.time;d!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=d:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,d,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:d),this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},t}(),i=function(){function t(u,a,d){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,a,v),new g(u+1,d,v)],this.cmdHistory=c(),this.logger=v}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,d){this.channels[a].setHandler(d)},n.addData=function(a,d){var v,S,T,I=!1;this.logger.time=a;for(var k=0;k<d.length;k+=2)if(S=d[k]&127,T=d[k+1]&127,!(S===0&&T===0)){if(this.logger.log(E.DATA,"["+p([d[k],d[k+1]])+"] -> ("+p([S,T])+")"),v=this.parseCmd(S,T),v||(v=this.parseMidrow(S,T)),v||(v=this.parsePAC(S,T)),v||(v=this.parseBackgroundAttributes(S,T)),!v&&(I=this.parseChars(S,T),I)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,T])+" orig: "+p([d[k],d[k+1]]))}},n.parseCmd=function(a,d){var v=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&d>=32&&d<=47,T=(a===23||a===31)&&d>=33&&d<=35;if(!(S||T))return!1;if(o(a,d,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([a,d])+") is dropped"),!0;var I=a===20||a===21||a===23?1:2,k=this.channels[I];return a===20||a===21||a===28||a===29?d===32?k.ccRCL():d===33?k.ccBS():d===34?k.ccAOF():d===35?k.ccAON():d===36?k.ccDER():d===37?k.ccRU(2):d===38?k.ccRU(3):d===39?k.ccRU(4):d===40?k.ccFON():d===41?k.ccRDC():d===42?k.ccTR():d===43?k.ccRTD():d===44?k.ccEDM():d===45?k.ccCR():d===46?k.ccENM():d===47&&k.ccEOC():k.ccTO(d-32),r(a,d,v),this.currentChannel=I,!0},n.parseMidrow=function(a,d){var v=0;if((a===17||a===25)&&d>=32&&d<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(d),this.logger.log(E.DEBUG,"MIDROW ("+p([a,d])+")"),!0):!1}return!1},n.parsePAC=function(a,d){var v,S=this.cmdHistory,T=(a>=17&&a<=23||a>=25&&a<=31)&&d>=64&&d<=127,I=(a===16||a===24)&&d>=64&&d<=95;if(!(T||I))return!1;if(o(a,d,S))return r(null,null,S),!0;var k=a<=23?1:2;d>=64&&d<=95?v=k===1?b[a]:y[a]:v=k===1?_[a]:x[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(v,d)),r(a,d,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,d){var v,S={color:null,italics:!1,indent:null,underline:!1,row:a};return d>95?v=d-96:v=d-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},n.parseChars=function(a,d){var v,S=null,T=null;if(a>=25?(v=2,T=a-8):(v=1,T=a),T>=17&&T<=19){var I;T===17?I=d+80:T===18?I=d+112:I=d+144,this.logger.log(E.INFO,"Special char '"+A(I)+"' in channel "+v),S=[I]}else a>=32&&a<=127&&(S=d===0?[a]:[a,d]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,d,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,d){var v=(a===16||a===24)&&d>=32&&d<=47,S=(a===23||a===31)&&d>=45&&d<=47;if(!(v||S))return!1;var T,I={};a===16||a===24?(T=Math.floor((d-32)/2),I.background=D[T],d%2===1&&(I.background=I.background+"_semi")):d===45?I.background="transparent":(I.foreground="black",d===47&&(I.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(I),r(a,d,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var d=this.channels[a];d&&d.reset()}this.cmdHistory=c()},n.cueSplitAtTime=function(a){for(var d=0;d<this.channels.length;d++){var v=this.channels[d];v&&v.cueSplitAtTime(a)}},t}();function r(t,n,u){u.a=t,u.b=n}function o(t,n,u){return u.a===t&&u.b===n}function c(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isCodecType",function(){return L}),l.d(R,"isCodecSupportedInMp4",function(){return A});var C={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 L(w,O){var b=C[O];return!!b&&b[w.slice(0,4)]===!0}function A(w,O){return MediaSource.isTypeSupported((O||"video")+'/mp4;codecs="'+w+'"')}},"./src/utils/cues.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/utils/vttparser.ts"),L=l("./src/utils/webvtt-parser.ts"),A=l("./src/utils/texttrack-utils.ts"),w=/\s/,O={newCue:function(_,y,x,D){for(var E=[],m,p,f,e,s,h=self.VTTCue||self.TextTrackCue,g=0;g<D.rows.length;g++)if(m=D.rows[g],f=!0,e=0,s="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)w.test(m.chars[i].uchar)&&f?e++:(s+=m.chars[i].uchar,f=!1);m.cueStartTime=y,y===x&&(x+=1e-4),e>=16?e--:e++;var r=Object(C.fixLineBreaks)(s.trim()),o=Object(L.generateCueId)(y,x,r);(!_||!_.cues||!_.cues.getCueById(o))&&(p=new h(y,x,r),p.id=o,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(A.addCueToTrack)(_,c)})),E}};R.default=O},"./src/utils/discontinuities.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFirstFragWithCC",function(){return w}),l.d(R,"shouldAlignOnDiscontinuities",function(){return O}),l.d(R,"findDiscontinuousReferenceFrag",function(){return b}),l.d(R,"adjustSlidingStart",function(){return y}),l.d(R,"alignStream",function(){return x}),l.d(R,"alignPDT",function(){return E}),l.d(R,"alignFragmentByPDTDelta",function(){return m}),l.d(R,"alignMediaPlaylistByPDT",function(){return p});var C=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/controller/level-helper.ts");function w(f,e){for(var s=null,h=0,g=f.length;h<g;h++){var i=f[h];if(i&&i.cc===e){s=i;break}}return s}function O(f,e,s){return!!(e.details&&(s.endCC>s.startCC||f&&f.cc<s.startCC))}function b(f,e){var s=f.fragments,h=e.fragments;if(!h.length||!s.length){L.logger.log("No fragments to align");return}var g=w(s,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(f,e){if(f){var s=f.start+e;f.start=f.startPTS=s,f.endPTS=s+f.duration}}function y(f,e){for(var s=e.fragments,h=0,g=s.length;h<g;h++)_(s[h],f);e.fragmentHint&&_(e.fragmentHint,f),e.alignedSliding=!0}function x(f,e,s){!e||(D(f,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(A.adjustSliding)(e.details,s))}function D(f,e,s){if(O(f,s,e)){var h=b(s.details,e);h&&Object(C.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=f.fragments[0].programDateTime,g=(h-s)/1e3+e.fragments[0].start;g&&Object(C.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-s)+"ms, sliding:"+g.toFixed(3)+" "+f.url+" "),y(g,f))}}function m(f,e){var s=f.programDateTime;if(!!s){var h=(s-e)/1e3;f.start=f.startPTS=h,f.endPTS=h+f.duration}}function p(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=e.fragments[0].start,g=s-h*1e3;f.fragments.forEach(function(i){m(i,g)}),f.fragmentHint&&m(f.fragmentHint,g),f.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/utils/ewma.ts"),L=function(){function A(O,b,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new C.default(O),this.fast_=new C.default(b)}var w=A.prototype;return w.update=function(b,_){var y=this.slow_,x=this.fast_;this.slow_.halfLife!==b&&(this.slow_=new C.default(b,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new C.default(_,x.getEstimate(),x.getTotalWeight()))},w.sample=function(b,_){b=Math.max(b,this.minDelayMs_);var y=8*_,x=b/1e3,D=y/x;this.fast_.sample(x,D),this.slow_.sample(x,D)},w.canEstimate=function(){var b=this.fast_;return b&&b.getTotalWeight()>=this.minWeight_},w.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},w.destroy=function(){},A}();R.default=L},"./src/utils/ewma.ts":function(j,R,l){"use strict";l.r(R);var C=function(){function L(w,O,b){O===void 0&&(O=0),b===void 0&&(b=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=w,this.alpha_=w?Math.exp(Math.log(.5)/w):0,this.estimate_=O,this.totalWeight_=b}var A=L.prototype;return A.sample=function(O,b){var _=Math.pow(this.alpha_,O);this.estimate_=b*(1-_)+_*this.estimate_,this.totalWeight_+=O},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var O=1-Math.pow(this.alpha_,this.totalWeight_);if(O)return this.estimate_/O}return this.estimate_},L}();R.default=C},"./src/utils/fetch-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"fetchSupported",function(){return m});var C=l("./src/polyfills/number.ts"),L=l("./src/loader/load-stats.ts"),A=l("./src/demux/chunk-cache.ts");function w(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,x(h,g)}function O(h){var g=typeof Map=="function"?new Map:void 0;return O=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,o)}function o(){return b(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),x(o,r)},O(h)}function b(h,g,i){return _()?b=Reflect.construct.bind():b=function(o,c,t){var n=[null];n.push.apply(n,c);var u=Function.bind.apply(o,n),a=new u;return t&&x(a,t.prototype),a},b.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,g){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},x(h,g)}function D(h){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(i){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=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,o,c){var t=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var u=f(r,this.controller.signal),a=c.onProgress,d=r.responseType==="arraybuffer",v=d?"byteLength":"length";this.context=r,this.config=o,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(n,r,t.response)},o.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var T=S.status,I=S.statusText;throw new s(I||"fetch, bad network response",T,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(C.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):d?S.arrayBuffer():S.text()}).then(function(S){var T=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[v];var I={url:T.url,data:S};a&&!Object(C.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,T),c.onSuccess(I,n,r,T)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var T=S&&S.code||0,I=S?S.message:null;c.onError({code:T,text:I},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},g.loadProgressively=function(r,o,c,t,n){t===void 0&&(t=0);var u=new A.default,a=r.body.getReader(),d=function v(){return a.read().then(function(S){if(S.done)return u.dataLength&&n(o,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var T=S.value,I=T.length;return o.loaded+=I,I<t||u.dataLength?(u.push(T),u.dataLength>=t&&n(o,c,u.flush(),r)):n(o,c,T,r),v()}).catch(function(){return Promise.reject()})};return d()},h}();function f(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var s=function(h){w(g,h);function g(i,r,o){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=o,c}return g}(O(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"IMSC1_CODEC",function(){return y}),l.d(R,"parseIMSC1",function(){return m});var C=l("./src/utils/mp4-tools.ts"),L=l("./src/utils/vttparser.ts"),A=l("./src/utils/vttcue.ts"),w=l("./src/demux/id3.ts"),O=l("./src/utils/timescale-conversion.ts"),b=l("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var u=arguments[n];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(t[a]=u[a])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,n,u,a,d){var v=Object(C.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){d(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(I){return Object(w.utf8ArrayToStr)(I)}),T=Object(O.toTimescaleFromScale)(n,1,u);try{S.forEach(function(I){return a(p(I,T))})}catch(I){d(I)}}function p(t,n){var u=new DOMParser,a=u.parseFromString(t,"text/xml"),d=a.getElementsByTagName("tt")[0];if(!d)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=d.getAttribute("ttp:"+W)||v[W],U},{}),T=d.getAttribute("xml:space")!=="preserve",I=e(f(d,"styling","style")),k=e(f(d,"layout","region")),B=f(d,"body","[begin]");return[].map.call(B,function(U){var W=s(U,T);if(!W||!U.hasAttribute("begin"))return null;var H=r(U.getAttribute("begin"),S),z=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(H===null)throw i(U);if(Y===null){if(z===null)throw i(U);Y=H+z}var $=new A.default(H-n,Y-n,W);$.id=Object(b.generateCueId)($.startTime,$.endTime,$.text);var ee=k[U.getAttribute("region")],q=I[U.getAttribute("style")];$.position=10,$.size=80;var re=h(ee,q,I),ae=re.textAlign;if(ae){var ne=E[ae];ne&&($.lineAlign=ne),$.align=ae}return _($,re),$}).filter(function(U){return U!==null})}function f(t,n,u){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function e(t){return t.reduce(function(n,u){var a=u.getAttribute("xml:id");return a&&(n[a]=u),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(u,a,d){var v;return a.nodeName==="br"&&d?u+`
|
|
22
|
+
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?s(a,n):n?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function h(t,n,u){var a="http://www.w3.org/ns/ttml#styling",d=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(d=u[S]),v.reduce(function(T,I){var k=g(n,a,I)||g(t,a,I)||g(d,a,I);return k&&(T[I]=k),T},{})}function g(t,n,u){return t&&t.hasAttributeNS(n,u)?t.getAttributeNS(n,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(x.test(t)?u=o(t,n):D.test(t)&&(u=c(t,n))),u}function o(t,n){var u=x.exec(t),a=(u[4]|0)+(u[5]|0)/n.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/n.frameRate}function c(t,n){var u=D.exec(t),a=Number(u[1]),d=u[2];switch(d){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/n.frameRate;case"t":return a/n.tickRate}return a}},"./src/utils/logger.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"enableLogs",function(){return b}),l.d(R,"logger",function(){return _});var C=function(){},L={trace:C,debug:C,log:C,warn:C,info:C,error:C},A=L;function w(y){var x=self.console[y];return x?x.bind(self.console,"["+y+"] >"):C}function O(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];D.forEach(function(m){A[m]=y[m]?y[m].bind(y):w(m)})}function b(y){if(self.console&&y===!0||typeof y=="object"){O(y,"debug","log","info","warn","error");try{A.log()}catch{A=L}}else A=L}var _=A},"./src/utils/mediakeys-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"KeySystems",function(){return C}),l.d(R,"requestMediaKeySystemAccess",function(){return L});var C;(function(A){A.WIDEVINE="com.widevine.alpha",A.PLAYREADY="com.microsoft.playready"})(C||(C={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getMediaSource",function(){return C});function C(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"RemuxerTrackIdConfig",function(){return b}),l.d(R,"bin2str",function(){return _}),l.d(R,"readUint16",function(){return y}),l.d(R,"readUint32",function(){return x}),l.d(R,"readSint32",function(){return D}),l.d(R,"writeUint32",function(){return E}),l.d(R,"findBox",function(){return m}),l.d(R,"parseSegmentIndex",function(){return p}),l.d(R,"parseInitSegment",function(){return f}),l.d(R,"getStartDTS",function(){return e}),l.d(R,"getDuration",function(){return s}),l.d(R,"computeRawDurationFromSamples",function(){return h}),l.d(R,"offsetStartDTS",function(){return g}),l.d(R,"segmentValidRange",function(){return i}),l.d(R,"appendUint8Array",function(){return r}),l.d(R,"parseSamples",function(){return o}),l.d(R,"parseSEIMessageFromNALu",function(){return n}),l.d(R,"parseEmsg",function(){return a});var C=l("./src/utils/typed-array.ts"),L=l("./src/loader/fragment.ts"),A=l("./src/demux/id3.ts"),w=Math.pow(2,32)-1,O=[].push,b={video:1,audio:2,id3:3,text:4};function _(d){return String.fromCharCode.apply(null,d)}function y(d,v){var S=d[v]<<8|d[v+1];return S<0?65536+S:S}function x(d,v){var S=D(d,v);return S<0?4294967296+S:S}function D(d,v){return d[v]<<24|d[v+1]<<16|d[v+2]<<8|d[v+3]}function E(d,v,S){d[v]=S>>24,d[v+1]=S>>16&255,d[v+2]=S>>8&255,d[v+3]=S&255}function m(d,v){var S=[];if(!v.length)return S;for(var T=d.byteLength,I=0;I<T;){var k=x(d,I),B=_(d.subarray(I+4,I+8)),U=k>1?I+k:T;if(B===v[0])if(v.length===1)S.push(d.subarray(I+8,U));else{var W=m(d.subarray(I+8,U),v.slice(1));W.length&&O.apply(S,W)}I=U}return S}function p(d){var v=[],S=d[0],T=8,I=x(d,T);T+=4;var k=0,B=0;S===0?T+=8:T+=16,T+=2;var U=d.length+B,W=y(d,T);T+=2;for(var H=0;H<W;H++){var z=T,Y=x(d,z);z+=4;var $=Y&2147483647,ee=(Y&2147483648)>>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var q=x(d,z);z+=4,v.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/I,start:U,end:U+$-1}}),U+=$,z+=4,T=z}return{earliestPresentationTime:k,timescale:I,version:S,referencesCount:W,references:v}}function f(d){for(var v=[],S=m(d,["moov","trak"]),T=0;T<S.length;T++){var I=S[T],k=m(I,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=x(k,U),H=m(I,["mdia","mdhd"])[0];if(H){B=H[0],U=B===0?12:20;var z=x(H,U),Y=m(I,["mdia","hdlr"])[0];if(Y){var $=_(Y.subarray(8,12)),ee={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[$];if(ee){var q=m(I,["mdia","minf","stbl","stsd"])[0],re=void 0;q&&(re=_(q.subarray(12,16))),v[W]={timescale:z,type:ee},v[ee]={timescale:z,id:W,codec:re}}}}}}var ae=m(d,["moov","mvex","trex"]);return ae.forEach(function(ne){var te=x(ne,4),he=v[te];he&&(he.default={duration:x(ne,12),flags:x(ne,20)})}),v}function e(d,v){return m(v,["moof","traf"]).reduce(function(S,T){var I=m(T,["tfdt"])[0],k=I[0],B=m(T,["tfhd"]).reduce(function(U,W){var H=x(W,4),z=d[H];if(z){var Y=x(I,4);k===1&&(Y*=Math.pow(2,32),Y+=x(I,8));var $=z.timescale||9e4,ee=Y/$;if(isFinite(ee)&&(U===null||ee<U))return ee}return U},null);return B!==null&&isFinite(B)&&(S===null||B<S)?B:S},null)||0}function s(d,v){for(var S=0,T=0,I=0,k=m(d,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=m(U,["tfhd"])[0],H=x(W,4),z=v[H];if(!!z){var Y=z.default,$=x(W,0)|(Y==null?void 0:Y.flags),ee=Y==null?void 0:Y.duration;$&8&&($&2?ee=x(W,12):ee=x(W,8));for(var q=z.timescale||9e4,re=m(U,["trun"]),ae=0;ae<re.length;ae++){if(S=h(re[ae]),!S&&ee){var ne=x(re[ae],4);S=ee*ne}z.type===L.ElementaryStreamTypes.VIDEO?T+=S/q:z.type===L.ElementaryStreamTypes.AUDIO&&(I+=S/q)}}}if(T===0&&I===0){for(var te=0,he=m(d,["sidx"]),ve=0;ve<he.length;ve++){var ie=p(he[ve]);ie!=null&&ie.references&&(te+=ie.references.reduce(function(Te,pe){return Te+pe.info.duration||0},0))}return te}return T||I}function h(d){var v=x(d,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var T=0,I=x(d,4),k=0;k<I;k++){if(v&256){var B=x(d,S);T+=B,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return T}function g(d,v,S){m(v,["moof","traf"]).forEach(function(T){m(T,["tfhd"]).forEach(function(I){var k=x(I,4),B=d[k];if(!!B){var U=B.timescale||9e4;m(T,["tfdt"]).forEach(function(W){var H=W[0],z=x(W,4);if(H===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=x(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(w+1)),$=Math.floor(z%(w+1));E(W,4,Y),E(W,8,$)}})}})})}function i(d){var v={valid:null,remainder:null},S=m(d,["moof"]);if(S){if(S.length<2)return v.remainder=d,v}else return v;var T=S[S.length-1];return v.valid=Object(C.sliceUint8)(d,0,T.byteOffset-8),v.remainder=Object(C.sliceUint8)(d,T.byteOffset-8),v}function r(d,v){var S=new Uint8Array(d.length+v.length);return S.set(d),S.set(v,d.length),S}function o(d,v){var S=[],T=v.samples,I=v.timescale,k=v.id,B=!1,U=m(T,["moof"]);return U.map(function(W){var H=W.byteOffset-8,z=m(W,["traf"]);z.map(function(Y){var $=m(Y,["tfdt"]).map(function(ee){var q=ee[0],re=x(ee,4);return q===1&&(re*=Math.pow(2,32),re+=x(ee,8)),re/I})[0];return $!==void 0&&(d=$),m(Y,["tfhd"]).map(function(ee){var q=x(ee,4),re=x(ee,0)&16777215,ae=(re&1)!==0,ne=(re&2)!==0,te=(re&8)!==0,he=0,ve=(re&16)!==0,ie=0,Te=(re&32)!==0,pe=8;q===k&&(ae&&(pe+=8),ne&&(pe+=4),te&&(he=x(ee,pe),pe+=4),ve&&(ie=x(ee,pe),pe+=4),Te&&(pe+=4),v.type==="video"&&(B=c(v.codec)),m(Y,["trun"]).map(function(xe){var Me=xe[0],Ae=x(xe,0)&16777215,We=(Ae&1)!==0,Ie=0,Be=(Ae&4)!==0,be=(Ae&256)!==0,Ge=0,He=(Ae&512)!==0,Qe=0,Ue=(Ae&1024)!==0,it=(Ae&2048)!==0,we=0,nt=x(xe,4),Oe=8;We&&(Ie=x(xe,Oe),Oe+=4),Be&&(Oe+=4);for(var Ce=Ie+H,Ye=0;Ye<nt;Ye++){if(be?(Ge=x(xe,Oe),Oe+=4):Ge=he,He?(Qe=x(xe,Oe),Oe+=4):Qe=ie,Ue&&(Oe+=4),it&&(Me===0?we=x(xe,Oe):we=D(xe,Oe),Oe+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var Re=0;Re<Qe;){var Le=x(T,Ce);Ce+=4;var at=T[Ce]&31;if(t(B,at)){var ze=T.subarray(Ce,Ce+Le);n(ze,d+we/I,S)}Ce+=Le,Re+=Le+4}d+=Ge/I}}))})})}),S}function c(d){if(!d)return!1;var v=d.indexOf("."),S=v<0?d:d.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(d,v){return d?v===39||v===40:v===6}function n(d,v,S){var T=u(d),I=0;I++;for(var k=0,B=0,U=!1,W=0;I<T.length;){k=0;do{if(I>=T.length)break;W=T[I++],k+=W}while(W===255);B=0;do{if(I>=T.length)break;W=T[I++],B+=W}while(W===255);var H=T.length-I;if(!U&&k===4&&I<T.length){U=!0;var z=T[I++];if(z===181){var Y=y(T,I);if(I+=2,Y===49){var $=x(T,I);if(I+=4,$===1195456820){var ee=T[I++];if(ee===3){var q=T[I++],re=31&q,ae=64&q,ne=ae?2+re*3:0,te=new Uint8Array(ne);if(ae){te[0]=q;for(var he=1;he<ne;he++)te[he]=T[I++]}S.push({type:ee,payloadType:k,pts:v,bytes:te})}}}}}else if(k===5&&B<H){if(U=!0,B>16){for(var ve=[],ie=0;ie<16;ie++){var Te=T[I++].toString(16);ve.push(Te.length==1?"0"+Te:Te),(ie===3||ie===5||ie===7||ie===9)&&ve.push("-")}for(var pe=B-16,xe=new Uint8Array(pe),Me=0;Me<pe;Me++)xe[Me]=T[I++];S.push({payloadType:k,pts:v,uuid:ve.join(""),userData:Object(A.utf8ArrayToStr)(xe),userDataBytes:xe})}}else if(B<H)I+=B;else if(B>H)break}}function u(d){for(var v=d.byteLength,S=[],T=1;T<v-2;)d[T]===0&&d[T+1]===0&&d[T+2]===3?(S.push(T+2),T+=2):T++;if(S.length===0)return d;var I=v-S.length,k=new Uint8Array(I),B=0;for(T=0;T<I;B++,T++)B===S[0]&&(B++,S.shift()),k[T]=d[B];return k}function a(d){var v=d[0],S="",T="",I=0,k=0,B=0,U=0,W=0,H=0;if(v===0){for(;_(d.subarray(H,H+1))!=="\0";)S+=_(d.subarray(H,H+1)),H+=1;for(S+=_(d.subarray(H,H+1)),H+=1;_(d.subarray(H,H+1))!=="\0";)T+=_(d.subarray(H,H+1)),H+=1;T+=_(d.subarray(H,H+1)),H+=1,I=x(d,12),k=x(d,16),U=x(d,20),W=x(d,24),H=28}else if(v===1){H+=4,I=x(d,H),H+=4;var z=x(d,H);H+=4;var Y=x(d,H);for(H+=4,B=Math.pow(2,32)*z+Y,Number.isSafeInteger(B)||(B=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),U=x(d,H),H+=4,W=x(d,H),H+=4;_(d.subarray(H,H+1))!=="\0";)S+=_(d.subarray(H,H+1)),H+=1;for(S+=_(d.subarray(H,H+1)),H+=1;_(d.subarray(H,H+1))!=="\0";)T+=_(d.subarray(H,H+1)),H+=1;T+=_(d.subarray(H,H+1)),H+=1}var $=d.subarray(H,d.byteLength);return{schemeIdUri:S,value:T,timeScale:I,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return C});var C=function(){function L(w,O){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=w,this.trackName=O}var A=L.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(O,b,_){(this.startTime===null||this.startTime>O)&&(this.startTime=O),this.endTime=b,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sendAddTrackEvent",function(){return L}),l.d(R,"addCueToTrack",function(){return A}),l.d(R,"clearCurrentCues",function(){return w}),l.d(R,"removeCuesInRange",function(){return O}),l.d(R,"getCuesInRange",function(){return _});var C=l("./src/utils/logger.ts");function L(y,x){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,x.dispatchEvent(D)}function A(y,x){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(x.id))try{if(y.addCue(x),!y.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(m){C.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function w(y){var x=y.mode;if(x==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);x==="disabled"&&(y.mode=x)}function O(y,x,D,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,x,D),f=0;f<p.length;f++)(!E||E(p[f]))&&y.removeCue(p[f]);m==="disabled"&&(y.mode=m)}function b(y,x){if(x<y[0].startTime)return 0;var D=y.length-1;if(x>y[D].endTime)return-1;for(var E=0,m=D;E<=m;){var p=Math.floor((m+E)/2);if(x<y[p].startTime)m=p-1;else if(x>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-x<x-y[m].startTime?E:m}function _(y,x,D){var E=[],m=b(y,x);if(m>-1)for(var p=m,f=y.length;p<f;p++){var e=y[p];if(e.startTime>=x&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(j,R,l){"use strict";l.r(R);var C={toString:function(A){for(var w="",O=A.length,b=0;b<O;b++)w+="["+A.start(b).toFixed(3)+","+A.end(b).toFixed(3)+"]";return w}};R.default=C},"./src/utils/timescale-conversion.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"toTimescaleFromBase",function(){return L}),l.d(R,"toTimescaleFromScale",function(){return A}),l.d(R,"toMsFromMpegTsClock",function(){return w}),l.d(R,"toMpegTsClockFromTimescale",function(){return O});var C=9e4;function L(b,_,y,x){y===void 0&&(y=1),x===void 0&&(x=!1);var D=b*_*y;return x?Math.round(D):D}function A(b,_,y,x){return y===void 0&&(y=1),x===void 0&&(x=!1),L(b,_,1/y,x)}function w(b,_){return _===void 0&&(_=!1),L(b,1e3,1/C,_)}function O(b,_){return _===void 0&&(_=1),L(b,C,1/_)}},"./src/utils/typed-array.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sliceUint8",function(){return C});function C(L,A,w){return Uint8Array.prototype.slice?L.slice(A,w):new Uint8Array(Array.prototype.slice.call(L,A,w))}},"./src/utils/vttcue.ts":function(j,R,l){"use strict";l.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var C=["","lr","rl"],L=["start","middle","end","left","right"];function A(y,x){if(typeof x!="string"||!Array.isArray(y))return!1;var D=x.toLowerCase();return~y.indexOf(D)?D:!1}function w(y){return A(C,y)}function O(y){return A(L,y)}function b(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var f in p)y[f]=p[f]}return y}function _(y,x,D){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",f=!1,e=y,s=x,h=D,g=null,i="",r=!0,o="auto",c="start",t=50,n="middle",u=50,a="middle";Object.defineProperty(E,"id",b({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",b({},m,{get:function(){return f},set:function(v){f=!!v}})),Object.defineProperty(E,"startTime",b({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",b({},m,{get:function(){return s},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",b({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",b({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",b({},m,{get:function(){return i},set:function(v){var S=w(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",b({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",b({},m,{get:function(){return o},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",b({},m,{get:function(){return c},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",b({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",b({},m,{get:function(){return n},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",b({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",b({},m,{get:function(){return a},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"parseTimeStamp",function(){return A}),l.d(R,"fixLineBreaks",function(){return x}),l.d(R,"VTTParser",function(){return D});var C=l("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(f,e){if(!f)return"";if(typeof f!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(f))},E}();function A(E){function m(f,e,s,h){return(f|0)*3600+(e|0)*60+(s|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var w=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(f,e){!this.get(f)&&e!==""&&(this.values[f]=e)},m.get=function(f,e,s){return s?this.has(f)?this.values[f]:e[s]:this.has(f)?this.values[f]:e},m.has=function(f){return f in this.values},m.alt=function(f,e,s){for(var h=0;h<s.length;++h)if(e===s[h]){this.set(f,e);break}},m.integer=function(f,e){/^-?\d+$/.test(e)&&this.set(f,parseInt(e,10))},m.percent=function(f,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(f,s),!0}return!1},E}();function O(E,m,p,f){var e=f?E.split(f):[E];for(var s in e)if(typeof e[s]=="string"){var h=e[s].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var b=new C.default(0,0,""),_=b.align==="middle"?"middle":"center";function y(E,m,p){var f=E;function e(){var g=A(E);if(g===null)throw new Error("Malformed timestamp: "+f);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function s(g,i){var r=new w;O(g,function(t,n){var u;switch(t){case"region":for(var a=p.length-1;a>=0;a--)if(p[a].id===n){r.set(t,p[a].region);break}break;case"vertical":r.alt(t,n,["rl","lr"]);break;case"line":u=n.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=n.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&b.line===-1&&(o=-1),i.line=o,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.get("position","auto");c==="auto"&&b.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+f);E=E.slice(3),h(),m.endTime=e(),h(),s(E,m)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
22
23
|
`)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var m=E.prototype;return m.parse=function(f){var e=this;f&&(e.buffer+=e.decoder.decode(f,{stream:!0}));function s(){var c=e.buffer,t=0;for(c=x(c);t<c.length&&c[t]!=="\r"&&c[t]!==`
|
|
23
24
|
`;)++t;var n=c.slice(0,t);return c[t]==="\r"&&++t,c[t]===`
|
|
24
|
-
`&&++t,e.buffer=c.slice(t),n}function h(c){O(c,function(t,n){},/:/)}try{var g="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;g=s();var i=g.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var r=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:g=s(),e.state){case"HEADER":/:/.test(g)?h(g):g||(e.state="ID");continue;case"NOTE":g||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){e.state="NOTE";break}if(!g)continue;if(e.cue=new
|
|
25
|
+
`&&++t,e.buffer=c.slice(t),n}function h(c){O(c,function(t,n){},/:/)}try{var g="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;g=s();var i=g.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var r=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:g=s(),e.state){case"HEADER":/:/.test(g)?h(g):g||(e.state="ID");continue;case"NOTE":g||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){e.state="NOTE";break}if(!g)continue;if(e.cue=new C.default(0,0,""),e.state="CUE",g.indexOf("-->")===-1){e.cue.id=g;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(g,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var o=g.indexOf("-->")!==-1;if(!g||o&&(r=!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+=`
|
|
25
26
|
`),e.cue.text+=g}continue;case"BADCUE":g||(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},m.flush=function(){var f=this;try{if((f.cue||f.state==="HEADER")&&(f.buffer+=`
|
|
26
27
|
|
|
27
|
-
`,f.parse()),f.state==="INITIAL"||f.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){f.onparsingerror&&f.onparsingerror(e)}return f.onflush&&f.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"generateCueId",function(){return D}),l.d(R,"parseWebVTT",function(){return m});var
|
|
28
|
+
`,f.parse()),f.state==="INITIAL"||f.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){f.onparsingerror&&f.onparsingerror(e)}return f.onflush&&f.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"generateCueId",function(){return D}),l.d(R,"parseWebVTT",function(){return m});var C=l("./src/polyfills/number.ts"),L=l("./src/utils/vttparser.ts"),A=l("./src/demux/id3.ts"),w=l("./src/utils/timescale-conversion.ts"),O=l("./src/remux/mp4-remuxer.ts"),b=/\r\n|\n\r|\n|\r/g,_=function(f,e,s){return s===void 0&&(s=0),f.slice(s,s+e.length)===e},y=function(f){var e=parseInt(f.slice(-3)),s=parseInt(f.slice(-6,-4)),h=parseInt(f.slice(-9,-7)),g=f.length>9?parseInt(f.substring(0,f.indexOf(":"))):0;if(!Object(C.isFiniteNumber)(e)||!Object(C.isFiniteNumber)(s)||!Object(C.isFiniteNumber)(h)||!Object(C.isFiniteNumber)(g))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+f);return e+=1e3*s,e+=60*1e3*h,e+=60*60*1e3*g,e},x=function(f){for(var e=5381,s=f.length;s;)e=e*33^f.charCodeAt(--s);return(e>>>0).toString()};function D(p,f,e){return x(p.toString())+x(f.toString())+x(e)}var E=function(f,e,s){var h=f[e],g=f[h.prevCC];if(!g||!g.new&&h.new){f.ccOffset=f.presentationOffset=h.start,h.new=!1;return}for(;(i=g)!==null&&i!==void 0&&i.new;){var i;f.ccOffset+=h.start-g.start,h.new=!1,h=g,g=f[h.prevCC]}f.presentationOffset=s};function m(p,f,e,s,h,g,i,r){var o=new L.VTTParser,c=Object(A.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(b,`
|
|
28
29
|
`).split(`
|
|
29
|
-
`),t=[],n=Object(
|
|
30
|
-
`)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/logger.ts"),L=l("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,M=function(){function 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=_?_.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var b=O.prototype;return b.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},b.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},b.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},b.load=function(y,x,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=x,this.callbacks=D,this.retryDelay=x.retryDelay,this.loadInternal()},b.loadInternal=function(){var y=this.config,x=this.context;if(!!y){var D=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(D,x.url)}catch{D.open("GET",x.url,!0),m(D,x.url)}D.readyState||D.open("GET",x.url,!0);var p=this.context.headers;if(p)for(var f in p)D.setRequestHeader(f,p[f])}catch(e){this.callbacks.onError({code:D.status,text:e.message},x,D);return}x.rangeEnd&&D.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},b.readystatechange=function(){var y=this.context,x=this.loader,D=this.stats;if(!(!y||!x)){var E=x.readyState,m=this.config;if(!D.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var p=x.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var f,e;if(y.responseType==="arraybuffer"?(f=x.response,e=f.byteLength):(f=x.responseText,e=f.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,f,x),!this.callbacks)return;var h={url:x.responseURL,data:f};this.callbacks.onSuccess(h,D,y,x)}else D.retry>=m.maxRetry||p>=400&&p<499?(P.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:x.statusText},y,x)):(P.logger.warn(p+" while loading "+y.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,m.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},b.loadtimeout=function(){P.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},b.loadprogress=function(y){var x=this.stats;x.loaded=y.loaded,y.lengthComputable&&(x.total=y.total)},b.getCacheAge=function(){var y=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");y=x?parseFloat(x):null}return y},O}();R.default=M}}).default})});var Ct=class{addEventListener(){}removeEventListener(){}dispatchEvent(R){return!0}};if(typeof DocumentFragment=="undefined"){class j extends Ct{}globalThis.DocumentFragment=j}var Ht=class extends Ct{},Ar=class extends Ct{},nn={get(j){},define(j,R,l){},upgrade(j){},whenDefined(j){return Promise.resolve(Ht)}},Vt,Lr=class{constructor(R,l={}){lt(this,Vt,void 0);ut(this,Vt,l==null?void 0:l.detail)}get detail(){return ze(this,Vt)}initCustomEvent(){}};Vt=new WeakMap;function an(j,R){return new Ht}var Xr={document:{createElement:an},DocumentFragment,customElements:nn,CustomEvent:Lr,EventTarget:Ct,HTMLElement:Ht,HTMLVideoElement:Ar},Qr=typeof window=="undefined"||typeof globalThis.customElements=="undefined",mt=Qr?Xr:globalThis,_r=Qr?Xr.document:globalThis.document;var fr=sr($r(),1),Lt=sr(lr(),1),Ir=sr(lr(),1),Mt=sr(lr(),1),zt=class extends Error{constructor(j,R=zt.MEDIA_ERR_CUSTOM,l){var P;super(j),this.name="MediaError",this.code=R,this.fatal=l!=null?l:R>=zt.MEDIA_ERR_NETWORK&&R<=zt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(P=zt.defaultMessages[this.code])!=null?P:"")}},Xe=zt;Xe.MEDIA_ERR_ABORTED=1,Xe.MEDIA_ERR_NETWORK=2,Xe.MEDIA_ERR_DECODE=3,Xe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Xe.MEDIA_ERR_ENCRYPTED=5,Xe.MEDIA_ERR_CUSTOM=100,Xe.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var ri=(j,R)=>j in R,Pr={ANY:"any",MUTED:"muted"},ur={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},_t={MSE:"mse",NATIVE:"native"},Cr={HEADER:"header",QUERY:"query",NONE:"none"},Fn=Object.values(Cr),Ft={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Mr={HLS:Ft.M3U8},wn=Object.keys(Mr),kn=[...Object.values(Ft),"hls","HLS"],Xt=(j,R,l,P)=>{j.addEventListener(R,l,P),j.addEventListener("teardown",()=>{j.removeEventListener(R,l)},{once:!0})};function sn(j,R,l){R&&l>R&&(l=R);for(let P=0;P<j.length;P++)if(j.start(P)<=l&&j.end(P)>=l)return!0;return!1}var on=j=>{let R=j.indexOf("?");if(R<0)return[j];let l=j.slice(0,R),P=j.slice(R);return[l,P]},ii=j=>{let R=j.type;if(R){let P=R.toUpperCase();return ri(P,Mr)?Mr[P]:R}let{src:l}=j;return l?ln(l):""},ln=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let l=R.lastIndexOf(".");if(l<0)return"";let P=R.slice(l+1).toUpperCase();return ri(P,Ft)?Ft[P]:""},un=Object.values(Pr),Jr=j=>typeof j=="boolean"||typeof j=="string"&&un.includes(j),fn=({autoplay:j},R,l)=>{let P=!1,L=!1,A=Jr(j)?j:!!j,M=()=>{P||Xt(R,"playing",()=>{P=!0},{once:!0})};if(M(),Xt(R,"loadstart",()=>{P=!1,M(),Rr(R,A)},{once:!0}),Xt(R,"loadstart",()=>{l||(L=!Number.isFinite(R.duration)),Rr(R,A)},{once:!0}),l&&l.once(Ir.default.Events.LEVEL_LOADED,(O,b)=>{var _;L=(_=b.details.live)!=null?_:!1}),!A){let O=()=>{!L||(l!=null&&l.liveSyncPosition?R.currentTime=l.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};l&&Xt(R,"play",()=>{R.preload==="metadata"?l.once(Ir.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{P||(A=Jr(O)?O:!!O,Rr(R,A))}},Rr=(j,R)=>{if(!R)return;let l=j.muted,P=()=>j.muted=l;switch(R){case Pr.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(P)});break;case Pr.MUTED:j.muted=!0,j.play().catch(P);break;default:j.play().catch(()=>{});break}},dn=({preload:j,src:R},l,P)=>{let L=x=>{x!=null&&["","none","metadata","auto"].includes(x)?l.setAttribute("preload",x):l.removeAttribute("preload")};if(!P)return L(j),L;let A=!1,M=!1,O=P.config.maxBufferLength,b=P.config.maxBufferSize,_=x=>{L(x);let D=x!=null?x:l.preload;M||D==="none"||(D==="metadata"?(P.config.maxBufferLength=1,P.config.maxBufferSize=1):(P.config.maxBufferLength=O,P.config.maxBufferSize=b),y())},y=()=>{!A&&R&&(A=!0,P.loadSource(R))};return Xt(l,"play",()=>{M=!0,P.config.maxBufferLength=O,P.config.maxBufferSize=b,y()},{once:!0}),_(j),_};function cn(j,R){R.on(Mt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:A})=>{A.forEach(M=>{var O;let b=(O=M.subtitleTrack)!=null?O:M.closedCaptions,_=R.subtitleTracks.findIndex(({lang:y,name:x,type:D})=>y==(b==null?void 0:b.lang)&&x===M.label&&D.toLowerCase()===M.kind);hn(j,M.kind,M.label,b==null?void 0:b.lang,`${M.kind}${_}`)})});let l=()=>{var L;if(!R.subtitleTracks.length)return;let A=Array.from(j.textTracks).find(O=>O.id&&O.mode==="showing"&&["subtitles","captions"].includes(O.kind)),M=`${(L=R.subtitleTracks[R.subtitleTrack])==null?void 0:L.type.toLowerCase()}${R.subtitleTrack}`;if(A&&(R.subtitleTrack<0||(A==null?void 0:A.id)!==M)){let O=R.subtitleTracks.findIndex(({lang:b,name:_,type:y})=>b==A.language&&_===A.label&&y.toLowerCase()===A.kind);R.subtitleTrack=O}A&&(A==null?void 0:A.id)===M&&A.cues&&Array.from(A.cues).forEach(O=>{A.addCue(O)})};j.textTracks.addEventListener("change",l),R.on(Mt.default.Events.CUES_PARSED,(L,{track:A,cues:M})=>{let O=j.textTracks.getTrackById(A);if(!O)return;let b=O.mode==="disabled";b&&(O.mode="hidden"),M.forEach(_=>{var y;(y=O.cues)!=null&&y.getCueById(_.id)||O.addCue(_)}),b&&(O.mode="disabled")}),R.once(Mt.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",l),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let P=()=>{Array.from(j.textTracks).forEach(L=>{var A,M;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((A=L.cues)!=null&&A.length)){let O=j.querySelector('track[label="thumbnails"]'),b=(M=O==null?void 0:O.getAttribute("src"))!=null?M:"";O==null||O.removeAttribute("src"),setTimeout(()=>{O==null||O.setAttribute("src",b)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};R.once(Mt.default.Events.MANIFEST_LOADED,P),R.once(Mt.default.Events.MEDIA_ATTACHED,P)}function hn(j,R,l,P,L){let A=document.createElement("track");return A.kind=R,A.label=l,P&&(A.srclang=P),L&&(A.id=L),A.track.mode="disabled",A.setAttribute("data-removeondestroy",""),j.append(A),A.track}var Zr,qr,vn=(qr=(Zr=globalThis==null?void 0:globalThis.navigator)==null?void 0:Zr.userAgent)!=null?qr:"",gn=vn.toLowerCase().indexOf("android")!==-1,Qt=new WeakMap,ni="mux.com",ei,ti,ai=(ti=(ei=Lt.default).isSupported)==null?void 0:ti.call(ei),mn=gn,si=()=>fr.default.utils.now(),pn=fr.default.utils.generateUUID,oi=(j,{domain:R=ni}={})=>{if(!j)return;let[l,P=""]=on(j);return`https://stream.${R}/${l}.m3u8${P}`},En=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},yn=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},Tn=j=>{var R,l,P;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:fi(j)&&(P=(l=En(j.playbackId))!=null?l:yn(j.src))!=null?P:j.src};var li=(j,R,l)=>{wr(R,l);let{metadata:P={}}=j,{view_session_id:L=pn()}=P,A=Tn(j);P.view_session_id=L,P.video_id=A,j.metadata=P,Qt.set(R,{});let M=xn(j,R);Dn(j,R,M),An(j,R,M);let O=fn(j,R,M),b=dn(j,R,M);return{engine:M,setAutoplay:O,setPreload:b}},wr=(j,R)=>{let l=R==null?void 0:R.engine;l&&(l.detachMedia(),l.destroy()),(j==null?void 0:j.mux)&&!j.mux.deleted&&(j.mux.destroy(),delete j.mux),j&&(j.removeAttribute("src"),j.load(),j.removeEventListener("error",ci),j.removeEventListener("error",Fr),j.removeEventListener("durationchange",di),Qt.delete(j),j.dispatchEvent(new Event("teardown")))};function ui(j,R){var l;let P=ii(j);if(P!==Ft.M3U8)return!0;let L=!P||((l=R.canPlayType(P))!=null?l:!0),{preferPlayback:A}=j,M=A===_t.MSE,O=A===_t.NATIVE;return L&&(O||!(ai&&(M||mn)))}var xn=(j,R)=>{let{debug:l,streamType:P,startTime:L=-1,metadata:A,preferCmcd:M}=j,O=ii(j)===Ft.M3U8,b=ui(j,R);if(O&&!b&&ai){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},y=Sn(P),x=M!==Cr.NONE?{useHeaders:M===Cr.HEADER,sessionId:A.view_session_id,contentId:A.video_id}:void 0;return new Lt.default({debug:l,startPosition:L,cmcd:x,..._,...y})}},Sn=j=>[ur.LIVE,ur.DVR].includes(j)?{backBufferLength:8}:[ur.LL_LIVE,ur.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},fi=({playbackId:j,src:R,customDomain:l})=>{if(j)return!0;if(typeof R!="string")return!1;let P=window==null?void 0:window.location.href,L=new URL(R,P).hostname.toLocaleLowerCase();return L.includes(ni)||!!l&&L.includes(l.toLocaleLowerCase())},Dn=(j,R,l)=>{var P;let{envKey:L}=j,A=fi(j);if(L||A){let{playerInitTime:M,playerSoftwareName:O,playerSoftwareVersion:b,beaconCollectionDomain:_,debug:y,disableCookies:x}=j,D={...j.metadata,video_title:((P=j==null?void 0:j.metadata)==null?void 0:P.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(m):m;fr.default.monitor(R,{debug:y,beaconCollectionDomain:_,hlsjs:l,Hls:l?Lt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:x,data:{...L?{env_key:L}:{},player_software_name:O,player_software:O,player_software_version:b,player_init_time:M,...D}})}},An=(j,R,l)=>{var P;let L=ui(j,R),{src:A}=j;R&&L?(typeof A=="string"?(R.setAttribute("src",A),j.startTime&&(((P=Qt.get(R))!=null?P:{}).startTime=j.startTime,R.addEventListener("durationchange",di,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",ci),R.addEventListener("error",Fr)):l&&A?(l.on(Lt.default.Events.ERROR,(M,O)=>{let b={[Lt.default.ErrorTypes.NETWORK_ERROR]:Xe.MEDIA_ERR_NETWORK,[Lt.default.ErrorTypes.MEDIA_ERROR]:Xe.MEDIA_ERR_DECODE},_=new Xe("",b[O.type]);_.fatal=O.fatal,_.data=O,R.dispatchEvent(new CustomEvent("error",{detail:_}))}),R.addEventListener("error",Fr),cn(R,l),l.attachMedia(R)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function di(j){var R;let l=j.target,P=(R=Qt.get(l))==null?void 0:R.startTime;if(!!P&&sn(l.seekable,l.duration,P)){let L=l.preload==="auto";L&&(l.preload="none"),l.currentTime=P,L&&(l.preload="auto")}}async function ci(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:l,code:P}=R.error,L=new Xe(l,P);if(R.src&&(P!==Xe.MEDIA_ERR_DECODE||P!==void 0))try{let{status:A}=await fetch(R.src);L.data={response:{code:A}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:L}))}function Fr(j){var R,l;if(!(j instanceof CustomEvent)||!(j.detail instanceof Xe))return;let P=j.target,L=j.detail;!L||!L.fatal||(((R=Qt.get(P))!=null?R:{}).error=L,(l=P.mux)==null||l.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var Ln=()=>{try{return"0.9.0"}catch{}return"UNKNOWN"},_n=Ln(),hi=()=>_n;var vi=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],gi=_r.createElement("template");gi.innerHTML=`
|
|
30
|
+
`),t=[],n=Object(w.toMpegTsClockFromTimescale)(f,e),u="00:00.000",a=0,d=0,v,S=!0;o.oncue=function(T){var I=s[h],k=s.ccOffset,B=(a-n)/9e4;I!=null&&I.new&&(d!==void 0?k=s.ccOffset=I.start:E(s,h,B)),B&&(k=B-s.presentationOffset);var U=T.endTime-T.startTime,W=Object(O.normalizePts)((T.startTime+k-d)*9e4,g*9e4)/9e4;T.startTime=Math.max(W,0),T.endTime=Math.max(W+U,0);var H=T.text.trim();T.text=decodeURIComponent(encodeURIComponent(H)),T.id||(T.id=D(T.startTime,T.endTime,H)),T.endTime>0&&t.push(T)},o.onparsingerror=function(T){v=T},o.onflush=function(){if(v){r(v);return}i(t)},c.forEach(function(T){if(S)if(_(T,"X-TIMESTAMP-MAP=")){S=!1,T.slice(16).split(",").forEach(function(I){_(I,"LOCAL:")?u=I.slice(6):_(I,"MPEGTS:")&&(a=parseInt(I.slice(7)))});try{d=y(u)/1e3}catch(I){v=I}return}else T===""&&(S=!1);o.parse(T+`
|
|
31
|
+
`)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,l){"use strict";l.r(R);var C=l("./src/utils/logger.ts"),L=l("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,w=function(){function 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=_?_.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var b=O.prototype;return b.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},b.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},b.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},b.load=function(y,x,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=x,this.callbacks=D,this.retryDelay=x.retryDelay,this.loadInternal()},b.loadInternal=function(){var y=this.config,x=this.context;if(!!y){var D=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(D,x.url)}catch{D.open("GET",x.url,!0),m(D,x.url)}D.readyState||D.open("GET",x.url,!0);var p=this.context.headers;if(p)for(var f in p)D.setRequestHeader(f,p[f])}catch(e){this.callbacks.onError({code:D.status,text:e.message},x,D);return}x.rangeEnd&&D.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},b.readystatechange=function(){var y=this.context,x=this.loader,D=this.stats;if(!(!y||!x)){var E=x.readyState,m=this.config;if(!D.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var p=x.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var f,e;if(y.responseType==="arraybuffer"?(f=x.response,e=f.byteLength):(f=x.responseText,e=f.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,f,x),!this.callbacks)return;var h={url:x.responseURL,data:f};this.callbacks.onSuccess(h,D,y,x)}else D.retry>=m.maxRetry||p>=400&&p<499?(C.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:x.statusText},y,x)):(C.logger.warn(p+" while loading "+y.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,m.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},b.loadtimeout=function(){C.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},b.loadprogress=function(y){var x=this.stats;x.loaded=y.loaded,y.lengthComputable&&(x.total=y.total)},b.getCacheAge=function(){var y=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");y=x?parseFloat(x):null}return y},O}();R.default=w}}).default})});var Ct=class{addEventListener(){}removeEventListener(){}dispatchEvent(R){return!0}};if(typeof DocumentFragment=="undefined"){class j extends Ct{}globalThis.DocumentFragment=j}var Vt=class extends Ct{},br=class extends Ct{},pn={get(j){},define(j,R,l){},upgrade(j){},whenDefined(j){return Promise.resolve(Vt)}},Yt,Or=class{constructor(R,l={}){ft(this,Yt,void 0);dt(this,Yt,l==null?void 0:l.detail)}get detail(){return qe(this,Yt)}initCustomEvent(){}};Yt=new WeakMap;function En(j,R){return new Vt}var ti={document:{createElement:En},DocumentFragment,customElements:pn,CustomEvent:Or,EventTarget:Ct,HTMLElement:Vt,HTMLVideoElement:br},ri=typeof window=="undefined"||typeof globalThis.customElements=="undefined",gt=ri?ti:globalThis,Rr=ri?ti.document:globalThis.document;var vr=fr(ii(),1),Lt=fr(cr(),1),Mr=fr(cr(),1),Mt=fr(cr(),1),Xt=class extends Error{constructor(j,R=Xt.MEDIA_ERR_CUSTOM,l){var C;super(j),this.name="MediaError",this.code=R,this.fatal=l!=null?l:R>=Xt.MEDIA_ERR_NETWORK&&R<=Xt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(C=Xt.defaultMessages[this.code])!=null?C:"")}},et=Xt;et.MEDIA_ERR_ABORTED=1,et.MEDIA_ERR_NETWORK=2,et.MEDIA_ERR_DECODE=3,et.MEDIA_ERR_SRC_NOT_SUPPORTED=4,et.MEDIA_ERR_ENCRYPTED=5,et.MEDIA_ERR_CUSTOM=100,et.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var yn=j=>j==null,ui=(j,R)=>yn(R)?!1:j in R,wr={ANY:"any",MUTED:"muted"},hr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},_t={MSE:"mse",NATIVE:"native"},Fr={HEADER:"header",QUERY:"query",NONE:"none"},Qn=Object.values(Fr),wt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},kr={HLS:wt.M3U8},$n=Object.keys(kr),Jn=[...Object.values(wt),"hls","HLS"],Qt=(j,R,l,C)=>{j.addEventListener(R,l,C),j.addEventListener("teardown",()=>{j.removeEventListener(R,l)},{once:!0})};function Tn(j,R,l){R&&l>R&&(l=R);for(let C=0;C<j.length;C++)if(j.start(C)<=l&&j.end(C)>=l)return!0;return!1}var xn=j=>{let R=j.indexOf("?");if(R<0)return[j];let l=j.slice(0,R),C=j.slice(R);return[l,C]},fi=j=>{let R=j.type;if(R){let C=R.toUpperCase();return ui(C,kr)?kr[C]:R}let{src:l}=j;return l?Sn(l):""},Sn=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let l=R.lastIndexOf(".");if(l<0)return"";let C=R.slice(l+1).toUpperCase();return ui(C,wt)?wt[C]:""},Dn=Object.values(wr),ni=j=>typeof j=="boolean"||typeof j=="string"&&Dn.includes(j),An=({autoplay:j},R,l)=>{let C=!1,L=!1,A=ni(j)?j:!!j,w=()=>{C||Qt(R,"playing",()=>{C=!0},{once:!0})};if(w(),Qt(R,"loadstart",()=>{C=!1,w(),Cr(R,A)},{once:!0}),Qt(R,"loadstart",()=>{l||(L=!Number.isFinite(R.duration)),Cr(R,A)},{once:!0}),l&&l.once(Mr.default.Events.LEVEL_LOADED,(O,b)=>{var _;L=(_=b.details.live)!=null?_:!1}),!A){let O=()=>{!L||(l!=null&&l.liveSyncPosition?R.currentTime=l.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};l&&Qt(R,"play",()=>{R.preload==="metadata"?l.once(Mr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{C||(A=ni(O)?O:!!O,Cr(R,A))}},Cr=(j,R)=>{if(!R)return;let l=j.muted,C=()=>j.muted=l;switch(R){case wr.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(C)});break;case wr.MUTED:j.muted=!0,j.play().catch(C);break;default:j.play().catch(()=>{});break}},Ln=({preload:j,src:R},l,C)=>{let L=x=>{x!=null&&["","none","metadata","auto"].includes(x)?l.setAttribute("preload",x):l.removeAttribute("preload")};if(!C)return L(j),L;let A=!1,w=!1,O=C.config.maxBufferLength,b=C.config.maxBufferSize,_=x=>{L(x);let D=x!=null?x:l.preload;w||D==="none"||(D==="metadata"?(C.config.maxBufferLength=1,C.config.maxBufferSize=1):(C.config.maxBufferLength=O,C.config.maxBufferSize=b),y())},y=()=>{!A&&R&&(A=!0,C.loadSource(R))};return Qt(l,"play",()=>{w=!0,C.config.maxBufferLength=O,C.config.maxBufferSize=b,y()},{once:!0}),_(j),_};function _n(j,R){R.on(Mt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:A})=>{A.forEach(w=>{var O;let b=(O=w.subtitleTrack)!=null?O:w.closedCaptions,_=R.subtitleTracks.findIndex(({lang:y,name:x,type:D})=>y==(b==null?void 0:b.lang)&&x===w.label&&D.toLowerCase()===w.kind);bn(j,w.kind,w.label,b==null?void 0:b.lang,`${w.kind}${_}`)})});let l=()=>{var L;if(!R.subtitleTracks.length)return;let A=Array.from(j.textTracks).find(O=>O.id&&O.mode==="showing"&&["subtitles","captions"].includes(O.kind)),w=`${(L=R.subtitleTracks[R.subtitleTrack])==null?void 0:L.type.toLowerCase()}${R.subtitleTrack}`;if(A&&(R.subtitleTrack<0||(A==null?void 0:A.id)!==w)){let O=R.subtitleTracks.findIndex(({lang:b,name:_,type:y})=>b==A.language&&_===A.label&&y.toLowerCase()===A.kind);R.subtitleTrack=O}A&&(A==null?void 0:A.id)===w&&A.cues&&Array.from(A.cues).forEach(O=>{A.addCue(O)})};j.textTracks.addEventListener("change",l),R.on(Mt.default.Events.CUES_PARSED,(L,{track:A,cues:w})=>{let O=j.textTracks.getTrackById(A);if(!O)return;let b=O.mode==="disabled";b&&(O.mode="hidden"),w.forEach(_=>{var y;(y=O.cues)!=null&&y.getCueById(_.id)||O.addCue(_)}),b&&(O.mode="disabled")}),R.once(Mt.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",l),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let C=()=>{Array.from(j.textTracks).forEach(L=>{var A,w;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((A=L.cues)!=null&&A.length)){let O=j.querySelector('track[label="thumbnails"]'),b=(w=O==null?void 0:O.getAttribute("src"))!=null?w:"";O==null||O.removeAttribute("src"),setTimeout(()=>{O==null||O.setAttribute("src",b)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};R.once(Mt.default.Events.MANIFEST_LOADED,C),R.once(Mt.default.Events.MEDIA_ATTACHED,C)}function bn(j,R,l,C,L){let A=document.createElement("track");return A.kind=R,A.label=l,C&&(A.srclang=C),L&&(A.id=L),A.track.mode="disabled",A.setAttribute("data-removeondestroy",""),j.append(A),A.track}var ai,si,On=(si=(ai=globalThis==null?void 0:globalThis.navigator)==null?void 0:ai.userAgent)!=null?si:"",Rn=On.toLowerCase().indexOf("android")!==-1,$t=new WeakMap,di="mux.com",oi,li,ci=(li=(oi=Lt.default).isSupported)==null?void 0:li.call(oi),In=Rn,hi=()=>vr.default.utils.now(),Pn=vr.default.utils.generateUUID,vi=(j,{domain:R=di}={})=>{if(!j)return;let[l,C=""]=xn(j);return`https://stream.${R}/${l}.m3u8${C}`},Cn=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},Mn=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},wn=j=>{var R,l,C;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:pi(j)&&(C=(l=Cn(j.playbackId))!=null?l:Mn(j.src))!=null?C:j.src};var gi=(j,R,l)=>{Ur(R,l);let{metadata:C={}}=j,{view_session_id:L=Pn()}=C,A=wn(j);C.view_session_id=L,C.video_id=A,j.metadata=C,$t.set(R,{});let w=Fn(j,R);Bn(j,R,w),Un(j,R,w);let O=An(j,R,w),b=Ln(j,R,w);return{engine:w,setAutoplay:O,setPreload:b}},Ur=(j,R)=>{let l=R==null?void 0:R.engine;l&&(l.detachMedia(),l.destroy()),(j==null?void 0:j.mux)&&!j.mux.deleted&&(j.mux.destroy(),delete j.mux),j&&(j.removeAttribute("src"),j.load(),j.removeEventListener("error",yi),j.removeEventListener("error",Br),j.removeEventListener("durationchange",Ei),$t.delete(j),j.dispatchEvent(new Event("teardown")))};function mi(j,R){var l;let C=fi(j);if(C!==wt.M3U8)return!0;let L=!C||((l=R.canPlayType(C))!=null?l:!0),{preferPlayback:A}=j,w=A===_t.MSE,O=A===_t.NATIVE;return L&&(O||!(ci&&(w||In)))}var Fn=(j,R)=>{let{debug:l,streamType:C,startTime:L=-1,metadata:A,preferCmcd:w}=j,O=fi(j)===wt.M3U8,b=mi(j,R);if(O&&!b&&ci){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},y=kn(C),x=w!==Fr.NONE?{useHeaders:w===Fr.HEADER,sessionId:A.view_session_id,contentId:A.video_id}:void 0;return new Lt.default({debug:l,startPosition:L,cmcd:x,..._,...y})}},kn=j=>[hr.LIVE,hr.DVR].includes(j)?{backBufferLength:8}:[hr.LL_LIVE,hr.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},pi=({playbackId:j,src:R,customDomain:l})=>{if(j)return!0;if(typeof R!="string")return!1;let C=window==null?void 0:window.location.href,L=new URL(R,C).hostname.toLocaleLowerCase();return L.includes(di)||!!l&&L.includes(l.toLocaleLowerCase())},Bn=(j,R,l)=>{var C;let{envKey:L}=j,A=pi(j);if(L||A){let{playerInitTime:w,playerSoftwareName:O,playerSoftwareVersion:b,beaconCollectionDomain:_,debug:y,disableCookies:x}=j,D={...j.metadata,video_title:((C=j==null?void 0:j.metadata)==null?void 0:C.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(m):m;vr.default.monitor(R,{debug:y,beaconCollectionDomain:_,hlsjs:l,Hls:l?Lt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:x,data:{...L?{env_key:L}:{},player_software_name:O,player_software:O,player_software_version:b,player_init_time:w,...D}})}},Un=(j,R,l)=>{var C;let L=mi(j,R),{src:A}=j;R&&L?(typeof A=="string"?(R.setAttribute("src",A),j.startTime&&(((C=$t.get(R))!=null?C:{}).startTime=j.startTime,R.addEventListener("durationchange",Ei,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",yi),R.addEventListener("error",Br)):l&&A?(l.on(Lt.default.Events.ERROR,(w,O)=>{let b={[Lt.default.ErrorTypes.NETWORK_ERROR]:et.MEDIA_ERR_NETWORK,[Lt.default.ErrorTypes.MEDIA_ERROR]:et.MEDIA_ERR_DECODE},_=new et("",b[O.type]);_.fatal=O.fatal,_.data=O,R.dispatchEvent(new CustomEvent("error",{detail:_}))}),R.addEventListener("error",Br),_n(R,l),l.attachMedia(R)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Ei(j){var R;let l=j.target,C=(R=$t.get(l))==null?void 0:R.startTime;if(!!C&&Tn(l.seekable,l.duration,C)){let L=l.preload==="auto";L&&(l.preload="none"),l.currentTime=C,L&&(l.preload="auto")}}async function yi(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:l,code:C}=R.error,L=new et(l,C);if(R.src&&(C!==et.MEDIA_ERR_DECODE||C!==void 0))try{let{status:A}=await fetch(R.src);L.data={response:{code:A}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:L}))}function Br(j){var R,l;if(!(j instanceof CustomEvent)||!(j.detail instanceof et))return;let C=j.target,L=j.detail;!L||!L.fatal||(((R=$t.get(C))!=null?R:{}).error=L,(l=C.mux)==null||l.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var Nn=()=>{try{return"0.9.1"}catch{}return"UNKNOWN"},Kn=Nn(),Ti=()=>Kn;var xi=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Si=Rr.createElement("template");Si.innerHTML=`
|
|
31
32
|
<style>
|
|
32
33
|
:host {
|
|
33
34
|
/* display:inline (like the native el) makes it so you can't fill
|
|
@@ -50,7 +51,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
50
51
|
|
|
51
52
|
<audio part="audio" crossorigin></audio>
|
|
52
53
|
<slot></slot>
|
|
53
|
-
`;var
|
|
54
|
+
`;var Jt,Ft,gr,bt=class extends gt.HTMLElement{constructor(){super();ft(this,Ft);ft(this,Jt,void 0);this.attachShadow({mode:"open"}),this.isConnected&&At(this,Ft,gr).call(this)}static get observedAttributes(){let l=[];Object.getOwnPropertyNames(this.prototype).forEach(L=>{let A=!1;try{typeof this.prototype[L]=="function"&&(A=!0)}catch{}!A&&L!==L.toUpperCase()&&l.push(L.toLowerCase())});let C=Object.getPrototypeOf(this).observedAttributes;return C&&(l=l.concat(C)),l}attributeChangedCallback(l,C,L){At(this,Ft,gr).call(this),this.forwardAttribute(l,C,L)}forwardAttribute(l,C,L){let A=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),w=Wn(A,l),O=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;w&&!O?typeof this[w]=="boolean"?L===null?this[w]=!1:this[w]=!0:this[w]=L:L===null?this.nativeEl.removeAttribute(l):["id","class"].indexOf(l)===-1&&this.nativeEl.setAttribute(l,L)}connectedCallback(){At(this,Ft,gr).call(this)}};Jt=new WeakMap,Ft=new WeakSet,gr=function(){if(qe(this,Jt))return;dt(this,Jt,!0),this.shadowRoot.append(Si.content.cloneNode(!0));let l=this.nativeEl=this.shadowRoot.querySelector("audio");xi.forEach(L=>{l.addEventListener(L,A=>{this.dispatchEvent(new CustomEvent(A.type,{detail:A.detail}))})});let C=this.shadowRoot.querySelector("slot");C.addEventListener("slotchange",()=>{C.assignedElements().forEach(L=>{!["track","source"].includes(L.localName)||l.append(L)})}),Array.from(this.attributes).forEach(L=>{this.forwardAttribute(L.name,null,L.value)}),l.defaultMuted&&(l.muted=!0)};var Di=[],Ai=Rr.createElement("audio"),jn=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let j=Object.getPrototypeOf(Ai);j&&j!==gt.HTMLElement.prototype;j=Object.getPrototypeOf(j))Object.keys(j).forEach(R=>{jn.indexOf(R)===-1&&Di.push(R)});Di.forEach(j=>{if(typeof Ai[j]=="function")bt.prototype[j]=function(){return this.nativeEl[j].apply(this.nativeEl,arguments)};else{let l={get(){return this.nativeEl[j]}};j!==j.toUpperCase()&&(l.set=function(C){this.nativeEl[j]=C}),Object.defineProperty(bt.prototype,j,l)}});function Wn(j,R){let l=null;return j.forEach(C=>{C.toLowerCase()==R.toLowerCase()&&(l=C)}),l}gt.customElements.get("custom-audio")||(gt.customElements.define("custom-audio",bt),gt.CustomAudioElement=bt);var Nr=bt;var De={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Gn=Object.values(De),Hn=Ti(),Vn="mux-audio",mt,kt,qt,Bt,er,Kr,Zt=class extends Nr{constructor(){super();ft(this,er);ft(this,mt,void 0);ft(this,kt,void 0);ft(this,qt,void 0);ft(this,Bt,{});dt(this,qt,hi())}static get observedAttributes(){var l;return[...Gn,...(l=Nr.observedAttributes)!=null?l:[]]}get playerInitTime(){return qe(this,qt)}get playerSoftwareName(){return Vn}get playerSoftwareVersion(){return Hn}get _hls(){var l;return(l=qe(this,mt))==null?void 0:l.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(l){l!==this.src&&(l==null?this.removeAttribute("src"):this.setAttribute("src",l))}get preload(){let l=this.getAttribute("preload");return l===""?"auto":["none","metadata","auto"].includes(l)?l:super.preload}set preload(l){l!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(l)?this.setAttribute("preload",l):this.removeAttribute("preload"))}get debug(){return this.getAttribute(De.DEBUG)!=null}set debug(l){l!==this.debug&&(l?this.setAttribute(De.DEBUG,""):this.removeAttribute(De.DEBUG))}get disableCookies(){return this.hasAttribute(De.DISABLE_COOKIES)}set disableCookies(l){l!==this.disableCookies&&(l?this.setAttribute(De.DISABLE_COOKIES,""):this.removeAttribute(De.DISABLE_COOKIES))}get startTime(){let l=this.getAttribute(De.START_TIME);if(l==null)return;let C=+l;return Number.isNaN(C)?void 0:C}set startTime(l){l!==this.startTime&&(l==null?this.removeAttribute(De.START_TIME):this.setAttribute(De.START_TIME,`${l}`))}get playbackId(){var l;return(l=this.getAttribute(De.PLAYBACK_ID))!=null?l:void 0}set playbackId(l){l!==this.playbackId&&(l?this.setAttribute(De.PLAYBACK_ID,l):this.removeAttribute(De.PLAYBACK_ID))}get envKey(){var l;return(l=this.getAttribute(De.ENV_KEY))!=null?l:void 0}set envKey(l){l!==this.envKey&&(l?this.setAttribute(De.ENV_KEY,l):this.removeAttribute(De.ENV_KEY))}get beaconCollectionDomain(){var l;return(l=this.getAttribute(De.BEACON_COLLECTION_DOMAIN))!=null?l:void 0}set beaconCollectionDomain(l){l!==this.beaconCollectionDomain&&(l?this.setAttribute(De.BEACON_COLLECTION_DOMAIN,l):this.removeAttribute(De.BEACON_COLLECTION_DOMAIN))}get streamType(){var l;return(l=this.getAttribute(De.STREAM_TYPE))!=null?l:void 0}set streamType(l){l!==this.streamType&&(l?this.setAttribute(De.STREAM_TYPE,l):this.removeAttribute(De.STREAM_TYPE))}get preferPlayback(){let l=this.getAttribute(De.PREFER_PLAYBACK);if(l===_t.MSE||l===_t.NATIVE)return l}set preferPlayback(l){l!==this.preferPlayback&&(l===_t.MSE||l===_t.NATIVE?this.setAttribute(De.PREFER_PLAYBACK,l):this.removeAttribute(De.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(C=>C.startsWith("metadata-")&&![De.METADATA_URL].includes(C)).reduce((C,L)=>{let A=this.getAttribute(L);return A!=null&&(C[L.replace(/^metadata-/,"").replace(/-/g,"_")]=A),C},{}),...qe(this,Bt)}}set metadata(l){dt(this,Bt,l!=null?l:{}),this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",qe(this,Bt)))}load(){dt(this,mt,gi(this,this.nativeEl,qe(this,mt)))}unload(){Ur(this.nativeEl,qe(this,mt)),dt(this,mt,void 0)}attributeChangedCallback(l,C,L){var A,w;switch(super.attributeChangedCallback(l,C,L),l){case"src":{let O=!!C,b=!!L;!O&&b?At(this,er,Kr).call(this):O&&!b?this.unload():O&&b&&(this.unload(),At(this,er,Kr).call(this));break}case"autoplay":if(L===C)break;(A=qe(this,mt))==null||A.setAutoplay(this.autoplay);break;case"preload":if(L===C)break;(w=qe(this,mt))==null||w.setPreload(L);break;case De.PLAYBACK_ID:this.src=vi(L!=null?L:void 0);break;case De.DEBUG:{let O=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=O);break}case De.METADATA_URL:L&&fetch(L).then(O=>O.json()).then(O=>this.metadata=O).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${L}!`));break;default:break}}disconnectedCallback(){this.unload()}};mt=new WeakMap,kt=new WeakMap,qt=new WeakMap,Bt=new WeakMap,er=new WeakSet,Kr=async function(){qe(this,kt)||(await dt(this,kt,Promise.resolve()),dt(this,kt,null),this.load())};gt.customElements.get("mux-audio")||(gt.customElements.define("mux-audio",Zt),gt.MuxAudioElement=Zt);var ca=Zt;})();
|
|
54
55
|
/*!
|
|
55
56
|
* JavaScript Cookie v2.1.3
|
|
56
57
|
* https://github.com/js-cookie/js-cookie
|
|
@@ -60,7 +61,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
60
61
|
*/
|
|
61
62
|
/*!
|
|
62
63
|
* mux-embed
|
|
63
|
-
* @version 4.
|
|
64
|
+
* @version 4.17.0
|
|
64
65
|
* @copyright 2022 Mux, Inc
|
|
65
66
|
*/
|
|
66
67
|
//# sourceMappingURL=mux-audio.js.map
|