@mux/playback-core 0.13.0 → 0.14.0

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.
@@ -1,33 +1,33 @@
1
- var xi=Object.create;var Sr=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty;var Dr=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var _i=(j,R,g,M)=>{if(R&&typeof R=="object"||typeof R=="function")for(let _ of Di(R))!Ai.call(j,_)&&_!==g&&Sr(j,_,{get:()=>R[_],enumerable:!(M=Si(R,_))||M.enumerable});return j};var jt=(j,R,g)=>(g=j!=null?xi(Li(j)):{},_i(R||!j||!j.__esModule?Sr(g,"default",{value:j,enumerable:!0}):g,j));var Lr=Dr((Gt,ar)=>{(function(){var j,R;j=this,R=function(){return function(){var g={80:function(L,C,b){L.exports=b(728).default},728:function(L,C,b){"use strict";b.d(C,{default:function(){return Ti}});var O=b(48),A=b.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(w){var I=16*Math.random()|0;return(w==="x"?I:3&I|8).toString(16)})},T=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||T()),w.muxId):w},E=function(w){var I;w&&w.nodeName!==void 0?w=D(I=w):I=document.querySelector(w);var F=I&&I.nodeName?I.nodeName.toLowerCase():"";return[I,w,F]},m=b(640),p=b.n(m),u=p().methodFactory;p().methodFactory=function(w,I,F){var N=u(w,I,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(A().doNotTrack||A().navigator&&A().navigator.doNotTrack)==="1"}var c={now:function(){var w=A().performance,I=w&&w.timing,F=w&&w.timeOrigin||I&&I.navigationStart;return typeof F=="number"&&typeof w.now=="function"?F+w.now():Date.now()}},v=b(678),i=b.n(v),r=function(w){return o(w)[0]},o=function(w){if(typeof w!="string"||w==="")return["localhost"];var I,F=(w.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return F&&(I=(F.match(/[^\.]+\.[^\.]+$/)||[])[0]),[F,I]},d={exists:function(){var w=A().performance;return(w&&w.timing)!==void 0},domContentLoadedEventEnd:function(){var w=A().performance,I=w&&w.timing;return I&&I.domContentLoadedEventEnd},navigationStart:function(){var w=A().performance,I=w&&w.timing;return I&&I.navigationStart}};function t(w,I,F){F=F===void 0?1:F,w[I]=w[I]||0,w[I]+=F}var n=["x-cdn","content-type","x-request-id"];function l(w){var I={};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)&&(I[K]=N.join(": "))}}),I}var a=function(w){var I={};for(var F in w){var N=w[F];N["DATA-ID"].search("io.litix.data.")!==-1&&(I[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return I};function f(w,I){var F=Object.keys(w);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(w);I&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(w,K).enumerable})),F.push.apply(F,N)}return F}function h(w){for(var I=1;I<arguments.length;I++){var F=arguments[I]!=null?arguments[I]:{};I%2?f(Object(F),!0).forEach(function(N){S(w,N,F[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(F)):f(Object(F)).forEach(function(N){Object.defineProperty(w,N,Object.getOwnPropertyDescriptor(F,N))})}return w}function S(w,I,F){return I in w?Object.defineProperty(w,I,{value:F,enumerable:!0,configurable:!0,writable:!0}):w[I]=F,w}var x=function(w){if(!w)return{};var I=d.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(I+N),responseStart:Math.round(I+K),responseEnd:Math.round(I+V)}},P=function(w){if(w&&typeof w.getAllResponseHeaders=="function")return l(w.getAllResponseHeaders())},k=function(w,I){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 I.getMetricsFor=="function"?I.getMetricsFor(K.mediaType).HttpList:I.getDashMetrics().getHttpRequests(K.mediaType);return ce.length>0&&(N=l(ce[ce.length-1]._responseHeaders||"")),{requestStart:Q,requestResponseStart:J,requestResponseEnd:X,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ee,requestHostname:V}},B=function(w,I){var F=I.getQualityFor(w),N=I.getCurrentTrackFor(w).bitrateList;return N?{currentLevel:F,renditionWidth:N[F].width||null,renditionHeight:N[F].height||null,renditionBitrate:N[F].bandwidth}:{}};function U(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&U(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),z=G;function Y(w,I){for(var F=0;F<I.length;F++){var N=I[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&&(A().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var I,F,N;return I=w,(F=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=A().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(A().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(I.prototype,F),N&&Y(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Z(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function q(w,I,F){return I&&Z(w.prototype,I),F&&Z(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ie=q(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F.viewErrored=!1}),I.on("error",function(){try{var N=I.errorTranslator({player_error_code:I.data.player_error_code,player_error_message:I.data.player_error_message});N?(I.data.player_error_code=N.player_error_code,I.data.player_error_message=N.player_error_message,F.viewErrored=!0):(delete I.data.player_error_code,delete I.data.player_error_message)}catch(K){I.mux.log.warn("Exception in error translator callback.",K),F.viewErrored=!0}})});function ne(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&ne(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function te(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&te(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function de(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&de(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Ee(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function me(w,I,F){return I&&Ee(w.prototype,I),F&&Ee(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Te=me(function w(I){if(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")}(this,w),!I.disableRebufferTracking){var F,N=function(){if(F){var K=I.data.viewer_time-F;t(I.data,"view_rebuffer_duration",K),F=I.data.viewer_time}I.data.view_watch_time>=0&&I.data.view_rebuffer_count>0&&(I.data.view_rebuffer_frequency=I.data.view_rebuffer_count/I.data.view_watch_time,I.data.view_rebuffer_percentage=I.data.view_rebuffer_duration/I.data.view_watch_time)};I.on("playbackheartbeat",function(){return N()}),I.on("rebufferstart",function(){F||(t(I.data,"view_rebuffer_count",1),F=I.data.viewer_time,I.one("rebufferend",function(){N(),F=void 0}))})}});function Me(w,I){for(var F=0;F<I.length;F++){var N=I[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){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:c.now()})}))}var I,F,N;return I=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(I.prototype,F),N&&Me(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),we=Ae;function Re(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ke=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||c.now(),Q):X.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||c.now(),Q)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var I,F,N;return I=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))}}])&&Re(I.prototype,F),N&&Re(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function _e(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Be(w,I,F){return I&&_e(w.prototype,I),F&&_e(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ke=Be(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){I.on(N,function(){if(F._lastPlayheadPosition>=0&&I.data.player_playhead_time>=0&&F._lastPlayerWidth>=0&&F._lastSourceWidth>0&&F._lastPlayerHeight>=0&&F._lastSourceHeight>0){var K=I.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);I.data.view_max_upscale_percentage=Math.max(I.data.view_max_upscale_percentage||0,H),I.data.view_max_downscale_percentage=Math.max(I.data.view_max_downscale_percentage||0,Q),t(I.data,"view_total_content_playback_time",K),t(I.data,"view_total_upscaling",H*K),t(I.data,"view_total_downscaling",Q*K)}F._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){I.on(N,function(){F._lastPlayheadPosition=I.data.player_playhead_time,F._lastPlayerWidth=I.data.player_width,F._lastPlayerHeight=I.data.player_height,F._lastSourceWidth=I.data.video_source_width,F._lastSourceHeight=I.data.video_source_height})})});function We(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ue(w,I,F){return I&&We(w.prototype,I),F&&We(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ze=Ue(function w(I){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,I.on("seeking",function(N,K){i()(I.data,K),F._lastSeekingTime=c.now(),F.isSeeking===!1&&(F.isSeeking=!0,I.send("seeking"))}),I.on("seeked",function(){F.isSeeking=!1;var N=F._lastSeekingTime||c.now(),K=c.now()-N;t(I.data,"view_seek_count",1),t(I.data,"view_seek_duration",K);var V=I.data.view_max_seek_time||0;I.data.view_max_seek_time=Math.max(V,K)}),I.on("viewend",function(){F.isSeeking=!1})});function Ce(w,I){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,I)||function(F,N){if(F){if(typeof F=="string")return qe(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)?qe(F,N):void 0}}(w,I)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ var xi=Object.create;var Sr=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty;var Dr=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var _i=(j,R,m,M)=>{if(R&&typeof R=="object"||typeof R=="function")for(let _ of Di(R))!Ai.call(j,_)&&_!==m&&Sr(j,_,{get:()=>R[_],enumerable:!(M=Si(R,_))||M.enumerable});return j};var jt=(j,R,m)=>(m=j!=null?xi(Li(j)):{},_i(R||!j||!j.__esModule?Sr(m,"default",{value:j,enumerable:!0}):m,j));var Lr=Dr((Gt,ar)=>{(function(){var j,R;j=this,R=function(){return function(){var m={80:function(L,C,b){L.exports=b(728).default},728:function(L,C,b){"use strict";b.d(C,{default:function(){return Ti}});var O=b(48),A=b.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(w){var I=16*Math.random()|0;return(w==="x"?I:3&I|8).toString(16)})},T=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||T()),w.muxId):w},E=function(w){var I;w&&w.nodeName!==void 0?w=D(I=w):I=document.querySelector(w);var F=I&&I.nodeName?I.nodeName.toLowerCase():"";return[I,w,F]},g=b(640),p=b.n(g),u=p().methodFactory;p().methodFactory=function(w,I,F){var N=u(w,I,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(A().doNotTrack||A().navigator&&A().navigator.doNotTrack)==="1"}var c={now:function(){var w=A().performance,I=w&&w.timing,F=w&&w.timeOrigin||I&&I.navigationStart;return typeof F=="number"&&typeof w.now=="function"?F+w.now():Date.now()}},v=b(678),i=b.n(v),r=function(w){return o(w)[0]},o=function(w){if(typeof w!="string"||w==="")return["localhost"];var I,F=(w.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return F&&(I=(F.match(/[^\.]+\.[^\.]+$/)||[])[0]),[F,I]},d={exists:function(){var w=A().performance;return(w&&w.timing)!==void 0},domContentLoadedEventEnd:function(){var w=A().performance,I=w&&w.timing;return I&&I.domContentLoadedEventEnd},navigationStart:function(){var w=A().performance,I=w&&w.timing;return I&&I.navigationStart}};function t(w,I,F){F=F===void 0?1:F,w[I]=w[I]||0,w[I]+=F}var n=["x-cdn","content-type","x-request-id"];function l(w){var I={};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)&&(I[K]=N.join(": "))}}),I}var a=function(w){var I={};for(var F in w){var N=w[F];N["DATA-ID"].search("io.litix.data.")!==-1&&(I[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return I};function f(w,I){var F=Object.keys(w);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(w);I&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(w,K).enumerable})),F.push.apply(F,N)}return F}function h(w){for(var I=1;I<arguments.length;I++){var F=arguments[I]!=null?arguments[I]:{};I%2?f(Object(F),!0).forEach(function(N){S(w,N,F[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(F)):f(Object(F)).forEach(function(N){Object.defineProperty(w,N,Object.getOwnPropertyDescriptor(F,N))})}return w}function S(w,I,F){return I in w?Object.defineProperty(w,I,{value:F,enumerable:!0,configurable:!0,writable:!0}):w[I]=F,w}var x=function(w){if(!w)return{};var I=d.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(I+N),responseStart:Math.round(I+K),responseEnd:Math.round(I+V)}},P=function(w){if(w&&typeof w.getAllResponseHeaders=="function")return l(w.getAllResponseHeaders())},k=function(w,I){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 I.getMetricsFor=="function"?I.getMetricsFor(K.mediaType).HttpList:I.getDashMetrics().getHttpRequests(K.mediaType);return ce.length>0&&(N=l(ce[ce.length-1]._responseHeaders||"")),{requestStart:Q,requestResponseStart:J,requestResponseEnd:X,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ee,requestHostname:V}},B=function(w,I){var F=I.getQualityFor(w),N=I.getCurrentTrackFor(w).bitrateList;return N?{currentLevel:F,renditionWidth:N[F].width||null,renditionHeight:N[F].height||null,renditionBitrate:N[F].bandwidth}:{}};function U(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&U(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),z=G;function Y(w,I){for(var F=0;F<I.length;F++){var N=I[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&&(A().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var I,F,N;return I=w,(F=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=A().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(A().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(I.prototype,F),N&&Y(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Z(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function q(w,I,F){return I&&Z(w.prototype,I),F&&Z(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ie=q(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F.viewErrored=!1}),I.on("error",function(){try{var N=I.errorTranslator({player_error_code:I.data.player_error_code,player_error_message:I.data.player_error_message});N?(I.data.player_error_code=N.player_error_code,I.data.player_error_message=N.player_error_message,F.viewErrored=!0):(delete I.data.player_error_code,delete I.data.player_error_message)}catch(K){I.mux.log.warn("Exception in error translator callback.",K),F.viewErrored=!0}})});function ne(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&ne(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function te(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&te(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function de(w,I){for(var F=0;F<I.length;F++){var N=I[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 I,F,N;return I=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(I.prototype,F),N&&de(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Ee(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function me(w,I,F){return I&&Ee(w.prototype,I),F&&Ee(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Te=me(function w(I){if(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")}(this,w),!I.disableRebufferTracking){var F,N=function(){if(F){var K=I.data.viewer_time-F;t(I.data,"view_rebuffer_duration",K),F=I.data.viewer_time}I.data.view_watch_time>=0&&I.data.view_rebuffer_count>0&&(I.data.view_rebuffer_frequency=I.data.view_rebuffer_count/I.data.view_watch_time,I.data.view_rebuffer_percentage=I.data.view_rebuffer_duration/I.data.view_watch_time)};I.on("playbackheartbeat",function(){return N()}),I.on("rebufferstart",function(){F||(t(I.data,"view_rebuffer_count",1),F=I.data.viewer_time,I.one("rebufferend",function(){N(),F=void 0}))})}});function Me(w,I){for(var F=0;F<I.length;F++){var N=I[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){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:c.now()})}))}var I,F,N;return I=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(I.prototype,F),N&&Me(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}(),we=Ae;function Re(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ke=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||c.now(),Q):X.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||c.now(),Q)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var I,F,N;return I=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))}}])&&Re(I.prototype,F),N&&Re(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function _e(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Be(w,I,F){return I&&_e(w.prototype,I),F&&_e(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ke=Be(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("viewinit",function(){F._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){I.on(N,function(){if(F._lastPlayheadPosition>=0&&I.data.player_playhead_time>=0&&F._lastPlayerWidth>=0&&F._lastSourceWidth>0&&F._lastPlayerHeight>=0&&F._lastSourceHeight>0){var K=I.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);I.data.view_max_upscale_percentage=Math.max(I.data.view_max_upscale_percentage||0,H),I.data.view_max_downscale_percentage=Math.max(I.data.view_max_downscale_percentage||0,Q),t(I.data,"view_total_content_playback_time",K),t(I.data,"view_total_upscaling",H*K),t(I.data,"view_total_downscaling",Q*K)}F._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){I.on(N,function(){F._lastPlayheadPosition=I.data.player_playhead_time,F._lastPlayerWidth=I.data.player_width,F._lastPlayerHeight=I.data.player_height,F._lastSourceWidth=I.data.video_source_width,F._lastSourceHeight=I.data.video_source_height})})});function We(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ue(w,I,F){return I&&We(w.prototype,I),F&&We(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ze=Ue(function w(I){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,I.on("seeking",function(N,K){i()(I.data,K),F._lastSeekingTime=c.now(),F.isSeeking===!1&&(F.isSeeking=!0,I.send("seeking"))}),I.on("seeked",function(){F.isSeeking=!1;var N=F._lastSeekingTime||c.now(),K=c.now()-N;t(I.data,"view_seek_count",1),t(I.data,"view_seek_duration",K);var V=I.data.view_max_seek_time||0;I.data.view_max_seek_time=Math.max(V,K)}),I.on("viewend",function(){F.isSeeking=!1})});function Ce(w,I){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,I)||function(F,N){if(F){if(typeof F=="string")return qe(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)?qe(F,N):void 0}}(w,I)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function qe(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}function Oe(w,I){for(var F=0;F<I.length;F++){var N=I[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,I){w.push(I),w.sort(function(F,N){return F.viewer_time-N.viewer_time})},Ve=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ie=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 I,F,N;return I=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=Ce(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=Ce(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(I.prototype,F),N&&Oe(I,N),Object.defineProperty(I,"prototype",{writable:!1}),w}();function Le(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function rt(w,I,F){return I&&Le(w.prototype,I),F&&Le(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var je=rt(function w(I){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(){I.disableRebufferTracking||F&&(t(I.data,"view_waiting_rebuffer_duration",c.now()-F),F=!1,A().clearInterval(N))},V=!1,H=function(){V=!1,K()};I.on("waiting",function(){V&&(I.disableRebufferTracking||(t(I.data,"view_waiting_rebuffer_count",1),F=c.now(),N=A().setInterval(function(){if(F){var Q=c.now();t(I.data,"view_waiting_rebuffer_duration",Q-F),F=Q}},250)))}),I.on("playing",function(){K(),V=!0}),I.on("pause",H),I.on("seeking",H)});function st(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function vt(w,I,F){return I&&st(w.prototype,I),F&&st(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ze=vt(function w(I){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=c.now(),I.on("before*",K)},K=function(V){var H=c.now(),Q=F.lastWallClockTime;F.lastWallClockTime=H,H-Q>3e4&&(I.emit("devicesleep",{viewer_time:Q}),i()(I.data,{viewer_time:Q}),I.send("devicesleep"),I.emit("devicewake",{viewer_time:H}),i()(I.data,{viewer_time:H}),I.send("devicewake"))};I.one("playbackheartbeat",N),I.on("playbackheartbeatend",function(){I.off("before*",K),I.one("playbackheartbeat",N)})}),xt=b(375),gt=b(655),it=b.n(gt),ot="muxData",nt=function(){var w;try{w=xt.parse(it().get(ot)||"")}catch{w={}}return w},mt=function(w){try{it().set(ot,xt.stringify(w),{expires:7300})}catch{}},ct=function(){var w=nt();return w.mux_viewer_id=w.mux_viewer_id||y(),w.msn=w.msn||Math.random(),mt(w),{mux_viewer_id:w.mux_viewer_id,mux_sample_number:w.msn}};function Xt(w,I){var F=I.beaconCollectionDomain,N=I.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 bt=function(){var w;switch(St()){case"cellular":w="cellular";break;case"ethernet":w="wired";break;case"wifi":w="wifi";break;case void 0:break;default:w="other"}return w},St=function(){var w=A().navigator,I=w&&(w.connection||w.mozConnection||w.webkitConnection);return I&&I.type};bt.getConnectionFromAPI=St;var Xe=bt,kt=Bt({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"}),Rt=Bt({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 Bt(w){var I={};for(var F in w)w.hasOwnProperty(F)&&(I[w[F]]=F);return I}function Pt(w){var I={},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=kt[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),Rt[J]?Q+=Rt[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]:I[Q]=w[N]}}),i()(I,F)}var Qt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},$t=["hb","requestcompleted","requestfailed","requestcanceled"],at=function(w,I){this._beaconUrl=w||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},Qt,I)};at.prototype.queueEvent=function(w,I){var F=i()({},I);return(this._eventQueue.length<=this._options.maxQueueLength||w==="eventrateexceeded")&&(this._eventQueue.push(F),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},at.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},at.prototype.destroy=function(){var w=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,w?this._clearBeaconQueue():this.flushEvents(),A().clearTimeout(this._sendTimeout)},at.prototype._clearBeaconQueue=function(){var w=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,I=this._eventQueue.slice(w);w>0&&i()(I[I.length-1],Pt({mux_view_message:"event queue truncated"}));var F=this._createPayload(I);Dt(this._beaconUrl,F,!0,function(){})},at.prototype._sendBeaconQueue=function(){var w=this;if(!this._postInFlight){var I=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var F=this._createPayload(I),N=c.now();Dt(this._beaconUrl,F,!1,function(K,V){V?(w._eventQueue=I.concat(w._eventQueue),w._failureCount+=1,e.info("Error sending beacon: "+V)):w._failureCount=0,w._roundTripTime=c.now()-N,w._postInFlight=!1})}},at.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},at.prototype._startBeaconSending=function(){var w=this;A().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=A().setTimeout(function(){w._eventQueue.length&&w._sendBeaconQueue(),w._startBeaconSending()},this._getNextBeaconTime()))},at.prototype._createPayload=function(w){var I,F,N,K=this,V={transmission_timestamp:Math.round(c.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){I=JSON.stringify({metadata:V,events:F||w}),N=I.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 $t.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()),I};var Dt=function(w,I,F,N){if(F&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(w,I))N();else if(A().fetch)A().fetch(w,{method:"POST",body:I,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(A().XMLHttpRequest){var K=new(A()).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(I)}N()}},Ut=at;function pt(w){return pt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},pt(w)}var Jt=["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"],jr=["viewstart","error","ended","viewend"],Nt=function(w,I){var F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=w,this.envKey=I,this.eventQueue=new Ut(Xt(I,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=Xe();K&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:K})),A()!==void 0&&A().location&&A().location.href&&(this.pageLevelData.page_url=A().location.href),this.viewerData=this.disableCookies?{}:ct()};Nt.prototype.send=function(w,I){if(w){if(this.respectDoNotTrack&&s())return e.info("Not sending `"+w+"` because Do Not Track is enabled");if(!I||pt(I)!=="object")return e.error("A data object was expected in send() but was not provided");var F,N,K=this.disableCookies?{}:(F=nt(),N=c.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,mt(F),{session_id:F.sid,session_start:F.sst,session_expires:F.sex}),V={};i()(V,this.pageLevelData),i()(V,I),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=Pt(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((jr.indexOf(w)>=0||this.mux.WINDOW_HIDDEN&&w==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",Q=Pt(V),this.eventQueue.queueEvent(V.event,Q),e.error("Beaconing disabled due to rate limit.")}}},Nt.prototype.destroy=function(){this.eventQueue.destroy(!1)},Nt.prototype._deduplicateBeaconData=function(w,I){var F=this,N={},K=I.view_id;if(!K||w==="viewstart"||w==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},I),K&&(this.previousBeaconData=N),K&&w==="viewend"&&(this.previousBeaconData=null);else{var V=w.indexOf("request")===0;Object.keys(I).forEach(function(H){var Q=I[H];(Q!==F.previousBeaconData[H]||Jt.indexOf(H)>-1||function(J,X,ee,ce){return!(!J||X.indexOf("request_")!==0||X!=="request_response_headers"&&pt(ee)==="object"&&pt(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 Gr=Nt;function vr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Hr(w,I,F){return I&&vr(w.prototype,I),F&&vr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Vr=Hr(function w(I){(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;I.on("requestcompleted",function(X,ee){var ce,ye,ve=ee.request_start,se=ee.request_response_start,le=ee.request_response_end,xe=ee.request_bytes_loaded;if(V++,se?(ce=se-ve,ye=le-se):ye=le-ve,ye>0&&xe>0){var Ye=xe/ye*8e3;H++,N+=xe,K+=ye,I.data.view_min_request_throughput=Math.min(I.data.view_min_request_throughput||1/0,Ye),I.data.view_average_request_throughput=N/K*8e3,I.data.view_request_count=V,ce>0&&(F+=ce,I.data.view_max_request_latency=Math.max(I.data.view_max_request_latency||0,ce),I.data.view_average_request_latency=F/H)}}),I.on("requestfailed",function(X,ee){V++,Q++,I.data.view_request_count=V,I.data.view_request_failed_count=Q}),I.on("requestcanceled",function(X,ee){V++,J++,I.data.view_request_count=V,I.data.view_request_canceled_count=J})});function gr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Yr(w,I,F){return I&&gr(w.prototype,I),F&&gr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var zr=Yr(function w(I){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),I.on("before*",function(N,K){var V=K.viewer_time,H=c.now(),Q=F._lastEventTime;if(F._lastEventTime=H,Q&&H-Q>36e5){var J=Object.keys(I.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,I.data[ee])):X},{});I.mux.log.info("Received event after at least an hour inactivity, creating a new view"),I.emit("viewinit",i()({viewer_time:V},J)),I.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(I.emit("play",{viewer_time:V}),N.type!=="playing"&&I.emit("playing",{viewer_time:V}))}})});function Zt(w){return Zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},Zt(w)}function Xr(w,I){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,I)||function(F,N){if(F){if(typeof F=="string")return mr(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)?mr(F,N):void 0}}(w,I)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function mr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}function pr(w,I){for(var F=0;F<I.length;F++){var N=I[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function qt(w,I){return qt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(F,N){return F.__proto__=N,F},qt(w,I)}function Qr(w){var I=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=Kt(w);if(I){var K=Kt(this).constructor;F=Reflect.construct(N,arguments,K)}else F=N.apply(this,arguments);return $r(this,F)}}function $r(w,I){if(I&&(Zt(I)==="object"||typeof I=="function"))return I;if(I!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fe(w)}function Fe(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}function Kt(w){return Kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(I){return I.__proto__||Object.getPrototypeOf(I)},Kt(w)}var Jr=["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"],Zr=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&&qt(H,Q)})(V,w);var I,F,N,K=Qr(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=d.domContentLoadedEventEnd(),X.NAVIGATION_START=d.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 Gr(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(Fe(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(Fe(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)}),Jr.forEach(function(se){X.on(se,function(le,xe){se.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,xe),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 zr(Fe(X)),X.errorTracker=new ie(Fe(X)),new ze(Fe(X)),X.seekingTracker=new Ze(Fe(X)),X.playheadTime=new re(Fe(X)),X.playbackHeartbeat=new $(Fe(X)),new Ke(Fe(X)),X.watchTimeTracker=new ae(Fe(X)),new fe(Fe(X)),X.adTracker=new Ie(Fe(X)),new we(Fe(X)),new Te(Fe(X)),new ke(Fe(X)),new je(Fe(X)),new Vr(Fe(X)),J.hlsjs&&X.addHLSJS(J),J.dashjs&&X.addDashJS(J),X.emit("viewinit",J.data),X}return I=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=Xr(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(d.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,be=oe.stats,De=oe.networkDetails,tt=oe.sessionData,Je={},lt={};he.forEach(function(dt,Ct){Je[Ct]={width:dt.width,height:dt.height,bitrate:dt.bitrate,attrs:dt.attrs}}),ue.forEach(function(dt,Ct){lt[Ct]={name:dt.name,language:dt.lang,bitrate:dt.bitrate}});var ut=x(be),ft=ut.bytesLoaded,He=ut.requestStart,ir=ut.responseStart,nr=ut.responseEnd;se("requestcompleted",h(h({},a(tt)),{},{request_event_type:pe,request_bytes_loaded:ft,request_start:He,request_response_start:ir,request_response_end:nr,request_type:"manifest",request_hostname:r(ge),request_response_headers:P(De),request_rendition_lists:{media:Je,audio:lt,video:{}}}))};X.on(ee.Events.MANIFEST_LOADED,le);var xe=function(pe,oe){var he=oe.details,ue=oe.level,ge=oe.networkDetails,be=oe.stats,De=x(be),tt=De.bytesLoaded,Je=De.requestStart,lt=De.responseStart,ut=De.responseEnd,ft=he.fragments[he.fragments.length-1],He=ve(ft)+ye(ft.duration);se("requestcompleted",{request_event_type:pe,request_bytes_loaded:tt,request_start:Je,request_response_start:lt,request_response_end:ut,request_current_level:ue,request_type:"manifest",request_hostname:r(he.url),request_response_headers:P(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,xe);var Ye=function(pe,oe){var he=oe.details,ue=oe.networkDetails,ge=oe.stats,be=x(ge),De=be.bytesLoaded,tt=be.requestStart,Je=be.responseStart,lt=be.responseEnd;se("requestcompleted",{request_event_type:pe,request_bytes_loaded:De,request_start:tt,request_response_start:Je,request_response_end:lt,request_type:"manifest",request_hostname:r(he.url),request_response_headers:P(ue)})};X.on(ee.Events.AUDIO_TRACK_LOADED,Ye);var Qe=function(pe,oe){var he=oe.stats,ue=oe.networkDetails,ge=oe.frag;he=he||ge.stats;var be=x(he),De={request_event_type:pe,request_bytes_loaded:be.bytesLoaded,request_start:be.requestStart,request_response_start:be.responseStart,request_response_end:be.responseEnd,request_hostname:ue?r(ue.responseURL):void 0,request_response_headers:P(ue),request_media_duration:ge.duration};ge.type==="main"?(De.request_type="media",De.request_current_level=ge.level,De.request_video_width=(X.levels[ge.level]||{}).width,De.request_video_height=(X.levels[ge.level]||{}).height):De.request_type=ge.type,se("requestcompleted",De)};X.on(ee.Events.FRAG_LOADED,Qe);var Et=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,Et);var Se=function(pe,oe){var he=oe.type,ue=oe.details,ge=oe.response,be=oe.fatal,De=oe.context,tt=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 Je=tt&&tt.url||De&&De.url||"";se("requestfailed",{request_error:ue,request_url:Je,request_hostname:r(Je),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})}be&&se("error",{player_error_code:he,player_error_message:ue})};X.on(ee.Events.ERROR,Se);var $e=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,$e);var Ge=function(pe,oe){var he=oe.level,ue=X.levels[he];if(ue&&ue.attrs&&ue.attrs.BANDWIDTH){var ge,be=ue.attrs.BANDWIDTH,De=parseFloat(ue.attrs["FRAME-RATE"]);isNaN(De)||(ge=De),be?se("renditionchange",{video_source_fps:ge,video_source_bitrate:be,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,xe),X.off(ee.Events.AUDIO_TRACK_LOADED,Ye),X.off(ee.Events.FRAG_LOADED,Qe),X.off(ee.Events.FRAG_CHANGED,Et),X.off(ee.Events.ERROR,Se),X.off(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e),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(Se,$e){return Q.emit(J,Se,$e)},ye=function(Se){var $e=Se.type,Ge=(Se.data||{}).url;ce("requestcompleted",{request_event_type:$e,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(Se){var $e=Se.type,Ge=Se.fragmentModel,pe=(Se.chunk||{}).mediaInfo||{},oe=pe.type,he=pe.bitrateList,ue={};(he=he||[]).forEach(function(ft,He){ue[He]={},ue[He].width=ft.width,ue[He].height=ft.height,ue[He].bitrate=ft.bandwidth,ue[He].attrs={}}),oe==="video"?ve.video=ue:oe==="audio"?ve.audio=ue:ve.media=ue;var ge=k(Ge,X),be=ge.requestStart,De=ge.requestResponseStart,tt=ge.requestResponseEnd,Je=ge.requestResponseHeaders,lt=ge.requestMediaDuration,ut=ge.requestHostname;ce("requestcompleted",{request_event_type:$e,request_start:be,request_response_start:De,request_response_end:tt,request_bytes_loaded:-1,request_type:oe+"_init",request_response_headers:Je,request_hostname:ut,request_media_duration:lt,request_rendition_lists:ve})};X.on("initFragmentLoaded",se);var le=function(Se){var $e=Se.type,Ge=Se.fragmentModel,pe=Se.chunk||{},oe=pe.mediaInfo,he=pe.start,ue=(oe||{}).type,ge=k(Ge,X),be=ge.requestStart,De=ge.requestResponseStart,tt=ge.requestResponseEnd,Je=ge.requestBytesLoaded,lt=ge.requestResponseHeaders,ut=ge.requestMediaDuration,ft=ge.requestHostname,He=B(ue,X),ir=He.currentLevel,nr=He.renditionWidth,dt=He.renditionHeight,Ct=He.renditionBitrate;ce("requestcompleted",{request_event_type:$e,request_start:be,request_response_start:De,request_response_end:tt,request_bytes_loaded:Je,request_type:ue,request_response_headers:lt,request_hostname:ft,request_media_start_time:he,request_media_duration:ut,request_current_level:ir,request_labeled_bitrate:Ct,request_video_width:nr,request_video_height:dt})};X.on("mediaFragmentLoaded",le);var xe={video:void 0,audio:void 0,totalBitrate:void 0},Ye=function(){if(xe.video&&typeof xe.video.bitrate=="number"){if(xe.video.width&&xe.video.height){var Se=xe.video.bitrate;return xe.audio&&typeof xe.audio.bitrate=="number"&&(Se+=xe.audio.bitrate),Se!==xe.totalBitrate?(xe.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:xe.video.height,video_source_width:xe.video.width}):void 0}ee.warn("have bitrate info for video but missing width/height")}},Qe=function(Se,$e,Ge){if(typeof Se.newQuality=="number"){var pe=Se.mediaType;if(pe==="audio"||pe==="video"){var oe=X.getBitrateInfoListFor(pe).find(function(ue){return ue.qualityIndex===Se.newQuality});if(oe&&typeof oe.bitrate=="number"){xe[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",Se)};X.on("qualityChangeRendered",Qe);var Et=function(Se){var $e=Se.error,Ge=Se.event,pe=(Ge=Ge||{}).request||{},oe=A().event&&A().event.currentTarget||{};ce("requestfailed",{request_error:$e+"_"+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",Et),X._stopMuxMonitor=function(){X.off("manifestLoaded",ye),X.off("initFragmentLoaded",se),X.off("mediaFragmentLoaded",le),X.off("qualityChangeRendered",Qe),X.off("error",Et),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&&pr(I.prototype,F),N&&pr(I,N),Object.defineProperty(I,"prototype",{writable:!1}),V}(z),qr=Zr,ei=b(153),It=b.n(ei);function er(w){return er=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},er(w)}function Er(w,I){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,I)||function(F,N){if(F){if(typeof F=="string")return yr(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)?yr(F,N):void 0}}(w,I)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function yr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}var Lt,ti=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],ri={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};A()&&A().WeakMap&&(Lt=new WeakMap);var ii="#EXT-X-TARGETDURATION",ni="#EXT-X-PART-INF",ai="#EXT-X-SERVER-CONTROL",si="#EXTINF",oi="#EXT-X-PROGRAM-DATE-TIME",li="#EXT-X-VERSION",ui="#EXT-X-SESSION-DATA",Wt=function(w){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(w),this.manifest};Wt.prototype.process=function(w){var I;for(this.buffer+=w,I=this.buffer.indexOf(`
5
5
  `);I>-1;I=this.buffer.indexOf(`
6
6
  `))this.processLine(this.buffer.substring(0,I)),this.buffer=this.buffer.substring(I+1)},Wt.prototype.processLine=function(w){var I=w.indexOf(":"),F=hi(w,I),N=F[0],K=F.length===2?rr(F[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 ii:if(!isFinite(K)||K<0)return;this.manifest.targetDuration=K,this.setHoldBack();break;case ni:tr(this.manifest,F),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case ai:tr(this.manifest,F),this.setHoldBack();break;case si:K===0?this.currentUri.duration=.01:K>0&&(this.currentUri.duration=K);break;case oi:var V=K,H=new Date(V);this.manifest.dateTimeString||(this.manifest.dateTimeString=V,this.manifest.dateTimeObject=H),this.currentUri.dateTimeString=V,this.currentUri.dateTimeObject=H;break;case li:tr(this.manifest,F);break;case ui:var Q=vi(F[1]),J=a(Q);i()(this.manifest.sessionData,J)}},Wt.prototype.setHoldBack=function(){var w=this.manifest,I=w.serverControl,F=w.targetDuration,N=w.partTargetDuration;if(I){var K="holdBack",V="partHoldBack",H=F&&3*F,Q=N&&2*N;F&&!I.hasOwnProperty(K)&&(I[K]=H),H&&I[K]<H&&(I[K]=H),N&&!I.hasOwnProperty(V)&&(I[V]=3*N),N&&I[V]<Q&&(I[V]=Q)}};var tr=function(w,I){var F,N=Tr(I[0].replace("#EXT-X-",""));ci(I[1])?(F={},F=i()(di(I[1]),F)):F=rr(I[1]),w[N]=F},Tr=function(w){return w.toLowerCase().replace(/-(\w)/g,function(I){return I[1].toUpperCase()})},rr=function(w){if(w.toLowerCase()==="yes"||w.toLowerCase()==="no")return w.toLowerCase()==="yes";var I=w.indexOf(":")!==-1?w:parseFloat(w);return isNaN(I)?w:I},fi=function(w){var I={},F=w.split("=");return F.length>1&&(I[Tr(F[0])]=rr(F[1])),I},di=function(w){for(var I=w.split(","),F={},N=0;I.length>N;N++){var K=I[N],V=fi(K);F=i()(V,F)}return F},ci=function(w){return w.indexOf("=")>-1},hi=function(w,I){return I===-1?[w]:[w.substring(0,I),w.substring(I+1)]},vi=function(w){var I={};if(w){var F=w.search(",");return[w.slice(0,F),w.slice(F+1)].forEach(function(N,K){for(var V=N.replace(/['"]+/g,"").split("="),H=0;H<V.length;H++)V[H]==="DATA-ID"&&(I["DATA-ID"]=V[1-H]),V[H]==="VALUE"&&(I.VALUE=V[1-H])}),{data:I}}},gi=Wt,mi={safeCall:function(w,I,F,N){var K=N;if(w&&typeof w[I]=="function")try{K=w[I].apply(w,F)}catch(V){e.info("safeCall error",V)}return K},safeIncrement:t,getComputedStyle:function(w,I){var F;if(w&&I&&A()&&typeof A().getComputedStyle=="function")return Lt&&Lt.has(w)&&(F=Lt.get(w)),F||(F=A().getComputedStyle(w,null),Lt&&Lt.set(w,F)),F.getPropertyValue(I)},secondsToMs:function(w){return Math.floor(1e3*w)},assign:i(),headersStringToObject:l,extractHostnameAndDomain:o,extractHostname:r,manifestParser:gi,generateShortID:T,generateUUID:y,now:c.now},pi={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 Ei(w,I){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,I)||function(F,N){if(F){if(typeof F=="string")return xr(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)?xr(F,N):void 0}}(w,I)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function xr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}var et={},Mt=function w(I){var F=arguments;typeof I=="string"?w.hasOwnProperty(I)?A().setTimeout(function(){F=Array.prototype.splice.call(F,1),w[I].apply(null,F)},0):e.warn("`"+I+"` is an unknown task"):typeof I=="function"?A().setTimeout(function(){I(w)},0):e.warn("`"+I+"` is invalid.")},yi={loaded:c.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(w,I){return function(F,N,K){var V=Er(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:It()&&!!(It().fullscreenElement||It().webkitFullscreenElement||It().mozFullScreenElement||It().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},xe=K.getPlayheadTime();if(H.getStartDate&&xe>0){var Ye=H.getStartDate();if(Ye&&typeof Ye.getTime=="function"&&Ye.getTime()){var Qe=Ye.getTime();if(le.player_program_time=Qe+xe,H.seekable.length>0){var Et=Qe+H.seekable.end(H.seekable.length-1);le.player_live_edge_program_time=Et}}}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=Er(E(ve),3),le=se[0],xe=se[1],Ye=se[2];return le?Ye!=="video"&&Ye!=="audio"?F.log.error("The element of `"+xe+"` 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(Qe){H.removeEventListener(Qe,le.mux.listeners[Qe],!1),le.addEventListener(Qe,le.mux.listeners[Qe],!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 `"+xe+"` 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={},ti.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=ri[H.error.code]||H.error.message}F.emit(Q,ve,se)},H.addEventListener(ve,H.mux.listeners[ve],!1))})}(Mt,w,I)},destroyMonitor:function(w){var I=Ei(E(w),1)[0];I&&I.mux&&typeof I.mux.destroy=="function"?I.mux.destroy():e.error("A video element monitor for `"+w+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(w,I){var F=D(w);et[F]?et[F].addHLSJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},addDashJS:function(w,I){var F=D(w);et[F]?et[F].addDashJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},removeHLSJS:function(w){var I=D(w);et[I]?et[I].removeHLSJS():e.error("A monitor for `"+I+"` has not been initialized.")},removeDashJS:function(w){var I=D(w);et[I]?et[I].removeDashJS():e.error("A monitor for `"+I+"` has not been initialized.")},init:function(w,I){s()&&I&&I.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var F=D(w);et[F]=new qr(Mt,F,I)},emit:function(w,I,F){var N=D(w);et[N]?(et[N].emit(I,F),I==="destroy"&&delete et[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:mi,events:pi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Mt,yi),A()!==void 0&&typeof A().addEventListener=="function"&&A().addEventListener("pagehide",function(w){w.persisted||(Mt.WINDOW_UNLOADING=!0)},!1);var Ti=Mt},655:function(L,C,b){var O,A;function y(T){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(T);}(function(T){var D=!1;if((A=typeof(O=T)=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A),D=!0,y(C)==="object"&&(L.exports=T(),D=!0),!D){var E=window.Cookies,m=window.Cookies=T();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var T=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,u,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},m.defaults,e)).expires=="number"){var c=new Date;c.setMilliseconds(c.getMilliseconds()+864e5*e.expires),e.expires=c}try{s=JSON.stringify(u),/^[\{\[]/.test(s)&&(u=s)}catch{}return u=E.write?E.write(u,p):encodeURIComponent(String(u)).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,"=",u,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var v=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<v.length;r++){var o=v[r].split("="),d=o.slice(1).join("=");d.charAt(0)==='"'&&(d=d.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(d=E.read?E.read(d,t):E(d,t)||d.replace(i,decodeURIComponent),this.json)try{d=JSON.parse(d)}catch{}if(p===t){s=d;break}p||(s[t]=d)}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,u){m(p,"",T(u,{expires:-1}))},m.withConverter=D,m}(function(){})})},153:function(L,C,b){var O,A=b.g!==void 0?b.g:typeof window!="undefined"?window:{},y=b(558);typeof document!="undefined"?O=document:(O=A["__GLOBAL_DOCUMENT_CACHE@4"])||(O=A["__GLOBAL_DOCUMENT_CACHE@4"]=y),L.exports=O},48:function(L,C,b){var O;O=typeof window!="undefined"?window:b.g!==void 0?b.g:typeof self!="undefined"?self:{},L.exports=O},678:function(L){var C=9007199254740991,b="[object Arguments]",O="[object Function]",A="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function T(S,x,P){switch(P.length){case 0:return S.call(x);case 1:return S.call(x,P[0]);case 2:return S.call(x,P[0],P[1]);case 3:return S.call(x,P[0],P[1],P[2])}return S.apply(x,P)}var D,E,m=Object.prototype,p=m.hasOwnProperty,u=m.toString,e=m.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),c=Math.max,v=!e.call({valueOf:1},"valueOf");function i(S,x){var P=n(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&l(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||u.call(W)==b)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],k=P.length,B=!!k;for(var U in S)!x&&!p.call(S,U)||B&&(U=="length"||o(U,k))||P.push(U);return P}function r(S,x,P){var k=S[x];p.call(S,x)&&t(k,P)&&(P!==void 0||x in S)||(S[x]=P)}function o(S,x){return!!(x=x==null?C:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function d(S){var x=S&&S.constructor;return S===(typeof x=="function"&&x.prototype||m)}function t(S,x){return S===x||S!=S&&x!=x}var n=Array.isArray;function l(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=C}(S.length)&&!function(x){var P=a(x)?u.call(x):"";return P==O||P==A}(S)}function a(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var f,h=(f=function(S,x){if(v||d(x)||l(x))(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]:$)}})(x,function(k){return l(k)?i(k):function(B){if(!d(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(x),S);else for(var P in x)p.call(x,P)&&r(S,P,x[P])},function(S,x){return x=c(x===void 0?S.length-1:x,0),function(){for(var P=arguments,k=-1,B=c(P.length-x,0),U=Array(B);++k<B;)U[k]=P[x+k];k=-1;for(var W=Array(x+1);++k<x;)W[k]=P[k];return W[x]=U,T(S,this,W)}}(function(S,x){var P=-1,k=x.length,B=k>1?x[k-1]:void 0,U=k>2?x[2]:void 0;for(B=f.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(G,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?l(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],G)}(x[0],x[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++P<k;){var W=x[P];W&&f(S,W,P,B)}return S}));L.exports=h},640:function(L,C,b){var O,A;(function(y,T){"use strict";O=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 u(n,l){var a=n[l];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?u(console,n):console.log!==void 0?u(console,"log"):D)}function c(n,l){for(var a=0;a<p.length;a++){var f=p[a];this[f]=a<n?D:this.methodFactory(f,n,l)}this.log=this.debug}function v(n,l,a){return function(){typeof console!==E&&(c.call(this,l,a),this[n].apply(this,arguments))}}function i(n,l,a){return s(n)||v.apply(this,arguments)}function r(n,l,a){var f,h=this;l=l==null?"WARN":l;var S="loglevel";function x(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 P(){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 h.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),h.name=n,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=a||i,h.getLevel=function(){return f},h.setLevel=function(U,W){if(typeof U=="string"&&h.levels[U.toUpperCase()]!==void 0&&(U=h.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=h.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(f=U,W!==!1&&x(U),c.call(h,U,n),typeof console===E&&U<h.levels.SILENT)return"No console available for logging"},h.setDefaultLevel=function(U){l=U,P()||h.setLevel(U,!1)},h.resetLevel=function(){h.setLevel(l,!1),k()},h.enableAll=function(U){h.setLevel(h.levels.TRACE,U)},h.disableAll=function(U){h.setLevel(h.levels.SILENT,U)};var B=P();B==null&&(B=l),h.setLevel(B,!1)}var o=new r,d={};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 l=d[n];return l||(l=d[n]=new r(n,o.getLevel(),o.methodFactory)),l};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 d},o.default=o,o},(A=typeof O=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A)})()},375:function(L,C){"use strict";var b=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function A(y){try{return encodeURIComponent(y)}catch{return null}}C.stringify=function(y,T){T=T||"";var D,E,m=[];for(E in typeof T!="string"&&(T="?"),y)if(b.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=A(E),D=A(D),E===null||D===null)continue;m.push(E+"="+D)}return m.length?T+m.join("&"):""},C.parse=function(y){for(var T,D=/([^=?#&]+)=?([^&]*)/g,E={};T=D.exec(y);){var m=O(T[1]),p=O(T[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},M={};function _(L){var C=M[L];if(C!==void 0)return C.exports;var b=M[L]={exports:{}};return g[L].call(b.exports,b,b.exports,_),b.exports}return _.n=function(L){var C=L&&L.__esModule?function(){return L.default}:function(){return L};return _.d(C,{a:C}),C},_.d=function(L,C){for(var b in C)_.o(C,b)&&!_.o(L,b)&&Object.defineProperty(L,b,{enumerable:!0,get:C[b]})},_.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),_.o=function(L,C){return Object.prototype.hasOwnProperty.call(L,C)},_(80)}()},typeof Gt=="object"&&typeof ar=="object"?ar.exports=R():typeof Gt=="object"?Gt.mux=R():j.mux=R()})()});var Ht=Dr((Ft,sr)=>{typeof window!="undefined"&&function(R,g){typeof Ft=="object"&&typeof sr=="object"?sr.exports=g():typeof define=="function"&&define.amd?define([],g):typeof Ft=="object"?Ft.Hls=g():R.Hls=g()}(Ft,function(){return function(j){var R={};function g(M){if(R[M])return R[M].exports;var _=R[M]={i:M,l:!1,exports:{}};return j[M].call(_.exports,_,_.exports,g),_.l=!0,_.exports}return g.m=j,g.c=R,g.d=function(M,_,L){g.o(M,_)||Object.defineProperty(M,_,{enumerable:!0,get:L})},g.r=function(M){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},g.t=function(M,_){if(_&1&&(M=g(M)),_&8||_&4&&typeof M=="object"&&M&&M.__esModule)return M;var L=Object.create(null);if(g.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:M}),_&2&&typeof M!="string")for(var C in M)g.d(L,C,function(b){return M[b]}.bind(null,C));return L},g.n=function(M){var _=M&&M.__esModule?function(){return M.default}:function(){return M};return g.d(_,"a",_),_},g.o=function(M,_){return Object.prototype.hasOwnProperty.call(M,_)},g.p="/dist/",g(g.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,g){"use strict";var M=Object.prototype.hasOwnProperty,_="~";function L(){}Object.create&&(L.prototype=Object.create(null),new L().__proto__||(_=!1));function C(y,T,D){this.fn=y,this.context=T,this.once=D||!1}function b(y,T,D,E,m){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new C(D,E||y,m),u=_?_+T:T;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],p]:y._events[u].push(p):(y._events[u]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new L:delete y._events[T]}function A(){this._events=new L,this._eventsCount=0}A.prototype.eventNames=function(){var T=[],D,E;if(this._eventsCount===0)return T;for(E in D=this._events)M.call(D,E)&&T.push(_?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(D)):T},A.prototype.listeners=function(T){var D=_?_+T:T,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,u=new Array(p);m<p;m++)u[m]=E[m].fn;return u},A.prototype.listenerCount=function(T){var D=_?_+T:T,E=this._events[D];return E?E.fn?1:E.length:0},A.prototype.emit=function(T,D,E,m,p,u){var e=_?_+T:T;if(!this._events[e])return!1;var s=this._events[e],c=arguments.length,v,i;if(s.fn){switch(s.once&&this.removeListener(T,s.fn,void 0,!0),c){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,u),!0}for(i=1,v=new Array(c-1);i<c;i++)v[i-1]=arguments[i];s.fn.apply(s.context,v)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(T,s[i].fn,void 0,!0),c){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(!v)for(o=1,v=new Array(c-1);o<c;o++)v[o-1]=arguments[o];s[i].fn.apply(s[i].context,v)}}return!0},A.prototype.on=function(T,D,E){return b(this,T,D,E,!1)},A.prototype.once=function(T,D,E){return b(this,T,D,E,!0)},A.prototype.removeListener=function(T,D,E,m){var p=_?_+T:T;if(!this._events[p])return this;if(!D)return O(this,p),this;var u=this._events[p];if(u.fn)u.fn===D&&(!m||u.once)&&(!E||u.context===E)&&O(this,p);else{for(var e=0,s=[],c=u.length;e<c;e++)(u[e].fn!==D||m&&!u[e].once||E&&u[e].context!==E)&&s.push(u[e]);s.length?this._events[p]=s.length===1?s[0]:s:O(this,p)}return this},A.prototype.removeAllListeners=function(T){var D;return T?(D=_?_+T:T,this._events[D]&&O(this,D)):(this._events=new L,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=_,A.EventEmitter=A,j.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,g){(function(M){var _=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,L=/^(?=([^\/?#]*))\1([^]*)$/,C=/(?:\/|^)\.(?=\/)/g,b=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(A,y,T){if(T=T||{},A=A.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return A;var D=O.parseURL(A);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}var E=O.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return T.alwaysNormalize?(E.path=O.normalizePath(E.path),O.buildURLFromParts(E)):y;var m=O.parseURL(A);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=L.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var u={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(u.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)u.path=m.path,E.params||(u.params=m.params,E.query||(u.query=m.query));else{var e=m.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;u.path=O.normalizePath(s)}return u.path===null&&(u.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(u)},parseURL:function(A){var y=_.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(C,"");A.length!==(A=A.replace(b,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};j.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,g){function M(T){var D={};function E(p){if(D[p])return D[p].exports;var u=D[p]={i:p,l:!1,exports:{}};return T[p].call(u.exports,u,u.exports,E),u.l=!0,u.exports}E.m=T,E.c=D,E.i=function(p){return p},E.d=function(p,u,e){E.o(p,u)||Object.defineProperty(p,u,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var u=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(u,"a",u),u},E.o=function(p,u){return Object.prototype.hasOwnProperty.call(p,u)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var _="[\\.|\\-|\\+|\\w|/|@]+",L="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+_+").*?\\)";function C(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(T){return!isNaN(1*T)}function O(T,D,E){var m={};m[E]=[];var p=D.toString(),u=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return m;for(var e=u[1],s=new RegExp("(\\\\n|\\W)"+C(e)+L,"g"),c;c=s.exec(p);)c[3]!=="dll-reference"&&m[E].push(c[3]);for(s=new RegExp("\\("+C(e)+'\\("(dll-reference\\s('+_+'))"\\)\\)'+L,"g");c=s.exec(p);)T[c[2]]||(m[E].push(c[1]),T[c[2]]=g(c[1]).m),m[c[2]]=m[c[2]]||[],m[c[2]].push(c[4]);for(var v=Object.keys(m),i=0;i<v.length;i++)for(var r=0;r<m[v[i]].length;r++)b(m[v[i]][r])&&(m[v[i]][r]=1*m[v[i]][r]);return m}function A(T){var D=Object.keys(T);return D.reduce(function(E,m){return E||T[m].length>0},!1)}function y(T,D){for(var E={main:[D]},m={main:[]},p={main:{}};A(E);)for(var u=Object.keys(E),e=0;e<u.length;e++){var s=u[e],c=E[s],v=c.pop();if(p[s]=p[s]||{},!(p[s][v]||!T[s][v])){p[s][v]=!0,m[s]=m[s]||[],m[s].push(v);for(var i=O(T,T[s][v],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(T,D){D=D||{};var E={main:g.m},m=D.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(m).filter(function(v){return v!=="main"}).forEach(function(v){for(var i=0;m[v][i];)i++;m[v].push(i),E[v][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+v+" = ("+M.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[v].map(function(r){return""+JSON.stringify(r)+": "+E[v][r].toString()}).join(",")+`});
8
- `}),p=p+"new (("+M.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+m.main.map(function(v){return""+JSON.stringify(v)+": "+E.main[v].toString()}).join(",")+"}))(self);";var u=new window.Blob([p],{type:"text/javascript"});if(D.bare)return u;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(u),c=new window.Worker(s);return c.objectURL=s,c}},"./src/config.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"hlsDefaultConfig",function(){return o}),g.d(R,"mergeConfig",function(){return t}),g.d(R,"enableStreamingMode",function(){return n});var M=g("./src/controller/abr-controller.ts"),_=g("./src/controller/audio-stream-controller.ts"),L=g("./src/controller/audio-track-controller.ts"),C=g("./src/controller/subtitle-stream-controller.ts"),b=g("./src/controller/subtitle-track-controller.ts"),O=g("./src/controller/buffer-controller.ts"),A=g("./src/controller/timeline-controller.ts"),y=g("./src/controller/cap-level-controller.ts"),T=g("./src/controller/fps-controller.ts"),D=g("./src/controller/eme-controller.ts"),E=g("./src/controller/cmcd-controller.ts"),m=g("./src/utils/xhr-loader.ts"),p=g("./src/utils/fetch-loader.ts"),u=g("./src/utils/cues.ts"),e=g("./src/utils/mediakeys-helper.ts"),s=g("./src/utils/logger.ts");function c(){return c=Object.assign?Object.assign.bind():function(l){for(var a=1;a<arguments.length;a++){var f=arguments[a];for(var h in f)Object.prototype.hasOwnProperty.call(f,h)&&(l[h]=f[h])}return l},c.apply(this,arguments)}function v(l,a){var f=Object.keys(l);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(l);a&&(h=h.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),f.push.apply(f,h)}return f}function i(l){for(var a=1;a<arguments.length;a++){var f=arguments[a]!=null?arguments[a]:{};a%2?v(Object(f),!0).forEach(function(h){r(l,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(f)):v(Object(f)).forEach(function(h){Object.defineProperty(l,h,Object.getOwnPropertyDescriptor(f,h))})}return l}function r(l,a,f){return a in l?Object.defineProperty(l,a,{value:f,enumerable:!0,configurable:!0,writable:!0}):l[a]=f,l}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:M.default,bufferController:O.default,capLevelController:y.default,fpsController:T.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},d()),{},{subtitleStreamController:C.SubtitleStreamController,subtitleTrackController:b.default,timelineController:A.TimelineController,audioStreamController:_.default,audioTrackController:L.default,emeController:D.default,cmcdController:E.default});function d(){return{cueHandler:u.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(l,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 c({},l,a)}function n(l){var a=l.loader;if(a!==p.default&&a!==m.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var f=Object(p.fetchSupported)();f&&(l.loader=p.default,l.progressive=!0,l.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/utils/ewma-bandwidth-estimator.ts"),L=g("./src/events.ts"),C=g("./src/utils/buffer-helper.ts"),b=g("./src/errors.ts"),O=g("./src/types/loader.ts"),A=g("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var u=m[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function T(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 u=p.config;this.bwEstimator=new _.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var u=this.hls;u.on(L.Events.FRAG_LOADING,this.onFragLoading,this),u.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(L.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var u=this.hls;u.off(L.Events.FRAG_LOADING,this.onFragLoading,this),u.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(L.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(u,e){var s=e.frag;if(s.type===O.PlaylistLevelType.MAIN&&!this.timer){var c;this.fragCurrent=s,this.partCurrent=(c=e.part)!=null?c:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(u,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 u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.autoLevelEnabled,v=s.config,i=s.media;if(!(!u||!i)){var r=e?e.stats:u.stats,o=e?e.duration:u.duration;if(r.aborted){A.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!c||i.paused||!i.playbackRate||!i.readyState)){var d=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(d<=500*o/t)){var n=s.levels,l=s.minAutoLevel,a=n[u.level],f=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),h=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/d),S=(f-r.loaded)/h,x=i.currentTime,P=(C.BufferHelper.bufferInfo(i,x,v.maxBufferHole).end-x)/t;if(!(P>=2*o/t||S<=P)){var k=Number.POSITIVE_INFINITY,B;for(B=u.level-1;B>l;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*h),k<P)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();A.logger.warn("Fragment "+u.sn+(e?" part "+e.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
7
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function xr(w,I){(I==null||I>w.length)&&(I=w.length);for(var F=0,N=new Array(I);F<I;F++)N[F]=w[F];return N}var et={},Mt=function w(I){var F=arguments;typeof I=="string"?w.hasOwnProperty(I)?A().setTimeout(function(){F=Array.prototype.splice.call(F,1),w[I].apply(null,F)},0):e.warn("`"+I+"` is an unknown task"):typeof I=="function"?A().setTimeout(function(){I(w)},0):e.warn("`"+I+"` is invalid.")},yi={loaded:c.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(w,I){return function(F,N,K){var V=Er(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:It()&&!!(It().fullscreenElement||It().webkitFullscreenElement||It().mozFullScreenElement||It().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},xe=K.getPlayheadTime();if(H.getStartDate&&xe>0){var Ye=H.getStartDate();if(Ye&&typeof Ye.getTime=="function"&&Ye.getTime()){var Qe=Ye.getTime();if(le.player_program_time=Qe+xe,H.seekable.length>0){var Et=Qe+H.seekable.end(H.seekable.length-1);le.player_live_edge_program_time=Et}}}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=Er(E(ve),3),le=se[0],xe=se[1],Ye=se[2];return le?Ye!=="video"&&Ye!=="audio"?F.log.error("The element of `"+xe+"` 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(Qe){H.removeEventListener(Qe,le.mux.listeners[Qe],!1),le.addEventListener(Qe,le.mux.listeners[Qe],!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 `"+xe+"` 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={},ti.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=ri[H.error.code]||H.error.message}F.emit(Q,ve,se)},H.addEventListener(ve,H.mux.listeners[ve],!1))})}(Mt,w,I)},destroyMonitor:function(w){var I=Ei(E(w),1)[0];I&&I.mux&&typeof I.mux.destroy=="function"?I.mux.destroy():e.error("A video element monitor for `"+w+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(w,I){var F=D(w);et[F]?et[F].addHLSJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},addDashJS:function(w,I){var F=D(w);et[F]?et[F].addDashJS(I):e.error("A monitor for `"+F+"` has not been initialized.")},removeHLSJS:function(w){var I=D(w);et[I]?et[I].removeHLSJS():e.error("A monitor for `"+I+"` has not been initialized.")},removeDashJS:function(w){var I=D(w);et[I]?et[I].removeDashJS():e.error("A monitor for `"+I+"` has not been initialized.")},init:function(w,I){s()&&I&&I.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var F=D(w);et[F]=new qr(Mt,F,I)},emit:function(w,I,F){var N=D(w);et[N]?(et[N].emit(I,F),I==="destroy"&&delete et[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:mi,events:pi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Mt,yi),A()!==void 0&&typeof A().addEventListener=="function"&&A().addEventListener("pagehide",function(w){w.persisted||(Mt.WINDOW_UNLOADING=!0)},!1);var Ti=Mt},655:function(L,C,b){var O,A;function y(T){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(T);}(function(T){var D=!1;if((A=typeof(O=T)=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A),D=!0,y(C)==="object"&&(L.exports=T(),D=!0),!D){var E=window.Cookies,g=window.Cookies=T();g.noConflict=function(){return window.Cookies=E,g}}})(function(){var T=function(){for(var D=0,E={};D<arguments.length;D++){var g=arguments[D];for(var p in g)E[p]=g[p]}return E};return function D(E){function g(p,u,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},g.defaults,e)).expires=="number"){var c=new Date;c.setMilliseconds(c.getMilliseconds()+864e5*e.expires),e.expires=c}try{s=JSON.stringify(u),/^[\{\[]/.test(s)&&(u=s)}catch{}return u=E.write?E.write(u,p):encodeURIComponent(String(u)).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,"=",u,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var v=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<v.length;r++){var o=v[r].split("="),d=o.slice(1).join("=");d.charAt(0)==='"'&&(d=d.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(d=E.read?E.read(d,t):E(d,t)||d.replace(i,decodeURIComponent),this.json)try{d=JSON.parse(d)}catch{}if(p===t){s=d;break}p||(s[t]=d)}catch{}}return s}}return g.set=g,g.get=function(p){return g.call(g,p)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(p,u){g(p,"",T(u,{expires:-1}))},g.withConverter=D,g}(function(){})})},153:function(L,C,b){var O,A=b.g!==void 0?b.g:typeof window!="undefined"?window:{},y=b(558);typeof document!="undefined"?O=document:(O=A["__GLOBAL_DOCUMENT_CACHE@4"])||(O=A["__GLOBAL_DOCUMENT_CACHE@4"]=y),L.exports=O},48:function(L,C,b){var O;O=typeof window!="undefined"?window:b.g!==void 0?b.g:typeof self!="undefined"?self:{},L.exports=O},678:function(L){var C=9007199254740991,b="[object Arguments]",O="[object Function]",A="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function T(S,x,P){switch(P.length){case 0:return S.call(x);case 1:return S.call(x,P[0]);case 2:return S.call(x,P[0],P[1]);case 3:return S.call(x,P[0],P[1],P[2])}return S.apply(x,P)}var D,E,g=Object.prototype,p=g.hasOwnProperty,u=g.toString,e=g.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),c=Math.max,v=!e.call({valueOf:1},"valueOf");function i(S,x){var P=n(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&l(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||u.call(W)==b)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],k=P.length,B=!!k;for(var U in S)!x&&!p.call(S,U)||B&&(U=="length"||o(U,k))||P.push(U);return P}function r(S,x,P){var k=S[x];p.call(S,x)&&t(k,P)&&(P!==void 0||x in S)||(S[x]=P)}function o(S,x){return!!(x=x==null?C:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function d(S){var x=S&&S.constructor;return S===(typeof x=="function"&&x.prototype||g)}function t(S,x){return S===x||S!=S&&x!=x}var n=Array.isArray;function l(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=C}(S.length)&&!function(x){var P=a(x)?u.call(x):"";return P==O||P==A}(S)}function a(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var f,h=(f=function(S,x){if(v||d(x)||l(x))(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]:$)}})(x,function(k){return l(k)?i(k):function(B){if(!d(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(x),S);else for(var P in x)p.call(x,P)&&r(S,P,x[P])},function(S,x){return x=c(x===void 0?S.length-1:x,0),function(){for(var P=arguments,k=-1,B=c(P.length-x,0),U=Array(B);++k<B;)U[k]=P[x+k];k=-1;for(var W=Array(x+1);++k<x;)W[k]=P[k];return W[x]=U,T(S,this,W)}}(function(S,x){var P=-1,k=x.length,B=k>1?x[k-1]:void 0,U=k>2?x[2]:void 0;for(B=f.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(G,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?l(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],G)}(x[0],x[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++P<k;){var W=x[P];W&&f(S,W,P,B)}return S}));L.exports=h},640:function(L,C,b){var O,A;(function(y,T){"use strict";O=function(){var D=function(){},E="undefined",g=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function u(n,l){var a=n[l];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"&&g?e:console[n]!==void 0?u(console,n):console.log!==void 0?u(console,"log"):D)}function c(n,l){for(var a=0;a<p.length;a++){var f=p[a];this[f]=a<n?D:this.methodFactory(f,n,l)}this.log=this.debug}function v(n,l,a){return function(){typeof console!==E&&(c.call(this,l,a),this[n].apply(this,arguments))}}function i(n,l,a){return s(n)||v.apply(this,arguments)}function r(n,l,a){var f,h=this;l=l==null?"WARN":l;var S="loglevel";function x(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 P(){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 h.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),h.name=n,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=a||i,h.getLevel=function(){return f},h.setLevel=function(U,W){if(typeof U=="string"&&h.levels[U.toUpperCase()]!==void 0&&(U=h.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=h.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(f=U,W!==!1&&x(U),c.call(h,U,n),typeof console===E&&U<h.levels.SILENT)return"No console available for logging"},h.setDefaultLevel=function(U){l=U,P()||h.setLevel(U,!1)},h.resetLevel=function(){h.setLevel(l,!1),k()},h.enableAll=function(U){h.setLevel(h.levels.TRACE,U)},h.disableAll=function(U){h.setLevel(h.levels.SILENT,U)};var B=P();B==null&&(B=l),h.setLevel(B,!1)}var o=new r,d={};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 l=d[n];return l||(l=d[n]=new r(n,o.getLevel(),o.methodFactory)),l};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 d},o.default=o,o},(A=typeof O=="function"?O.call(C,b,C,L):O)===void 0||(L.exports=A)})()},375:function(L,C){"use strict";var b=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function A(y){try{return encodeURIComponent(y)}catch{return null}}C.stringify=function(y,T){T=T||"";var D,E,g=[];for(E in typeof T!="string"&&(T="?"),y)if(b.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=A(E),D=A(D),E===null||D===null)continue;g.push(E+"="+D)}return g.length?T+g.join("&"):""},C.parse=function(y){for(var T,D=/([^=?#&]+)=?([^&]*)/g,E={};T=D.exec(y);){var g=O(T[1]),p=O(T[2]);g===null||p===null||g in E||(E[g]=p)}return E}},558:function(){}},M={};function _(L){var C=M[L];if(C!==void 0)return C.exports;var b=M[L]={exports:{}};return m[L].call(b.exports,b,b.exports,_),b.exports}return _.n=function(L){var C=L&&L.__esModule?function(){return L.default}:function(){return L};return _.d(C,{a:C}),C},_.d=function(L,C){for(var b in C)_.o(C,b)&&!_.o(L,b)&&Object.defineProperty(L,b,{enumerable:!0,get:C[b]})},_.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),_.o=function(L,C){return Object.prototype.hasOwnProperty.call(L,C)},_(80)}()},typeof Gt=="object"&&typeof ar=="object"?ar.exports=R():typeof Gt=="object"?Gt.mux=R():j.mux=R()})()});var Ht=Dr((Ft,sr)=>{typeof window!="undefined"&&function(R,m){typeof Ft=="object"&&typeof sr=="object"?sr.exports=m():typeof define=="function"&&define.amd?define([],m):typeof Ft=="object"?Ft.Hls=m():R.Hls=m()}(Ft,function(){return function(j){var R={};function m(M){if(R[M])return R[M].exports;var _=R[M]={i:M,l:!1,exports:{}};return j[M].call(_.exports,_,_.exports,m),_.l=!0,_.exports}return m.m=j,m.c=R,m.d=function(M,_,L){m.o(M,_)||Object.defineProperty(M,_,{enumerable:!0,get:L})},m.r=function(M){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},m.t=function(M,_){if(_&1&&(M=m(M)),_&8||_&4&&typeof M=="object"&&M&&M.__esModule)return M;var L=Object.create(null);if(m.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:M}),_&2&&typeof M!="string")for(var C in M)m.d(L,C,function(b){return M[b]}.bind(null,C));return L},m.n=function(M){var _=M&&M.__esModule?function(){return M.default}:function(){return M};return m.d(_,"a",_),_},m.o=function(M,_){return Object.prototype.hasOwnProperty.call(M,_)},m.p="/dist/",m(m.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,m){"use strict";var M=Object.prototype.hasOwnProperty,_="~";function L(){}Object.create&&(L.prototype=Object.create(null),new L().__proto__||(_=!1));function C(y,T,D){this.fn=y,this.context=T,this.once=D||!1}function b(y,T,D,E,g){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new C(D,E||y,g),u=_?_+T:T;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],p]:y._events[u].push(p):(y._events[u]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new L:delete y._events[T]}function A(){this._events=new L,this._eventsCount=0}A.prototype.eventNames=function(){var T=[],D,E;if(this._eventsCount===0)return T;for(E in D=this._events)M.call(D,E)&&T.push(_?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(D)):T},A.prototype.listeners=function(T){var D=_?_+T:T,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var g=0,p=E.length,u=new Array(p);g<p;g++)u[g]=E[g].fn;return u},A.prototype.listenerCount=function(T){var D=_?_+T:T,E=this._events[D];return E?E.fn?1:E.length:0},A.prototype.emit=function(T,D,E,g,p,u){var e=_?_+T:T;if(!this._events[e])return!1;var s=this._events[e],c=arguments.length,v,i;if(s.fn){switch(s.once&&this.removeListener(T,s.fn,void 0,!0),c){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,g),!0;case 5:return s.fn.call(s.context,D,E,g,p),!0;case 6:return s.fn.call(s.context,D,E,g,p,u),!0}for(i=1,v=new Array(c-1);i<c;i++)v[i-1]=arguments[i];s.fn.apply(s.context,v)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(T,s[i].fn,void 0,!0),c){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,g);break;default:if(!v)for(o=1,v=new Array(c-1);o<c;o++)v[o-1]=arguments[o];s[i].fn.apply(s[i].context,v)}}return!0},A.prototype.on=function(T,D,E){return b(this,T,D,E,!1)},A.prototype.once=function(T,D,E){return b(this,T,D,E,!0)},A.prototype.removeListener=function(T,D,E,g){var p=_?_+T:T;if(!this._events[p])return this;if(!D)return O(this,p),this;var u=this._events[p];if(u.fn)u.fn===D&&(!g||u.once)&&(!E||u.context===E)&&O(this,p);else{for(var e=0,s=[],c=u.length;e<c;e++)(u[e].fn!==D||g&&!u[e].once||E&&u[e].context!==E)&&s.push(u[e]);s.length?this._events[p]=s.length===1?s[0]:s:O(this,p)}return this},A.prototype.removeAllListeners=function(T){var D;return T?(D=_?_+T:T,this._events[D]&&O(this,D)):(this._events=new L,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=_,A.EventEmitter=A,j.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,m){(function(M){var _=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,L=/^(?=([^\/?#]*))\1([^]*)$/,C=/(?:\/|^)\.(?=\/)/g,b=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(A,y,T){if(T=T||{},A=A.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return A;var D=O.parseURL(A);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}var E=O.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return T.alwaysNormalize?(E.path=O.normalizePath(E.path),O.buildURLFromParts(E)):y;var g=O.parseURL(A);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var p=L.exec(g.path);g.netLoc=p[1],g.path=p[2]}g.netLoc&&!g.path&&(g.path="/");var u={scheme:g.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(u.netLoc=g.netLoc,E.path[0]!=="/"))if(!E.path)u.path=g.path,E.params||(u.params=g.params,E.query||(u.query=g.query));else{var e=g.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;u.path=O.normalizePath(s)}return u.path===null&&(u.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(u)},parseURL:function(A){var y=_.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(C,"");A.length!==(A=A.replace(b,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};j.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,m){function M(T){var D={};function E(p){if(D[p])return D[p].exports;var u=D[p]={i:p,l:!1,exports:{}};return T[p].call(u.exports,u,u.exports,E),u.l=!0,u.exports}E.m=T,E.c=D,E.i=function(p){return p},E.d=function(p,u,e){E.o(p,u)||Object.defineProperty(p,u,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var u=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(u,"a",u),u},E.o=function(p,u){return Object.prototype.hasOwnProperty.call(p,u)},E.p="/",E.oe=function(p){throw console.error(p),p};var g=E(E.s=ENTRY_MODULE);return g.default||g}var _="[\\.|\\-|\\+|\\w|/|@]+",L="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+_+").*?\\)";function C(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(T){return!isNaN(1*T)}function O(T,D,E){var g={};g[E]=[];var p=D.toString(),u=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return g;for(var e=u[1],s=new RegExp("(\\\\n|\\W)"+C(e)+L,"g"),c;c=s.exec(p);)c[3]!=="dll-reference"&&g[E].push(c[3]);for(s=new RegExp("\\("+C(e)+'\\("(dll-reference\\s('+_+'))"\\)\\)'+L,"g");c=s.exec(p);)T[c[2]]||(g[E].push(c[1]),T[c[2]]=m(c[1]).m),g[c[2]]=g[c[2]]||[],g[c[2]].push(c[4]);for(var v=Object.keys(g),i=0;i<v.length;i++)for(var r=0;r<g[v[i]].length;r++)b(g[v[i]][r])&&(g[v[i]][r]=1*g[v[i]][r]);return g}function A(T){var D=Object.keys(T);return D.reduce(function(E,g){return E||T[g].length>0},!1)}function y(T,D){for(var E={main:[D]},g={main:[]},p={main:{}};A(E);)for(var u=Object.keys(E),e=0;e<u.length;e++){var s=u[e],c=E[s],v=c.pop();if(p[s]=p[s]||{},!(p[s][v]||!T[s][v])){p[s][v]=!0,g[s]=g[s]||[],g[s].push(v);for(var i=O(T,T[s][v],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 g}j.exports=function(T,D){D=D||{};var E={main:m.m},g=D.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(g).filter(function(v){return v!=="main"}).forEach(function(v){for(var i=0;g[v][i];)i++;g[v].push(i),E[v][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+v+" = ("+M.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[v].map(function(r){return""+JSON.stringify(r)+": "+E[v][r].toString()}).join(",")+`});
8
+ `}),p=p+"new (("+M.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+g.main.map(function(v){return""+JSON.stringify(v)+": "+E.main[v].toString()}).join(",")+"}))(self);";var u=new window.Blob([p],{type:"text/javascript"});if(D.bare)return u;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(u),c=new window.Worker(s);return c.objectURL=s,c}},"./src/config.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"hlsDefaultConfig",function(){return o}),m.d(R,"mergeConfig",function(){return t}),m.d(R,"enableStreamingMode",function(){return n});var M=m("./src/controller/abr-controller.ts"),_=m("./src/controller/audio-stream-controller.ts"),L=m("./src/controller/audio-track-controller.ts"),C=m("./src/controller/subtitle-stream-controller.ts"),b=m("./src/controller/subtitle-track-controller.ts"),O=m("./src/controller/buffer-controller.ts"),A=m("./src/controller/timeline-controller.ts"),y=m("./src/controller/cap-level-controller.ts"),T=m("./src/controller/fps-controller.ts"),D=m("./src/controller/eme-controller.ts"),E=m("./src/controller/cmcd-controller.ts"),g=m("./src/utils/xhr-loader.ts"),p=m("./src/utils/fetch-loader.ts"),u=m("./src/utils/cues.ts"),e=m("./src/utils/mediakeys-helper.ts"),s=m("./src/utils/logger.ts");function c(){return c=Object.assign?Object.assign.bind():function(l){for(var a=1;a<arguments.length;a++){var f=arguments[a];for(var h in f)Object.prototype.hasOwnProperty.call(f,h)&&(l[h]=f[h])}return l},c.apply(this,arguments)}function v(l,a){var f=Object.keys(l);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(l);a&&(h=h.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),f.push.apply(f,h)}return f}function i(l){for(var a=1;a<arguments.length;a++){var f=arguments[a]!=null?arguments[a]:{};a%2?v(Object(f),!0).forEach(function(h){r(l,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(f)):v(Object(f)).forEach(function(h){Object.defineProperty(l,h,Object.getOwnPropertyDescriptor(f,h))})}return l}function r(l,a,f){return a in l?Object.defineProperty(l,a,{value:f,enumerable:!0,configurable:!0,writable:!0}):l[a]=f,l}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:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:M.default,bufferController:O.default,capLevelController:y.default,fpsController:T.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},d()),{},{subtitleStreamController:C.SubtitleStreamController,subtitleTrackController:b.default,timelineController:A.TimelineController,audioStreamController:_.default,audioTrackController:L.default,emeController:D.default,cmcdController:E.default});function d(){return{cueHandler:u.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(l,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 c({},l,a)}function n(l){var a=l.loader;if(a!==p.default&&a!==g.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var f=Object(p.fetchSupported)();f&&(l.loader=p.default,l.progressive=!0,l.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/utils/ewma-bandwidth-estimator.ts"),L=m("./src/events.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/errors.ts"),O=m("./src/types/loader.ts"),A=m("./src/utils/logger.ts");function y(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function T(E,g,p){return g&&y(E.prototype,g),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 u=p.config;this.bwEstimator=new _.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var g=E.prototype;return g.registerListeners=function(){var u=this.hls;u.on(L.Events.FRAG_LOADING,this.onFragLoading,this),u.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(L.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(L.Events.FRAG_LOADING,this.onFragLoading,this),u.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(L.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(u,e){var s=e.frag;if(s.type===O.PlaylistLevelType.MAIN&&!this.timer){var c;this.fragCurrent=s,this.partCurrent=(c=e.part)!=null?c:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(u,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.autoLevelEnabled,v=s.config,i=s.media;if(!(!u||!i)){var r=e?e.stats:u.stats,o=e?e.duration:u.duration;if(r.aborted){A.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!c||i.paused||!i.playbackRate||!i.readyState)){var d=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(d<=500*o/t)){var n=s.levels,l=s.minAutoLevel,a=n[u.level],f=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),h=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/d),S=(f-r.loaded)/h,x=i.currentTime,P=(C.BufferHelper.bufferInfo(i,x,v.maxBufferHole).end-x)/t;if(!(P>=2*o/t||S<=P)){var k=Number.POSITIVE_INFINITY,B;for(B=u.level-1;B>l;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*h),k<P)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();A.logger.warn("Fragment "+u.sn+(e?" part "+e.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
9
9
  Current BW estimate: `+(Object(M.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
10
10
  Estimated load time for current fragment: `+S.toFixed(3)+` s
11
11
  Estimated load time for the next fragment: `+k.toFixed(3)+` s
12
- Time to underbuffer: `+P.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(d,r.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(L.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:e,stats:r})}}}}}},m.onFragLoaded=function(u,e){var s=e.frag,c=e.part;if(s.type===O.PlaylistLevelType.MAIN&&Object(M.isFiniteNumber)(s.sn)){var v=c?c.stats:s.stats,i=c?c.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)+v.loaded,d=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:d},r.realBitrate=Math.round(8*o/d)}if(s.bitrateTest){var t={stats:v,frag:s,part:c,id:s.type};this.onFragBuffered(L.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(u,e){var s=e.frag,c=e.part,v=c?c.stats:s.stats;if(!v.aborted&&!(s.type!==O.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=v.parsing.end-v.loading.start;this.bwEstimator.sample(i,v.loaded),v.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(u,e){switch(e.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.maxAutoLevel,v=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:u?u.duration:0,d=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():v.abrEwmaDefaultEstimate,l=(C.BufferHelper.bufferInfo(r,d,v.maxBufferHole).end-d)/t,a=this.findBestLevel(n,i,c,l,v.abrBandWidthFactor,v.abrBandWidthUpFactor);if(a>=0)return a;A.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=o?Math.min(o,v.maxStarvationDelay):v.maxStarvationDelay,h=v.abrBandWidthFactor,S=v.abrBandWidthUpFactor;if(!l){var x=this.bitrateTestDelay;if(x){var P=o?Math.min(o,v.maxLoadingDelay):v.maxLoadingDelay;f=P-x,A.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),h=S=1}}return a=this.findBestLevel(n,i,c,l+f,h,S),Math.max(a,0)},m.findBestLevel=function(u,e,s,c,v,i){for(var r,o=this.fragCurrent,d=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,l=n[t],a=!!(l!=null&&(r=l.details)!==null&&r!==void 0&&r.live),f=l==null?void 0:l.codecSet,h=d?d.duration:o?o.duration:0,S=s;S>=e;S--){var x=n[S];if(!(!x||f&&x.codecSet!==f)){var P=x.details,k=(d?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||h,B=void 0;S<=t?B=v*u:B=i*u;var U=n[S].maxBitrate,W=U*k/B;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+c+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<c))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,e=this.bwEstimator;if(u!==-1&&!e.canEstimate())return u;var s=this.getNextABRAutoLevel();return u!==-1&&this.hls.levels[s].loadError?u:(u!==-1&&(s=Math.min(u,s)),s)},set:function(u){this._nextAutoLevel=u}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/controller/base-stream-controller.ts"),L=g("./src/events.ts"),C=g("./src/utils/buffer-helper.ts"),b=g("./src/controller/fragment-tracker.ts"),O=g("./src/types/level.ts"),A=g("./src/types/loader.ts"),y=g("./src/loader/fragment.ts"),T=g("./src/demux/chunk-cache.ts"),D=g("./src/demux/transmuxer-interface.ts"),E=g("./src/types/transmuxer.ts"),m=g("./src/controller/fragment-finders.ts"),p=g("./src/utils/discontinuities.ts"),u=g("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var d=arguments[o];for(var t in d)Object.prototype.hasOwnProperty.call(d,t)&&(r[t]=d[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,c(r,o)}function c(r,o){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},c(r,o)}var v=100,i=function(r){s(o,r);function o(t,n){var l;return l=r.call(this,t,n,"[audio-stream-controller]")||this,l.videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.audioSwitch=!1,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}var d=o.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var n=this.hls;n.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(L.Events.ERROR,this.onError,this),n.on(L.Events.BUFFER_RESET,this.onBufferReset,this),n.on(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var n=this.hls;n.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(L.Events.ERROR,this.onError,this),n.off(L.Events.BUFFER_RESET,this.onBufferReset,this),n.off(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(n,l){var a=l.frag,f=l.id,h=l.initPTS;if(f==="main"){var S=a.cc;this.initPTS[a.cc]=h,this.log("InitPTS for cc: "+S+" found from main: "+h),this.videoTrackCC=S,this.state===_.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=_.State.STOPPED;return}var l=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,l>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),n=l,this.state=_.State.IDLE):(this.loadedmetadata=!1,this.state=_.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},d.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_TRACK:{var n,l=this.levels,a=this.trackId,f=l==null||(n=l[a])===null||n===void 0?void 0:n.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=_.State.WAITING_INIT_PTS}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var h,S=performance.now(),x=this.retryDate;(!x||S>=x||(h=this.media)!==null&&h!==void 0&&h.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=_.State.IDLE);break}case _.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var k=P.frag,B=P.part,U=P.cache,W=P.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=_.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(),$=C.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=_.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var l=this.mediaBuffer?this.mediaBuffer:n,a=l.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},d.doTickIdle=function(){var n,l,a=this.hls,f=this.levels,h=this.media,S=this.trackId,x=a.config;if(!(!f||!f[S])&&!(!h&&(this.startFragRequested||!x.startFragPrefetch))){var P=f[S],k=P.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=_.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,A.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.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(L.Events.BUFFER_EOS,{type:"audio"}),this.state=_.State.ENDED;return}var $=k.fragments,Z=$[0].start,q=U.end;if(Y&&h){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"),h.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"&&!((l=ne.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(ne,k):this.loadFragment(ne,k,q)}}}}},d.getMaxBufferLength=function(n){var l=r.prototype.getMaxBufferLength.call(this);return n?Math.max(l,n):l},d.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(n,l){var a=l.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(f){return new O.Level(f)})},d.onAudioTrackSwitching=function(n,l){var a=!!l.url;this.trackId=l.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(v):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=_.State.IDLE):this.state=_.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(n,l){this.mainDetails=l.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(n,l){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=l;return}var f=this.levels,h=l.details,S=l.id;if(!f){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+h.startSN+","+h.endSN+"],duration:"+h.totalduration);var x=f[S],P=0;if(h.live||(a=x.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed||!k)return;!x.details&&h.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(h,k),P=h.fragments[0].start):P=this.alignPlaylists(h,x.details)}x.details=h,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!h.live)&&this.setStartPosition(x.details,P),this.state===_.State.WAITING_TRACK&&!this.waitForCdnTuneIn(h)&&(this.state=_.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(n){var l,a=n.frag,f=n.part,h=n.payload,S=this.config,x=this.trackId,P=this.levels;if(!P){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=P[x];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,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[a.cc],z=(l=a.initSegment)===null||l===void 0?void 0:l.data;if(G!==void 0){var Y=!1,$=f?f.index:-1,Z=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,h.byteLength,$,Z);W.push(h,z,U,"",a,f,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 "+x);var ie=this.waitingData=this.waitingData||{frag:a,part:f,cache:new T.default,complete:!1},ne=ie.cache;ne.push(new Uint8Array(h)),this.waitingVideoCC=this.videoTrackCC,this.state=_.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(n,l){var a=l.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer||null)},d.onFragBuffered=function(n,l){var a=l.frag,f=l.part;if(a.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(f?" p: "+f.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(L.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,f)}},d.onError=function(n,l){switch(l.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,l);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==_.State.ERROR&&this.state!==_.State.STOPPED&&(this.state=l.fatal?_.State.ERROR:_.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var a=!0,f=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);f&&f.len>.5&&(a=!this.reduceMaxBufferLength(f.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}},d.onBufferFlushed=function(n,l){var a=l.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(n){var l,a="audio",f=this.hls,h=n.remuxResult,S=n.chunkMeta,x=this.getCurrentContext(S);if(!x){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 P=x.frag,k=x.part,B=x.level.details,U=h.audio,W=h.text,G=h.id3,z=h.initSegment;if(!(this.fragContextChanged(P)||!B)){if(this.state=_.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,P,S),f.trigger(L.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,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}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,Z,q),this.bufferFragmentData(U,P,k,S)}if(G!=null&&(l=G.samples)!==null&&l!==void 0&&l.length){var ie=e({id:a,frag:P,details:B},G);f.trigger(L.Events.FRAG_PARSING_METADATA,ie)}if(W){var ne=e({id:a,frag:P,details:B},W);f.trigger(L.Events.FRAG_PARSING_USERDATA,ne)}}},d._bufferInitSegment=function(n,l,a){if(this.state===_.State.PARSING){n.video&&delete n.video;var f=n.audio;if(!!f){f.levelCodec=f.codec,f.id="audio",this.log("Init audio buffer, container:"+f.container+", codecs[parsed]=["+f.codec+"]"),this.hls.trigger(L.Events.BUFFER_CODECS,n);var h=f.initSegment;if(h!=null&&h.byteLength){var S={type:"audio",frag:l,part:null,chunkMeta:a,parent:l.type,data:h};this.hls.trigger(L.Events.BUFFER_APPENDING,S)}this.tick()}}},d.loadFragment=function(n,l,a){var f=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||f===b.FragmentState.NOT_LOADED||f===b.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):l.live&&!Object(M.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=_.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,l,a)))},d.completeAudioSwitch=function(){var n=this.hls,l=this.media,a=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(_.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/events.ts"),_=g("./src/errors.ts"),L=g("./src/controller/base-playlist-controller.ts"),C=g("./src/types/loader.ts");function b(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 O(D,E,m){return E&&b(D.prototype,E),m&&b(D,m),Object.defineProperty(D,"prototype",{writable:!1}),D}function A(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,u){return p.__proto__=u,p},y(D,E)}var T=function(D){A(E,D);function E(p){var u;return u=D.call(this,p,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var m=E.prototype;return m.registerListeners=function(){var u=this.hls;u.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(M.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var u=this.hls;u.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(M.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(u,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(u,e){var s=e.id,c=e.details,v=this.tracksInGroup[s];if(!v){this.warn("Invalid audio track id "+s);return}var i=v.details;v.details=e.details,this.log("audioTrack "+s+" loaded ["+c.startSN+"-"+c.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},m.onLevelLoading=function(u,e){this.switchLevel(e.level)},m.onLevelSwitching=function(u,e){this.switchLevel(e.level)},m.switchLevel=function(u){var e=this.hls.levels[u];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var c=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!c.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=c;var v={audioTracks:c};this.log("Updating audio tracks, "+c.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(M.Events.AUDIO_TRACKS_UPDATED,v),this.selectInitialTrack()}}},m.onError=function(u,e){D.prototype.onError.call(this,u,e),!(e.fatal||!e.context)&&e.context.type===C.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(u){var e=this.tracksInGroup;if(u<0||u>=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 "+u);var c=e[u],v=c.id,i=c.groupId,r=i===void 0?"":i,o=c.name,d=c.type,t=c.url;if(this.trackId=u,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHING,{id:v,groupId:r,name:o,type:d,url:t}),!(c.details&&!c.details.live)){var n=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(n)}},m.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.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(M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(u){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var c=e[s];if((!this.selectDefaultTrack||c.default)&&(!u||u===c.name))return c.id}return-1},m.loadPlaylist=function(u){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,c=e.groupId,v=e.url;if(u)try{v=u.addDirectives(v)}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(M.Events.AUDIO_TRACK_LOADING,{url:v,id:s,groupId:c,deliveryDirectives:u||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),E}(L.default);R.default=T},"./src/controller/base-playlist-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return O});var M=g("./src/polyfills/number.ts"),_=g("./src/types/level.ts"),L=g("./src/controller/level-helper.ts"),C=g("./src/utils/logger.ts"),b=g("./src/errors.ts"),O=function(){function A(T,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=C.logger.log.bind(C.logger,D+":"),this.warn=C.logger.warn.bind(C.logger,D+":"),this.hls=T}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===b.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 u=m[p],e=""+u.URI;if(e===D.slice(-e.length)){var s=parseInt(u["LAST-MSN"]),c=parseInt(u["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var v=Math.min(E.age-E.partTarget,E.targetduration);c!==void 0&&v>E.partTarget&&(c+=1)}if(Object(M.isFiniteNumber)(s))return new _.HlsUrlParameters(s,Object(M.isFiniteNumber)(c)?c:void 0,_.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,u=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||m!=null&&m.live){if(u.reloaded(m),m&&this.log("live playlist "+D+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),m&&u.fragments.length>0&&Object(L.mergeDetails)(m,u),!this.canLoad||!u.live)return;var c,v=void 0,i=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var r=this.hls.config.lowLatencyMode,o=u.lastPartSn,d=u.endSN,t=u.lastPartIndex,n=t!==-1,l=o===d,a=r?0:t;n?(v=l?d+1:o,i=l?a:t+1):v=d+1;var f=u.age,h=f+u.ageHeader,S=Math.min(h-u.partTarget,u.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: "+u.age),S=0;else{var x=Math.floor(S/u.targetduration);if(v+=x,i!==void 0){var P=Math.round(S%u.targetduration/u.partTarget);i+=P}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}u.tuneInGoal=S}if(c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i),r||!l){this.loadPlaylist(c);return}}else c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i);var k=Object(L.computeReloadInterval)(u,e);v!==void 0&&u.canBlockReload&&(k-=u.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(c)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,m,p){var u=Object(_.getSkipValue)(D,m);return E!=null&&E.skip&&D.deltaUpdateFailed&&(m=E.msn,p=E.part,u=_.HlsSkip.No),new _.HlsUrlParameters(m,p,u)},y.retryLoadingOrFail=function(D){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var u;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(u=D.context)!==null&&u!==void 0&&u.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},A}()},"./src/controller/base-stream-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"State",function(){return d}),g.d(R,"default",function(){return t});var M=g("./src/polyfills/number.ts"),_=g("./src/task-loop.ts"),L=g("./src/controller/fragment-tracker.ts"),C=g("./src/utils/buffer-helper.ts"),b=g("./src/utils/logger.ts"),O=g("./src/events.ts"),A=g("./src/errors.ts"),y=g("./src/types/transmuxer.ts"),T=g("./src/utils/mp4-tools.ts"),D=g("./src/utils/discontinuities.ts"),E=g("./src/controller/fragment-finders.ts"),m=g("./src/controller/level-helper.ts"),p=g("./src/loader/fragment-loader.ts"),u=g("./src/crypt/decrypter.ts"),e=g("./src/utils/time-ranges.ts"),s=g("./src/types/loader.ts");function c(n,l){for(var a=0;a<l.length;a++){var f=l[a];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(n,f.key,f)}}function v(n,l,a){return l&&c(n.prototype,l),a&&c(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,l){n.prototype=Object.create(l.prototype),n.prototype.constructor=n,o(n,l)}function o(n,l){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,h){return f.__proto__=h,f},o(n,l)}var d={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(l,n);function l(f,h,S){var x;return x=n.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=d.STOPPED,x.media=null,x.mediaBuffer=null,x.config=void 0,x.bitrateTest=!1,x.lastCurrentTime=0,x.nextLoadPosition=0,x.startPosition=0,x.loadedmetadata=!1,x.fragLoadError=0,x.retryDate=0,x.levels=null,x.fragmentLoader=void 0,x.levelLastLoaded=null,x.startFragRequested=!1,x.decrypter=void 0,x.initPTS=[],x.onvseeking=null,x.onvended=null,x.logPrefix="",x.log=void 0,x.warn=void 0,x.logPrefix=S,x.log=b.logger.log.bind(b.logger,S+":"),x.warn=b.logger.warn.bind(b.logger,S+":"),x.hls=f,x.fragmentLoader=new p.default(f.config),x.fragmentTracker=h,x.config=f.config,x.decrypter=new u.default(f,f.config),f.on(O.Events.KEY_LOADED,x.onKeyLoaded,i(x)),f.on(O.Events.LEVEL_SWITCHING,x.onLevelSwitching,i(x)),x}var a=l.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(h){},a.stopLoad=function(){this.fragmentLoader.abort();var h=this.fragCurrent;h&&this.fragmentTracker.removeFragment(h),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},a._streamEnded=function(h,S){var x=this.fragCurrent,P=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!h.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=C.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=P.getState(x);return W===L.FragmentState.PARTIAL||W===L.FragmentState.OK}return!1},a.onMediaAttached=function(h,S){var x=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(P.startPosition)},a.onMediaDetaching=function(){var h=this.media;h!=null&&h.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),h&&this.onvseeking&&this.onvended&&(h.removeEventListener("seeking",this.onvseeking),h.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 h=this.config,S=this.fragCurrent,x=this.media,P=this.mediaBuffer,k=this.state,B=x?x.currentTime:0,U=C.BufferHelper.bufferInfo(P||x,B,h.maxBufferHole);if(this.log("media seeking to "+(Object(M.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===d.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=h.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())}x&&(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(h,S){if(!(this.state!==d.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},a.onLevelSwitching=function(h,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.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(h,S){this.log("Loading key for "+h.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level),this.state=d.KEY_LOADING,this.fragCurrent=h,this.hls.trigger(O.Events.KEY_LOADING,{frag:h})},a.loadFragment=function(h,S,x){this._loadFragForPlayback(h,S,x)},a._loadFragForPlayback=function(h,S,x){var P=this,k=function(U){if(P.fragContextChanged(h)){P.warn("Fragment "+h.sn+(U.part?" p: "+U.part.index:"")+" of level "+h.level+" was dropped during download."),P.fragmentTracker.removeFragment(h);return}h.stats.chunkCount++,P._handleFragmentLoadProgress(U)};this._doFragLoad(h,S,x,k).then(function(B){if(!!B){P.fragLoadError=0;var U=P.state;if(P.fragContextChanged(h)){(U===d.FRAG_LOADING||!P.fragCurrent&&U===d.PARSING)&&(P.fragmentTracker.removeFragment(h),P.state=d.IDLE);return}"payload"in B&&(P.log("Loaded fragment "+h.sn+" of level "+h.level),P.hls.trigger(O.Events.FRAG_LOADED,B)),P._handleFragmentLoadComplete(B)}}).catch(function(B){P.state===d.STOPPED||P.state===d.ERROR||(P.warn(B),P.resetFragmentLoading(h))})},a.flushMainBuffer=function(h,S,x){if(x===void 0&&(x=null),!!(h-S)){var P={startOffset:h,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},a._loadInitSegment=function(h){var S=this;this._doFragLoad(h).then(function(x){if(!x||S.fragContextChanged(h)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var P=S.hls,k=x.payload,B=h.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 P.trigger(O.Events.FRAG_DECRYPTED,{frag:h,payload:W,stats:{tstart:U,tdecrypt:G}}),x.payload=W,x})}return x}).then(function(x){var P=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[h.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=h.stats;S.state=d.IDLE,S.fragLoadError=0,h.data=new Uint8Array(x.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),x.frag===P&&k.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:P,part:null,id:h.type}),S.tick()}).catch(function(x){S.state===d.STOPPED||S.state===d.ERROR||(S.warn(x),S.resetFragmentLoading(h))})},a.fragContextChanged=function(h){var S=this.fragCurrent;return!h||!S||h.level!==S.level||h.sn!==S.sn||h.urlId!==S.urlId},a.fragBufferedComplete=function(h,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+h.type+" sn: "+h.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level+" "+(x?e.default.toString(C.BufferHelper.getBuffered(x)):"(detached)")),this.state=d.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(h){var S=this.transmuxer;if(!!S){var x=h.frag,P=h.part,k=h.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,P?P.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(h){},a._doFragLoad=function(h,S,x,P){var k=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(h.start,x||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&P){x>h.end&&S.fragmentHint&&(h=S.fragmentHint);var U=this.getNextPart(B,h,x);if(U>-1){var W=B[U];return this.log("Loading part sn: "+h.sn+" p: "+W.index+" cc: "+h.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,part:B[U],targetBufferTime:x}),this.doFragPartsLoad(h,B,U,P).catch(function(G){return k.handleFragLoadError(G)})}else if(!h.url||this.loadedEndOfParts(B,x))return Promise.resolve(null)}}return this.log("Loading fragment "+h.sn+" cc: "+h.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),Object(M.isFiniteNumber)(h.sn)&&!this.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,targetBufferTime:x}),this.fragmentLoader.load(h,P).catch(function(G){return k.handleFragLoadError(G)})},a.doFragPartsLoad=function(h,S,x,P){var k=this;return new Promise(function(B,U){var W=[],G=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(h,$,P).then(function(Z){W[$.index]=Z;var q=Z.part;k.hls.trigger(O.Events.FRAG_LOADED,Z);var ie=S[Y+1];if(ie&&ie.fragment===h)z(Y+1);else return B({frag:h,part:q,partsLoaded:W})}).catch(U)};G(x)})},a.handleFragLoadError=function(h){var S=h.data;return S&&S.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},a._handleTransmuxerFlush=function(h){var S=this.getCurrentContext(h);if(!S||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var x=S.frag,P=S.part,k=S.level,B=self.performance.now();x.stats.parsing.end=B,P&&(P.stats.parsing.end=B),this.updateLevelTiming(x,P,k,h.partial)},a.getCurrentContext=function(h){var S=this.levels,x=h.level,P=h.sn,k=h.part;if(!S||!S[x])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+x+". The current chunk will not be buffered."),null;var B=S[x],U=k>-1?Object(m.getPartWith)(B,P,k):null,W=U?U.fragment:Object(m.getFragmentWithSN)(B,P,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(h,S,x,P){if(!(!h||this.state!==d.PARSING)){var k=h.data1,B=h.data2,U=k;if(k&&B&&(U=Object(T.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:h.type,frag:S,part:x,chunkMeta:P,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),h.dropped&&h.independent&&!x&&this.flushBufferGap(S)}}},a.flushBufferGap=function(h){var S=this.media;if(!!S){if(!C.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,h.start);return}var x=S.currentTime,P=C.BufferHelper.bufferInfo(S,x,0),k=h.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(h.start-B,P.end-B),x+B);h.start-U>B&&this.flushMainBuffer(U,h.start)}},a.getFwdBufferInfo=function(h,S){var x=this.config,P=this.getLoadPosition();if(!Object(M.isFiniteNumber)(P))return null;var k=C.BufferHelper.bufferInfo(h,P,x.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(P,S);if(B&&k.nextStart<B.end)return C.BufferHelper.bufferInfo(h,P,Math.max(k.nextStart,x.maxBufferHole))}return k},a.getMaxBufferLength=function(h){var S=this.config,x;return h?x=Math.max(8*S.maxBufferSize/h,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(h){var S=this.config,x=h||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(h,S){var x=S.fragments,P=x.length;if(!P)return null;var k=this.config,B=x[0].start,U;if(S.live){var W=k.initialLiveManifestSize;if(P<W)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,x),this.startPosition=U?this.hls.liveSyncPosition||U.start:h)}else h<=B&&(U=x[0]);if(!U){var G=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(h,G,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(h){return h!=null&&h.initSegment&&!(h!=null&&h.initSegment.data)&&!this.bitrateTest?h.initSegment:h},a.getNextPart=function(h,S,x){for(var P=-1,k=!1,B=!0,U=0,W=h.length;U<W;U++){var G=h[U];if(B=B&&!G.independent,P>-1&&x<G.start)break;var z=G.loaded;!z&&(k||G.independent||B)&&G.fragment===S&&(P=U),k=z}return P},a.loadedEndOfParts=function(h,S){var x=h[h.length-1];return x&&S>x.start&&x.loaded},a.getInitialLiveFragment=function(h,S){var x=this.fragPrevious,P=null;if(x){if(h.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),P=Object(E.findFragmentByPDT)(S,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var k=x.sn+1;if(k>=h.startSN&&k<=h.endSN){var B=S[k-h.startSN];x.cc===B.cc&&(P=B,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(E.findFragWithCC)(S,x.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(P=this.getFragmentAtPosition(U,this.bitrateTest?h.fragmentEnd:h.edge,h))}return P},a.getFragmentAtPosition=function(h,S,x){var P=this.config,k=this.fragPrevious,B=x.fragments,U=x.endSN,W=x.fragmentHint,G=P.maxFragLookUpTolerance,z=!!(P.lowLatencyMode&&x.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(h<S){var $=h>S-G?0:G;Y=Object(E.findFragmentByPTS)(k,B,h,$)}else Y=B[B.length-1];if(Y){var Z=Y.sn-x.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)!==L.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+ie.sn),Y=ie):Y=null}}}return Y},a.synchronizeToLiveEdge=function(h){var S=this.config,x=this.media;if(!!x){var P=this.hls.liveSyncPosition,k=x.currentTime,B=h.fragments[0].start,U=h.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(P!==null&&x.duration>P&&(k<P||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*h.targetduration;(!W&&x.readyState<4||k<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=P),x.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+P.toFixed(3)),x.currentTime=P))}}},a.alignPlaylists=function(h,S){var x=this.levels,P=this.levelLastLoaded,k=this.fragPrevious,B=P!==null?x[P]:null,U=h.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=h.fragments[0].start,G=!S,z=h.alignedSliding&&Object(M.isFiniteNumber)(W);if(G||!z&&!W){Object(D.alignStream)(k,B,h);var Y=h.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+h.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(h){var S=3;return h.live&&h.canBlockReload&&h.partTarget&&h.tuneInGoal>Math.max(h.partHoldBack,h.partTarget*S)},a.setStartPosition=function(h,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var P=h.startTimeOffset;Object(M.isFiniteNumber)(P)?(x=S+P,P<0&&(x+=h.totalduration),x=Math.min(Math.max(S,x),S+h.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+x),this.startPosition=x):h.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},a.getLoadPosition=function(){var h=this.media,S=0;return this.loadedmetadata&&h?S=h.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(h,S){this.transmuxer&&h.sn!=="initSegment"&&h.stats.aborted&&(this.warn("Fragment "+h.sn+(S?" part"+S.index:"")+" of level "+h.level+" was aborted"),this.resetFragmentLoading(h))},a.resetFragmentLoading=function(h){(!this.fragCurrent||!this.fragContextChanged(h)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},a.onFragmentOrKeyLoadError=function(h,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==h)){var P=this.fragCurrent;console.assert(P&&x.sn===P.sn&&x.level===P.level&&x.urlId===P.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 "+x.sn+" of "+h+" "+x.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(h===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(b.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},a.afterBufferFlushed=function(h,S,x){if(!!h){var P=C.BufferHelper.getBuffered(h);this.fragmentTracker.detectEvictedFragments(S,P,x),this.state===d.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},a.resetStartWhenNotLoaded=function(h){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[h].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(h,S,x,P){var k=this,B=x.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(h.elementaryStreams).reduce(function(W,G){var z=h.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+h.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var $=P?0:Object(m.updateFragPTSDTS)(B,h,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:B,level:x,drift:$,type:G,frag:h,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+h.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:h,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},v(l,[{key:"state",get:function(){return this._state},set:function(h){var S=this._state;S!==h&&(this._state=h,this.log(S+"->"+h))}}]),l}(_.default)},"./src/controller/buffer-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return E});var M=g("./src/polyfills/number.ts"),_=g("./src/events.ts"),L=g("./src/utils/logger.ts"),C=g("./src/errors.ts"),b=g("./src/utils/buffer-helper.ts"),O=g("./src/utils/mediasource-helper.ts"),A=g("./src/loader/fragment.ts"),y=g("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(u){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,c=e.media,v=e.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),c&&(e.updateMediaElementDuration(),s.trigger(_.Events.MEDIA_ATTACHED,{media:c})),v&&v.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=u,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(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.Events.BUFFER_RESET,this.onBufferReset,this),e.on(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.Events.BUFFER_EOS,this.onBufferEos,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.Events.FRAG_PARSED,this.onFragParsed,this),e.on(_.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.Events.BUFFER_RESET,this.onBufferReset,this),e.off(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.Events.BUFFER_EOS,this.onBufferEos,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.Events.FRAG_PARSED,this.onFragParsed,this),e.off(_.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 c=2;(s.audio&&!s.video||!s.altAudio)&&(c=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=c,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var c=this.media=s.media;if(c&&T){var v=this.mediaSource=new T;v.addEventListener("sourceopen",this._onMediaSourceOpen),v.addEventListener("sourceended",this._onMediaSourceEnded),v.addEventListener("sourceclose",this._onMediaSourceClose),c.src=self.URL.createObjectURL(v),this._objectUrl=c.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,c=this._objectUrl;if(s){if(L.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(v){L.logger.warn("[buffer-controller]: onMediaDetaching: "+v.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(c&&self.URL.revokeObjectURL(c),e.src===c?(e.removeAttribute("src"),e.load()):L.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(_.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var c=e.sourceBuffer[s];try{c&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(c),e.sourceBuffer[s]=void 0)}catch(v){L.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",v)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var c=this,v=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(v){var r=c.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],d=o.id,t=o.codec,n=o.levelCodec,l=o.container,a=o.metadata,f=(r.levelCodec||r.codec).replace(D,"$1"),h=(n||t).replace(D,"$1");if(f!==h){var S=l+";codecs="+(n||t);c.appendChangeType(i,S),L.logger.log("[buffer-controller]: switching codec "+f+" to "+h),c.tracks[i]={buffer:r.buffer,codec:t,container:l,levelCodec:n,metadata:a,id:d}}}}else c.pendingTracks[i]=s[i]}),!v&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var c=this,v=this.operationQueue,i={execute:function(){var o=c.sourceBuffer[e];o&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),v.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){L.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};v.append(i,e)},p.onBufferAppending=function(e,s){var c=this,v=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,d=s.type,t=s.frag,n=s.part,l=s.chunkMeta,a=l.buffering[d],f=self.performance.now();a.start=f;var h=t.stats.buffering,S=n?n.stats.buffering:null;h.start===0&&(h.start=f),S&&S.start===0&&(S.start=f);var x=r.audio,P=d==="audio"&&l.id===1&&(x==null?void 0:x.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),P){var U=c.sourceBuffer[d];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}c.appendExecutor(o,d)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,h.first===0&&(h.first=U),S&&S.first===0&&(S.first=U);var W=c.sourceBuffer,G={};for(var z in W)G[z]=b.BufferHelper.getBuffered(W[z]);c.appendError=0,c.hls.trigger(_.Events.BUFFER_APPENDED,{type:d,frag:t,part:n,chunkMeta:l,parent:t.type,timeRanges:G})},onError:function(U){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",U);var W={type:C.ErrorTypes.MEDIA_ERROR,parent:t.type,details:C.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=C.ErrorDetails.BUFFER_FULL_ERROR:(c.appendError++,W.details=C.ErrorDetails.BUFFER_APPEND_ERROR,c.appendError>v.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+v.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,v.stopLoad())),v.trigger(_.Events.ERROR,W)}};i.append(k,d)},p.onBufferFlushing=function(e,s){var c=this,v=this.operationQueue,i=function(o){return{execute:c.removeExecutor.bind(c,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){c.hls.trigger(_.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){L.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?v.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){v.append(i(r),r)})},p.onFragParsed=function(e,s){var c=this,v=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:v.elementaryStreams;o[A.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[A.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[A.ElementaryStreamTypes.VIDEO]&&r.push("video"));var d=function(){var n=self.performance.now();v.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var l=i?i.stats:v.stats;c.hls.trigger(_.Events.FRAG_BUFFERED,{frag:v,part:i,stats:l,id:v.type})};r.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+v.type+" level: "+v.level+" sn: "+v.sn),this.blockBuffers(d,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var c=this,v=this.getSourceBufferTypes().reduce(function(i,r){var o=c.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,L.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);v&&this.blockBuffers(function(){var i=c.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var c=s.details;!c.fragments.length||(this.details=c,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,c=this.media,v=this.sourceBuffer;if(!(!c||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(M.isFiniteNumber)(r)||r<0)){var o=c.currentTime,d=s.levelTargetDuration,t=Math.max(r,d),n=Math.floor(o/d)*d-t;i.forEach(function(l){var a=v[l];if(a){var f=b.BufferHelper.getBuffered(a);f.length>0&&n>f.start(0)&&(e.trigger(_.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(_.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:l}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,c=this.media,v=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=c.duration,o=Object(M.isFiniteNumber)(v.duration)?v.duration:0;e.live&&s.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),v.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(M.isFiniteNumber)(r))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),v.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,c=e.fragments,v=c.length;if(v&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,c[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,c=this.pendingTracks,v=Object.keys(c).length;if(v&&!e||v===2){this.createSourceBuffers(c),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.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,c=this.mediaSource;if(!c)throw Error("createSourceBuffers called when mediaSource was null");var v=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,d=r.container+";codecs="+o;L.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var t=s[i]=c.addSourceBuffer(d),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},v++}catch(l){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:d})}}v&&this.hls.trigger(_.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,c=s.current(e);c.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,c=s.current(e);c.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var c=this.operationQueue.current(e);c&&c.onError(s)},p.removeExecutor=function(e,s,c){var v=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,d=o[e];if(!v||!i||!d){L.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(M.isFiniteNumber)(v.duration)?v.duration:1/0,n=Object(M.isFiniteNumber)(i.duration)?i.duration:1/0,l=Math.max(0,s),a=Math.min(c,t,n);a>l?(L.logger.log("[buffer-controller]: Removing ["+l+","+a+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(l,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var c=this.operationQueue,v=this.sourceBuffer,i=v[s];if(!i){L.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),c.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 c=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var v=this.operationQueue,i=s.map(function(r){return v.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=c.sourceBuffer[r];(!o||!o.updating)&&v.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,c){var v=this.sourceBuffer[e];if(!!v){var i=c.bind(this,e);this.listeners[e].push({event:s,listener:i}),v.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(c){s.removeEventListener(c.event,c.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return _});var M=g("./src/utils/logger.ts"),_=function(){function L(b){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=b}var C=L.prototype;return C.append=function(O,A){var y=this.queues[A];y.push(O),y.length===1&&this.buffers[A]&&this.executeNext(A)},C.insertAbort=function(O,A){var y=this.queues[A];y.unshift(O),this.executeNext(A)},C.appendBlocker=function(O){var A,y=new Promise(function(D){A=D}),T={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},C.executeNext=function(O){var A=this.buffers,y=this.queues,T=A[O],D=y[O];if(D.length){var E=D[0];try{E.execute()}catch(m){M.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!T||!T.updating)&&(D.shift(),this.executeNext(O))}}},C.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},C.current=function(O){return this.queues[O][0]},L}()},"./src/controller/cap-level-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/events.ts");function _(b,O){for(var A=0;A<O.length;A++){var y=O[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(b,y.key,y)}}function L(b,O,A){return O&&_(b.prototype,O),A&&_(b,A),Object.defineProperty(b,"prototype",{writable:!1}),b}var C=function(){function b(A){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=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=b.prototype;return O.setStreamController=function(y){this.streamController=y},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var y=this.hls;y.on(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){b.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},O.onMediaAttaching=function(y,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},O.onManifestParsed=function(y,T){var D=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(y,T){var D=this.hls;D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(y.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},O.getMaxLevel=function(y){var T=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(m,p){return b.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,b.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},O.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())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,T={width:0,height:0};if(y){var D=y.getBoundingClientRect();T.width=D.width,T.height=D.height,!T.width&&!T.height&&(T.width=D.right-D.left||y.width||0,T.height=D.bottom-D.top||y.height||0)}return this.clientRect=T,T},b.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},b.getMaxLevelByMediaSize=function(y,T,D){if(!y||!y.length)return-1;for(var E=function(s,c){return c?s.width!==c.width||s.height!==c.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var u=y[p];if((u.width>=T||u.height>=D)&&E(u,y[p+1])){m=p;break}}return m},L(b,[{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}}]),b}();R.default=C},"./src/controller/cmcd-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return E});var M=g("./src/events.ts"),_=g("./src/types/cmcd.ts"),L=g("./src/utils/buffer-helper.ts"),C=g("./src/utils/logger.ts");function b(m,p){for(var u=0;u<p.length;u++){var e=p[u];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function O(m,p,u){return p&&b(m.prototype,p),u&&b(m,u),Object.defineProperty(m,"prototype",{writable:!1}),m}function A(m,p){var u=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(u)return(u=u.call(m)).next.bind(u);if(Array.isArray(m)||(u=y(m))||p&&m&&typeof m.length=="number"){u&&(m=u);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 T(m,p);var u=Object.prototype.toString.call(m).slice(8,-1);if(u==="Object"&&m.constructor&&(u=m.constructor.name),u==="Map"||u==="Set")return Array.from(m);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(m,p)}}function T(m,p){(p==null||p>m.length)&&(p=m.length);for(var u=0,e=new Array(p);u<p;u++)e[u]=m[u];return e}function D(){return D=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var u=arguments[p];for(var e in u)Object.prototype.hasOwnProperty.call(u,e)&&(m[e]=u[e])}return m},D.apply(this,arguments)}var E=function(){function m(u){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(v){try{e.apply(v,{ot:_.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){C.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(v){try{var i=v.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),d={d:i.duration*1e3,ot:o};(o===_.CMCDObjectType.VIDEO||o===_.CMCDObjectType.AUDIO||o==_.CMCDObjectType.MUXED)&&(d.br=r.bitrate/1e3,d.tb=e.getTopBandwidth(o)/1e3,d.bl=e.getBufferLength(o)),e.apply(v,d)}catch(t){C.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=u;var s=this.config=u.config,c=s.cmcd;c!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=c.sessionId||m.uuid(),this.cid=c.contentId,this.useHeaders=c.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(M.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 c,v;this.audioBuffer=(c=s.tracks.audio)===null||c===void 0?void 0:c.buffer,this.videoBuffer=(v=s.tracks.video)===null||v===void 0?void 0:v.buffer},p.createData=function(){var e;return{v:_.CMCDVersion,sf:_.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 c=s.ot===_.CMCDObjectType.INIT||s.ot===_.CMCDObjectType.VIDEO||s.ot===_.CMCDObjectType.MUXED;if(this.starved&&c&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var v=m.toHeaders(s);if(!Object.keys(v).length)return;e.headers||(e.headers={}),D(e.headers,v)}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 _.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return _.CMCDObjectType.INIT;if(s==="audio")return _.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?_.CMCDObjectType.VIDEO:_.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,c,v=this.hls;if(e===_.CMCDObjectType.AUDIO)c=v.audioTracks;else{var i=v.maxAutoLevel,r=i>-1?i+1:v.levels.length;c=v.levels.slice(0,r)}for(var o=A(c),d;!(d=o()).done;){var t=d.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,c=e===_.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!c||!s)return NaN;var v=L.BufferHelper.bufferInfo(c,s.currentTime,this.config.maxBufferHole);return v.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},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=[],c=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},v=function(P){return Math.round(P)},i=function(P){return v(P/100)*100},r=function(P){return encodeURIComponent(P)},o={br:v,d:v,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:v},d=Object.keys(e||{}).sort(),t=A(d),n;!(n=t()).done;){var l=n.value,a=e[l];if(!!c(a)&&!(l==="v"&&a===1)&&!(l=="pr"&&a===1)){var f=o[l];f&&(a=f(a));var h=typeof a,S=void 0;l==="ot"||l==="sf"||l==="st"?S=l+"="+a:h==="boolean"?S=l:h==="number"?S=l+"="+a:S=l+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},m.toHeaders=function(e){for(var s=Object.keys(e),c={},v=["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,d=s;o<d.length;o++){var t=d[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var l=0;l<i.length;l++){var a=m.serialize(i[l]);a&&(c["CMCD-"+v[l]]=a)}return c},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,s){if(!s)return e;var c=e.includes("?")?"&":"?";return""+e+c+s},m}()},"./src/controller/eme-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/events.ts"),_=g("./src/errors.ts"),L=g("./src/utils/logger.ts"),C=g("./src/utils/mediakeys-helper.ts");function b(E,m){for(var p=0;p<m.length;p++){var u=m[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,m,p){return m&&b(E.prototype,m),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var A=3,y=function(m,p,u){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[e]},T=function(m,p,u,e){switch(m){case C.KeySystems.WIDEVINE:return y(p,u,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(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(u){switch(u){case C.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},m._attemptKeySystemAccess=function(u,e,s){var c=this,v=T(u,e,s,this._drmSystemOptions);L.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(u,v);this.mediaKeysPromise=i.then(function(r){return c._onMediaKeySystemAccessObtained(u,r)}),i.catch(function(r){L.logger.error('Failed to obtain key-system "'+u+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(u,e){var s=this;L.logger.log('Access for key-system "'+u+'" obtained');var c={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:u};this._mediaKeysList.push(c);var v=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return c.mediaKeys=i,L.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),i});return v.catch(function(i){L.logger.error("Failed to create media-keys:",i)}),v},m._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),u._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(u){var e=this;L.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){e._onKeySessionMessage(u,s.message)},!1)},m._onKeySessionMessage=function(u,e){L.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){L.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s).catch(function(c){L.logger.warn("Updating key-session failed: "+c)})})},m.onMediaEncrypted=function(u){var e=this;if(L.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(v){!e._media||(e._attemptSetMediaKeys(v),e._generateRequestWithPreferredKeySession(u.initDataType,u.initData))};this.mediaKeysPromise.then(s).catch(s)},m._attemptSetMediaKeys=function(u){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){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}L.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(u,e){var s=this,c=this._mediaKeysList[0];if(!c){L.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(c.mediaKeysSessionInitialized){L.logger.warn("Key-Session already initialized but requested again");return}var v=c.mediaKeysSession;if(!v){L.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){L.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}L.logger.log('Generating key-session request for "'+u+'" init data type'),c.mediaKeysSessionInitialized=!0,v.generateRequest(u,e).then(function(){L.logger.debug("Key-session generation succeeded")}).catch(function(i){L.logger.error("Error generating key-session request:",i),s.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(u,e,s){var c=new XMLHttpRequest;c.responseType="arraybuffer",c.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,c,u,e,s);var v=this._licenseXhrSetup;if(v)try{v.call(this.hls,c,u),v=void 0}catch(i){L.logger.error(i)}try{c.readyState||c.open("POST",u,!0),v&&v.call(this.hls,c,u)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return c},m._onLicenseRequestReadyStageChange=function(u,e,s,c){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,L.logger.log("License request succeeded");var v=u.response,i=this._licenseResponseCallback;if(i)try{v=i.call(this.hls,u,e)}catch(o){L.logger.error(o)}c(v)}else{if(L.logger.error("License Request XHR failed ("+e+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=A-this._requestLicenseFailureCount+1;L.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,c)}break}},m._generateLicenseRequestChallenge=function(u,e){switch(u.mediaKeySystemDomain){case C.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},m._requestLicense=function(u,e){L.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){L.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var c=this.getLicenseServerUrl(s.mediaKeySystemDomain),v=this._createLicenseXhr(c,u,e);L.logger.log("Sending license request to URL: "+c);var i=this._generateLicenseRequestChallenge(s,u);v.send(i)}catch(r){L.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(u,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var u=this._media,e=this._mediaKeysList;!u||(u.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 u.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(u,e){if(!!this._emeEnabled){var s=e.levels.map(function(v){return v.audioCodec}).filter(function(v){return!!v}),c=e.levels.map(function(v){return v.videoCodec}).filter(function(v){return!!v});this._attemptKeySystemAccess(C.KeySystems.WIDEVINE,s,c)}},O(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,g){"use strict";g.r(R);var M=g("./src/events.ts"),_=g("./src/utils/logger.ts"),L=function(){function C(O){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=O,this.registerListeners()}var b=C.prototype;return b.setStreamController=function(A){this.streamController=A},b.registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching)},b.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},b.onMediaAttaching=function(A,y){var T=this.hls.config;if(T.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),T.fpsDroppedMonitoringPeriod)}},b.checkFPS=function(A,y,T){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,m=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,u=1e3*m/E,e=this.hls;if(e.trigger(M.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:T}),u>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;_.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(M.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},b.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},C}();R.default=L},"./src/controller/fragment-finders.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"findFragmentByPDT",function(){return L}),g.d(R,"findFragmentByPTS",function(){return C}),g.d(R,"fragmentWithinToleranceTest",function(){return b}),g.d(R,"pdtWithinToleranceTest",function(){return O}),g.d(R,"findFragWithCC",function(){return A});var M=g("./src/polyfills/number.ts"),_=g("./src/utils/binary-search.ts");function L(y,T,D){if(T===null||!Array.isArray(y)||!y.length||!Object(M.isFiniteNumber)(T))return null;var E=y[0].programDateTime;if(T<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(T>=(m||0))return null;D=D||0;for(var p=0;p<y.length;++p){var u=y[p];if(O(T,D,u))return u}return null}function C(y,T,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var m=null;if(y?m=T[y.sn-T[0].sn+1]||null:D===0&&T[0].start===0&&(m=T[0]),m&&b(D,E,m)===0)return m;var p=_.default.search(T,b.bind(null,D,E));return p||m}function b(y,T,D){y===void 0&&(y=0),T===void 0&&(T=0);var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function O(y,T,D){var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,m=D.endProgramDateTime||0;return m-E>y}function A(y,T){return _.default.search(y,function(D){return D.cc<T?1:D.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"FragmentState",function(){return L}),g.d(R,"FragmentTracker",function(){return C});var M=g("./src/events.ts"),_=g("./src/types/loader.ts"),L;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(L||(L={}));var C=function(){function A(T){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=T,this._registerListeners()}var y=A.prototype;return y._registerListeners=function(){var D=this.hls;D.on(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===_.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var u=p.length;u--;){var e=p[u],s=e?e.end:m.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return u>9&&(this.activeParts=p.slice(u-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),u=p.length;u--;){var e=m[p[u]];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(u){var e=p.fragments[u];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(c){var v=!p.isTimeBuffered(c.startPTS,c.endPTS,E);return v&&p.removeFragment(e.body),v})}})},y.detectPartialFragments=function(D){var E=this,m=this.timeRanges,p=D.frag,u=D.part;if(!(!m||p.sn==="initSegment")){var e=O(p),s=this.fragments[e];!s||(Object.keys(m).forEach(function(c){var v=p.elementaryStreams[c];if(!!v){var i=m[c],r=u!==null||v.partial===!0;s.range[c]=E.getBufferedTimes(p,u,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=O(D),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(D,E,m,p){for(var u={time:[],partial:m},e=E?E.start:D.start,s=E?E.end:D.end,c=D.minEndPTS||s,v=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(v>=r&&c<=o){u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)u.partial=!0,u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return u},y.getPartialFragment=function(D){var E=null,m,p,u,e=0,s=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(v){var i=c[v];!i||b(i)&&(p=i.body.start-s,u=i.body.end+s,D>=p&&D<=u&&(m=Math.min(D-p,u-D),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(D){var E=O(D),m=this.fragments[E];return m?m.buffered?b(m)?L.PARTIAL:L.OK:L.APPENDING:L.NOT_LOADED},y.isTimeBuffered=function(D,E,m){for(var p,u,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,u=m.end(e)+this.bufferPadding,D>=p&&E<=u)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 u=O(m);this.fragments[u]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var m=this,p=E.frag,u=E.part,e=E.timeRanges;if(p.type===_.PlaylistLevelType.MAIN)if(this.activeFragment=p,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(c){var v=e[c];if(m.detectEvictedFragments(c,v),!u)for(var i=0;i<v.length;i++)p.appendedPTS=Math.max(v.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=O(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(u){var e=p.fragments[u];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=O(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},A}();function b(A){var y,T;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((T=A.range.audio)===null||T===void 0?void 0:T.partial))}function O(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"STALL_MINIMUM_DURATION_MS",function(){return b}),g.d(R,"MAX_START_GAP_JUMP",function(){return O}),g.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),g.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),g.d(R,"default",function(){return T});var M=g("./src/utils/buffer-helper.ts"),_=g("./src/errors.ts"),L=g("./src/events.ts"),C=g("./src/utils/logger.ts"),b=250,O=2,A=.1,y=.05,T=function(){function D(m,p,u,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=u,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,u){var e=this.config,s=this.media,c=this.stalled;if(s!==null){var v=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,v!==p){if(this.moved=!0,c!==null){if(this.stallReported){var d=self.performance.now()-c;C.logger.warn("playback not stuck anymore @"+v+", after "+Math.round(d)+"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||!M.BufferHelper.getBuffered(s).length)){var t=M.BufferHelper.bufferInfo(s,v,0),n=t.len>0,l=t.nextStart||0;if(!(!n&&!l)){if(i){var a=t.len>O,f=!l||u&&u.start<=v||l-v>O&&!this.fragmentTracker.getPartialFragment(v);if(a||f)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h,S=Math.max(l,t.start||0)-v,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||(h=x.details)===null||h===void 0?void 0:h.live,k=P?x.details.targetduration*2:O;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(c===null){this.stalled=B;return}var U=B-c;if(!(!i&&U>=b&&(this._reportStall(t),!this.media))){var W=M.BufferHelper.bufferInfo(s,v,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,u){var e=this.config,s=this.fragmentTracker,c=this.media;if(c!==null){var v=c.currentTime,i=s.getPartialFragment(v);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&u>e.highBufferWatchdogPeriod*1e3&&(C.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var u=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,C.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var u=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var c=s.currentTime,v=0,i=M.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(c+u.maxBufferHole>=v&&c<o){var d=Math.max(o+y,s.currentTime+A);return C.logger.warn("skipping hole, adjusting currentTime from "+c+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,p&&e.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+c+" to "+d,frag:p}),d}v=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,u=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var c=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var v=c+(s+1)*p.nudgeOffset;C.logger.warn("Nudging 'currentTime' from "+c+" to "+v),e.currentTime=v,u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else C.logger.error("Playhead still not moving while enough data buffered @"+c+" after "+p.nudgeMaxRetry+" nudges"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/events.ts"),L=g("./src/utils/texttrack-utils.ts"),C=g("./src/demux/id3.ts"),b=g("./src/loader/date-range.ts"),O=g("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(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(u){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=u,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(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(L.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 c=e[s];if(c.kind==="metadata"&&c.label==="id3")return Object(L.sendAddTrackEvent)(c,this.media),c}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var c=this.hls.config,v=c.enableEmsgMetadataCues,i=c.enableID3MetadataCues;if(!(!v&&!i)){var r=s.frag,o=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=d.edge||r.end,n=y(),l=!1,a={},f=0;f<o.length;f++){var h=o[f].type;if(!(h===O.MetadataSchema.emsg&&!v||!i)){var S=C.getID3Frames(o[f].data);if(S){var x=o[f].pts,P=t,k=P-x;k<=0&&(P=x+A);for(var B=0;B<S.length;B++){var U=S[B];if(!C.isTimeStampFrame(U)){var W=new n(x,P,"");W.value=U,h&&(W.type=h),this.id3Track.addCue(W),a[U.key]=null,l=!0}}}}}l&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,c=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(c)for(var v=c.length;v--;){var i,r=c[v],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var d=e[o];d&&r.endTime!==d&&(r.endTime=d),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var c=s.startOffset,v=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var d=o.config,t=d.enableEmsgMetadataCues,n=d.enableID3MetadataCues;if(r&&(t||n)){var l;i==="audio"?l=function(f){return f.type===O.MetadataSchema.audioId3&&n}:i==="video"?l=function(f){return f.type===O.MetadataSchema.emsg&&t}:l=function(f){return f.type===O.MetadataSchema.audioId3&&n||f.type===O.MetadataSchema.emsg&&t},Object(L.removeCuesInRange)(r,c,v,l)}}},p.onLevelUpdated=function(e,s){var c=this,v=s.details;if(!(!this.media||!v.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=v.dateRanges,d=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!d.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]},l=t.length;l--;)n(l);var a=v.fragments[v.fragments.length-1];if(!(d.length===0||!Object(M.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=a.programDateTime/1e3-a.start,h=v.edge||a.end,S=y(),x=function(B){var U=d[B],W=o[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,$=T(W.startDate,f),Z=h,q=W.endDate;if(q)Z=T(q,f),Y=!0;else if(W.endOnNext&&!Y){var ie=d.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=T(ie.startDate,f),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var te=ne[ae];if(!(te===b.DateRangeAttribute.ID||te===b.DateRangeAttribute.CLASS||te===b.DateRangeAttribute.START_DATE||te===b.DateRangeAttribute.DURATION||te===b.DateRangeAttribute.END_DATE||te===b.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===b.DateRangeAttribute.SCTE35_OUT||te===b.DateRangeAttribute.SCTE35_IN)&&(de=D(de)),fe.value={key:te,data:de},fe.type=O.MetadataSchema.dateRange,c.id3Track.addCue(fe),z[te]=fe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},P=0;P<d.length;P++)x(P)}}},m}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return O});var M=g("./src/errors.ts"),_=g("./src/events.ts"),L=g("./src/utils/logger.ts");function C(A,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(A,D.key,D)}}function b(A,y,T){return y&&C(A.prototype,y),T&&C(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var O=function(){function A(T){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=T,this.config=T.config,this.registerListeners()}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(_.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(_.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===M.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.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,u=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!u||e===1)){var s=this.targetLatency;if(s!==null){var c=m-s,v=Math.min(this.maxLatency,s+E.targetduration),i=c<v;if(E.live&&i&&c>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*c-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},b(A,[{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,u=this.config,e=u.liveSyncDuration,s=u.liveSyncDurationCount,c=u.lowLatencyMode,v=this.hls.userConfig,i=c&&m||E;(v.liveSyncDuration||v.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,u=D-E-this.edgeStalled,e=p-m.totalduration,s=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,u),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}}]),A}()},"./src/controller/level-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return u});var M=g("./src/types/level.ts"),_=g("./src/events.ts"),L=g("./src/errors.ts"),C=g("./src/utils/codecs.ts"),b=g("./src/controller/level-helper.ts"),O=g("./src/controller/base-playlist-controller.ts"),A=g("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var c=arguments[s];for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(e[v]=c[v])}return e},y.apply(this,arguments)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),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(v,i){return v.__proto__=i,v},m(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(e){E(s,e);function s(v){var i;return i=e.call(this,v,"[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 c=s.prototype;return c._registerListeners=function(){var i=this.hls;i.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(_.Events.ERROR,this.onError,this)},c._unregisterListeners=function(){var i=this.hls;i.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(_.Events.ERROR,this.onError,this)},c.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},c.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},c.onManifestLoaded=function(i,r){var o=[],d=[],t=[],n,l={},a,f=!1,h=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;f=f||!!(B.width&&B.height),h=h||!!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=l[W],a?a.url.push(B.url):(a=new M.Level(B),l[W]=a,o.push(a)),U&&(U.AUDIO&&Object(b.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(b.addGroupId)(a,"text",U.SUBTITLES))}),(f||h)&&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(C.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(C.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(d=r.audioTracks.filter(function(B){return!B.audioCodec||Object(C.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(b.assignTrackIdsByGroup)(d)),r.subtitles&&(t=r.subtitles,Object(b.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var x=0;x<o.length;x++)if(o[x].bitrate===n){this._firstLevel=x,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var P=S&&!h,k={levels:o,audioTracks:d,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:h,altAudio:!P&&d.some(function(B){return!!B.url})};this.hls.trigger(_.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},c.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var d=r.context,t=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&d.groupId===t.audioGroupIds[t.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&d.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,l=!0,a;switch(r.details){case L.ErrorDetails.FRAG_LOAD_ERROR:case L.ErrorDetails.FRAG_LOAD_TIMEOUT:case L.ErrorDetails.KEY_LOAD_ERROR:case L.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===A.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,h=this._levels[f];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=f)):a=f}break;case L.ErrorDetails.LEVEL_LOAD_ERROR:case L.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(l=!1),a=d.level),n=!0;break;case L.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,l)}},c.recoverLevel=function(i,r,o,d){var t=i.details,n=this._levels[r];if(n.loadError++,o){var l=this.retryLoadingOrFail(i);if(l)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var f=-1,h=this._levels,S=h.length;S--;){var x=(S+this.currentLevelIndex)%h.length;if(x!==this.currentLevelIndex&&h[x].loadError===0){f=x;break}}f>-1&&this.currentLevelIndex!==f&&(this.warn(t+": switch to "+f),i.levelRetry=!0,this.hls.nextAutoLevel=f)}}},c.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var d=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(t){t.urlId=d}),this.level=i}},c.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===A.PlaylistLevelType.MAIN){var d=this._levels[o.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},c.onLevelLoaded=function(i,r){var o,d=r.level,t=r.details,n=this._levels[d];if(!n){var l;this.warn("Invalid level index "+d),(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(d,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},c.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var d=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){d=n;break}d!==o.urlId&&(o.urlId=d,this.startLoad())}},c.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var d=o.urlId,t=o.url[d];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 "+d+" "+t),this.clearTimer(),this.hls.trigger(_.Events.LEVEL_LOADING,{url:t,level:r,id:d,deliveryDirectives:i||null})}},c.removeLevel=function(i,r){var o=function(n,l){return l!==r},d=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 l=t.details;return l!=null&&l.fragments&&l.fragments.forEach(function(a){a.level=n}),t});this._levels=d,this.hls.trigger(_.Events.LEVELS_UPDATED,{levels:d})},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 d=i<0;if(this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],l=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},l,{level:i,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete a._urlId,this.hls.trigger(_.Events.LEVEL_SWITCHING,a);var f=l.details;if(!f||f.live){var h=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(h)}}}},{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}(O.default)},"./src/controller/level-helper.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"addGroupId",function(){return b}),g.d(R,"assignTrackIdsByGroup",function(){return O}),g.d(R,"updatePTS",function(){return A}),g.d(R,"updateFragPTSDTS",function(){return T}),g.d(R,"mergeDetails",function(){return D}),g.d(R,"mapPartIntersection",function(){return m}),g.d(R,"mapFragmentIntersection",function(){return p}),g.d(R,"adjustSliding",function(){return u}),g.d(R,"addSliding",function(){return e}),g.d(R,"computeReloadInterval",function(){return s}),g.d(R,"getFragmentWithSN",function(){return c}),g.d(R,"getPartWith",function(){return v});var M=g("./src/polyfills/number.ts"),_=g("./src/utils/logger.ts"),L=g("./src/loader/date-range.ts");function C(){return C=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&(i[d]=o[d])}return i},C.apply(this,arguments)}function b(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 O(i){var r={};i.forEach(function(o){var d=o.groupId||"";o.id=r[d]=r[d]||0,r[d]++})}function A(i,r,o){var d=i[r],t=i[o];y(d,t)}function y(i,r){var o=r.startPTS;if(Object(M.isFiniteNumber)(o)){var d=0,t;r.sn>i.sn?(d=o-i.start,t=i):(d=i.start-o,t=r),t.duration!==d&&(t.duration=d)}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 T(i,r,o,d,t,n){var l=d-o;l<=0&&(_.logger.warn("Fragment should have a positive duration",r),d=o+r.duration,n=t+r.duration);var a=o,f=d,h=r.startPTS,S=r.endPTS;if(Object(M.isFiniteNumber)(h)){var x=Math.abs(h-o);Object(M.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,a=Math.max(o,h),o=Math.min(o,h),t=Math.min(t,r.startDTS),f=Math.min(d,S),d=Math.max(d,S),n=Math.max(n,r.endDTS)}r.duration=d-o;var P=o-r.start;r.appendedPTS=d,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=d,r.minEndPTS=f,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,P}function D(i,r){for(var o=null,d=i.fragments,t=d.length-1;t>=0;t--){var n=d[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var l=0,a;if(p(i,r,function(B,U){B.relurl&&(l=B.cc-U.cc),Object(M.isFiniteNumber)(B.startPTS)&&Object(M.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 f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.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){_.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=r.skippedSegments;h--;)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(l){_.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=l}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?T(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):u(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var P=r.advancedDateTime;if(r.advanced&&P){var k=r.edge;r.driftStart||(r.driftStartTime=P,r.driftStart=k),r.driftEndTime=P,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var d=C({},i);return o&&o.forEach(function(t){delete d[t]}),Object.keys(r).forEach(function(t){var n=new L.DateRange(r[t].attr,d[t]);n.isValid?d[t]=n:_.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),d}function m(i,r,o){if(i&&r)for(var d=0,t=0,n=i.length;t<=n;t++){var l=i[t],a=r[t+d];l&&a&&l.index===a.index&&l.fragment.sn===a.fragment.sn?o(l,a):d--}}function p(i,r,o){for(var d=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(d?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,l=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t;h<=n;h++){var S=f[l+h],x=a[h];d&&!x&&h<d&&(x=r.fragments[h]=S),S&&x&&o(S,x)}}function u(i,r){var o=r.startSN+r.skippedSegments-i.startSN,d=i.fragments;o<0||o>=d.length||e(r,d[o].start)}function e(i,r){if(r){for(var o=i.fragments,d=i.skippedSegments;d<o.length;d++)o[d].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,d=o/2,t=i.age,n=t>0&&t<o*3,l=r.loading.end-r.loading.start,a,f=i.availabilityDelay;if(i.updated===!1)if(n){var h=333*i.misses;a=Math.max(Math.min(d,l*2),h),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=d;else n?(f=Math.min(f||o/2,t),i.availabilityDelay=f,a=f+o-t):a=o-l;return Math.round(a)}function c(i,r,o){if(!i||!i.details)return null;var d=i.details,t=d.fragments[r-d.startSN];return t||(t=d.fragmentHint,t&&t.sn===r)?t:r<d.startSN&&o&&o.sn===r?o:null}function v(i,r,o){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var t=d.length;t--;){var n=d[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return v});var M=g("./src/polyfills/number.ts"),_=g("./src/controller/base-stream-controller.ts"),L=g("./src/is-supported.ts"),C=g("./src/events.ts"),b=g("./src/utils/buffer-helper.ts"),O=g("./src/controller/fragment-tracker.ts"),A=g("./src/types/loader.ts"),y=g("./src/loader/fragment.ts"),T=g("./src/demux/transmuxer-interface.ts"),D=g("./src/types/transmuxer.ts"),E=g("./src/controller/gap-controller.ts"),m=g("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var d=r[o];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function u(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(d,t){return d.__proto__=t,d},s(i,r)}var c=100,v=function(i){e(r,i);function r(d,t){var n;return n=i.call(this,d,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(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(C.Events.ERROR,this.onError,this),t.on(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(C.Events.ERROR,this.onError,this),t.off(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(c),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=l.startLevel;a===-1&&(l.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=l.nextAutoLevel),this.level=l.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=_.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=_.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_LEVEL:{var t,n=this.levels,l=this.level,a=n==null||(t=n[l])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=_.State.IDLE;break}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var f,h=self.performance.now(),S=this.retryDate;(!S||h>=S||(f=this.media)!==null&&f!==void 0&&f.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=_.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,l=this.hls,a=this.levelLastLoaded,f=this.levels,h=this.media,S=l.config,x=l.nextLoadLevel;if(!(a===null||!h&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!f||!f[x])){var P=f[x];this.level=l.nextLoadLevel=x;var k=P.details;if(!k||this.state===_.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==x){this.state=_.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(P.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(C.Events.BUFFER_EOS,G),this.state=_.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)!==O.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)===O.FragmentState.OK&&this.nextLoadPosition>z){var ne=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;h&&this.afterBufferFlushed(h,ne,A.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,l){var a,f=this.fragmentTracker.getState(t);this.fragCurrent=t,f===O.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,l)):f===O.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,A.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,A.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 l,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var f=this.hls.nextLoadLevel,h=t[f],S=this.fragLastKbps;S&&this.fragCurrent?l=this.fragCurrent.duration*h.maxBitrate/(1e3*S)+1:l=0}else l=0;var x=this.getBufferedFrag(n.currentTime+l);if(x){var P=this.followingBufferedFrag(x);if(P){this.abortCurrentFrag();var k=P.maxStartPTS?P.maxStartPTS:P.start,B=P.duration,U=Math.max(x.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 _.State.KEY_LOADING:case _.State.FRAG_LOADING:case _.State.FRAG_LOADING_WAITING_RETRY:case _.State.PARSING:case _.State.PARSED:this.state=_.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 l=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,l,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(M.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(C.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 l=!1,a=!1,f;n.levels.forEach(function(h){f=h.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(l=!0),f.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=l&&a&&!Object(L.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 l=this.levels;if(!(!l||this.state!==_.State.IDLE)){var a=l[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=_.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var l,a=this.levels,f=n.level,h=n.details,S=h.totalduration;if(!a){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+h.startSN+","+h.endSN+"], cc ["+h.startCC+", "+h.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===_.State.FRAG_LOADING||this.state===_.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==n.level&&x.loader&&(this.state=_.State.IDLE,this.backtrackFragment=null,x.loader.abort());var P=a[f],k=0;if(h.live||(l=P.details)!==null&&l!==void 0&&l.live){if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed)return;k=this.alignPlaylists(h,P.details)}if(P.details=h,this.levelLastLoaded=f,this.hls.trigger(C.Events.LEVEL_UPDATED,{details:h,level:f}),this.state===_.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=_.State.IDLE}this.startFragRequested?h.live&&this.synchronizeToLiveEdge(h):this.setStartPosition(h,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,l=t.frag,a=t.part,f=t.payload,h=this.levels;if(!h){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var S=h[l.level],x=S.details;if(!x){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var P=S.videoCodec,k=x.PTSKnown||!x.live,B=(n=l.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=a?a.index:-1,z=G!==-1,Y=new D.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,f.byteLength,G,z),$=this.initPTS[l.cc];W.push(f,B,U,P,l,a,x.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var l=this.altAudio,a=!!n.url,f=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 h=this.fragCurrent;h!=null&&h.loader&&(this.log("Switching to main audio track, cancel main fragment load"),h.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;l&&S.trigger(C.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(C.Events.AUDIO_TRACK_SWITCHED,{id:f})}},o.onAudioTrackSwitched=function(t,n){var l=n.id,a=!!this.hls.audioTracks[l].url;if(a){var f=this.videoBuffer;f&&this.mediaBuffer!==f&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=f)}this.altAudio=a,this.tick()},o.onBufferCreated=function(t,n){var l=n.tracks,a,f,h=!1;for(var S in l){var x=l[S];if(x.id==="main"){if(f=S,a=x,S==="video"){var P=l[S];P&&(this.videoBuffer=P.buffer)}}else h=!0}h&&a?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var l=n.frag,a=n.part;if(!(l&&l.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(a?" p: "+a.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===_.State.PARSED&&(this.state=_.State.IDLE);return}var f=a?a.stats:l.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,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(A.PlaylistLevelType.MAIN,n);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==_.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=_.State.ERROR):!n.levelRetry&&this.state===_.State.WAITING_LEVEL&&(this.state=_.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var l=!0,a=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);a&&a.len>.5&&(l=!this.reduceMaxBufferLength(a.len)),l&&(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||!b.BufferHelper.getBuffered(t).length){var l=this.state!==_.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,l)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=_.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var l=n.type;if(l!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(l===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,l,A.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,l=this.startPosition;if(l>=0&&n<l){if(t.seeking){this.log("could not seek to "+l+", already seeking at "+n);return}var a=b.BufferHelper.getBuffered(t),f=a.length?a.start(0):0,h=f-l;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),l+=h,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+n),t.currentTime=l}}},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(l){var a=n.hls;if(!(!l||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=_.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var f=t.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),a.trigger(C.Events.FRAG_LOADED,l),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,l="main",a=this.hls,f=t.remuxResult,h=t.chunkMeta,S=this.getCurrentContext(h);if(!S){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(h.level);return}var x=S.frag,P=S.part,k=S.level,B=f.video,U=f.text,W=f.id3,G=f.initSegment,z=k.details,Y=this.altAudio?void 0:f.audio;if(!this.fragContextChanged(x)){if(this.state=_.State.PARSING,G){G.tracks&&(this._bufferInitSegment(k,G.tracks,x,h),a.trigger(C.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:l,tracks:G.tracks}));var $=G.initPTS,Z=G.timescale;Object(M.isFiniteNumber)($)&&(this.initPTS[x.cc]=$,a.trigger(C.Events.INIT_PTS_FOUND,{frag:x,id:l,initPTS:$,timescale:Z}))}if(B&&f.independent!==!1){if(z){var q=B.startPTS,ie=B.endPTS,ne=B.startDTS,ae=B.endDTS;if(P)P.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(x);return}x.setElementaryStreamInfo(B.type,x.start,ie,x.start,ae,!0)}x.setElementaryStreamInfo(B.type,q,ie,ne,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(B,x,P,h)}}else if(f.independent===!1){this.backtrack(x);return}if(Y){var re=Y.startPTS,Ee=Y.endPTS,me=Y.startDTS,Te=Y.endDTS;P&&(P.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:Ee,startDTS:me,endDTS:Te}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,Ee,me,Te),this.bufferFragmentData(Y,x,P,h)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:l,frag:x,details:z,samples:W.samples};a.trigger(C.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Ae={id:l,frag:x,details:z,samples:U.samples};a.trigger(C.Events.FRAG_PARSING_USERDATA,Ae)}}},o._bufferInitSegment=function(t,n,l,a){var f=this;if(this.state===_.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var h=n.audio,S=n.video,x=n.audiovideo;if(h){var P=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),h.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(P="mp4a.40.5")),k.indexOf("android")!==-1&&h.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),t.audioCodec&&t.audioCodec!==P&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+P+'"'),h.levelCodec=P,h.id="main",this.log("Init audio buffer, container:"+h.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(t.audioCodec||"")+"/"+h.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),x&&this.log("Init audiovideo buffer, container:"+x.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+x.codec+"]"),this.hls.trigger(C.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&f.hls.trigger(C.Events.BUFFER_APPENDING,{type:B,data:W,frag:l,part:null,chunkMeta:a,parent:l.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.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=_.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var l=t.currentTime;if(b.BufferHelper.isBuffered(t,l)?n=this.getAppendedFrag(l):b.BufferHelper.isBuffered(t,l+.1)&&(n=this.getAppendedFrag(l+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,f=n.level;(!a||n.sn!==a.sn||a.level!==f||n.urlId!==a.urlId)&&(this.hls.trigger(C.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==f)&&this.hls.trigger(C.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=n)}}},u(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,l=this.currentFrag;if(l&&Object(M.isFiniteNumber)(n)&&Object(M.isFiniteNumber)(l.programDateTime)){var a=l.programDateTime+(n-l.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}(_.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"SubtitleStreamController",function(){return e});var M=g("./src/events.ts"),_=g("./src/utils/buffer-helper.ts"),L=g("./src/controller/fragment-finders.ts"),C=g("./src/utils/discontinuities.ts"),b=g("./src/controller/level-helper.ts"),O=g("./src/controller/fragment-tracker.ts"),A=g("./src/controller/base-stream-controller.ts"),y=g("./src/types/loader.ts"),T=g("./src/types/level.ts");function D(c,v){for(var i=0;i<v.length;i++){var r=v[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,r.key,r)}}function E(c,v,i){return v&&D(c.prototype,v),i&&D(c,i),Object.defineProperty(c,"prototype",{writable:!1}),c}function m(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,p(c,v)}function p(c,v){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(c,v)}var u=500,e=function(c){m(v,c);function v(r,o){var d;return d=c.call(this,r,o,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=v.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this),o.on(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this),o.off(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(u),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(o,d){var t=d.frag,n=d.success;if(this.fragPrevious=t,this.state=A.State.IDLE,!!n){var l=this.tracksBuffered[this.currentTrackId];if(!!l){for(var a,f=t.start,h=0;h<l.length;h++)if(f>=l[h].start&&f<=l[h].end){a=l[h];break}var S=t.start+t.duration;a?a.end=S:(a={start:f,end:S},l.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,d){var t=d.startOffset,n=d.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var l=this.currentTrackId,a=this.levels;if(!a.length||!a[l]||!a[l].details)return;var f=a[l].details,h=f.targetduration,S=n-h;if(S<=0)return;d.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(x){for(var P=0;P<x.length;){if(x[P].end<=S){x.shift();continue}else if(x[P].start<S)x[P].start=S;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(o,d){var t,n=d.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(o,d){var t=this,n=d.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(l){return new T.Level(l)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(l){t.tracksBuffered[l.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,d){if(this.currentTrackId=d.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(u)},i.onSubtitleTrackLoaded=function(o,d){var t,n=d.details,l=d.id,a=this.currentTrackId,f=this.levels;if(!!f.length){var h=f[a];if(!(l>=f.length||l!==a||!h)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=h.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!h.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(C.alignMediaPlaylistByPDT)(n,S):x&&Object(b.addSliding)(n,x.start);else{var P=this.alignPlaylists(n,h.details);P===0&&x&&Object(b.addSliding)(n,x.start)}}if(h.details=n,this.levelLastLoaded=l,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var k=Object(L.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var d=o.frag,t=o.payload,n=d.decryptdata,l=this.hls;if(!this.fragContextChanged(d)&&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(f){var h=performance.now();l.trigger(M.Events.FRAG_DECRYPTED,{frag:d,payload:f,stats:{tstart:a,tdecrypt:h}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var o=this.currentTrackId,d=this.levels;if(!d.length||!d[o]||!d[o].details)return;var t=d[o].details,n=t.targetduration,l=this.config,a=this.media,f=_.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,l.maxBufferHole),h=f.end,S=f.len,x=this.getMaxBufferLength()+n;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var P=t.fragments,k=P.length,B=t.edge,U,W=this.fragPrevious;if(h<B){var G=l.maxFragLookUpTolerance;U=Object(L.findFragmentByPTS)(W,P,Math.max(P[0].start,h),G),!U&&W&&W.start<P[0].start&&(U=P[0])}else U=P[k-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==O.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,h)}},i.loadFragment=function(o,d,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):c.prototype.loadFragment.call(this,o,d,t)},E(v,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),v}(A.default),s=function(v){this.buffered=void 0;var i=function(o,d,t){if(d=d>>>0,d>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+t+")");return v[d][o]};this.buffered={get length(){return v.length},end:function(o){return i("end",o,v.length)},start:function(o){return i("start",o,v.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/events.ts"),_=g("./src/utils/texttrack-utils.ts"),L=g("./src/controller/base-playlist-controller.ts"),C=g("./src/types/loader.ts");function b(E,m){for(var p=0;p<m.length;p++){var u=m[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,m,p){return m&&b(E.prototype,m),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function A(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(u,e){return u.__proto__=e,u},y(E,m)}var T=function(E){A(m,E);function m(u){var e;return e=E.call(this,u,"[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(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(M.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(_.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 c=s.id,v=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+c);return}var o=r.details;r.details=s.details,this.log("subtitle track "+c+" loaded ["+v.startSN+"-"+v.endSN+"]"),c===this.trackId&&(this.retryCount=0,this.playlistLoaded(c,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 c=s.textGroupIds[s.urlId];if(this.groupId!==c){var v=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!c||d.groupId===c});this.tracksInGroup=i;var r=this.findTrackId(v==null?void 0:v.name)||this.findTrackId();this.groupId=c;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+c+'" group-id'),this.hls.trigger(M.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,v)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,c=0;c<s.length;c++){var v=s[c];if((!this.selectDefaultTrack||v.default)&&(!e||e===v.name))return v.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===C.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 c=s.id,v=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 "+c),this.hls.trigger(M.Events.SUBTITLE_TRACK_LOADING,{url:i,id:c,groupId:v,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,c=this.media,v=this.trackId;if(!!c){var i=D(c.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[v];o&&(o.mode="disabled")}var d=r[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var c,v=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(c=v[e])!==null&&c!==void 0&&c.details)||e<-1||e>=v.length)){this.clearTimer();var i=v[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,d=o===void 0?"":o,t=i.name,n=i.type,l=i.url;this.hls.trigger(M.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:d,name:t,type:n,url:l});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(M.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),c=0;c<s.length;c++)if(s[c].mode==="hidden")e=c;else if(s[c].mode==="showing"){e=c;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(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}(L.default);function D(E){for(var m=[],p=0;p<E.length;p++){var u=E[p];u.kind==="subtitles"&&u.label&&m.push(E[p])}return m}R.default=T},"./src/controller/timeline-controller.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"TimelineController",function(){return E});var M=g("./src/polyfills/number.ts"),_=g("./src/events.ts"),L=g("./src/utils/cea-608-parser.ts"),C=g("./src/utils/output-filter.ts"),b=g("./src/utils/webvtt-parser.ts"),O=g("./src/utils/texttrack-utils.ts"),A=g("./src/utils/imsc1-ttml-parser.ts"),y=g("./src/utils/mp4-tools.ts"),T=g("./src/types/loader.ts"),D=g("./src/utils/logger.ts"),E=function(){function e(c){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=u(),this.captionsProperties=void 0,this.hls=c,this.config=c.config,this.Cues=c.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 v=new C.default(this,"textTrack1"),i=new C.default(this,"textTrack2"),r=new C.default(this,"textTrack3"),o=new C.default(this,"textTrack4");this.cea608Parser1=new L.default(1,v,i),this.cea608Parser2=new L.default(3,r,o)}c.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),c.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),c.on(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(_.Events.FRAG_LOADING,this.onFragLoading,this),c.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),c.on(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),c.on(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),c.on(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),c.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var v=this.hls;v.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(_.Events.FRAG_LOADING,this.onFragLoading,this),v.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),v.off(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),v.off(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),v.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(v,i,r,o,d){for(var t=!1,n=d.length;n--;){var l=d[n],a=p(l[0],l[1],i,r);if(a>=0&&(l[0]=Math.min(l[0],i),l[1]=Math.max(l[1],r),t=!0,a/(r-i)>.5))return}if(t||d.push([i,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[v];this.Cues.newCue(f,i,r,o)}else{var h=this.Cues.newCue(null,i,r,o);this.hls.trigger(_.Events.CUES_PARSED,{type:"captions",cues:h,track:v})}},s.onInitPtsFound=function(v,i){var r=this,o=i.frag,d=i.id,t=i.initPTS,n=i.timescale,l=this.unparsedVttFrags;d==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),l.length&&(this.unparsedVttFrags=[],l.forEach(function(a){r.onFragLoaded(_.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(v){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[v])return o}return null},s.createCaptionsTrack=function(v){this.config.renderTextTracksNatively?this.createNativeTrack(v):this.createNonNativeTrack(v)},s.createNativeTrack=function(v){if(!this.captionsTracks[v]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,d=i[v],t=d.label,n=d.languageCode,l=this.getExistingTrack(v);if(l)r[v]=l,Object(O.clearCurrentCues)(r[v]),Object(O.sendAddTrackEvent)(r[v],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[v]=!0,r[v]=a)}}},s.createNonNativeTrack=function(v){if(!this.nonNativeCaptionsTracks[v]){var i=this.captionsProperties[v];if(!!i){var r=i.label,o={_id:v,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[v]=o,this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(v,i,r){var o=this.media;if(!!o)return o.addTextTrack(v,i,r)},s.onMediaAttaching=function(v,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var v=this.captionsTracks;Object.keys(v).forEach(function(i){Object(O.clearCurrentCues)(v[i]),delete v[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=u(),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 v=this.media;if(!!v){var i=v.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(v,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],d=o.some(function(a){return a.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&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,f){var h;if(f<n.length){for(var S=null,x=0;x<n.length;x++)if(m(n[x],a)){S=n[x];break}S&&(h=S)}if(h)Object(O.clearCurrentCues)(h);else{var P=r._captionsOrSubtitlesFromCharacteristics(a);h=r.createTextTrack(P,a.name,a.lang),h&&(h.mode="disabled")}h&&(h.groupId=a.groupId,r.textTracks.push(h))})}else if(!t&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},s._captionsOrSubtitlesFromCharacteristics=function(v){var i;if((i=v.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(v.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(v.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(v,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var d=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!d){var t="textTrack"+d[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2,d=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===T.PlaylistLevelType.MAIN){var n,l,a=i.frag.sn,f=(n=i==null||(l=i.part)===null||l===void 0?void 0:l.index)!=null?n:-1;a===d+1||a===d&&f===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=f}},s.onFragLoaded=function(v,i){var r=i.frag,o=i.payload,d=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(M.isFiniteNumber)(d[r.cc])){t.push(i),d.length&&this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,l="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||l){var a=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===A.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,f)}}else this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(v,i){var r=this,o=this.hls;Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(d){r._appendCues(d,v.level),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(d){D.logger.log("Failed to parse IMSC1: "+d),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:d})})},s._parseVTTs=function(v,i,r){var o,d=this,t=this.hls,n=(o=v.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(v.initSegment.data,new Uint8Array(i)):i;Object(b.parseWebVTT)(n,this.initPTS[v.cc],this.timescale[v.cc],r,v.cc,v.start,function(l){d._appendCues(l,v.level),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(l){d._fallbackToIMSC1(v,i),D.logger.log("Failed to parse VTT cue: "+l),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:l})})},s._fallbackToIMSC1=function(v,i){var r=this,o=this.tracks[v.level];o.textCodec||Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(){o.textCodec=A.IMSC1_CODEC,r._parseIMSC1(v,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(v,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;v.forEach(function(n){return Object(O.addCueToTrack)(o,n)})}else{var d=this.tracks[i];if(!d)return;var t=d.default?"default":"subtitles"+i;r.trigger(_.Events.CUES_PARSED,{type:"subtitles",cues:v,track:t})}},s.onFragDecrypted=function(v,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(M.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(_.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var d=0;d<i.samples.length;d++){var t=i.samples[d].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[d].pts,n[0]),o.addData(i.samples[d].pts,n[1])}}},s.onBufferFlushing=function(v,i){var r=i.startOffset,o=i.endOffset,d=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(f){return Object(O.removeCuesInRange)(l[f],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&d!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(f){return Object(O.removeCuesInRange)(a[f],r,d)})}}},s.extractCea608Data=function(v){for(var i=[[],[]],r=v[0]&31,o=2,d=0;d<r;d++){var t=v[o++],n=127&v[o++],l=127&v[o++];if(!(n===0&&l===0)){var a=(4&t)!==0;if(a){var f=3&t;(f===0||f===1)&&(i[f].push(n),i[f].push(l))}}}return i},e}();function m(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,c,v){return Math.min(s,v)-Math.max(e,c)}function u(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.aesIV=void 0,this.subtle=C,this.aesIV=b}var L=_.prototype;return L.decrypt=function(b,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,b)},_}()},"./src/crypt/aes-decryptor.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"removePadding",function(){return _}),g.d(R,"default",function(){return L});var M=g("./src/utils/typed-array.ts");function _(C){var b=C.byteLength,O=b&&new DataView(C.buffer).getUint8(b-1);return O?Object(M.sliceUint8)(C,0,b-O):C}var L=function(){function C(){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 b=C.prototype;return b.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),T=new Uint32Array(4),D=0;D<4;D++)T[D]=y.getUint32(D*4);return T},b.initTable=function(){var A=this.sBox,y=this.invSBox,T=this.subMix,D=T[0],E=T[1],m=T[2],p=T[3],u=this.invSubMix,e=u[0],s=u[1],c=u[2],v=u[3],i=new Uint32Array(256),r=0,o=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,A[r]=t,y[t]=r;var n=i[r],l=i[n],a=i[l],f=i[t]*257^t*16843008;D[r]=f<<24|f>>>8,E[r]=f<<16|f>>>16,m[r]=f<<8|f>>>24,p[r]=f,f=a*16843009^l*65537^n*257^r*16843008,e[t]=f<<24|f>>>8,s[t]=f<<16|f>>>16,c[t]=f<<8|f>>>24,v[t]=f,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},b.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),T=!0,D=0;D<y.length&&T;)T=y[D]===this.key[D],D++;if(!T){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,u,e=this.keySchedule=new Uint32Array(m),s=this.invKeySchedule=new Uint32Array(m),c=this.sBox,v=this.rcon,i=this.invSubMix,r=i[0],o=i[1],d=i[2],t=i[3],n,l;for(p=0;p<m;p++){if(p<E){n=e[p]=y[p];continue}l=n,p%E===0?(l=l<<8|l>>>24,l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255],l^=v[p/E|0]<<24):E>6&&p%E===4&&(l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255]),e[p]=n=(e[p-E]^l)>>>0}for(u=0;u<m;u++)p=m-u,u&3?l=e[p]:l=e[p-4],u<4||p<=4?s[u]=l:s[u]=r[c[l>>>24]]^o[c[l>>>16&255]]^d[c[l>>>8&255]]^t[c[l&255]],s[u]=s[u]>>>0}},b.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},b.decrypt=function(A,y,T){for(var D=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,u=p[0],e=p[1],s=p[2],c=p[3],v=this.uint8ArrayToUint32Array_(T),i=v[0],r=v[1],o=v[2],d=v[3],t=new Int32Array(A),n=new Int32Array(t.length),l,a,f,h,S,x,P,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],x=G^E[1],P=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)l=u[S>>>24]^e[x>>16&255]^s[P>>8&255]^c[k&255]^E[z],a=u[x>>>24]^e[P>>16&255]^s[k>>8&255]^c[S&255]^E[z+1],f=u[P>>>24]^e[k>>16&255]^s[S>>8&255]^c[x&255]^E[z+2],h=u[k>>>24]^e[S>>16&255]^s[x>>8&255]^c[P&255]^E[z+3],S=l,x=a,P=f,k=h,z=z+4;l=m[S>>>24]<<24^m[x>>16&255]<<16^m[P>>8&255]<<8^m[k&255]^E[z],a=m[x>>>24]<<24^m[P>>16&255]<<16^m[k>>8&255]<<8^m[S&255]^E[z+1],f=m[P>>>24]<<24^m[k>>16&255]<<16^m[S>>8&255]<<8^m[x&255]^E[z+2],h=m[k>>>24]<<24^m[S>>16&255]<<16^m[x>>8&255]<<8^m[P&255]^E[z+3],n[y]=$(l^i),n[y+1]=$(h^r),n[y+2]=$(f^o),n[y+3]=$(a^d),i=B,r=U,o=W,d=G,y=y+4}return n.buffer},C}()},"./src/crypt/decrypter.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return y});var M=g("./src/crypt/aes-crypto.ts"),_=g("./src/crypt/fast-aes-key.ts"),L=g("./src/crypt/aes-decryptor.ts"),C=g("./src/utils/logger.ts"),b=g("./src/utils/mp4-tools.ts"),O=g("./src/utils/typed-array.ts"),A=16,y=function(){function T(E,m,p){var u=p===void 0?{}:p,e=u.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 c=self.crypto;c&&(this.subtle=c.subtle||c.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=T.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(L.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,u,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,u);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,u).then(e)},D.softwareDecrypt=function(m,p,u){var e=this.currentIV,s=this.currentResult,c=this.remainderData;this.logOnce("JS AES decrypt"),c&&(m=Object(b.appendUint8Array)(c,m),this.remainderData=null);var v=this.getValidChunk(m);if(!v.length)return null;e&&(u=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new L.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(v.buffer,0,u),this.currentIV=Object(O.sliceUint8)(v,-16).buffer,r||null},D.webCryptoDecrypt=function(m,p,u){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new _.default(s,p)),this.fastAesKey.expandKey().then(function(c){if(!s)return Promise.reject(new Error("web crypto not initialized"));var v=new M.default(s,u);return v.decrypt(m.buffer,c)}).catch(function(c){return e.onWebCryptoError(c,m,p,u)})},D.onWebCryptoError=function(m,p,u,e){return C.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,u,e)},D.getValidChunk=function(m){var p=m,u=m.length-m.length%A;return u!==m.length&&(p=Object(O.sliceUint8)(m,0,u),this.remainderData=Object(O.sliceUint8)(m,u)),p},D.logOnce=function(m){!this.logEnabled||(C.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.key=void 0,this.subtle=C,this.key=b}var L=_.prototype;return L.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},_}()},"./src/demux/aacdemuxer.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/demux/base-audio-demuxer.ts"),_=g("./src/demux/adts.ts"),L=g("./src/utils/logger.ts"),C=g("./src/demux/id3.ts");function b(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var A=function(y){b(T,y);function T(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=T.prototype;return D.resetInitSegment=function(m,p,u,e){y.prototype.resetInitSegment.call(this,m,p,u,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}},T.probe=function(m){if(!m)return!1;for(var p=C.getID3Data(m,0)||[],u=p.length,e=m.length;u<e;u++)if(_.probe(m,u))return L.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(m,p){return _.canParse(m,p)},D.appendFrame=function(m,p,u){_.initTrackConfig(m,this.observer,p,u,m.manifestCodec);var e=_.appendFrame(m,p,u,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(M.default);R.default=A},"./src/demux/adts.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"getAudioConfig",function(){return C}),g.d(R,"isHeaderPattern",function(){return b}),g.d(R,"getHeaderLength",function(){return O}),g.d(R,"getFullFrameLength",function(){return A}),g.d(R,"canGetFrameLength",function(){return y}),g.d(R,"isHeader",function(){return T}),g.d(R,"canParse",function(){return D}),g.d(R,"probe",function(){return E}),g.d(R,"initTrackConfig",function(){return m}),g.d(R,"getFrameDuration",function(){return p}),g.d(R,"parseFrameHeader",function(){return u}),g.d(R,"appendFrame",function(){return e});var M=g("./src/utils/logger.ts"),_=g("./src/errors.ts"),L=g("./src/events.ts");function C(s,c,v,i){var r,o,d,t,n=navigator.userAgent.toLowerCase(),l=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((c[v+2]&192)>>>6)+1;var f=(c[v+2]&60)>>>2;if(f>a.length-1){s.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return d=(c[v+2]&1)<<2,d|=(c[v+3]&192)>>>6,M.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+f),/firefox/i.test(n)?f>=6?(r=5,t=new Array(4),o=f-3):(r=2,t=new Array(2),o=f):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=f):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&f>=6?o=f-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(f>=6&&d===1||/vivaldi/i.test(n))||!i&&d===1)&&(r=2,t=new Array(2)),o=f)),t[0]=r<<3,t[0]|=(f&14)>>1,t[1]|=(f&1)<<7,t[1]|=d<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[f],channelCount:d,codec:"mp4a.40."+r,manifestCodec:l}}function b(s,c){return s[c]===255&&(s[c+1]&246)===240}function O(s,c){return s[c+1]&1?7:9}function A(s,c){return(s[c+3]&3)<<11|s[c+4]<<3|(s[c+5]&224)>>>5}function y(s,c){return c+5<s.length}function T(s,c){return c+1<s.length&&b(s,c)}function D(s,c){return y(s,c)&&b(s,c)&&A(s,c)<=s.length-c}function E(s,c){if(T(s,c)){var v=O(s,c);if(c+v>=s.length)return!1;var i=A(s,c);if(i<=v)return!1;var r=c+i;return r===s.length||T(s,r)}return!1}function m(s,c,v,i,r){if(!s.samplerate){var o=C(c,v,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,M.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function u(s,c){var v=O(s,c);if(c+v<=s.length){var i=A(s,c)-v;if(i>0)return{headerLength:v,frameLength:i}}}function e(s,c,v,i,r){var o=p(s.samplerate),d=i+r*o,t=u(c,v),n;if(t){var l=t.frameLength,a=t.headerLength,f=a+l,h=Math.max(0,v+f-c.length);h?(n=new Uint8Array(f-a),n.set(c.subarray(v+a,c.length),0)):n=c.subarray(v+a,v+f);var S={unit:n,pts:d};return h||s.samples.push(S),{sample:S,length:f,missing:h}}var x=c.length-v;n=new Uint8Array(x),n.set(c.subarray(v,c.length),0);var P={unit:n,pts:d};return{sample:P,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"initPTSFn",function(){return y});var M=g("./src/polyfills/number.ts"),_=g("./src/demux/id3.ts"),L=g("./src/types/demuxer.ts"),C=g("./src/demux/dummy-demuxed-track.ts"),b=g("./src/utils/mp4-tools.ts"),O=g("./src/utils/typed-array.ts"),A=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=T.prototype;return D.resetInitSegment=function(m,p,u,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,u){},D.demux=function(m,p){this.cachedData&&(m=Object(b.appendUint8Array)(this.cachedData,m),this.cachedData=null);var u=_.getID3Data(m,0),e=u?u.length:0,s,c,v=this._audioTrack,i=this._id3Track,r=u?_.getTimeStamp(u):void 0,o=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(M.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),u&&u.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:u,type:L.MetadataSchema.audioId3}),c=this.basePTS;e<o;){if(this.canParse(m,e)){var d=this.appendFrame(v,m,e);d?(this.frameIndex++,c=d.sample.pts,e+=d.length,s=e):e=o}else _.canParse(m,e)?(u=_.getID3Data(m,e),i.samples.push({pts:c,dts:c,data:u,type:L.MetadataSchema.audioId3}),e+=u.length,s=e):e++;if(e===o&&s!==o){var t=Object(O.sliceUint8)(m,s);this.cachedData?this.cachedData=Object(b.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:v,videoTrack:Object(C.dummyTrack)(),id3Track:i,textTrack:Object(C.dummyTrack)()}},D.demuxSampleAes=function(m,p,u){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(C.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(C.dummyTrack)()}},D.destroy=function(){},T}(),y=function(D,E,m){return Object(M.isFiniteNumber)(D)?D*90:E*9e4+(m||0)};R.default=A},"./src/demux/chunk-cache.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return M});var M=function(){function L(){this.chunks=[],this.dataLength=0}var C=L.prototype;return C.push=function(O){this.chunks.push(O),this.dataLength+=O.length},C.flush=function(){var O=this.chunks,A=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=_(O,A);else return new Uint8Array(0);return this.reset(),y},C.reset=function(){this.chunks.length=0,this.dataLength=0},L}();function _(L,C){for(var b=new Uint8Array(C),O=0,A=0;A<L.length;A++){var y=L[A];b.set(y,O),O+=y.length}return b}},"./src/demux/dummy-demuxed-track.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"dummyTrack",function(){return M});function M(_,L){return _===void 0&&(_=""),L===void 0&&(L=9e4),{type:_,id:-1,pid:-1,inputTimeScale:L,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/utils/logger.ts"),_=function(){function L(b){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=b,this.bytesAvailable=b.byteLength,this.word=0,this.bitsAvailable=0}var C=L.prototype;return C.loadWord=function(){var O=this.data,A=this.bytesAvailable,y=O.byteLength-A,T=new Uint8Array(4),D=Math.min(4,A);if(D===0)throw new Error("no bytes available");T.set(O.subarray(y,y+D)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},C.skipBits=function(O){var A;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,A=O>>3,O-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},C.readBits=function(O){var A=Math.min(this.bitsAvailable,O),y=this.word>>>32-A;return O>32&&M.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=O-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},C.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},C.skipUEG=function(){this.skipBits(1+this.skipLZ())},C.skipEG=function(){this.skipBits(1+this.skipLZ())},C.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},C.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},C.readBoolean=function(){return this.readBits(1)===1},C.readUByte=function(){return this.readBits(8)},C.readUShort=function(){return this.readBits(16)},C.readUInt=function(){return this.readBits(32)},C.skipScalingList=function(O){for(var A=8,y=8,T,D=0;D<O;D++)y!==0&&(T=this.readEG(),y=(A+T+256)%256),A=y===0?A:y},C.readSPS=function(){var O=0,A=0,y=0,T=0,D,E,m,p=this.readUByte.bind(this),u=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),c=this.skipBits.bind(this),v=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(u(5),c(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var d=e();if(d===3&&c(1),i(),i(),c(1),s())for(E=d!==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(c(1),v(),v(),D=e(),m=0;m<D;m++)v();i(),c(1);var n=e(),l=e(),a=u(1);a===0&&c(1),c(1),s()&&(O=e(),A=e(),y=e(),T=e());var f=[1,1];if(s()&&s()){var h=p();switch(h){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:{f=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((n+1)*16-O*2-A*2),height:(2-a)*(l+1)*16-(a?2:4)*(y+T),pixelRatio:f}},C.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},L}();R.default=_},"./src/demux/id3.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"isHeader",function(){return M}),g.d(R,"isFooter",function(){return _}),g.d(R,"getID3Data",function(){return L}),g.d(R,"canParse",function(){return b}),g.d(R,"getTimeStamp",function(){return O}),g.d(R,"isTimeStampFrame",function(){return A}),g.d(R,"getID3Frames",function(){return T}),g.d(R,"decodeFrame",function(){return D}),g.d(R,"utf8ArrayToStr",function(){return e}),g.d(R,"testables",function(){return s});var M=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},_=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},L=function(r,o){for(var d=o,t=0;M(r,o);){t+=10;var n=C(r,o+6);t+=n,_(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(d,d+t)},C=function(r,o){var d=0;return d=(r[o]&127)<<21,d|=(r[o+1]&127)<<14,d|=(r[o+2]&127)<<7,d|=r[o+3]&127,d},b=function(r,o){return M(r,o)&&C(r,o+6)+10<=r.length-o},O=function(r){for(var o=T(r),d=0;d<o.length;d++){var t=o[d];if(A(t))return u(t)}},A=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]),d=C(r,4),t=10;return{type:o,size:d,data:r.subarray(t,t+d)}},T=function(r){for(var o=0,d=[];M(r,o);){var t=C(r,o+6);o+=10;for(var n=o+t;o+8<n;){var l=y(r.subarray(o)),a=D(l);a&&d.push(a),o+=l.size+10}_(r,o)&&(o+=10)}return d},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),d=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:d.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,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,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,data:t}}var n=e(r.data);return{key:r.type,data:n}},u=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),d=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,d&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var d=v();if(d){var t=d.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var l=r.length,a,f,h,S="",x=0;x<l;){if(a=r[x++],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:f=r[x++],S+=String.fromCharCode((a&31)<<6|f&63);break;case 14:f=r[x++],h=r[x++],S+=String.fromCharCode((a&15)<<12|(f&63)<<6|(h&63)<<0);break;default:}}return S},s={decodeTextFrame:m},c;function v(){return!c&&typeof self.TextDecoder!="undefined"&&(c=new self.TextDecoder("utf-8")),c}},"./src/demux/mp3demuxer.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/demux/base-audio-demuxer.ts"),_=g("./src/demux/id3.ts"),L=g("./src/utils/logger.ts"),C=g("./src/demux/mpegaudio.ts");function b(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},O(y,T)}var A=function(y){b(T,y);function T(){return y.apply(this,arguments)||this}var D=T.prototype;return D.resetInitSegment=function(m,p,u,e){y.prototype.resetInitSegment.call(this,m,p,u,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}},T.probe=function(m){if(!m)return!1;for(var p=_.getID3Data(m,0)||[],u=p.length,e=m.length;u<e;u++)if(C.probe(m,u))return L.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(m,p){return C.canParse(m,p)},D.appendFrame=function(m,p,u){if(this.basePTS!==null)return C.appendFrame(m,p,u,this.basePTS,this.frameIndex)},T}(M.default);R.default=A},"./src/demux/mp4demuxer.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/types/demuxer.ts"),L=g("./src/utils/mp4-tools.ts"),C=g("./src/demux/dummy-demuxed-track.ts"),b=/\/emsg[-/]ID3/i,O=function(){function A(T,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=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,m,p){var u=Object(L.parseInitSegment)(D),e=this.videoTrack=Object(C.dummyTrack)("video",1),s=this.audioTrack=Object(C.dummyTrack)("audio",1),c=this.txtTrack=Object(C.dummyTrack)("text",1);if(this.id3Track=Object(C.dummyTrack)("id3",1),this.timeOffset=0,u.video){var v=u.video,i=v.id,r=v.timescale,o=v.codec;e.id=i,e.timescale=c.timescale=r,e.codec=o}if(u.audio){var d=u.audio,t=d.id,n=d.timescale,l=d.codec;s.id=t,s.timescale=n,s.codec=l}c.id=L.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},A.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(L.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var m=D,p=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(L.appendUint8Array)(this.remainderData,D));var e=Object(L.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var s=this.extractID3Track(p,E);return u.samples=Object(L.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(L.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(C.dummyTrack)(),id3Track:p,textTrack:Object(C.dummyTrack)()}},y.extractID3Track=function(D,E){var m=this.id3Track;if(D.samples.length){var p=Object(L.findBox)(D.samples,["emsg"]);p&&p.forEach(function(u){var e=Object(L.parseEmsg)(u);if(b.test(e.schemeIdUri)){var s=Object(M.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,c=e.payload;m.samples.push({data:c,len:c.byteLength,dts:s,pts:s,type:_.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(){},A}();R.default=O},"./src/demux/mpegaudio.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"appendFrame",function(){return O}),g.d(R,"parseHeader",function(){return A}),g.d(R,"isHeaderPattern",function(){return y}),g.d(R,"isHeader",function(){return T}),g.d(R,"canParse",function(){return D}),g.d(R,"probe",function(){return E});var M=null,_=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],L=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],C=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],b=[0,1,1,4];function O(m,p,u,e,s){if(!(u+24>p.length)){var c=A(p,u);if(c&&u+c.frameLength<=p.length){var v=c.samplesPerFrame*9e4/c.sampleRate,i=e+s*v,r={unit:p.subarray(u,u+c.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=c.channelCount,m.samplerate=c.sampleRate,m.samples.push(r),{sample:r,length:c.frameLength,missing:0}}}}function A(m,p){var u=m[p+1]>>3&3,e=m[p+1]>>1&3,s=m[p+2]>>4&15,c=m[p+2]>>2&3;if(u!==1&&s!==0&&s!==15&&c!==3){var v=m[p+2]>>1&1,i=m[p+3]>>6,r=u===3?3-e:e===3?3:4,o=_[r*14+s-1]*1e3,d=u===3?0:u===2?1:2,t=L[d*3+c],n=i===3?1:2,l=C[u][e],a=b[e],f=l*8*a,h=Math.floor(l*o/t+v)*a;if(M===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);M=x?parseInt(x[1]):0}var P=!!M&&M<=87;return P&&e===2&&o>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:n,frameLength:h,samplesPerFrame:f}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function T(m,p){return p+1<m.length&&y(m,p)}function D(m,p){var u=4;return y(m,p)&&u<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var u=4,e=A(m,p),s=u;e!=null&&e.frameLength&&(s=e.frameLength);var c=p+s;return c===m.length||T(m,c)}return!1}},"./src/demux/sample-aes.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/crypt/decrypter.ts"),_=g("./src/demux/tsdemuxer.ts"),L=function(){function C(O,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new M.default(O,A,{removePKCS7Padding:!1})}var b=C.prototype;return b.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},b.decryptAacSample=function(A,y,T,D){var E=A[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),u=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||u.decryptAacSamples(A,y+1,T)})}},b.decryptAacSamples=function(A,y,T){for(;;y++){if(y>=A.length){T();return}if(!(A[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(A,y,T,D),!D)return}}},b.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,T=new Int8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)T.set(A.subarray(E,E+16),D);return T},b.getAvcDecryptedUnit=function(A,y){for(var T=new Uint8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)A.set(T.subarray(D,D+16),E);return A},b.decryptAvcSample=function(A,y,T,D,E,m){var p=Object(_.discardEPB)(E.data),u=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(u.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),m||e.decryptAvcSamples(A,y,T+1,D)})},b.decryptAvcSamples=function(A,y,T,D){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=A.length){D();return}for(var E=A[y].units;!(T>=E.length);T++){var m=E[T];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(A,y,T,D,m,p),!p)return}}}},C}();R.default=L},"./src/demux/transmuxer-interface.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return E});var M=g("./node_modules/webworkify-webpack/index.js"),_=g.n(M),L=g("./src/events.ts"),C=g("./src/demux/transmuxer.ts"),b=g("./src/utils/logger.ts"),O=g("./src/errors.ts"),A=g("./src/utils/mediasource-helper.ts"),y=g("./node_modules/eventemitter3/index.js"),T=g.n(y),D=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(u,e,s,c){var v=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=u,this.id=e,this.onTransmuxComplete=s,this.onFlush=c;var i=u.config,r=function(l,a){a=a||{},a.frag=v.frag,a.id=v.id,u.trigger(l,a)};this.observer=new y.EventEmitter,this.observer.on(L.Events.FRAG_DECRYPTED,r),this.observer.on(L.Events.ERROR,r);var o={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){b.logger.log("demuxing in webworker");var t;try{t=this.worker=M("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){u.trigger(L.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:d,id:e,config:JSON.stringify(i)})}catch(n){b.logger.warn("Error in worker:",n),b.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new C.default(this.observer,o,i,d,e),this.worker=null}}else this.transmuxer=new C.default(this.observer,o,i,d,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 c=this.observer;c&&c.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,c,v,i,r,o,d,t,n){var l,a,f=this;t.transmuxing.start=self.performance.now();var h=this.transmuxer,S=this.worker,x=r?r.start:i.start,P=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&&((l=i.initSegment)===null||l===void 0?void 0:l.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new C.TransmuxState(B,Y,d,U,x,Z);if(!Y||B||Z){b.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
12
+ Time to underbuffer: `+P.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(d,r.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(L.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:e,stats:r})}}}}}},g.onFragLoaded=function(u,e){var s=e.frag,c=e.part;if(s.type===O.PlaylistLevelType.MAIN&&Object(M.isFiniteNumber)(s.sn)){var v=c?c.stats:s.stats,i=c?c.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)+v.loaded,d=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:d},r.realBitrate=Math.round(8*o/d)}if(s.bitrateTest){var t={stats:v,frag:s,part:c,id:s.type};this.onFragBuffered(L.Events.FRAG_BUFFERED,t)}}},g.onFragBuffered=function(u,e){var s=e.frag,c=e.part,v=c?c.stats:s.stats;if(!v.aborted&&!(s.type!==O.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=v.parsing.end-v.loading.start;this.bwEstimator.sample(i,v.loaded),v.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(u,e){switch(e.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var u=this.fragCurrent,e=this.partCurrent,s=this.hls,c=s.maxAutoLevel,v=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:u?u.duration:0,d=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():v.abrEwmaDefaultEstimate,l=(C.BufferHelper.bufferInfo(r,d,v.maxBufferHole).end-d)/t,a=this.findBestLevel(n,i,c,l,v.abrBandWidthFactor,v.abrBandWidthUpFactor);if(a>=0)return a;A.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=o?Math.min(o,v.maxStarvationDelay):v.maxStarvationDelay,h=v.abrBandWidthFactor,S=v.abrBandWidthUpFactor;if(!l){var x=this.bitrateTestDelay;if(x){var P=o?Math.min(o,v.maxLoadingDelay):v.maxLoadingDelay;f=P-x,A.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),h=S=1}}return a=this.findBestLevel(n,i,c,l+f,h,S),Math.max(a,0)},g.findBestLevel=function(u,e,s,c,v,i){for(var r,o=this.fragCurrent,d=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,l=n[t],a=!!(l!=null&&(r=l.details)!==null&&r!==void 0&&r.live),f=l==null?void 0:l.codecSet,h=d?d.duration:o?o.duration:0,S=s;S>=e;S--){var x=n[S];if(!(!x||f&&x.codecSet!==f)){var P=x.details,k=(d?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||h,B=void 0;S<=t?B=v*u:B=i*u;var U=n[S].maxBitrate,W=U*k/B;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+c+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<c))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,e=this.bwEstimator;if(u!==-1&&!e.canEstimate())return u;var s=this.getNextABRAutoLevel();return u!==-1&&this.hls.levels[s].loadError?u:(u!==-1&&(s=Math.min(u,s)),s)},set:function(u){this._nextAutoLevel=u}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/controller/base-stream-controller.ts"),L=m("./src/events.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/controller/fragment-tracker.ts"),O=m("./src/types/level.ts"),A=m("./src/types/loader.ts"),y=m("./src/loader/fragment.ts"),T=m("./src/demux/chunk-cache.ts"),D=m("./src/demux/transmuxer-interface.ts"),E=m("./src/types/transmuxer.ts"),g=m("./src/controller/fragment-finders.ts"),p=m("./src/utils/discontinuities.ts"),u=m("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var d=arguments[o];for(var t in d)Object.prototype.hasOwnProperty.call(d,t)&&(r[t]=d[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,c(r,o)}function c(r,o){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},c(r,o)}var v=100,i=function(r){s(o,r);function o(t,n){var l;return l=r.call(this,t,n,"[audio-stream-controller]")||this,l.videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.audioSwitch=!1,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}var d=o.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var n=this.hls;n.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(L.Events.ERROR,this.onError,this),n.on(L.Events.BUFFER_RESET,this.onBufferReset,this),n.on(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var n=this.hls;n.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(L.Events.ERROR,this.onError,this),n.off(L.Events.BUFFER_RESET,this.onBufferReset,this),n.off(L.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(n,l){var a=l.frag,f=l.id,h=l.initPTS;if(f==="main"){var S=a.cc;this.initPTS[a.cc]=h,this.log("InitPTS for cc: "+S+" found from main: "+h),this.videoTrackCC=S,this.state===_.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=_.State.STOPPED;return}var l=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,l>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),n=l,this.state=_.State.IDLE):(this.loadedmetadata=!1,this.state=_.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},d.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_TRACK:{var n,l=this.levels,a=this.trackId,f=l==null||(n=l[a])===null||n===void 0?void 0:n.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=_.State.WAITING_INIT_PTS}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var h,S=performance.now(),x=this.retryDate;(!x||S>=x||(h=this.media)!==null&&h!==void 0&&h.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=_.State.IDLE);break}case _.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var k=P.frag,B=P.part,U=P.cache,W=P.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=_.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(),$=C.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),Z=Object(g.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=_.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var l=this.mediaBuffer?this.mediaBuffer:n,a=l.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},d.doTickIdle=function(){var n,l,a=this.hls,f=this.levels,h=this.media,S=this.trackId,x=a.config;if(!(!f||!f[S])&&!(!h&&(this.startFragRequested||!x.startFragPrefetch))){var P=f[S],k=P.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=_.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,A.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.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(L.Events.BUFFER_EOS,{type:"audio"}),this.state=_.State.ENDED;return}var $=k.fragments,Z=$[0].start,q=U.end;if(Y&&h){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"),h.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"&&!((l=ne.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(ne,k):this.loadFragment(ne,k,q)}}}}},d.getMaxBufferLength=function(n){var l=r.prototype.getMaxBufferLength.call(this);return n?Math.max(l,n):l},d.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(n,l){var a=l.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(f){return new O.Level(f)})},d.onAudioTrackSwitching=function(n,l){var a=!!l.url;this.trackId=l.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(v):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=_.State.IDLE):this.state=_.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(n,l){this.mainDetails=l.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(n,l){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=l;return}var f=this.levels,h=l.details,S=l.id;if(!f){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+h.startSN+","+h.endSN+"],duration:"+h.totalduration);var x=f[S],P=0;if(h.live||(a=x.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed||!k)return;!x.details&&h.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(h,k),P=h.fragments[0].start):P=this.alignPlaylists(h,x.details)}x.details=h,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!h.live)&&this.setStartPosition(x.details,P),this.state===_.State.WAITING_TRACK&&!this.waitForCdnTuneIn(h)&&(this.state=_.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(n){var l,a=n.frag,f=n.part,h=n.payload,S=this.config,x=this.trackId,P=this.levels;if(!P){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=P[x];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,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[a.cc],z=(l=a.initSegment)===null||l===void 0?void 0:l.data;if(G!==void 0){var Y=!1,$=f?f.index:-1,Z=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,h.byteLength,$,Z);W.push(h,z,U,"",a,f,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 "+x);var ie=this.waitingData=this.waitingData||{frag:a,part:f,cache:new T.default,complete:!1},ne=ie.cache;ne.push(new Uint8Array(h)),this.waitingVideoCC=this.videoTrackCC,this.state=_.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(n,l){var a=l.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer||null)},d.onFragBuffered=function(n,l){var a=l.frag,f=l.part;if(a.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(f?" p: "+f.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(L.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,f)}},d.onError=function(n,l){switch(l.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,l);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==_.State.ERROR&&this.state!==_.State.STOPPED&&(this.state=l.fatal?_.State.ERROR:_.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var a=!0,f=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);f&&f.len>.5&&(a=!this.reduceMaxBufferLength(f.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}},d.onBufferFlushed=function(n,l){var a=l.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(n){var l,a="audio",f=this.hls,h=n.remuxResult,S=n.chunkMeta,x=this.getCurrentContext(S);if(!x){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 P=x.frag,k=x.part,B=x.level.details,U=h.audio,W=h.text,G=h.id3,z=h.initSegment;if(!(this.fragContextChanged(P)||!B)){if(this.state=_.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,P,S),f.trigger(L.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,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}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,Z,q),this.bufferFragmentData(U,P,k,S)}if(G!=null&&(l=G.samples)!==null&&l!==void 0&&l.length){var ie=e({id:a,frag:P,details:B},G);f.trigger(L.Events.FRAG_PARSING_METADATA,ie)}if(W){var ne=e({id:a,frag:P,details:B},W);f.trigger(L.Events.FRAG_PARSING_USERDATA,ne)}}},d._bufferInitSegment=function(n,l,a){if(this.state===_.State.PARSING){n.video&&delete n.video;var f=n.audio;if(!!f){f.levelCodec=f.codec,f.id="audio",this.log("Init audio buffer, container:"+f.container+", codecs[parsed]=["+f.codec+"]"),this.hls.trigger(L.Events.BUFFER_CODECS,n);var h=f.initSegment;if(h!=null&&h.byteLength){var S={type:"audio",frag:l,part:null,chunkMeta:a,parent:l.type,data:h};this.hls.trigger(L.Events.BUFFER_APPENDING,S)}this.tick()}}},d.loadFragment=function(n,l,a){var f=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||f===b.FragmentState.NOT_LOADED||f===b.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):l.live&&!Object(M.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=_.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,l,a)))},d.completeAudioSwitch=function(){var n=this.hls,l=this.media,a=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(_.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/controller/base-playlist-controller.ts"),C=m("./src/types/loader.ts");function b(D,E){for(var g=0;g<E.length;g++){var p=E[g];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function O(D,E,g){return E&&b(D.prototype,E),g&&b(D,g),Object.defineProperty(D,"prototype",{writable:!1}),D}function A(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,u){return p.__proto__=u,p},y(D,E)}var T=function(D){A(E,D);function E(p){var u;return u=D.call(this,p,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var g=E.prototype;return g.registerListeners=function(){var u=this.hls;u.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(M.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var u=this.hls;u.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(M.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(u,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(u,e){var s=e.id,c=e.details,v=this.tracksInGroup[s];if(!v){this.warn("Invalid audio track id "+s);return}var i=v.details;v.details=e.details,this.log("audioTrack "+s+" loaded ["+c.startSN+"-"+c.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},g.onLevelLoading=function(u,e){this.switchLevel(e.level)},g.onLevelSwitching=function(u,e){this.switchLevel(e.level)},g.switchLevel=function(u){var e=this.hls.levels[u];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var c=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!c.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=c;var v={audioTracks:c};this.log("Updating audio tracks, "+c.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(M.Events.AUDIO_TRACKS_UPDATED,v),this.selectInitialTrack()}}},g.onError=function(u,e){D.prototype.onError.call(this,u,e),!(e.fatal||!e.context)&&e.context.type===C.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(u){var e=this.tracksInGroup;if(u<0||u>=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 "+u);var c=e[u],v=c.id,i=c.groupId,r=i===void 0?"":i,o=c.name,d=c.type,t=c.url;if(this.trackId=u,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHING,{id:v,groupId:r,name:o,type:d,url:t}),!(c.details&&!c.details.live)){var n=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(n)}},g.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.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(M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(u){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var c=e[s];if((!this.selectDefaultTrack||c.default)&&(!u||u===c.name))return c.id}return-1},g.loadPlaylist=function(u){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,c=e.groupId,v=e.url;if(u)try{v=u.addDirectives(v)}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(M.Events.AUDIO_TRACK_LOADING,{url:v,id:s,groupId:c,deliveryDirectives:u||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),E}(L.default);R.default=T},"./src/controller/base-playlist-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/polyfills/number.ts"),_=m("./src/types/level.ts"),L=m("./src/controller/level-helper.ts"),C=m("./src/utils/logger.ts"),b=m("./src/errors.ts"),O=function(){function A(T,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=C.logger.log.bind(C.logger,D+":"),this.warn=C.logger.warn.bind(C.logger,D+":"),this.hls=T}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===b.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 g=E==null?void 0:E.renditionReports;if(g)for(var p=0;p<g.length;p++){var u=g[p],e=""+u.URI;if(e===D.slice(-e.length)){var s=parseInt(u["LAST-MSN"]),c=parseInt(u["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var v=Math.min(E.age-E.partTarget,E.targetduration);c!==void 0&&v>E.partTarget&&(c+=1)}if(Object(M.isFiniteNumber)(s))return new _.HlsUrlParameters(s,Object(M.isFiniteNumber)(c)?c:void 0,_.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,g){var p=this,u=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||g!=null&&g.live){if(u.reloaded(g),g&&this.log("live playlist "+D+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),g&&u.fragments.length>0&&Object(L.mergeDetails)(g,u),!this.canLoad||!u.live)return;var c,v=void 0,i=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var r=this.hls.config.lowLatencyMode,o=u.lastPartSn,d=u.endSN,t=u.lastPartIndex,n=t!==-1,l=o===d,a=r?0:t;n?(v=l?d+1:o,i=l?a:t+1):v=d+1;var f=u.age,h=f+u.ageHeader,S=Math.min(h-u.partTarget,u.targetduration*1.5);if(S>0){if(g&&S>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+S+" with playlist age: "+u.age),S=0;else{var x=Math.floor(S/u.targetduration);if(v+=x,i!==void 0){var P=Math.round(S%u.targetduration/u.partTarget);i+=P}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}u.tuneInGoal=S}if(c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i),r||!l){this.loadPlaylist(c);return}}else c=this.getDeliveryDirectives(u,E.deliveryDirectives,v,i);var k=Object(L.computeReloadInterval)(u,e);v!==void 0&&u.canBlockReload&&(k-=u.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(c)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,g,p){var u=Object(_.getSkipValue)(D,g);return E!=null&&E.skip&&D.deltaUpdateFailed&&(g=E.msn,p=E.part,u=_.HlsSkip.No),new _.HlsUrlParameters(g,p,u)},y.retryLoadingOrFail=function(D){var E=this,g=this.hls.config,p=this.retryCount<g.levelLoadingMaxRetry;if(p){var u;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(u=D.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.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},A}()},"./src/controller/base-stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"State",function(){return d}),m.d(R,"default",function(){return t});var M=m("./src/polyfills/number.ts"),_=m("./src/task-loop.ts"),L=m("./src/controller/fragment-tracker.ts"),C=m("./src/utils/buffer-helper.ts"),b=m("./src/utils/logger.ts"),O=m("./src/events.ts"),A=m("./src/errors.ts"),y=m("./src/types/transmuxer.ts"),T=m("./src/utils/mp4-tools.ts"),D=m("./src/utils/discontinuities.ts"),E=m("./src/controller/fragment-finders.ts"),g=m("./src/controller/level-helper.ts"),p=m("./src/loader/fragment-loader.ts"),u=m("./src/crypt/decrypter.ts"),e=m("./src/utils/time-ranges.ts"),s=m("./src/types/loader.ts");function c(n,l){for(var a=0;a<l.length;a++){var f=l[a];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(n,f.key,f)}}function v(n,l,a){return l&&c(n.prototype,l),a&&c(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,l){n.prototype=Object.create(l.prototype),n.prototype.constructor=n,o(n,l)}function o(n,l){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,h){return f.__proto__=h,f},o(n,l)}var d={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(l,n);function l(f,h,S){var x;return x=n.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=d.STOPPED,x.media=null,x.mediaBuffer=null,x.config=void 0,x.bitrateTest=!1,x.lastCurrentTime=0,x.nextLoadPosition=0,x.startPosition=0,x.loadedmetadata=!1,x.fragLoadError=0,x.retryDate=0,x.levels=null,x.fragmentLoader=void 0,x.levelLastLoaded=null,x.startFragRequested=!1,x.decrypter=void 0,x.initPTS=[],x.onvseeking=null,x.onvended=null,x.logPrefix="",x.log=void 0,x.warn=void 0,x.logPrefix=S,x.log=b.logger.log.bind(b.logger,S+":"),x.warn=b.logger.warn.bind(b.logger,S+":"),x.hls=f,x.fragmentLoader=new p.default(f.config),x.fragmentTracker=h,x.config=f.config,x.decrypter=new u.default(f,f.config),f.on(O.Events.KEY_LOADED,x.onKeyLoaded,i(x)),f.on(O.Events.LEVEL_SWITCHING,x.onLevelSwitching,i(x)),x}var a=l.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(h){},a.stopLoad=function(){this.fragmentLoader.abort();var h=this.fragCurrent;h&&this.fragmentTracker.removeFragment(h),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},a._streamEnded=function(h,S){var x=this.fragCurrent,P=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!h.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=C.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=P.getState(x);return W===L.FragmentState.PARTIAL||W===L.FragmentState.OK}return!1},a.onMediaAttached=function(h,S){var x=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(P.startPosition)},a.onMediaDetaching=function(){var h=this.media;h!=null&&h.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),h&&this.onvseeking&&this.onvended&&(h.removeEventListener("seeking",this.onvseeking),h.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 h=this.config,S=this.fragCurrent,x=this.media,P=this.mediaBuffer,k=this.state,B=x?x.currentTime:0,U=C.BufferHelper.bufferInfo(P||x,B,h.maxBufferHole);if(this.log("media seeking to "+(Object(M.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===d.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=h.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())}x&&(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(h,S){if(!(this.state!==d.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},a.onLevelSwitching=function(h,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.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(h,S){this.log("Loading key for "+h.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level),this.state=d.KEY_LOADING,this.fragCurrent=h,this.hls.trigger(O.Events.KEY_LOADING,{frag:h})},a.loadFragment=function(h,S,x){this._loadFragForPlayback(h,S,x)},a._loadFragForPlayback=function(h,S,x){var P=this,k=function(U){if(P.fragContextChanged(h)){P.warn("Fragment "+h.sn+(U.part?" p: "+U.part.index:"")+" of level "+h.level+" was dropped during download."),P.fragmentTracker.removeFragment(h);return}h.stats.chunkCount++,P._handleFragmentLoadProgress(U)};this._doFragLoad(h,S,x,k).then(function(B){if(!!B){P.fragLoadError=0;var U=P.state;if(P.fragContextChanged(h)){(U===d.FRAG_LOADING||!P.fragCurrent&&U===d.PARSING)&&(P.fragmentTracker.removeFragment(h),P.state=d.IDLE);return}"payload"in B&&(P.log("Loaded fragment "+h.sn+" of level "+h.level),P.hls.trigger(O.Events.FRAG_LOADED,B)),P._handleFragmentLoadComplete(B)}}).catch(function(B){P.state===d.STOPPED||P.state===d.ERROR||(P.warn(B),P.resetFragmentLoading(h))})},a.flushMainBuffer=function(h,S,x){if(x===void 0&&(x=null),!!(h-S)){var P={startOffset:h,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},a._loadInitSegment=function(h){var S=this;this._doFragLoad(h).then(function(x){if(!x||S.fragContextChanged(h)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var P=S.hls,k=x.payload,B=h.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 P.trigger(O.Events.FRAG_DECRYPTED,{frag:h,payload:W,stats:{tstart:U,tdecrypt:G}}),x.payload=W,x})}return x}).then(function(x){var P=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[h.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=h.stats;S.state=d.IDLE,S.fragLoadError=0,h.data=new Uint8Array(x.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),x.frag===P&&k.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:P,part:null,id:h.type}),S.tick()}).catch(function(x){S.state===d.STOPPED||S.state===d.ERROR||(S.warn(x),S.resetFragmentLoading(h))})},a.fragContextChanged=function(h){var S=this.fragCurrent;return!h||!S||h.level!==S.level||h.sn!==S.sn||h.urlId!==S.urlId},a.fragBufferedComplete=function(h,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+h.type+" sn: "+h.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level+" "+(x?e.default.toString(C.BufferHelper.getBuffered(x)):"(detached)")),this.state=d.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(h){var S=this.transmuxer;if(!!S){var x=h.frag,P=h.part,k=h.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,P?P.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(h){},a._doFragLoad=function(h,S,x,P){var k=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(h.start,x||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&P){x>h.end&&S.fragmentHint&&(h=S.fragmentHint);var U=this.getNextPart(B,h,x);if(U>-1){var W=B[U];return this.log("Loading part sn: "+h.sn+" p: "+W.index+" cc: "+h.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,part:B[U],targetBufferTime:x}),this.doFragPartsLoad(h,B,U,P).catch(function(G){return k.handleFragLoadError(G)})}else if(!h.url||this.loadedEndOfParts(B,x))return Promise.resolve(null)}}return this.log("Loading fragment "+h.sn+" cc: "+h.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(x.toFixed(3))),Object(M.isFiniteNumber)(h.sn)&&!this.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),this.state=d.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:h,targetBufferTime:x}),this.fragmentLoader.load(h,P).catch(function(G){return k.handleFragLoadError(G)})},a.doFragPartsLoad=function(h,S,x,P){var k=this;return new Promise(function(B,U){var W=[],G=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(h,$,P).then(function(Z){W[$.index]=Z;var q=Z.part;k.hls.trigger(O.Events.FRAG_LOADED,Z);var ie=S[Y+1];if(ie&&ie.fragment===h)z(Y+1);else return B({frag:h,part:q,partsLoaded:W})}).catch(U)};G(x)})},a.handleFragLoadError=function(h){var S=h.data;return S&&S.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},a._handleTransmuxerFlush=function(h){var S=this.getCurrentContext(h);if(!S||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var x=S.frag,P=S.part,k=S.level,B=self.performance.now();x.stats.parsing.end=B,P&&(P.stats.parsing.end=B),this.updateLevelTiming(x,P,k,h.partial)},a.getCurrentContext=function(h){var S=this.levels,x=h.level,P=h.sn,k=h.part;if(!S||!S[x])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+x+". The current chunk will not be buffered."),null;var B=S[x],U=k>-1?Object(g.getPartWith)(B,P,k):null,W=U?U.fragment:Object(g.getFragmentWithSN)(B,P,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(h,S,x,P){if(!(!h||this.state!==d.PARSING)){var k=h.data1,B=h.data2,U=k;if(k&&B&&(U=Object(T.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:h.type,frag:S,part:x,chunkMeta:P,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),h.dropped&&h.independent&&!x&&this.flushBufferGap(S)}}},a.flushBufferGap=function(h){var S=this.media;if(!!S){if(!C.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,h.start);return}var x=S.currentTime,P=C.BufferHelper.bufferInfo(S,x,0),k=h.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(h.start-B,P.end-B),x+B);h.start-U>B&&this.flushMainBuffer(U,h.start)}},a.getFwdBufferInfo=function(h,S){var x=this.config,P=this.getLoadPosition();if(!Object(M.isFiniteNumber)(P))return null;var k=C.BufferHelper.bufferInfo(h,P,x.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(P,S);if(B&&k.nextStart<B.end)return C.BufferHelper.bufferInfo(h,P,Math.max(k.nextStart,x.maxBufferHole))}return k},a.getMaxBufferLength=function(h){var S=this.config,x;return h?x=Math.max(8*S.maxBufferSize/h,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(h){var S=this.config,x=h||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(h,S){var x=S.fragments,P=x.length;if(!P)return null;var k=this.config,B=x[0].start,U;if(S.live){var W=k.initialLiveManifestSize;if(P<W)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,x),this.startPosition=U?this.hls.liveSyncPosition||U.start:h)}else h<=B&&(U=x[0]);if(!U){var G=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(h,G,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(h){return h!=null&&h.initSegment&&!(h!=null&&h.initSegment.data)&&!this.bitrateTest?h.initSegment:h},a.getNextPart=function(h,S,x){for(var P=-1,k=!1,B=!0,U=0,W=h.length;U<W;U++){var G=h[U];if(B=B&&!G.independent,P>-1&&x<G.start)break;var z=G.loaded;!z&&(k||G.independent||B)&&G.fragment===S&&(P=U),k=z}return P},a.loadedEndOfParts=function(h,S){var x=h[h.length-1];return x&&S>x.start&&x.loaded},a.getInitialLiveFragment=function(h,S){var x=this.fragPrevious,P=null;if(x){if(h.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),P=Object(E.findFragmentByPDT)(S,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var k=x.sn+1;if(k>=h.startSN&&k<=h.endSN){var B=S[k-h.startSN];x.cc===B.cc&&(P=B,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(E.findFragWithCC)(S,x.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(P=this.getFragmentAtPosition(U,this.bitrateTest?h.fragmentEnd:h.edge,h))}return P},a.getFragmentAtPosition=function(h,S,x){var P=this.config,k=this.fragPrevious,B=x.fragments,U=x.endSN,W=x.fragmentHint,G=P.maxFragLookUpTolerance,z=!!(P.lowLatencyMode&&x.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(h<S){var $=h>S-G?0:G;Y=Object(E.findFragmentByPTS)(k,B,h,$)}else Y=B[B.length-1];if(Y){var Z=Y.sn-x.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)!==L.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+ie.sn),Y=ie):Y=null}}}return Y},a.synchronizeToLiveEdge=function(h){var S=this.config,x=this.media;if(!!x){var P=this.hls.liveSyncPosition,k=x.currentTime,B=h.fragments[0].start,U=h.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(P!==null&&x.duration>P&&(k<P||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*h.targetduration;(!W&&x.readyState<4||k<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=P),x.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+P.toFixed(3)),x.currentTime=P))}}},a.alignPlaylists=function(h,S){var x=this.levels,P=this.levelLastLoaded,k=this.fragPrevious,B=P!==null?x[P]:null,U=h.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=h.fragments[0].start,G=!S,z=h.alignedSliding&&Object(M.isFiniteNumber)(W);if(G||!z&&!W){Object(D.alignStream)(k,B,h);var Y=h.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+h.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(h){var S=3;return h.live&&h.canBlockReload&&h.partTarget&&h.tuneInGoal>Math.max(h.partHoldBack,h.partTarget*S)},a.setStartPosition=function(h,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var P=h.startTimeOffset;Object(M.isFiniteNumber)(P)?(x=S+P,P<0&&(x+=h.totalduration),x=Math.min(Math.max(S,x),S+h.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+x),this.startPosition=x):h.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},a.getLoadPosition=function(){var h=this.media,S=0;return this.loadedmetadata&&h?S=h.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(h,S){this.transmuxer&&h.sn!=="initSegment"&&h.stats.aborted&&(this.warn("Fragment "+h.sn+(S?" part"+S.index:"")+" of level "+h.level+" was aborted"),this.resetFragmentLoading(h))},a.resetFragmentLoading=function(h){(!this.fragCurrent||!this.fragContextChanged(h)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},a.onFragmentOrKeyLoadError=function(h,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==h)){var P=this.fragCurrent;console.assert(P&&x.sn===P.sn&&x.level===P.level&&x.urlId===P.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 "+x.sn+" of "+h+" "+x.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(h===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(b.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},a.afterBufferFlushed=function(h,S,x){if(!!h){var P=C.BufferHelper.getBuffered(h);this.fragmentTracker.detectEvictedFragments(S,P,x),this.state===d.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},a.resetStartWhenNotLoaded=function(h){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[h].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(h,S,x,P){var k=this,B=x.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(h.elementaryStreams).reduce(function(W,G){var z=h.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+h.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var $=P?0:Object(g.updateFragPTSDTS)(B,h,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:B,level:x,drift:$,type:G,frag:h,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+h.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:h,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},v(l,[{key:"state",get:function(){return this._state},set:function(h){var S=this._state;S!==h&&(this._state=h,this.log(S+"->"+h))}}]),l}(_.default)},"./src/controller/buffer-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts"),C=m("./src/errors.ts"),b=m("./src/utils/buffer-helper.ts"),O=m("./src/utils/mediasource-helper.ts"),A=m("./src/loader/fragment.ts"),y=m("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function g(u){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,c=e.media,v=e.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),c&&(e.updateMediaElementDuration(),s.trigger(_.Events.MEDIA_ATTACHED,{media:c})),v&&v.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var p=g.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(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.Events.BUFFER_RESET,this.onBufferReset,this),e.on(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.Events.BUFFER_EOS,this.onBufferEos,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.Events.FRAG_PARSED,this.onFragParsed,this),e.on(_.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.Events.BUFFER_RESET,this.onBufferReset,this),e.off(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.Events.BUFFER_EOS,this.onBufferEos,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.Events.FRAG_PARSED,this.onFragParsed,this),e.off(_.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 c=2;(s.audio&&!s.video||!s.altAudio)&&(c=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=c,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var c=this.media=s.media;if(c&&T){var v=this.mediaSource=new T;v.addEventListener("sourceopen",this._onMediaSourceOpen),v.addEventListener("sourceended",this._onMediaSourceEnded),v.addEventListener("sourceclose",this._onMediaSourceClose),c.src=self.URL.createObjectURL(v),this._objectUrl=c.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,c=this._objectUrl;if(s){if(L.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(v){L.logger.warn("[buffer-controller]: onMediaDetaching: "+v.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(c&&self.URL.revokeObjectURL(c),e.src===c?(e.removeAttribute("src"),e.load()):L.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(_.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var c=e.sourceBuffer[s];try{c&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(c),e.sourceBuffer[s]=void 0)}catch(v){L.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",v)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var c=this,v=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(v){var r=c.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],d=o.id,t=o.codec,n=o.levelCodec,l=o.container,a=o.metadata,f=(r.levelCodec||r.codec).replace(D,"$1"),h=(n||t).replace(D,"$1");if(f!==h){var S=l+";codecs="+(n||t);c.appendChangeType(i,S),L.logger.log("[buffer-controller]: switching codec "+f+" to "+h),c.tracks[i]={buffer:r.buffer,codec:t,container:l,levelCodec:n,metadata:a,id:d}}}}else c.pendingTracks[i]=s[i]}),!v&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var c=this,v=this.operationQueue,i={execute:function(){var o=c.sourceBuffer[e];o&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),v.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){L.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};v.append(i,e)},p.onBufferAppending=function(e,s){var c=this,v=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,d=s.type,t=s.frag,n=s.part,l=s.chunkMeta,a=l.buffering[d],f=self.performance.now();a.start=f;var h=t.stats.buffering,S=n?n.stats.buffering:null;h.start===0&&(h.start=f),S&&S.start===0&&(S.start=f);var x=r.audio,P=d==="audio"&&l.id===1&&(x==null?void 0:x.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),P){var U=c.sourceBuffer[d];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}c.appendExecutor(o,d)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,h.first===0&&(h.first=U),S&&S.first===0&&(S.first=U);var W=c.sourceBuffer,G={};for(var z in W)G[z]=b.BufferHelper.getBuffered(W[z]);c.appendError=0,c.hls.trigger(_.Events.BUFFER_APPENDED,{type:d,frag:t,part:n,chunkMeta:l,parent:t.type,timeRanges:G})},onError:function(U){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",U);var W={type:C.ErrorTypes.MEDIA_ERROR,parent:t.type,details:C.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=C.ErrorDetails.BUFFER_FULL_ERROR:(c.appendError++,W.details=C.ErrorDetails.BUFFER_APPEND_ERROR,c.appendError>v.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+v.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,v.stopLoad())),v.trigger(_.Events.ERROR,W)}};i.append(k,d)},p.onBufferFlushing=function(e,s){var c=this,v=this.operationQueue,i=function(o){return{execute:c.removeExecutor.bind(c,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){c.hls.trigger(_.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){L.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?v.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){v.append(i(r),r)})},p.onFragParsed=function(e,s){var c=this,v=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:v.elementaryStreams;o[A.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[A.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[A.ElementaryStreamTypes.VIDEO]&&r.push("video"));var d=function(){var n=self.performance.now();v.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var l=i?i.stats:v.stats;c.hls.trigger(_.Events.FRAG_BUFFERED,{frag:v,part:i,stats:l,id:v.type})};r.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+v.type+" level: "+v.level+" sn: "+v.sn),this.blockBuffers(d,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var c=this,v=this.getSourceBufferTypes().reduce(function(i,r){var o=c.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,L.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);v&&this.blockBuffers(function(){var i=c.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var c=s.details;!c.fragments.length||(this.details=c,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,c=this.media,v=this.sourceBuffer;if(!(!c||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(M.isFiniteNumber)(r)||r<0)){var o=c.currentTime,d=s.levelTargetDuration,t=Math.max(r,d),n=Math.floor(o/d)*d-t;i.forEach(function(l){var a=v[l];if(a){var f=b.BufferHelper.getBuffered(a);f.length>0&&n>f.start(0)&&(e.trigger(_.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(_.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:l}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,c=this.media,v=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=c.duration,o=Object(M.isFiniteNumber)(v.duration)?v.duration:0;e.live&&s.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),v.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(M.isFiniteNumber)(r))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),v.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,c=e.fragments,v=c.length;if(v&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,c[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,c=this.pendingTracks,v=Object.keys(c).length;if(v&&!e||v===2){this.createSourceBuffers(c),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.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,c=this.mediaSource;if(!c)throw Error("createSourceBuffers called when mediaSource was null");var v=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,d=r.container+";codecs="+o;L.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var t=s[i]=c.addSourceBuffer(d),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},v++}catch(l){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:d})}}v&&this.hls.trigger(_.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,c=s.current(e);c.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,c=s.current(e);c.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(_.Events.ERROR,{type:C.ErrorTypes.MEDIA_ERROR,details:C.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var c=this.operationQueue.current(e);c&&c.onError(s)},p.removeExecutor=function(e,s,c){var v=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,d=o[e];if(!v||!i||!d){L.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(M.isFiniteNumber)(v.duration)?v.duration:1/0,n=Object(M.isFiniteNumber)(i.duration)?i.duration:1/0,l=Math.max(0,s),a=Math.min(c,t,n);a>l?(L.logger.log("[buffer-controller]: Removing ["+l+","+a+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(l,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var c=this.operationQueue,v=this.sourceBuffer,i=v[s];if(!i){L.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),c.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 c=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var v=this.operationQueue,i=s.map(function(r){return v.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=c.sourceBuffer[r];(!o||!o.updating)&&v.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,c){var v=this.sourceBuffer[e];if(!!v){var i=c.bind(this,e);this.listeners[e].push({event:s,listener:i}),v.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(c){s.removeEventListener(c.event,c.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return _});var M=m("./src/utils/logger.ts"),_=function(){function L(b){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=b}var C=L.prototype;return C.append=function(O,A){var y=this.queues[A];y.push(O),y.length===1&&this.buffers[A]&&this.executeNext(A)},C.insertAbort=function(O,A){var y=this.queues[A];y.unshift(O),this.executeNext(A)},C.appendBlocker=function(O){var A,y=new Promise(function(D){A=D}),T={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},C.executeNext=function(O){var A=this.buffers,y=this.queues,T=A[O],D=y[O];if(D.length){var E=D[0];try{E.execute()}catch(g){M.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(g),(!T||!T.updating)&&(D.shift(),this.executeNext(O))}}},C.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},C.current=function(O){return this.queues[O][0]},L}()},"./src/controller/cap-level-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts");function _(b,O){for(var A=0;A<O.length;A++){var y=O[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(b,y.key,y)}}function L(b,O,A){return O&&_(b.prototype,O),A&&_(b,A),Object.defineProperty(b,"prototype",{writable:!1}),b}var C=function(){function b(A){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=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=b.prototype;return O.setStreamController=function(y){this.streamController=y},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var y=this.hls;y.on(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(M.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(M.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){b.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},O.onMediaAttaching=function(y,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},O.onManifestParsed=function(y,T){var D=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(y,T){var D=this.hls;D.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(y.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},O.getMaxLevel=function(y){var T=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(g,p){return b.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,b.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},O.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())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,T={width:0,height:0};if(y){var D=y.getBoundingClientRect();T.width=D.width,T.height=D.height,!T.width&&!T.height&&(T.width=D.right-D.left||y.width||0,T.height=D.bottom-D.top||y.height||0)}return this.clientRect=T,T},b.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},b.getMaxLevelByMediaSize=function(y,T,D){if(!y||!y.length)return-1;for(var E=function(s,c){return c?s.width!==c.width||s.height!==c.height:!0},g=y.length-1,p=0;p<y.length;p+=1){var u=y[p];if((u.width>=T||u.height>=D)&&E(u,y[p+1])){g=p;break}}return g},L(b,[{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}}]),b}();R.default=C},"./src/controller/cmcd-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./src/events.ts"),_=m("./src/types/cmcd.ts"),L=m("./src/utils/buffer-helper.ts"),C=m("./src/utils/logger.ts");function b(g,p){for(var u=0;u<p.length;u++){var e=p[u];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function O(g,p,u){return p&&b(g.prototype,p),u&&b(g,u),Object.defineProperty(g,"prototype",{writable:!1}),g}function A(g,p){var u=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(u)return(u=u.call(g)).next.bind(u);if(Array.isArray(g)||(u=y(g))||p&&g&&typeof g.length=="number"){u&&(g=u);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[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(g,p){if(!!g){if(typeof g=="string")return T(g,p);var u=Object.prototype.toString.call(g).slice(8,-1);if(u==="Object"&&g.constructor&&(u=g.constructor.name),u==="Map"||u==="Set")return Array.from(g);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(g,p)}}function T(g,p){(p==null||p>g.length)&&(p=g.length);for(var u=0,e=new Array(p);u<p;u++)e[u]=g[u];return e}function D(){return D=Object.assign?Object.assign.bind():function(g){for(var p=1;p<arguments.length;p++){var u=arguments[p];for(var e in u)Object.prototype.hasOwnProperty.call(u,e)&&(g[e]=u[e])}return g},D.apply(this,arguments)}var E=function(){function g(u){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(v){try{e.apply(v,{ot:_.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){C.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(v){try{var i=v.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),d={d:i.duration*1e3,ot:o};(o===_.CMCDObjectType.VIDEO||o===_.CMCDObjectType.AUDIO||o==_.CMCDObjectType.MUXED)&&(d.br=r.bitrate/1e3,d.tb=e.getTopBandwidth(o)/1e3,d.bl=e.getBufferLength(o)),e.apply(v,d)}catch(t){C.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=u;var s=this.config=u.config,c=s.cmcd;c!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=c.sessionId||g.uuid(),this.cid=c.contentId,this.useHeaders=c.useHeaders===!0,this.registerListeners())}var p=g.prototype;return p.registerListeners=function(){var e=this.hls;e.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(M.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 c,v;this.audioBuffer=(c=s.tracks.audio)===null||c===void 0?void 0:c.buffer,this.videoBuffer=(v=s.tracks.video)===null||v===void 0?void 0:v.buffer},p.createData=function(){var e;return{v:_.CMCDVersion,sf:_.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 c=s.ot===_.CMCDObjectType.INIT||s.ot===_.CMCDObjectType.VIDEO||s.ot===_.CMCDObjectType.MUXED;if(this.starved&&c&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var v=g.toHeaders(s);if(!Object.keys(v).length)return;e.headers||(e.headers={}),D(e.headers,v)}else{var i=g.toQuery(s);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var s=e.type;if(s==="subtitle")return _.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return _.CMCDObjectType.INIT;if(s==="audio")return _.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?_.CMCDObjectType.VIDEO:_.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,c,v=this.hls;if(e===_.CMCDObjectType.AUDIO)c=v.audioTracks;else{var i=v.maxAutoLevel,r=i>-1?i+1:v.levels.length;c=v.levels.slice(0,r)}for(var o=A(c),d;!(d=o()).done;){var t=d.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,c=e===_.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!c||!s)return NaN;var v=L.BufferHelper.bufferInfo(c,s.currentTime,this.config.maxBufferHole);return v.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,c=e||this.config.loader;return function(){function v(r){this.loader=void 0,this.loader=new c(r)}var i=v.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,d,t){s(o),this.loader.load(o,d,t)},O(v,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),v}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},g.serialize=function(e){for(var s=[],c=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},v=function(P){return Math.round(P)},i=function(P){return v(P/100)*100},r=function(P){return encodeURIComponent(P)},o={br:v,d:v,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:v},d=Object.keys(e||{}).sort(),t=A(d),n;!(n=t()).done;){var l=n.value,a=e[l];if(!!c(a)&&!(l==="v"&&a===1)&&!(l=="pr"&&a===1)){var f=o[l];f&&(a=f(a));var h=typeof a,S=void 0;l==="ot"||l==="sf"||l==="st"?S=l+"="+a:h==="boolean"?S=l:h==="number"?S=l+"="+a:S=l+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},g.toHeaders=function(e){for(var s=Object.keys(e),c={},v=["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,d=s;o<d.length;o++){var t=d[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var l=0;l<i.length;l++){var a=g.serialize(i[l]);a&&(c["CMCD-"+v[l]]=a)}return c},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,s){if(!s)return e;var c=e.includes("?")?"&":"?";return""+e+c+s},g}()},"./src/controller/eme-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/utils/logger.ts"),C=m("./src/utils/mediakeys-helper.ts");function b(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,g,p){return g&&b(E.prototype,g),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var A=3,y=function(g,p,u){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[e]},T=function(g,p,u,e){switch(g){case C.KeySystems.WIDEVINE:return y(p,u,e);default:throw new Error("Unknown key-system: "+g)}},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 g=E.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(M.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(u){switch(u){case C.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},g._attemptKeySystemAccess=function(u,e,s){var c=this,v=T(u,e,s,this._drmSystemOptions);L.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(u,v);this.mediaKeysPromise=i.then(function(r){return c._onMediaKeySystemAccessObtained(u,r)}),i.catch(function(r){L.logger.error('Failed to obtain key-system "'+u+'" access:',r)})},g._onMediaKeySystemAccessObtained=function(u,e){var s=this;L.logger.log('Access for key-system "'+u+'" obtained');var c={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:u};this._mediaKeysList.push(c);var v=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return c.mediaKeys=i,L.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),i});return v.catch(function(i){L.logger.error("Failed to create media-keys:",i)}),v},g._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),u._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(u){var e=this;L.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){e._onKeySessionMessage(u,s.message)},!1)},g._onKeySessionMessage=function(u,e){L.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){L.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s).catch(function(c){L.logger.warn("Updating key-session failed: "+c)})})},g.onMediaEncrypted=function(u){var e=this;if(L.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(v){!e._media||(e._attemptSetMediaKeys(v),e._generateRequestWithPreferredKeySession(u.initDataType,u.initData))};this.mediaKeysPromise.then(s).catch(s)},g._attemptSetMediaKeys=function(u){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){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}L.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(u,e){var s=this,c=this._mediaKeysList[0];if(!c){L.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(c.mediaKeysSessionInitialized){L.logger.warn("Key-Session already initialized but requested again");return}var v=c.mediaKeysSession;if(!v){L.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){L.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}L.logger.log('Generating key-session request for "'+u+'" init data type'),c.mediaKeysSessionInitialized=!0,v.generateRequest(u,e).then(function(){L.logger.debug("Key-session generation succeeded")}).catch(function(i){L.logger.error("Error generating key-session request:",i),s.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(u,e,s){var c=new XMLHttpRequest;c.responseType="arraybuffer",c.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,c,u,e,s);var v=this._licenseXhrSetup;if(v)try{v.call(this.hls,c,u),v=void 0}catch(i){L.logger.error(i)}try{c.readyState||c.open("POST",u,!0),v&&v.call(this.hls,c,u)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return c},g._onLicenseRequestReadyStageChange=function(u,e,s,c){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,L.logger.log("License request succeeded");var v=u.response,i=this._licenseResponseCallback;if(i)try{v=i.call(this.hls,u,e)}catch(o){L.logger.error(o)}c(v)}else{if(L.logger.error("License Request XHR failed ("+e+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=A-this._requestLicenseFailureCount+1;L.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,c)}break}},g._generateLicenseRequestChallenge=function(u,e){switch(u.mediaKeySystemDomain){case C.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},g._requestLicense=function(u,e){L.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){L.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var c=this.getLicenseServerUrl(s.mediaKeySystemDomain),v=this._createLicenseXhr(c,u,e);L.logger.log("Sending license request to URL: "+c);var i=this._generateLicenseRequestChallenge(s,u);v.send(i)}catch(r){L.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(u,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var u=this._media,e=this._mediaKeysList;!u||(u.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 u.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(u,e){if(!!this._emeEnabled){var s=e.levels.map(function(v){return v.audioCodec}).filter(function(v){return!!v}),c=e.levels.map(function(v){return v.videoCodec}).filter(function(v){return!!v});this._attemptKeySystemAccess(C.KeySystems.WIDEVINE,s,c)}},O(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,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/utils/logger.ts"),L=function(){function C(O){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=O,this.registerListeners()}var b=C.prototype;return b.setStreamController=function(A){this.streamController=A},b.registerListeners=function(){this.hls.on(M.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(M.Events.MEDIA_ATTACHING,this.onMediaAttaching)},b.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},b.onMediaAttaching=function(A,y){var T=this.hls.config;if(T.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),T.fpsDroppedMonitoringPeriod)}},b.checkFPS=function(A,y,T){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,g=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,u=1e3*g/E,e=this.hls;if(e.trigger(M.Events.FPS_DROP,{currentDropped:g,currentDecoded:p,totalDroppedFrames:T}),u>0&&g>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;_.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(M.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},b.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},C}();R.default=L},"./src/controller/fragment-finders.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"findFragmentByPDT",function(){return L}),m.d(R,"findFragmentByPTS",function(){return C}),m.d(R,"fragmentWithinToleranceTest",function(){return b}),m.d(R,"pdtWithinToleranceTest",function(){return O}),m.d(R,"findFragWithCC",function(){return A});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/binary-search.ts");function L(y,T,D){if(T===null||!Array.isArray(y)||!y.length||!Object(M.isFiniteNumber)(T))return null;var E=y[0].programDateTime;if(T<(E||0))return null;var g=y[y.length-1].endProgramDateTime;if(T>=(g||0))return null;D=D||0;for(var p=0;p<y.length;++p){var u=y[p];if(O(T,D,u))return u}return null}function C(y,T,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var g=null;if(y?g=T[y.sn-T[0].sn+1]||null:D===0&&T[0].start===0&&(g=T[0]),g&&b(D,E,g)===0)return g;var p=_.default.search(T,b.bind(null,D,E));return p||g}function b(y,T,D){y===void 0&&(y=0),T===void 0&&(T=0);var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function O(y,T,D){var E=Math.min(T,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,g=D.endProgramDateTime||0;return g-E>y}function A(y,T){return _.default.search(y,function(D){return D.cc<T?1:D.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"FragmentState",function(){return L}),m.d(R,"FragmentTracker",function(){return C});var M=m("./src/events.ts"),_=m("./src/types/loader.ts"),L;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(L||(L={}));var C=function(){function A(T){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=T,this._registerListeners()}var y=A.prototype;return y._registerListeners=function(){var D=this.hls;D.on(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(M.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(M.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===_.PlaylistLevelType.MAIN){var g=this.activeFragment,p=this.activeParts;if(!g)return null;if(p)for(var u=p.length;u--;){var e=p[u],s=e?e.end:g.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return u>9&&(this.activeParts=p.slice(u-9)),e}else if(g.start<=D&&g.appendedPTS!==void 0&&D<=g.appendedPTS)return g}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var g=this.fragments,p=Object.keys(g),u=p.length;u--;){var e=g[p[u]];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,g){var p=this;Object.keys(this.fragments).forEach(function(u){var e=p.fragments[u];if(!!e){if(!e.buffered){e.body.type===g&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(c){var v=!p.isTimeBuffered(c.startPTS,c.endPTS,E);return v&&p.removeFragment(e.body),v})}})},y.detectPartialFragments=function(D){var E=this,g=this.timeRanges,p=D.frag,u=D.part;if(!(!g||p.sn==="initSegment")){var e=O(p),s=this.fragments[e];!s||(Object.keys(g).forEach(function(c){var v=p.elementaryStreams[c];if(!!v){var i=g[c],r=u!==null||v.partial===!0;s.range[c]=E.getBufferedTimes(p,u,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=O(D),g=this.fragments[E];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(D,E,g,p){for(var u={time:[],partial:g},e=E?E.start:D.start,s=E?E.end:D.end,c=D.minEndPTS||s,v=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(v>=r&&c<=o){u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)u.partial=!0,u.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return u},y.getPartialFragment=function(D){var E=null,g,p,u,e=0,s=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(v){var i=c[v];!i||b(i)&&(p=i.body.start-s,u=i.body.end+s,D>=p&&D<=u&&(g=Math.min(D-p,u-D),e<=g&&(E=i.body,e=g)))}),E},y.getState=function(D){var E=O(D),g=this.fragments[E];return g?g.buffered?b(g)?L.PARTIAL:L.OK:L.APPENDING:L.NOT_LOADED},y.isTimeBuffered=function(D,E,g){for(var p,u,e=0;e<g.length;e++){if(p=g.start(e)-this.bufferPadding,u=g.end(e)+this.bufferPadding,D>=p&&E<=u)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var g=E.frag,p=E.part;if(!(g.sn==="initSegment"||g.bitrateTest||p)){var u=O(g);this.fragments[u]={body:g,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var g=this,p=E.frag,u=E.part,e=E.timeRanges;if(p.type===_.PlaylistLevelType.MAIN)if(this.activeFragment=p,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(c){var v=e[c];if(g.detectEvictedFragments(c,v),!u)for(var i=0;i<v.length;i++)p.appendedPTS=Math.max(v.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=O(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,g){var p=this;Object.keys(this.fragments).forEach(function(u){var e=p.fragments[u];if(!!e&&e.buffered){var s=e.body;s.type===g&&s.start<E&&s.end>D&&p.removeFragment(s)}})},y.removeFragment=function(D){var E=O(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},A}();function b(A){var y,T;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((T=A.range.audio)===null||T===void 0?void 0:T.partial))}function O(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"STALL_MINIMUM_DURATION_MS",function(){return b}),m.d(R,"MAX_START_GAP_JUMP",function(){return O}),m.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),m.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),m.d(R,"default",function(){return T});var M=m("./src/utils/buffer-helper.ts"),_=m("./src/errors.ts"),L=m("./src/events.ts"),C=m("./src/utils/logger.ts"),b=250,O=2,A=.1,y=.05,T=function(){function D(g,p,u,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=g,this.media=p,this.fragmentTracker=u,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,u){var e=this.config,s=this.media,c=this.stalled;if(s!==null){var v=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,v!==p){if(this.moved=!0,c!==null){if(this.stallReported){var d=self.performance.now()-c;C.logger.warn("playback not stuck anymore @"+v+", after "+Math.round(d)+"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||!M.BufferHelper.getBuffered(s).length)){var t=M.BufferHelper.bufferInfo(s,v,0),n=t.len>0,l=t.nextStart||0;if(!(!n&&!l)){if(i){var a=t.len>O,f=!l||u&&u.start<=v||l-v>O&&!this.fragmentTracker.getPartialFragment(v);if(a||f)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h,S=Math.max(l,t.start||0)-v,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||(h=x.details)===null||h===void 0?void 0:h.live,k=P?x.details.targetduration*2:O;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(c===null){this.stalled=B;return}var U=B-c;if(!(!i&&U>=b&&(this._reportStall(t),!this.media))){var W=M.BufferHelper.bufferInfo(s,v,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,u){var e=this.config,s=this.fragmentTracker,c=this.media;if(c!==null){var v=c.currentTime,i=s.getPartialFragment(v);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&u>e.highBufferWatchdogPeriod*1e3&&(C.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var u=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,C.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var u=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var c=s.currentTime,v=0,i=M.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(c+u.maxBufferHole>=v&&c<o){var d=Math.max(o+y,s.currentTime+A);return C.logger.warn("skipping hole, adjusting currentTime from "+c+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,p&&e.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+c+" to "+d,frag:p}),d}v=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,u=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var c=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var v=c+(s+1)*p.nudgeOffset;C.logger.warn("Nudging 'currentTime' from "+c+" to "+v),e.currentTime=v,u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else C.logger.error("Playhead still not moving while enough data buffered @"+c+" after "+p.nudgeMaxRetry+" nudges"),u.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/texttrack-utils.ts"),C=m("./src/demux/id3.ts"),b=m("./src/loader/date-range.ts"),O=m("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(g,p){return g.getTime()/1e3-p}function D(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function g(u){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=u,this._registerListeners()}var p=g.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(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(L.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 c=e[s];if(c.kind==="metadata"&&c.label==="id3")return Object(L.sendAddTrackEvent)(c,this.media),c}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var c=this.hls.config,v=c.enableEmsgMetadataCues,i=c.enableID3MetadataCues;if(!(!v&&!i)){var r=s.frag,o=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=d.edge||r.end,n=y(),l=!1,a={},f=0;f<o.length;f++){var h=o[f].type;if(!(h===O.MetadataSchema.emsg&&!v||!i)){var S=C.getID3Frames(o[f].data);if(S){var x=o[f].pts,P=t,k=P-x;k<=0&&(P=x+A);for(var B=0;B<S.length;B++){var U=S[B];if(!C.isTimeStampFrame(U)){var W=new n(x,P,"");W.value=U,h&&(W.type=h),this.id3Track.addCue(W),a[U.key]=null,l=!0}}}}}l&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,c=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(c)for(var v=c.length;v--;){var i,r=c[v],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var d=e[o];d&&r.endTime!==d&&(r.endTime=d),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var c=s.startOffset,v=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var d=o.config,t=d.enableEmsgMetadataCues,n=d.enableID3MetadataCues;if(r&&(t||n)){var l;i==="audio"?l=function(f){return f.type===O.MetadataSchema.audioId3&&n}:i==="video"?l=function(f){return f.type===O.MetadataSchema.emsg&&t}:l=function(f){return f.type===O.MetadataSchema.audioId3&&n||f.type===O.MetadataSchema.emsg&&t},Object(L.removeCuesInRange)(r,c,v,l)}}},p.onLevelUpdated=function(e,s){var c=this,v=s.details;if(!(!this.media||!v.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=v.dateRanges,d=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!d.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]},l=t.length;l--;)n(l);var a=v.fragments[v.fragments.length-1];if(!(d.length===0||!Object(M.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=a.programDateTime/1e3-a.start,h=v.edge||a.end,S=y(),x=function(B){var U=d[B],W=o[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,$=T(W.startDate,f),Z=h,q=W.endDate;if(q)Z=T(q,f),Y=!0;else if(W.endOnNext&&!Y){var ie=d.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=T(ie.startDate,f),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var te=ne[ae];if(!(te===b.DateRangeAttribute.ID||te===b.DateRangeAttribute.CLASS||te===b.DateRangeAttribute.START_DATE||te===b.DateRangeAttribute.DURATION||te===b.DateRangeAttribute.END_DATE||te===b.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===b.DateRangeAttribute.SCTE35_OUT||te===b.DateRangeAttribute.SCTE35_IN)&&(de=D(de)),fe.value={key:te,data:de},fe.type=O.MetadataSchema.dateRange,c.id3Track.addCue(fe),z[te]=fe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},P=0;P<d.length;P++)x(P)}}},g}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/errors.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts");function C(A,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(A,D.key,D)}}function b(A,y,T){return y&&C(A.prototype,y),T&&C(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var O=function(){function A(T){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=T,this.config=T.config,this.registerListeners()}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(_.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(_.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 g=E.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===M.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.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 g=this.computeLatency();if(g!==null){this._latency=g;var p=this.config,u=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!u||e===1)){var s=this.targetLatency;if(s!==null){var c=g-s,v=Math.min(this.maxLatency,s+E.targetduration),i=c<v;if(E.live&&i&&c>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*c-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},b(A,[{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,g=D.partHoldBack,p=D.targetduration,u=this.config,e=u.liveSyncDuration,s=u.liveSyncDurationCount,c=u.lowLatencyMode,v=this.hls.userConfig,i=c&&g||E;(v.liveSyncDuration||v.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,g=this.levelDetails;if(D===null||E===null||g===null)return null;var p=g.edge,u=D-E-this.edgeStalled,e=p-g.totalduration,s=p-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,u),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 g=D.buffered.length;return(g?D.buffered.end(g-1):E.edge)-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return u});var M=m("./src/types/level.ts"),_=m("./src/events.ts"),L=m("./src/errors.ts"),C=m("./src/utils/codecs.ts"),b=m("./src/controller/level-helper.ts"),O=m("./src/controller/base-playlist-controller.ts"),A=m("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var c=arguments[s];for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(e[v]=c[v])}return e},y.apply(this,arguments)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,i){return v.__proto__=i,v},g(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(e){E(s,e);function s(v){var i;return i=e.call(this,v,"[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 c=s.prototype;return c._registerListeners=function(){var i=this.hls;i.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(_.Events.ERROR,this.onError,this)},c._unregisterListeners=function(){var i=this.hls;i.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(_.Events.ERROR,this.onError,this)},c.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},c.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},c.onManifestLoaded=function(i,r){var o=[],d=[],t=[],n,l={},a,f=!1,h=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;f=f||!!(B.width&&B.height),h=h||!!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=l[W],a?a.url.push(B.url):(a=new M.Level(B),l[W]=a,o.push(a)),U&&(U.AUDIO&&Object(b.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(b.addGroupId)(a,"text",U.SUBTITLES))}),(f||h)&&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(C.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(C.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(d=r.audioTracks.filter(function(B){return!B.audioCodec||Object(C.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(b.assignTrackIdsByGroup)(d)),r.subtitles&&(t=r.subtitles,Object(b.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var x=0;x<o.length;x++)if(o[x].bitrate===n){this._firstLevel=x,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var P=S&&!h,k={levels:o,audioTracks:d,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:h,altAudio:!P&&d.some(function(B){return!!B.url})};this.hls.trigger(_.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},c.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var d=r.context,t=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&d.groupId===t.audioGroupIds[t.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&d.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,l=!0,a;switch(r.details){case L.ErrorDetails.FRAG_LOAD_ERROR:case L.ErrorDetails.FRAG_LOAD_TIMEOUT:case L.ErrorDetails.KEY_LOAD_ERROR:case L.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===A.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,h=this._levels[f];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=f)):a=f}break;case L.ErrorDetails.LEVEL_LOAD_ERROR:case L.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(l=!1),a=d.level),n=!0;break;case L.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,l)}},c.recoverLevel=function(i,r,o,d){var t=i.details,n=this._levels[r];if(n.loadError++,o){var l=this.retryLoadingOrFail(i);if(l)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var f=-1,h=this._levels,S=h.length;S--;){var x=(S+this.currentLevelIndex)%h.length;if(x!==this.currentLevelIndex&&h[x].loadError===0){f=x;break}}f>-1&&this.currentLevelIndex!==f&&(this.warn(t+": switch to "+f),i.levelRetry=!0,this.hls.nextAutoLevel=f)}}},c.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var d=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(t){t.urlId=d}),this.level=i}},c.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===A.PlaylistLevelType.MAIN){var d=this._levels[o.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},c.onLevelLoaded=function(i,r){var o,d=r.level,t=r.details,n=this._levels[d];if(!n){var l;this.warn("Invalid level index "+d),(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(d,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},c.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var d=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){d=n;break}d!==o.urlId&&(o.urlId=d,this.startLoad())}},c.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var d=o.urlId,t=o.url[d];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 "+d+" "+t),this.clearTimer(),this.hls.trigger(_.Events.LEVEL_LOADING,{url:t,level:r,id:d,deliveryDirectives:i||null})}},c.removeLevel=function(i,r){var o=function(n,l){return l!==r},d=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 l=t.details;return l!=null&&l.fragments&&l.fragments.forEach(function(a){a.level=n}),t});this._levels=d,this.hls.trigger(_.Events.LEVELS_UPDATED,{levels:d})},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 d=i<0;if(this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],l=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},l,{level:i,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete a._urlId,this.hls.trigger(_.Events.LEVEL_SWITCHING,a);var f=l.details;if(!f||f.live){var h=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(h)}}}},{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}(O.default)},"./src/controller/level-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"addGroupId",function(){return b}),m.d(R,"assignTrackIdsByGroup",function(){return O}),m.d(R,"updatePTS",function(){return A}),m.d(R,"updateFragPTSDTS",function(){return T}),m.d(R,"mergeDetails",function(){return D}),m.d(R,"mapPartIntersection",function(){return g}),m.d(R,"mapFragmentIntersection",function(){return p}),m.d(R,"adjustSliding",function(){return u}),m.d(R,"addSliding",function(){return e}),m.d(R,"computeReloadInterval",function(){return s}),m.d(R,"getFragmentWithSN",function(){return c}),m.d(R,"getPartWith",function(){return v});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/logger.ts"),L=m("./src/loader/date-range.ts");function C(){return C=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&(i[d]=o[d])}return i},C.apply(this,arguments)}function b(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 O(i){var r={};i.forEach(function(o){var d=o.groupId||"";o.id=r[d]=r[d]||0,r[d]++})}function A(i,r,o){var d=i[r],t=i[o];y(d,t)}function y(i,r){var o=r.startPTS;if(Object(M.isFiniteNumber)(o)){var d=0,t;r.sn>i.sn?(d=o-i.start,t=i):(d=i.start-o,t=r),t.duration!==d&&(t.duration=d)}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 T(i,r,o,d,t,n){var l=d-o;l<=0&&(_.logger.warn("Fragment should have a positive duration",r),d=o+r.duration,n=t+r.duration);var a=o,f=d,h=r.startPTS,S=r.endPTS;if(Object(M.isFiniteNumber)(h)){var x=Math.abs(h-o);Object(M.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,a=Math.max(o,h),o=Math.min(o,h),t=Math.min(t,r.startDTS),f=Math.min(d,S),d=Math.max(d,S),n=Math.max(n,r.endDTS)}r.duration=d-o;var P=o-r.start;r.appendedPTS=d,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=d,r.minEndPTS=f,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,P}function D(i,r){for(var o=null,d=i.fragments,t=d.length-1;t>=0;t--){var n=d[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var l=0,a;if(p(i,r,function(B,U){B.relurl&&(l=B.cc-U.cc),Object(M.isFiniteNumber)(B.startPTS)&&Object(M.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 f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.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){_.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=r.skippedSegments;h--;)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(l){_.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=l}r.skippedSegments&&(r.startCC=r.fragments[0].cc),g(i.partList,r.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),a?T(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):u(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var P=r.advancedDateTime;if(r.advanced&&P){var k=r.edge;r.driftStart||(r.driftStartTime=P,r.driftStart=k),r.driftEndTime=P,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var d=C({},i);return o&&o.forEach(function(t){delete d[t]}),Object.keys(r).forEach(function(t){var n=new L.DateRange(r[t].attr,d[t]);n.isValid?d[t]=n:_.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),d}function g(i,r,o){if(i&&r)for(var d=0,t=0,n=i.length;t<=n;t++){var l=i[t],a=r[t+d];l&&a&&l.index===a.index&&l.fragment.sn===a.fragment.sn?o(l,a):d--}}function p(i,r,o){for(var d=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(d?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,l=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t;h<=n;h++){var S=f[l+h],x=a[h];d&&!x&&h<d&&(x=r.fragments[h]=S),S&&x&&o(S,x)}}function u(i,r){var o=r.startSN+r.skippedSegments-i.startSN,d=i.fragments;o<0||o>=d.length||e(r,d[o].start)}function e(i,r){if(r){for(var o=i.fragments,d=i.skippedSegments;d<o.length;d++)o[d].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,d=o/2,t=i.age,n=t>0&&t<o*3,l=r.loading.end-r.loading.start,a,f=i.availabilityDelay;if(i.updated===!1)if(n){var h=333*i.misses;a=Math.max(Math.min(d,l*2),h),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=d;else n?(f=Math.min(f||o/2,t),i.availabilityDelay=f,a=f+o-t):a=o-l;return Math.round(a)}function c(i,r,o){if(!i||!i.details)return null;var d=i.details,t=d.fragments[r-d.startSN];return t||(t=d.fragmentHint,t&&t.sn===r)?t:r<d.startSN&&o&&o.sn===r?o:null}function v(i,r,o){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var t=d.length;t--;){var n=d[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return v});var M=m("./src/polyfills/number.ts"),_=m("./src/controller/base-stream-controller.ts"),L=m("./src/is-supported.ts"),C=m("./src/events.ts"),b=m("./src/utils/buffer-helper.ts"),O=m("./src/controller/fragment-tracker.ts"),A=m("./src/types/loader.ts"),y=m("./src/loader/fragment.ts"),T=m("./src/demux/transmuxer-interface.ts"),D=m("./src/types/transmuxer.ts"),E=m("./src/controller/gap-controller.ts"),g=m("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var d=r[o];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function u(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(d,t){return d.__proto__=t,d},s(i,r)}var c=100,v=function(i){e(r,i);function r(d,t){var n;return n=i.call(this,d,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(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(C.Events.ERROR,this.onError,this),t.on(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(C.Events.ERROR,this.onError,this),t.off(C.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(C.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(C.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(C.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(C.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(c),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=l.startLevel;a===-1&&(l.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=l.nextAutoLevel),this.level=l.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=_.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=_.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_LEVEL:{var t,n=this.levels,l=this.level,a=n==null||(t=n[l])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=_.State.IDLE;break}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var f,h=self.performance.now(),S=this.retryDate;(!S||h>=S||(f=this.media)!==null&&f!==void 0&&f.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=_.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,l=this.hls,a=this.levelLastLoaded,f=this.levels,h=this.media,S=l.config,x=l.nextLoadLevel;if(!(a===null||!h&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!f||!f[x])){var P=f[x];this.level=l.nextLoadLevel=x;var k=P.details;if(!k||this.state===_.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==x){this.state=_.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(P.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(C.Events.BUFFER_EOS,G),this.state=_.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)!==O.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)===O.FragmentState.OK&&this.nextLoadPosition>z){var ne=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;h&&this.afterBufferFlushed(h,ne,A.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,l){var a,f=this.fragmentTracker.getState(t);this.fragCurrent=t,f===O.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,l)):f===O.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,A.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,A.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 l,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var f=this.hls.nextLoadLevel,h=t[f],S=this.fragLastKbps;S&&this.fragCurrent?l=this.fragCurrent.duration*h.maxBitrate/(1e3*S)+1:l=0}else l=0;var x=this.getBufferedFrag(n.currentTime+l);if(x){var P=this.followingBufferedFrag(x);if(P){this.abortCurrentFrag();var k=P.maxStartPTS?P.maxStartPTS:P.start,B=P.duration,U=Math.max(x.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 _.State.KEY_LOADING:case _.State.FRAG_LOADING:case _.State.FRAG_LOADING_WAITING_RETRY:case _.State.PARSING:case _.State.PARSED:this.state=_.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 l=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,l,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(M.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(C.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 l=!1,a=!1,f;n.levels.forEach(function(h){f=h.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(l=!0),f.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=l&&a&&!Object(L.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 l=this.levels;if(!(!l||this.state!==_.State.IDLE)){var a=l[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=_.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var l,a=this.levels,f=n.level,h=n.details,S=h.totalduration;if(!a){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+h.startSN+","+h.endSN+"], cc ["+h.startCC+", "+h.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===_.State.FRAG_LOADING||this.state===_.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==n.level&&x.loader&&(this.state=_.State.IDLE,this.backtrackFragment=null,x.loader.abort());var P=a[f],k=0;if(h.live||(l=P.details)!==null&&l!==void 0&&l.live){if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed)return;k=this.alignPlaylists(h,P.details)}if(P.details=h,this.levelLastLoaded=f,this.hls.trigger(C.Events.LEVEL_UPDATED,{details:h,level:f}),this.state===_.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=_.State.IDLE}this.startFragRequested?h.live&&this.synchronizeToLiveEdge(h):this.setStartPosition(h,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,l=t.frag,a=t.part,f=t.payload,h=this.levels;if(!h){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var S=h[l.level],x=S.details;if(!x){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var P=S.videoCodec,k=x.PTSKnown||!x.live,B=(n=l.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=a?a.index:-1,z=G!==-1,Y=new D.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,f.byteLength,G,z),$=this.initPTS[l.cc];W.push(f,B,U,P,l,a,x.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var l=this.altAudio,a=!!n.url,f=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 h=this.fragCurrent;h!=null&&h.loader&&(this.log("Switching to main audio track, cancel main fragment load"),h.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;l&&S.trigger(C.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(C.Events.AUDIO_TRACK_SWITCHED,{id:f})}},o.onAudioTrackSwitched=function(t,n){var l=n.id,a=!!this.hls.audioTracks[l].url;if(a){var f=this.videoBuffer;f&&this.mediaBuffer!==f&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=f)}this.altAudio=a,this.tick()},o.onBufferCreated=function(t,n){var l=n.tracks,a,f,h=!1;for(var S in l){var x=l[S];if(x.id==="main"){if(f=S,a=x,S==="video"){var P=l[S];P&&(this.videoBuffer=P.buffer)}}else h=!0}h&&a?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var l=n.frag,a=n.part;if(!(l&&l.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(a?" p: "+a.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===_.State.PARSED&&(this.state=_.State.IDLE);return}var f=a?a.stats:l.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,a)}},o.onError=function(t,n){switch(n.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,n);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==_.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=_.State.ERROR):!n.levelRetry&&this.state===_.State.WAITING_LEVEL&&(this.state=_.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var l=!0,a=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);a&&a.len>.5&&(l=!this.reduceMaxBufferLength(a.len)),l&&(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||!b.BufferHelper.getBuffered(t).length){var l=this.state!==_.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,l)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=_.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var l=n.type;if(l!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(l===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,l,A.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,l=this.startPosition;if(l>=0&&n<l){if(t.seeking){this.log("could not seek to "+l+", already seeking at "+n);return}var a=b.BufferHelper.getBuffered(t),f=a.length?a.start(0):0,h=f-l;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),l+=h,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+n),t.currentTime=l}}},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(l){var a=n.hls;if(!(!l||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=_.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var f=t.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),a.trigger(C.Events.FRAG_LOADED,l),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,l="main",a=this.hls,f=t.remuxResult,h=t.chunkMeta,S=this.getCurrentContext(h);if(!S){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(h.level);return}var x=S.frag,P=S.part,k=S.level,B=f.video,U=f.text,W=f.id3,G=f.initSegment,z=k.details,Y=this.altAudio?void 0:f.audio;if(!this.fragContextChanged(x)){if(this.state=_.State.PARSING,G){G.tracks&&(this._bufferInitSegment(k,G.tracks,x,h),a.trigger(C.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:l,tracks:G.tracks}));var $=G.initPTS,Z=G.timescale;Object(M.isFiniteNumber)($)&&(this.initPTS[x.cc]=$,a.trigger(C.Events.INIT_PTS_FOUND,{frag:x,id:l,initPTS:$,timescale:Z}))}if(B&&f.independent!==!1){if(z){var q=B.startPTS,ie=B.endPTS,ne=B.startDTS,ae=B.endDTS;if(P)P.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(x);return}x.setElementaryStreamInfo(B.type,x.start,ie,x.start,ae,!0)}x.setElementaryStreamInfo(B.type,q,ie,ne,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(B,x,P,h)}}else if(f.independent===!1){this.backtrack(x);return}if(Y){var re=Y.startPTS,Ee=Y.endPTS,me=Y.startDTS,Te=Y.endDTS;P&&(P.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:Ee,startDTS:me,endDTS:Te}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,Ee,me,Te),this.bufferFragmentData(Y,x,P,h)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:l,frag:x,details:z,samples:W.samples};a.trigger(C.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Ae={id:l,frag:x,details:z,samples:U.samples};a.trigger(C.Events.FRAG_PARSING_USERDATA,Ae)}}},o._bufferInitSegment=function(t,n,l,a){var f=this;if(this.state===_.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var h=n.audio,S=n.video,x=n.audiovideo;if(h){var P=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),h.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(P="mp4a.40.5")),k.indexOf("android")!==-1&&h.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),t.audioCodec&&t.audioCodec!==P&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+P+'"'),h.levelCodec=P,h.id="main",this.log("Init audio buffer, container:"+h.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(t.audioCodec||"")+"/"+h.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),x&&this.log("Init audiovideo buffer, container:"+x.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+x.codec+"]"),this.hls.trigger(C.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&f.hls.trigger(C.Events.BUFFER_APPENDING,{type:B,data:W,frag:l,part:null,chunkMeta:a,parent:l.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.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=_.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var l=t.currentTime;if(b.BufferHelper.isBuffered(t,l)?n=this.getAppendedFrag(l):b.BufferHelper.isBuffered(t,l+.1)&&(n=this.getAppendedFrag(l+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,f=n.level;(!a||n.sn!==a.sn||a.level!==f||n.urlId!==a.urlId)&&(this.hls.trigger(C.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==f)&&this.hls.trigger(C.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=n)}}},u(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,l=this.currentFrag;if(l&&Object(M.isFiniteNumber)(n)&&Object(M.isFiniteNumber)(l.programDateTime)){var a=l.programDateTime+(n-l.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}(_.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"SubtitleStreamController",function(){return e});var M=m("./src/events.ts"),_=m("./src/utils/buffer-helper.ts"),L=m("./src/controller/fragment-finders.ts"),C=m("./src/utils/discontinuities.ts"),b=m("./src/controller/level-helper.ts"),O=m("./src/controller/fragment-tracker.ts"),A=m("./src/controller/base-stream-controller.ts"),y=m("./src/types/loader.ts"),T=m("./src/types/level.ts");function D(c,v){for(var i=0;i<v.length;i++){var r=v[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,r.key,r)}}function E(c,v,i){return v&&D(c.prototype,v),i&&D(c,i),Object.defineProperty(c,"prototype",{writable:!1}),c}function g(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,p(c,v)}function p(c,v){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(c,v)}var u=500,e=function(c){g(v,c);function v(r,o){var d;return d=c.call(this,r,o,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=v.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this),o.on(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this),o.off(M.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(M.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(M.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(M.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(u),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(o,d){var t=d.frag,n=d.success;if(this.fragPrevious=t,this.state=A.State.IDLE,!!n){var l=this.tracksBuffered[this.currentTrackId];if(!!l){for(var a,f=t.start,h=0;h<l.length;h++)if(f>=l[h].start&&f<=l[h].end){a=l[h];break}var S=t.start+t.duration;a?a.end=S:(a={start:f,end:S},l.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,d){var t=d.startOffset,n=d.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var l=this.currentTrackId,a=this.levels;if(!a.length||!a[l]||!a[l].details)return;var f=a[l].details,h=f.targetduration,S=n-h;if(S<=0)return;d.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(x){for(var P=0;P<x.length;){if(x[P].end<=S){x.shift();continue}else if(x[P].start<S)x[P].start=S;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(o,d){var t,n=d.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(o,d){var t=this,n=d.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(l){return new T.Level(l)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(l){t.tracksBuffered[l.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,d){if(this.currentTrackId=d.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(u)},i.onSubtitleTrackLoaded=function(o,d){var t,n=d.details,l=d.id,a=this.currentTrackId,f=this.levels;if(!!f.length){var h=f[a];if(!(l>=f.length||l!==a||!h)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=h.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!h.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(C.alignMediaPlaylistByPDT)(n,S):x&&Object(b.addSliding)(n,x.start);else{var P=this.alignPlaylists(n,h.details);P===0&&x&&Object(b.addSliding)(n,x.start)}}if(h.details=n,this.levelLastLoaded=l,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var k=Object(L.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var d=o.frag,t=o.payload,n=d.decryptdata,l=this.hls;if(!this.fragContextChanged(d)&&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(f){var h=performance.now();l.trigger(M.Events.FRAG_DECRYPTED,{frag:d,payload:f,stats:{tstart:a,tdecrypt:h}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var o=this.currentTrackId,d=this.levels;if(!d.length||!d[o]||!d[o].details)return;var t=d[o].details,n=t.targetduration,l=this.config,a=this.media,f=_.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,l.maxBufferHole),h=f.end,S=f.len,x=this.getMaxBufferLength()+n;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var P=t.fragments,k=P.length,B=t.edge,U,W=this.fragPrevious;if(h<B){var G=l.maxFragLookUpTolerance;U=Object(L.findFragmentByPTS)(W,P,Math.max(P[0].start,h),G),!U&&W&&W.start<P[0].start&&(U=P[0])}else U=P[k-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==O.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,h)}},i.loadFragment=function(o,d,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):c.prototype.loadFragment.call(this,o,d,t)},E(v,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),v}(A.default),s=function(v){this.buffered=void 0;var i=function(o,d,t){if(d=d>>>0,d>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+t+")");return v[d][o]};this.buffered={get length(){return v.length},end:function(o){return i("end",o,v.length)},start:function(o){return i("start",o,v.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/events.ts"),_=m("./src/utils/texttrack-utils.ts"),L=m("./src/controller/base-playlist-controller.ts"),C=m("./src/types/loader.ts");function b(E,g){for(var p=0;p<g.length;p++){var u=g[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(E,u.key,u)}}function O(E,g,p){return g&&b(E.prototype,g),p&&b(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function A(E,g){E.prototype=Object.create(g.prototype),E.prototype.constructor=E,y(E,g)}function y(E,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,e){return u.__proto__=e,u},y(E,g)}var T=function(E){A(g,E);function g(u){var e;return e=E.call(this,u,"[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=g.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(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(M.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(_.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 c=s.id,v=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+c);return}var o=r.details;r.details=s.details,this.log("subtitle track "+c+" loaded ["+v.startSN+"-"+v.endSN+"]"),c===this.trackId&&(this.retryCount=0,this.playlistLoaded(c,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 c=s.textGroupIds[s.urlId];if(this.groupId!==c){var v=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!c||d.groupId===c});this.tracksInGroup=i;var r=this.findTrackId(v==null?void 0:v.name)||this.findTrackId();this.groupId=c;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+c+'" group-id'),this.hls.trigger(M.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,v)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,c=0;c<s.length;c++){var v=s[c];if((!this.selectDefaultTrack||v.default)&&(!e||e===v.name))return v.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===C.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 c=s.id,v=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 "+c),this.hls.trigger(M.Events.SUBTITLE_TRACK_LOADING,{url:i,id:c,groupId:v,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,c=this.media,v=this.trackId;if(!!c){var i=D(c.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[v];o&&(o.mode="disabled")}var d=r[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var c,v=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(c=v[e])!==null&&c!==void 0&&c.details)||e<-1||e>=v.length)){this.clearTimer();var i=v[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,d=o===void 0?"":o,t=i.name,n=i.type,l=i.url;this.hls.trigger(M.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:d,name:t,type:n,url:l});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(M.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),c=0;c<s.length;c++)if(s[c].mode==="hidden")e=c;else if(s[c].mode==="showing"){e=c;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(g,[{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)}}]),g}(L.default);function D(E){for(var g=[],p=0;p<E.length;p++){var u=E[p];u.kind==="subtitles"&&u.label&&g.push(E[p])}return g}R.default=T},"./src/controller/timeline-controller.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"TimelineController",function(){return E});var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/utils/cea-608-parser.ts"),C=m("./src/utils/output-filter.ts"),b=m("./src/utils/webvtt-parser.ts"),O=m("./src/utils/texttrack-utils.ts"),A=m("./src/utils/imsc1-ttml-parser.ts"),y=m("./src/utils/mp4-tools.ts"),T=m("./src/types/loader.ts"),D=m("./src/utils/logger.ts"),E=function(){function e(c){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=u(),this.captionsProperties=void 0,this.hls=c,this.config=c.config,this.Cues=c.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 v=new C.default(this,"textTrack1"),i=new C.default(this,"textTrack2"),r=new C.default(this,"textTrack3"),o=new C.default(this,"textTrack4");this.cea608Parser1=new L.default(1,v,i),this.cea608Parser2=new L.default(3,r,o)}c.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),c.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),c.on(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(_.Events.FRAG_LOADING,this.onFragLoading,this),c.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),c.on(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),c.on(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),c.on(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),c.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var v=this.hls;v.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(_.Events.FRAG_LOADING,this.onFragLoading,this),v.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),v.off(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),v.off(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),v.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(v,i,r,o,d){for(var t=!1,n=d.length;n--;){var l=d[n],a=p(l[0],l[1],i,r);if(a>=0&&(l[0]=Math.min(l[0],i),l[1]=Math.max(l[1],r),t=!0,a/(r-i)>.5))return}if(t||d.push([i,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[v];this.Cues.newCue(f,i,r,o)}else{var h=this.Cues.newCue(null,i,r,o);this.hls.trigger(_.Events.CUES_PARSED,{type:"captions",cues:h,track:v})}},s.onInitPtsFound=function(v,i){var r=this,o=i.frag,d=i.id,t=i.initPTS,n=i.timescale,l=this.unparsedVttFrags;d==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),l.length&&(this.unparsedVttFrags=[],l.forEach(function(a){r.onFragLoaded(_.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(v){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[v])return o}return null},s.createCaptionsTrack=function(v){this.config.renderTextTracksNatively?this.createNativeTrack(v):this.createNonNativeTrack(v)},s.createNativeTrack=function(v){if(!this.captionsTracks[v]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,d=i[v],t=d.label,n=d.languageCode,l=this.getExistingTrack(v);if(l)r[v]=l,Object(O.clearCurrentCues)(r[v]),Object(O.sendAddTrackEvent)(r[v],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[v]=!0,r[v]=a)}}},s.createNonNativeTrack=function(v){if(!this.nonNativeCaptionsTracks[v]){var i=this.captionsProperties[v];if(!!i){var r=i.label,o={_id:v,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[v]=o,this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(v,i,r){var o=this.media;if(!!o)return o.addTextTrack(v,i,r)},s.onMediaAttaching=function(v,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var v=this.captionsTracks;Object.keys(v).forEach(function(i){Object(O.clearCurrentCues)(v[i]),delete v[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=u(),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 v=this.media;if(!!v){var i=v.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(v,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],d=o.some(function(a){return a.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&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,f){var h;if(f<n.length){for(var S=null,x=0;x<n.length;x++)if(g(n[x],a)){S=n[x];break}S&&(h=S)}if(h)Object(O.clearCurrentCues)(h);else{var P=r._captionsOrSubtitlesFromCharacteristics(a);h=r.createTextTrack(P,a.name,a.lang),h&&(h.mode="disabled")}h&&(h.groupId=a.groupId,r.textTracks.push(h))})}else if(!t&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},s._captionsOrSubtitlesFromCharacteristics=function(v){var i;if((i=v.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(v.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(v.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(v,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var d=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!d){var t="textTrack"+d[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2,d=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===T.PlaylistLevelType.MAIN){var n,l,a=i.frag.sn,f=(n=i==null||(l=i.part)===null||l===void 0?void 0:l.index)!=null?n:-1;a===d+1||a===d&&f===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=f}},s.onFragLoaded=function(v,i){var r=i.frag,o=i.payload,d=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(M.isFiniteNumber)(d[r.cc])){t.push(i),d.length&&this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,l="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||l){var a=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===A.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,f)}}else this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(v,i){var r=this,o=this.hls;Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(d){r._appendCues(d,v.level),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(d){D.logger.log("Failed to parse IMSC1: "+d),o.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:d})})},s._parseVTTs=function(v,i,r){var o,d=this,t=this.hls,n=(o=v.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(v.initSegment.data,new Uint8Array(i)):i;Object(b.parseWebVTT)(n,this.initPTS[v.cc],this.timescale[v.cc],r,v.cc,v.start,function(l){d._appendCues(l,v.level),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(l){d._fallbackToIMSC1(v,i),D.logger.log("Failed to parse VTT cue: "+l),t.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:l})})},s._fallbackToIMSC1=function(v,i){var r=this,o=this.tracks[v.level];o.textCodec||Object(A.parseIMSC1)(i,this.initPTS[v.cc],this.timescale[v.cc],function(){o.textCodec=A.IMSC1_CODEC,r._parseIMSC1(v,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(v,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;v.forEach(function(n){return Object(O.addCueToTrack)(o,n)})}else{var d=this.tracks[i];if(!d)return;var t=d.default?"default":"subtitles"+i;r.trigger(_.Events.CUES_PARSED,{type:"subtitles",cues:v,track:t})}},s.onFragDecrypted=function(v,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(M.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(_.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(v,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var d=0;d<i.samples.length;d++){var t=i.samples[d].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[d].pts,n[0]),o.addData(i.samples[d].pts,n[1])}}},s.onBufferFlushing=function(v,i){var r=i.startOffset,o=i.endOffset,d=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(f){return Object(O.removeCuesInRange)(l[f],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&d!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(f){return Object(O.removeCuesInRange)(a[f],r,d)})}}},s.extractCea608Data=function(v){for(var i=[[],[]],r=v[0]&31,o=2,d=0;d<r;d++){var t=v[o++],n=127&v[o++],l=127&v[o++];if(!(n===0&&l===0)){var a=(4&t)!==0;if(a){var f=3&t;(f===0||f===1)&&(i[f].push(n),i[f].push(l))}}}return i},e}();function g(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,c,v){return Math.min(s,v)-Math.max(e,c)}function u(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.aesIV=void 0,this.subtle=C,this.aesIV=b}var L=_.prototype;return L.decrypt=function(b,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,b)},_}()},"./src/crypt/aes-decryptor.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"removePadding",function(){return _}),m.d(R,"default",function(){return L});var M=m("./src/utils/typed-array.ts");function _(C){var b=C.byteLength,O=b&&new DataView(C.buffer).getUint8(b-1);return O?Object(M.sliceUint8)(C,0,b-O):C}var L=function(){function C(){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 b=C.prototype;return b.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),T=new Uint32Array(4),D=0;D<4;D++)T[D]=y.getUint32(D*4);return T},b.initTable=function(){var A=this.sBox,y=this.invSBox,T=this.subMix,D=T[0],E=T[1],g=T[2],p=T[3],u=this.invSubMix,e=u[0],s=u[1],c=u[2],v=u[3],i=new Uint32Array(256),r=0,o=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,A[r]=t,y[t]=r;var n=i[r],l=i[n],a=i[l],f=i[t]*257^t*16843008;D[r]=f<<24|f>>>8,E[r]=f<<16|f>>>16,g[r]=f<<8|f>>>24,p[r]=f,f=a*16843009^l*65537^n*257^r*16843008,e[t]=f<<24|f>>>8,s[t]=f<<16|f>>>16,c[t]=f<<8|f>>>24,v[t]=f,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},b.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),T=!0,D=0;D<y.length&&T;)T=y[D]===this.key[D],D++;if(!T){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 g=this.ksRows=(E+6+1)*4,p,u,e=this.keySchedule=new Uint32Array(g),s=this.invKeySchedule=new Uint32Array(g),c=this.sBox,v=this.rcon,i=this.invSubMix,r=i[0],o=i[1],d=i[2],t=i[3],n,l;for(p=0;p<g;p++){if(p<E){n=e[p]=y[p];continue}l=n,p%E===0?(l=l<<8|l>>>24,l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255],l^=v[p/E|0]<<24):E>6&&p%E===4&&(l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[l&255]),e[p]=n=(e[p-E]^l)>>>0}for(u=0;u<g;u++)p=g-u,u&3?l=e[p]:l=e[p-4],u<4||p<=4?s[u]=l:s[u]=r[c[l>>>24]]^o[c[l>>>16&255]]^d[c[l>>>8&255]]^t[c[l&255]],s[u]=s[u]>>>0}},b.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},b.decrypt=function(A,y,T){for(var D=this.keySize+6,E=this.invKeySchedule,g=this.invSBox,p=this.invSubMix,u=p[0],e=p[1],s=p[2],c=p[3],v=this.uint8ArrayToUint32Array_(T),i=v[0],r=v[1],o=v[2],d=v[3],t=new Int32Array(A),n=new Int32Array(t.length),l,a,f,h,S,x,P,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],x=G^E[1],P=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)l=u[S>>>24]^e[x>>16&255]^s[P>>8&255]^c[k&255]^E[z],a=u[x>>>24]^e[P>>16&255]^s[k>>8&255]^c[S&255]^E[z+1],f=u[P>>>24]^e[k>>16&255]^s[S>>8&255]^c[x&255]^E[z+2],h=u[k>>>24]^e[S>>16&255]^s[x>>8&255]^c[P&255]^E[z+3],S=l,x=a,P=f,k=h,z=z+4;l=g[S>>>24]<<24^g[x>>16&255]<<16^g[P>>8&255]<<8^g[k&255]^E[z],a=g[x>>>24]<<24^g[P>>16&255]<<16^g[k>>8&255]<<8^g[S&255]^E[z+1],f=g[P>>>24]<<24^g[k>>16&255]<<16^g[S>>8&255]<<8^g[x&255]^E[z+2],h=g[k>>>24]<<24^g[S>>16&255]<<16^g[x>>8&255]<<8^g[P&255]^E[z+3],n[y]=$(l^i),n[y+1]=$(h^r),n[y+2]=$(f^o),n[y+3]=$(a^d),i=B,r=U,o=W,d=G,y=y+4}return n.buffer},C}()},"./src/crypt/decrypter.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return y});var M=m("./src/crypt/aes-crypto.ts"),_=m("./src/crypt/fast-aes-key.ts"),L=m("./src/crypt/aes-decryptor.ts"),C=m("./src/utils/logger.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/utils/typed-array.ts"),A=16,y=function(){function T(E,g,p){var u=p===void 0?{}:p,e=u.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=g,this.removePKCS7Padding=s,s)try{var c=self.crypto;c&&(this.subtle=c.subtle||c.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=T.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var p=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(L.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(g,p,u,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),p,u);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),p,u).then(e)},D.softwareDecrypt=function(g,p,u){var e=this.currentIV,s=this.currentResult,c=this.remainderData;this.logOnce("JS AES decrypt"),c&&(g=Object(b.appendUint8Array)(c,g),this.remainderData=null);var v=this.getValidChunk(g);if(!v.length)return null;e&&(u=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new L.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(v.buffer,0,u),this.currentIV=Object(O.sliceUint8)(v,-16).buffer,r||null},D.webCryptoDecrypt=function(g,p,u){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new _.default(s,p)),this.fastAesKey.expandKey().then(function(c){if(!s)return Promise.reject(new Error("web crypto not initialized"));var v=new M.default(s,u);return v.decrypt(g.buffer,c)}).catch(function(c){return e.onWebCryptoError(c,g,p,u)})},D.onWebCryptoError=function(g,p,u,e){return C.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,u,e)},D.getValidChunk=function(g){var p=g,u=g.length-g.length%A;return u!==g.length&&(p=Object(O.sliceUint8)(g,0,u),this.remainderData=Object(O.sliceUint8)(g,u)),p},D.logOnce=function(g){!this.logEnabled||(C.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.subtle=void 0,this.key=void 0,this.subtle=C,this.key=b}var L=_.prototype;return L.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},_}()},"./src/demux/aacdemuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/demux/base-audio-demuxer.ts"),_=m("./src/demux/adts.ts"),L=m("./src/utils/logger.ts"),C=m("./src/demux/id3.ts");function b(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,g){return E.__proto__=g,E},O(y,T)}var A=function(y){b(T,y);function T(E,g){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=g,p}var D=T.prototype;return D.resetInitSegment=function(g,p,u,e){y.prototype.resetInitSegment.call(this,g,p,u,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}},T.probe=function(g){if(!g)return!1;for(var p=C.getID3Data(g,0)||[],u=p.length,e=g.length;u<e;u++)if(_.probe(g,u))return L.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(g,p){return _.canParse(g,p)},D.appendFrame=function(g,p,u){_.initTrackConfig(g,this.observer,p,u,g.manifestCodec);var e=_.appendFrame(g,p,u,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(M.default);R.default=A},"./src/demux/adts.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"getAudioConfig",function(){return C}),m.d(R,"isHeaderPattern",function(){return b}),m.d(R,"getHeaderLength",function(){return O}),m.d(R,"getFullFrameLength",function(){return A}),m.d(R,"canGetFrameLength",function(){return y}),m.d(R,"isHeader",function(){return T}),m.d(R,"canParse",function(){return D}),m.d(R,"probe",function(){return E}),m.d(R,"initTrackConfig",function(){return g}),m.d(R,"getFrameDuration",function(){return p}),m.d(R,"parseFrameHeader",function(){return u}),m.d(R,"appendFrame",function(){return e});var M=m("./src/utils/logger.ts"),_=m("./src/errors.ts"),L=m("./src/events.ts");function C(s,c,v,i){var r,o,d,t,n=navigator.userAgent.toLowerCase(),l=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((c[v+2]&192)>>>6)+1;var f=(c[v+2]&60)>>>2;if(f>a.length-1){s.trigger(L.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return d=(c[v+2]&1)<<2,d|=(c[v+3]&192)>>>6,M.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+f),/firefox/i.test(n)?f>=6?(r=5,t=new Array(4),o=f-3):(r=2,t=new Array(2),o=f):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=f):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&f>=6?o=f-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(f>=6&&d===1||/vivaldi/i.test(n))||!i&&d===1)&&(r=2,t=new Array(2)),o=f)),t[0]=r<<3,t[0]|=(f&14)>>1,t[1]|=(f&1)<<7,t[1]|=d<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[f],channelCount:d,codec:"mp4a.40."+r,manifestCodec:l}}function b(s,c){return s[c]===255&&(s[c+1]&246)===240}function O(s,c){return s[c+1]&1?7:9}function A(s,c){return(s[c+3]&3)<<11|s[c+4]<<3|(s[c+5]&224)>>>5}function y(s,c){return c+5<s.length}function T(s,c){return c+1<s.length&&b(s,c)}function D(s,c){return y(s,c)&&b(s,c)&&A(s,c)<=s.length-c}function E(s,c){if(T(s,c)){var v=O(s,c);if(c+v>=s.length)return!1;var i=A(s,c);if(i<=v)return!1;var r=c+i;return r===s.length||T(s,r)}return!1}function g(s,c,v,i,r){if(!s.samplerate){var o=C(c,v,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,M.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function u(s,c){var v=O(s,c);if(c+v<=s.length){var i=A(s,c)-v;if(i>0)return{headerLength:v,frameLength:i}}}function e(s,c,v,i,r){var o=p(s.samplerate),d=i+r*o,t=u(c,v),n;if(t){var l=t.frameLength,a=t.headerLength,f=a+l,h=Math.max(0,v+f-c.length);h?(n=new Uint8Array(f-a),n.set(c.subarray(v+a,c.length),0)):n=c.subarray(v+a,v+f);var S={unit:n,pts:d};return h||s.samples.push(S),{sample:S,length:f,missing:h}}var x=c.length-v;n=new Uint8Array(x),n.set(c.subarray(v,c.length),0);var P={unit:n,pts:d};return{sample:P,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"initPTSFn",function(){return y});var M=m("./src/polyfills/number.ts"),_=m("./src/demux/id3.ts"),L=m("./src/types/demuxer.ts"),C=m("./src/demux/dummy-demuxed-track.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/utils/typed-array.ts"),A=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=T.prototype;return D.resetInitSegment=function(g,p,u,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(g,p){return!1},D.appendFrame=function(g,p,u){},D.demux=function(g,p){this.cachedData&&(g=Object(b.appendUint8Array)(this.cachedData,g),this.cachedData=null);var u=_.getID3Data(g,0),e=u?u.length:0,s,c,v=this._audioTrack,i=this._id3Track,r=u?_.getTimeStamp(u):void 0,o=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(M.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),u&&u.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:u,type:L.MetadataSchema.audioId3}),c=this.basePTS;e<o;){if(this.canParse(g,e)){var d=this.appendFrame(v,g,e);d?(this.frameIndex++,c=d.sample.pts,e+=d.length,s=e):e=o}else _.canParse(g,e)?(u=_.getID3Data(g,e),i.samples.push({pts:c,dts:c,data:u,type:L.MetadataSchema.audioId3}),e+=u.length,s=e):e++;if(e===o&&s!==o){var t=Object(O.sliceUint8)(g,s);this.cachedData?this.cachedData=Object(b.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:v,videoTrack:Object(C.dummyTrack)(),id3Track:i,textTrack:Object(C.dummyTrack)()}},D.demuxSampleAes=function(g,p,u){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(g){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(C.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(C.dummyTrack)()}},D.destroy=function(){},T}(),y=function(D,E,g){return Object(M.isFiniteNumber)(D)?D*90:E*9e4+(g||0)};R.default=A},"./src/demux/chunk-cache.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function L(){this.chunks=[],this.dataLength=0}var C=L.prototype;return C.push=function(O){this.chunks.push(O),this.dataLength+=O.length},C.flush=function(){var O=this.chunks,A=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=_(O,A);else return new Uint8Array(0);return this.reset(),y},C.reset=function(){this.chunks.length=0,this.dataLength=0},L}();function _(L,C){for(var b=new Uint8Array(C),O=0,A=0;A<L.length;A++){var y=L[A];b.set(y,O),O+=y.length}return b}},"./src/demux/dummy-demuxed-track.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"dummyTrack",function(){return M});function M(_,L){return _===void 0&&(_=""),L===void 0&&(L=9e4),{type:_,id:-1,pid:-1,inputTimeScale:L,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/logger.ts"),_=function(){function L(b){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=b,this.bytesAvailable=b.byteLength,this.word=0,this.bitsAvailable=0}var C=L.prototype;return C.loadWord=function(){var O=this.data,A=this.bytesAvailable,y=O.byteLength-A,T=new Uint8Array(4),D=Math.min(4,A);if(D===0)throw new Error("no bytes available");T.set(O.subarray(y,y+D)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},C.skipBits=function(O){var A;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,A=O>>3,O-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},C.readBits=function(O){var A=Math.min(this.bitsAvailable,O),y=this.word>>>32-A;return O>32&&M.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=O-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},C.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},C.skipUEG=function(){this.skipBits(1+this.skipLZ())},C.skipEG=function(){this.skipBits(1+this.skipLZ())},C.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},C.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},C.readBoolean=function(){return this.readBits(1)===1},C.readUByte=function(){return this.readBits(8)},C.readUShort=function(){return this.readBits(16)},C.readUInt=function(){return this.readBits(32)},C.skipScalingList=function(O){for(var A=8,y=8,T,D=0;D<O;D++)y!==0&&(T=this.readEG(),y=(A+T+256)%256),A=y===0?A:y},C.readSPS=function(){var O=0,A=0,y=0,T=0,D,E,g,p=this.readUByte.bind(this),u=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),c=this.skipBits.bind(this),v=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(u(5),c(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var d=e();if(d===3&&c(1),i(),i(),c(1),s())for(E=d!==3?8:12,g=0;g<E;g++)s()&&(g<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(c(1),v(),v(),D=e(),g=0;g<D;g++)v();i(),c(1);var n=e(),l=e(),a=u(1);a===0&&c(1),c(1),s()&&(O=e(),A=e(),y=e(),T=e());var f=[1,1];if(s()&&s()){var h=p();switch(h){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:{f=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((n+1)*16-O*2-A*2),height:(2-a)*(l+1)*16-(a?2:4)*(y+T),pixelRatio:f}},C.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},L}();R.default=_},"./src/demux/id3.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isHeader",function(){return M}),m.d(R,"isFooter",function(){return _}),m.d(R,"getID3Data",function(){return L}),m.d(R,"canParse",function(){return b}),m.d(R,"getTimeStamp",function(){return O}),m.d(R,"isTimeStampFrame",function(){return A}),m.d(R,"getID3Frames",function(){return T}),m.d(R,"decodeFrame",function(){return D}),m.d(R,"utf8ArrayToStr",function(){return e}),m.d(R,"testables",function(){return s});var M=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},_=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},L=function(r,o){for(var d=o,t=0;M(r,o);){t+=10;var n=C(r,o+6);t+=n,_(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(d,d+t)},C=function(r,o){var d=0;return d=(r[o]&127)<<21,d|=(r[o+1]&127)<<14,d|=(r[o+2]&127)<<7,d|=r[o+3]&127,d},b=function(r,o){return M(r,o)&&C(r,o+6)+10<=r.length-o},O=function(r){for(var o=T(r),d=0;d<o.length;d++){var t=o[d];if(A(t))return u(t)}},A=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]),d=C(r,4),t=10;return{type:o,size:d,data:r.subarray(t,t+d)}},T=function(r){for(var o=0,d=[];M(r,o);){var t=C(r,o+6);o+=10;for(var n=o+t;o+8<n;){var l=y(r.subarray(o)),a=D(l);a&&d.push(a),o+=l.size+10}_(r,o)&&(o+=10)}return d},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):g(r)},E=function(r){if(!(r.size<2)){var o=e(r.data,!0),d=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:d.buffer}}},g=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,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,d=e(r.data.subarray(o),!0);o+=d.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:d,data:t}}var n=e(r.data);return{key:r.type,data:n}},u=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),d=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,d&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var d=v();if(d){var t=d.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var l=r.length,a,f,h,S="",x=0;x<l;){if(a=r[x++],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:f=r[x++],S+=String.fromCharCode((a&31)<<6|f&63);break;case 14:f=r[x++],h=r[x++],S+=String.fromCharCode((a&15)<<12|(f&63)<<6|(h&63)<<0);break;default:}}return S},s={decodeTextFrame:g},c;function v(){return!c&&typeof self.TextDecoder!="undefined"&&(c=new self.TextDecoder("utf-8")),c}},"./src/demux/mp3demuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/demux/base-audio-demuxer.ts"),_=m("./src/demux/id3.ts"),L=m("./src/utils/logger.ts"),C=m("./src/demux/mpegaudio.ts");function b(y,T){y.prototype=Object.create(T.prototype),y.prototype.constructor=y,O(y,T)}function O(y,T){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,g){return E.__proto__=g,E},O(y,T)}var A=function(y){b(T,y);function T(){return y.apply(this,arguments)||this}var D=T.prototype;return D.resetInitSegment=function(g,p,u,e){y.prototype.resetInitSegment.call(this,g,p,u,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}},T.probe=function(g){if(!g)return!1;for(var p=_.getID3Data(g,0)||[],u=p.length,e=g.length;u<e;u++)if(C.probe(g,u))return L.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(g,p){return C.canParse(g,p)},D.appendFrame=function(g,p,u){if(this.basePTS!==null)return C.appendFrame(g,p,u,this.basePTS,this.frameIndex)},T}(M.default);R.default=A},"./src/demux/mp4demuxer.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/types/demuxer.ts"),L=m("./src/utils/mp4-tools.ts"),C=m("./src/demux/dummy-demuxed-track.ts"),b=/\/emsg[-/]ID3/i,O=function(){function A(T,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=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,g,p){var u=Object(L.parseInitSegment)(D),e=this.videoTrack=Object(C.dummyTrack)("video",1),s=this.audioTrack=Object(C.dummyTrack)("audio",1),c=this.txtTrack=Object(C.dummyTrack)("text",1);if(this.id3Track=Object(C.dummyTrack)("id3",1),this.timeOffset=0,u.video){var v=u.video,i=v.id,r=v.timescale,o=v.codec;e.id=i,e.timescale=c.timescale=r,e.codec=o}if(u.audio){var d=u.audio,t=d.id,n=d.timescale,l=d.codec;s.id=t,s.timescale=n,s.codec=l}c.id=L.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},A.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(L.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var g=D,p=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(L.appendUint8Array)(this.remainderData,D));var e=Object(L.segmentValidRange)(g);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=g;var s=this.extractID3Track(p,E);return u.samples=Object(L.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,g=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return g.samples=Object(L.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(C.dummyTrack)(),id3Track:p,textTrack:Object(C.dummyTrack)()}},y.extractID3Track=function(D,E){var g=this.id3Track;if(D.samples.length){var p=Object(L.findBox)(D.samples,["emsg"]);p&&p.forEach(function(u){var e=Object(L.parseEmsg)(u);if(b.test(e.schemeIdUri)){var s=Object(M.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,c=e.payload;g.samples.push({data:c,len:c.byteLength,dts:s,pts:s,type:_.MetadataSchema.emsg})}})}return g},y.demuxSampleAes=function(D,E,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},A}();R.default=O},"./src/demux/mpegaudio.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"appendFrame",function(){return O}),m.d(R,"parseHeader",function(){return A}),m.d(R,"isHeaderPattern",function(){return y}),m.d(R,"isHeader",function(){return T}),m.d(R,"canParse",function(){return D}),m.d(R,"probe",function(){return E});var M=null,_=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],L=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],C=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],b=[0,1,1,4];function O(g,p,u,e,s){if(!(u+24>p.length)){var c=A(p,u);if(c&&u+c.frameLength<=p.length){var v=c.samplesPerFrame*9e4/c.sampleRate,i=e+s*v,r={unit:p.subarray(u,u+c.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=c.channelCount,g.samplerate=c.sampleRate,g.samples.push(r),{sample:r,length:c.frameLength,missing:0}}}}function A(g,p){var u=g[p+1]>>3&3,e=g[p+1]>>1&3,s=g[p+2]>>4&15,c=g[p+2]>>2&3;if(u!==1&&s!==0&&s!==15&&c!==3){var v=g[p+2]>>1&1,i=g[p+3]>>6,r=u===3?3-e:e===3?3:4,o=_[r*14+s-1]*1e3,d=u===3?0:u===2?1:2,t=L[d*3+c],n=i===3?1:2,l=C[u][e],a=b[e],f=l*8*a,h=Math.floor(l*o/t+v)*a;if(M===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);M=x?parseInt(x[1]):0}var P=!!M&&M<=87;return P&&e===2&&o>=224e3&&i===0&&(g[p+3]=g[p+3]|128),{sampleRate:t,channelCount:n,frameLength:h,samplesPerFrame:f}}}function y(g,p){return g[p]===255&&(g[p+1]&224)===224&&(g[p+1]&6)!==0}function T(g,p){return p+1<g.length&&y(g,p)}function D(g,p){var u=4;return y(g,p)&&u<=g.length-p}function E(g,p){if(p+1<g.length&&y(g,p)){var u=4,e=A(g,p),s=u;e!=null&&e.frameLength&&(s=e.frameLength);var c=p+s;return c===g.length||T(g,c)}return!1}},"./src/demux/sample-aes.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/crypt/decrypter.ts"),_=m("./src/demux/tsdemuxer.ts"),L=function(){function C(O,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new M.default(O,A,{removePKCS7Padding:!1})}var b=C.prototype;return b.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},b.decryptAacSample=function(A,y,T,D){var E=A[y].unit;if(!(E.length<=16)){var g=E.subarray(16,E.length-E.length%16),p=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),u=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||u.decryptAacSamples(A,y+1,T)})}},b.decryptAacSamples=function(A,y,T){for(;;y++){if(y>=A.length){T();return}if(!(A[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(A,y,T,D),!D)return}}},b.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,T=new Int8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)T.set(A.subarray(E,E+16),D);return T},b.getAvcDecryptedUnit=function(A,y){for(var T=new Uint8Array(y),D=0,E=32;E<A.length-16;E+=160,D+=16)A.set(T.subarray(D,D+16),E);return A},b.decryptAvcSample=function(A,y,T,D,E,g){var p=Object(_.discardEPB)(E.data),u=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(u.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),g||e.decryptAvcSamples(A,y,T+1,D)})},b.decryptAvcSamples=function(A,y,T,D){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=A.length){D();return}for(var E=A[y].units;!(T>=E.length);T++){var g=E[T];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(A,y,T,D,g,p),!p)return}}}},C}();R.default=L},"./src/demux/transmuxer-interface.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E});var M=m("./node_modules/webworkify-webpack/index.js"),_=m.n(M),L=m("./src/events.ts"),C=m("./src/demux/transmuxer.ts"),b=m("./src/utils/logger.ts"),O=m("./src/errors.ts"),A=m("./src/utils/mediasource-helper.ts"),y=m("./node_modules/eventemitter3/index.js"),T=m.n(y),D=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function g(u,e,s,c){var v=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=u,this.id=e,this.onTransmuxComplete=s,this.onFlush=c;var i=u.config,r=function(l,a){a=a||{},a.frag=v.frag,a.id=v.id,u.trigger(l,a)};this.observer=new y.EventEmitter,this.observer.on(L.Events.FRAG_DECRYPTED,r),this.observer.on(L.Events.ERROR,r);var o={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){b.logger.log("demuxing in webworker");var t;try{t=this.worker=M("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){u.trigger(L.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:d,id:e,config:JSON.stringify(i)})}catch(n){b.logger.warn("Error in worker:",n),b.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new C.default(this.observer,o,i,d,e),this.worker=null}}else this.transmuxer=new C.default(this.observer,o,i,d,e)}var p=g.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 c=this.observer;c&&c.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,c,v,i,r,o,d,t,n){var l,a,f=this;t.transmuxing.start=self.performance.now();var h=this.transmuxer,S=this.worker,x=r?r.start:i.start,P=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&&((l=i.initSegment)===null||l===void 0?void 0:l.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new C.TransmuxState(B,Y,d,U,x,Z);if(!Y||B||Z){b.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
14
14
  discontinuity: `+B+`
15
15
  trackSwitch: `+U+`
16
16
  contiguous: `+Y+`
17
17
  accurateTimeOffset: `+d+`
18
18
  timeOffset: `+x+`
19
- initSegmentChange: `+Z);var ie=new C.TransmuxConfig(c,v,s,o,n);this.configureTransmuxer(ie)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:P,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(h){var ne=h.push(e,P,t,q);Object(C.isPromise)(ne)?ne.then(function(ae){f.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var c=this.transmuxer,v=this.worker;if(v)v.postMessage({cmd:"flush",chunkMeta:e});else if(c){var i=c.flush(e);Object(C.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var c=this;e.forEach(function(v){c.handleTransmuxComplete(v)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,c=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":b.logger[s.data.logType]&&b.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,c.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,c=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):c&&c.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,g){"use strict";g.r(R),g.d(R,"default",function(){return O});var M=g("./src/demux/transmuxer.ts"),_=g("./src/events.ts"),L=g("./src/utils/logger.ts"),C=g("./node_modules/eventemitter3/index.js"),b=g.n(C);function O(E){var m=new C.EventEmitter,p=function(s,c){E.postMessage({event:s,data:c})};m.on(_.Events.FRAG_DECRYPTED,p),m.on(_.Events.ERROR,p);var u=function(){var s=function(i){var r=function(d){p("workerLog",{logType:i,message:d})};L.logger[i]=r};for(var c in L.logger)s(c)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var c=JSON.parse(s.config);E.transmuxer=new M.default(m,s.typeSupported,c,s.vendor,s.id),Object(L.enableLogs)(c.debug),u(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var v=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(M.isPromise)(v)?v.then(function(o){A(E,o)}):A(E,v);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(M.isPromise)(r)?r.then(function(o){T(E,o,i)}):T(E,r,i);break}default:break}})}function A(E,m){if(D(m.remuxResult))return!1;var p=[],u=m.remuxResult,e=u.audio,s=u.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 T(E,m,p){var u=m.reduce(function(e,s){return A(E,s)||e},!1);u||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,g){"use strict";g.r(R),g.d(R,"default",function(){return p}),g.d(R,"isPromise",function(){return s}),g.d(R,"TransmuxConfig",function(){return c}),g.d(R,"TransmuxState",function(){return v});var M=g("./src/events.ts"),_=g("./src/errors.ts"),L=g("./src/crypt/decrypter.ts"),C=g("./src/demux/aacdemuxer.ts"),b=g("./src/demux/mp4demuxer.ts"),O=g("./src/demux/tsdemuxer.ts"),A=g("./src/demux/mp3demuxer.ts"),y=g("./src/remux/mp4-remuxer.ts"),T=g("./src/remux/passthrough-remuxer.ts"),D=g("./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:O.default,remux:y.default},{demux:b.default,remux:T.default},{demux:C.default,remux:y.default},{demux:A.default,remux:y.default}],p=function(){function i(o,d,t,n,l){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=d,this.config=t,this.vendor=n,this.id=l}var r=i.prototype;return r.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},r.push=function(d,t,n,l){var a=this,f=n.transmuxing;f.executeStart=E();var h=new Uint8Array(d),S=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;l&&(this.currentTransmuxState=l);var k=l||x,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,G=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=P.audioCodec,Z=P.videoCodec,q=P.defaultInitPts,ie=P.duration,ne=P.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,$,Z,ie),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ae=u(h,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var fe=te.softwareDecrypt(h,ae.key.buffer,ae.iv.buffer);if(!fe)return f.executeEnd=E(),e(n);h=new Uint8Array(fe)}else return this.decryptionPromise=te.webCryptoDecrypt(h,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(h,U,W)&&this.configureTransmuxer(h,P);var de=this.transmux(h,ae,z,G,n),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,f.executeEnd=E(),de},r.flush=function(d){var t=this,n=d.transmuxing;n.executeStart=E();var l=this.decrypter,a=this.currentTransmuxState,f=this.decryptionPromise;if(f)return f.then(function(){return t.flush(d)});var h=[],S=a.timeOffset;if(l){var x=l.flush();x&&h.push(this.push(x,null,d))}var P=this.demuxer,k=this.remuxer;if(!P||!k)return this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(d)];var B=P.flush(S);return s(B)?B.then(function(U){return t.flushRemux(h,U,d),h}):(this.flushRemux(h,B,d),h)},r.flushRemux=function(d,t,n){var l=t.audioTrack,a=t.videoTrack,f=t.id3Track,h=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,P=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(l,a,f,h,P,x,!0,this.id);d.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(d){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(d),n.resetTimeStamp(d))},r.resetContiguity=function(){var d=this.demuxer,t=this.remuxer;!d||!t||(d.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(d,t,n,l){var a=this.demuxer,f=this.remuxer;!a||!f||(a.resetInitSegment(d,t,n,l),f.resetInitSegment(d,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(d,t,n,l,a){var f;return t&&t.method==="SAMPLE-AES"?f=this.transmuxSampleAes(d,t,n,l,a):f=this.transmuxUnencrypted(d,n,l,a),f},r.transmuxUnencrypted=function(d,t,n,l){var a=this.demuxer.demux(d,t,!1,!this.config.progressive),f=a.audioTrack,h=a.videoTrack,S=a.id3Track,x=a.textTrack,P=this.remuxer.remux(f,h,S,x,t,n,!1,this.id);return{remuxResult:P,chunkMeta:l}},r.transmuxSampleAes=function(d,t,n,l,a){var f=this;return this.demuxer.demuxSampleAes(d,t,n).then(function(h){var S=f.remuxer.remux(h.audioTrack,h.videoTrack,h.id3Track,h.textTrack,n,l,!1,f.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(d,t){for(var n=this.config,l=this.observer,a=this.typeSupported,f=this.vendor,h=t.audioCodec,S=t.defaultInitPts,x=t.duration,P=t.initSegmentData,k=t.videoCodec,B,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(d)){B=m[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:b.default,remux:T.default});var G=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(l,n,a,f)),(!G||!(G instanceof $))&&(this.demuxer=new $(l,n,a),this.probe=$.probe),this.resetInitSegment(P,h,k,x),this.resetInitialTimestamp(S)},r.needsProbing=function(d,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new L.default(this.observer,this.config)),d},i}();function u(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 c=function(r,o,d,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=d,this.duration=t,this.defaultInitPts=n},v=function(r,o,d,t,n,l){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=d,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=l}},"./src/demux/tsdemuxer.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"discardEPB",function(){return c});var M=g("./src/demux/adts.ts"),_=g("./src/demux/mpegaudio.ts"),L=g("./src/demux/exp-golomb.ts"),C=g("./src/demux/sample-aes.ts"),b=g("./src/events.ts"),O=g("./src/utils/mp4-tools.ts"),A=g("./src/utils/logger.ts"),y=g("./src/errors.ts"),T=g("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(v){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(v[o]=r[o])}return v},D.apply(this,arguments)}var E=function(){function v(r,o,d){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=d}v.probe=function(o){return o[0]===71&&o[188]===71},v.createTrack=function(o,d){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:O.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?d:void 0}};var i=v.prototype;return i.resetInitSegment=function(o,d,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=v.createTrack("video"),this._audioTrack=v.createTrack("audio",n),this._id3Track=v.createTrack("id3"),this._txtTrack=v.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,d=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),d&&(d.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,d,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var l,a=this._avcTrack,f=this._audioTrack,h=this._id3Track,S=this._txtTrack,x=a.pid,P=a.pesData,k=f.pid,B=h.pid,U=f.pesData,W=h.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(O.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:f,videoTrack:a,id3Track:h,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 x:ie&&(P&&(l=e(P))&&this.parseAVCPES(a,S,l,!1),P={data:[],size:0}),P&&(P.data.push(o.subarray(te,q+188)),P.size+=q+188-te);break;case k:if(ie){if(U&&(l=e(U)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,l);break;case"mp3":this.parseMPEGPES(f,l);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:ie&&(W&&(l=e(W))&&this.parseID3PES(h,l),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=u(o,te,this.typeSupported,t);x=fe.avc,x>0&&(a.pid=x),k=fe.audio,k>0&&(f.pid=k,f.segmentCodec=fe.segmentCodec),B=fe.id3,B>0&&(h.pid=B),G!==null&&!z&&(A.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(b.Events.ERROR,b.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=P,f.pesData=U,h.pesData=W;var de={audioTrack:f,videoTrack:a,id3Track:h,textTrack:S};return n&&this.extractRemainingSamples(de),de},i.flush=function(){var o=this.remainderData;this.remainderData=null;var d;return o?d=this.demux(o,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(o){var d=o.audioTrack,t=o.videoTrack,n=o.id3Track,l=o.textTrack,a=t.pesData,f=d.pesData,h=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,l,S,!0),t.pesData=null):t.pesData=a,f&&(S=e(f))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,S);break;case"mp3":this.parseMPEGPES(d,S);break}d.pesData=null}else f!=null&&f.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=f;h&&(S=e(h))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=h},i.demuxSampleAes=function(o,d,t){var n=this.demux(o,t,!0,!this.config.progressive),l=this.sampleAes=new C.default(this.observer,this.config,d);return this.decrypt(n,l)},i.decrypt=function(o,d){return new Promise(function(t){var n=o.audioTrack,l=o.videoTrack;n.samples&&n.segmentCodec==="aac"?d.decryptAacSamples(n.samples,0,function(){l.samples?d.decryptAvcSamples(l.samples,0,0,function(){t(o)}):t(o)}):l.samples&&d.decryptAvcSamples(l.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,d,t,n){var l=this,a=this.parseAVCNALu(o,t.data),f=!1,h=this.avcSample,S,x=!1;t.data=null,h&&a.length&&!o.audFound&&(s(h,o),h=this.avcSample=m(!1,t.pts,t.dts,"")),a.forEach(function(P){switch(P.type){case 1:{S=!0,h||(h=l.avcSample=m(!0,t.pts,t.dts,"")),f&&(h.debug+="NDR "),h.frame=!0;var k=P.data;if(x&&k.length>4){var B=new L.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(h.key=!0)}break}case 5:S=!0,h||(h=l.avcSample=m(!0,t.pts,t.dts,"")),f&&(h.debug+="IDR "),h.key=!0,h.frame=!0;break;case 6:{S=!0,f&&h&&(h.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(c(P.data),t.pts,d.samples);break}case 7:if(S=!0,x=!0,f&&h&&(h.debug+="SPS "),!o.sps){var U=new L.default(P.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[P.data],o.duration=l._duration;for(var G=P.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,f&&h&&(h.debug+="PPS "),o.pps||(o.pps=[P.data]);break;case 9:S=!1,o.audFound=!0,h&&s(h,o),h=l.avcSample=m(!1,t.pts,t.dts,f?"AUD ":"");break;case 12:S=!0;break;default:S=!1,h&&(h.debug+="unknown NAL "+P.type+" ");break}if(h&&S){var Z=h.units;Z.push(P)}}),n&&h&&(s(h,o),this.avcSample=null)},i.getLastNalUnit=function(o){var d,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(d=t)!==null&&d!==void 0&&d.units){var l=t.units;n=l[l.length-1]}return n},i.parseAVCNALu=function(o,d){var t=d.byteLength,n=o.naluState||0,l=n,a=[],f=0,h,S,x,P=-1,k=0;for(n===-1&&(P=0,k=d[0]&31,n=0,f=1);f<t;){if(h=d[f++],!n){n=h?0:1;continue}if(n===1){n=h?0:2;continue}if(!h)n=3;else if(h===1){if(P>=0){var B={data:d.subarray(P,f-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(l&&f<=4-l&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-l)),S=f-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(d.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}f<t?(x=d[f]&31,P=f,k=x,n=0):n=-1}else n=0}if(P>=0&&n>=0){var G={data:d.subarray(P,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+d.byteLength);Y.set(z.data,0),Y.set(d,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,d){var t=0,n=this.aacOverFlow,l=d.data;if(n){this.aacOverFlow=null;var a=n.missing,f=n.sample.unit.byteLength;if(a===-1){var h=new Uint8Array(f+l.byteLength);h.set(n.sample.unit,0),h.set(l,f),l=h}else{var S=f-a;n.sample.unit.set(l.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var x,P;for(x=t,P=l.length;x<P-1&&!M.isHeader(l,x);x++);if(x!==t){var k,B;if(x<P-1?(k="AAC PES did not start with ADTS header,offset:"+x,B=!1):(k="no ADTS header found in AAC PES",B=!0),A.logger.warn("parsing error:"+k),this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}M.initTrackConfig(o,this.observer,l,x,this.audioCodec);var U;if(d.pts!==void 0)U=d.pts;else if(n){var W=M.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;x<P;)if(z=M.appendFrame(o,l,x,U,G),x+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;x<P-1&&!M.isHeader(l,x);x++);},i.parseMPEGPES=function(o,d){var t=d.data,n=t.length,l=0,a=0,f=d.pts;if(f===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(_.isHeader(t,a)){var h=_.appendFrame(o,t,a,f,l);if(h)a+=h.length,l++;else break}else a++},i.parseID3PES=function(o,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},d,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});o.samples.push(t)},v}();function m(v,i,r,o){return{key:v,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(v,i){return(v[i+10]&31)<<8|v[i+11]}function u(v,i,r,o){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(v[i+1]&15)<<8|v[i+2],n=i+3+t-4,l=(v[i+10]&15)<<8|v[i+11];for(i+=12+l;i<n;){var a=(v[i+1]&31)<<8|v[i+2];switch(v[i]){case 207:if(!o){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=a);break;case 21:d.id3===-1&&(d.id3=a);break;case 219:if(!o){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=a,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((v[i+3]&15)<<8|v[i+4])+5}return d}function e(v){var i=0,r,o,d,t,n,l=v.data;if(!v||v.size===0)return null;for(;l[0].length<19&&l.length>1;){var a=new Uint8Array(l[0].length+l[1].length);a.set(l[0]),a.set(l[1],l[0].length),l[0]=a,l.splice(1,1)}r=l[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){if(o=(r[4]<<8)+r[5],o&&o>v.size-6)return null;var h=r[7];h&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,h&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&&(A.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),d=r[8];var S=d+9;if(v.size<=S)return null;v.size-=S;for(var x=new Uint8Array(v.size),P=0,k=l.length;P<k;P++){r=l[P];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;x.set(r,i),i+=B}return o&&(o-=d+3),{data:x,pts:t,dts:n,len:o}}return null}function s(v,i){if(v.units.length&&v.frame){if(v.pts===void 0){var r=i.samples,o=r.length;if(o){var d=r[o-1];v.pts=d.pts,v.dts=d.dts}else{i.dropped++;return}}i.samples.push(v)}v.debug.length&&A.logger.log(v.pts+"/"+v.dts+":"+v.debug)}function c(v){for(var i=v.byteLength,r=[],o=1;o<i-2;)v[o]===0&&v[o+1]===0&&v[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return v;var d=i-r.length,t=new Uint8Array(d),n=0;for(o=0;o<d;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=v[n];return t}R.default=E},"./src/errors.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"ErrorTypes",function(){return M}),g.d(R,"ErrorDetails",function(){return _});var M;(function(L){L.NETWORK_ERROR="networkError",L.MEDIA_ERROR="mediaError",L.KEY_SYSTEM_ERROR="keySystemError",L.MUX_ERROR="muxError",L.OTHER_ERROR="otherError"})(M||(M={}));var _;(function(L){L.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",L.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",L.KEY_SYSTEM_NO_SESSION="keySystemNoSession",L.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",L.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",L.MANIFEST_LOAD_ERROR="manifestLoadError",L.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",L.MANIFEST_PARSING_ERROR="manifestParsingError",L.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",L.LEVEL_EMPTY_ERROR="levelEmptyError",L.LEVEL_LOAD_ERROR="levelLoadError",L.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",L.LEVEL_SWITCH_ERROR="levelSwitchError",L.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",L.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",L.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",L.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",L.FRAG_LOAD_ERROR="fragLoadError",L.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",L.FRAG_DECRYPT_ERROR="fragDecryptError",L.FRAG_PARSING_ERROR="fragParsingError",L.REMUX_ALLOC_ERROR="remuxAllocError",L.KEY_LOAD_ERROR="keyLoadError",L.KEY_LOAD_TIMEOUT="keyLoadTimeOut",L.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",L.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",L.BUFFER_APPEND_ERROR="bufferAppendError",L.BUFFER_APPENDING_ERROR="bufferAppendingError",L.BUFFER_STALLED_ERROR="bufferStalledError",L.BUFFER_FULL_ERROR="bufferFullError",L.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",L.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",L.INTERNAL_EXCEPTION="internalException",L.INTERNAL_ABORTED="aborted",L.UNKNOWN="unknown"})(_||(_={}))},"./src/events.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"Events",function(){return M});var M;(function(_){_.MEDIA_ATTACHING="hlsMediaAttaching",_.MEDIA_ATTACHED="hlsMediaAttached",_.MEDIA_DETACHING="hlsMediaDetaching",_.MEDIA_DETACHED="hlsMediaDetached",_.BUFFER_RESET="hlsBufferReset",_.BUFFER_CODECS="hlsBufferCodecs",_.BUFFER_CREATED="hlsBufferCreated",_.BUFFER_APPENDING="hlsBufferAppending",_.BUFFER_APPENDED="hlsBufferAppended",_.BUFFER_EOS="hlsBufferEos",_.BUFFER_FLUSHING="hlsBufferFlushing",_.BUFFER_FLUSHED="hlsBufferFlushed",_.MANIFEST_LOADING="hlsManifestLoading",_.MANIFEST_LOADED="hlsManifestLoaded",_.MANIFEST_PARSED="hlsManifestParsed",_.LEVEL_SWITCHING="hlsLevelSwitching",_.LEVEL_SWITCHED="hlsLevelSwitched",_.LEVEL_LOADING="hlsLevelLoading",_.LEVEL_LOADED="hlsLevelLoaded",_.LEVEL_UPDATED="hlsLevelUpdated",_.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",_.LEVELS_UPDATED="hlsLevelsUpdated",_.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",_.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",_.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",_.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",_.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",_.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",_.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",_.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",_.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",_.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",_.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",_.CUES_PARSED="hlsCuesParsed",_.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",_.INIT_PTS_FOUND="hlsInitPtsFound",_.FRAG_LOADING="hlsFragLoading",_.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",_.FRAG_LOADED="hlsFragLoaded",_.FRAG_DECRYPTED="hlsFragDecrypted",_.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",_.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",_.FRAG_PARSING_METADATA="hlsFragParsingMetadata",_.FRAG_PARSED="hlsFragParsed",_.FRAG_BUFFERED="hlsFragBuffered",_.FRAG_CHANGED="hlsFragChanged",_.FPS_DROP="hlsFpsDrop",_.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",_.ERROR="hlsError",_.DESTROYING="hlsDestroying",_.KEY_LOADING="hlsKeyLoading",_.KEY_LOADED="hlsKeyLoaded",_.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",_.BACK_BUFFER_REACHED="hlsBackBufferReached"})(M||(M={}))},"./src/hls.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return i});var M=g("./node_modules/url-toolkit/src/url-toolkit.js"),_=g.n(M),L=g("./src/loader/playlist-loader.ts"),C=g("./src/loader/key-loader.ts"),b=g("./src/controller/id3-track-controller.ts"),O=g("./src/controller/latency-controller.ts"),A=g("./src/controller/level-controller.ts"),y=g("./src/controller/fragment-tracker.ts"),T=g("./src/controller/stream-controller.ts"),D=g("./src/is-supported.ts"),E=g("./src/utils/logger.ts"),m=g("./src/config.ts"),p=g("./node_modules/eventemitter3/index.js"),u=g.n(p),e=g("./src/events.ts"),s=g("./src/errors.ts");function c(r,o){for(var d=0;d<o.length;d++){var t=o[d];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function v(r,o,d){return o&&c(r.prototype,o),d&&c(r,d),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(d){d===void 0&&(d={}),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,d);this.userConfig=d,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var n=t.abrController,l=t.bufferController,a=t.capLevelController,f=t.fpsController,h=this.abrController=new n(this),S=this.bufferController=new l(this),x=this.capLevelController=new a(this),P=new f(this),k=new L.default(this),B=new C.default(this),U=new b.default(this),W=this.levelController=new A.default(this),G=new y.FragmentTracker(this),z=this.streamController=new T.default(this,G);x.setStreamController(z),P.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[h,S,x,P,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(O.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,l){if(t){var a=n?new t(this,n):new t(this);return l&&l.push(a),a}return null},o.on=function(t,n,l){l===void 0&&(l=this),this._emitter.on(t,n,l)},o.once=function(t,n,l){l===void 0&&(l=this),this._emitter.once(t,n,l)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,l,a){l===void 0&&(l=this),this._emitter.off(t,n,l,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,l){return this._emitter.emit(t,n,l)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(l){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:l})}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,l=this.url,a=this.url=M.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&l&&l!==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)},v(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 l=t.length,a=0;a<l;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,l;return n===-1&&t&&t.length?l=t.length-1:l=n,l}},{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,g){"use strict";g.r(R),g.d(R,"isSupported",function(){return L}),g.d(R,"changeTypeSupported",function(){return C});var M=g("./src/utils/mediasource-helper.ts");function _(){return self.SourceBuffer||self.WebKitSourceBuffer}function L(){var b=Object(M.getMediaSource)();if(!b)return!1;var O=_(),A=b&&typeof b.isTypeSupported=="function"&&b.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!A&&!!y}function C(){var b,O=_();return typeof(O==null||(b=O.prototype)===null||b===void 0?void 0:b.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"DateRangeAttribute",function(){return A}),g.d(R,"DateRange",function(){return y});var M=g("./src/polyfills/number.ts"),_=g("./src/utils/attr-list.ts"),L=g("./src/utils/logger.ts");function C(){return C=Object.assign?Object.assign.bind():function(T){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(T[m]=E[m])}return T},C.apply(this,arguments)}function b(T,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(T,m.key,m)}}function O(T,D,E){return D&&b(T.prototype,D),E&&b(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var A;(function(T){T.ID="ID",T.CLASS="CLASS",T.START_DATE="START-DATE",T.DURATION="DURATION",T.END_DATE="END-DATE",T.END_ON_NEXT="END-ON-NEXT",T.PLANNED_DURATION="PLANNED-DURATION",T.SCTE35_OUT="SCTE35-OUT",T.SCTE35_IN="SCTE35-IN"})(A||(A={}));var y=function(){function T(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]){L.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=C(new _.AttrList({}),m,D)}if(this.attr=D,this._startDate=new Date(D[A.START_DATE]),A.END_DATE in this.attr){var u=new Date(this.attr[A.END_DATE]);Object(M.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}return O(T,[{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(A.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(A.DURATION);if(Object(M.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(M.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return E}),g.d(R,"LoadError",function(){return p});var M=g("./src/polyfills/number.ts"),_=g("./src/errors.ts");function L(u,e){u.prototype=Object.create(e.prototype),u.prototype.constructor=u,y(u,e)}function C(u){var e=typeof Map=="function"?new Map:void 0;return C=function(c){if(c===null||!A(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(c))return e.get(c);e.set(c,v)}function v(){return b(c,arguments,T(this).constructor)}return v.prototype=Object.create(c.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),y(v,c)},C(u)}function b(u,e,s){return O()?b=Reflect.construct.bind():b=function(v,i,r){var o=[null];o.push.apply(o,i);var d=Function.bind.apply(v,o),t=new d;return r&&y(t,r.prototype),t},b.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,v){return c.__proto__=v,c},y(u,e)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},T(u)}var D=Math.pow(2,17),E=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=u.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(c,v){var i=this,r=c.url;if(!r)return Promise.reject(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){i.loader&&i.loader.destroy();var a=i.loader=c.loader=d?new d(o):new t(o),f=m(c),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:c.sn==="initSegment"?1/0:D};c.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){i.resetLoader(c,a),n({frag:c,part:null,payload:x.data,networkDetails:B})},onError:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,response:x,networkDetails:k}))},onAbort:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,networkDetails:k}))},onTimeout:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,networkDetails:k}))},onProgress:function(x,P,k,B){v&&v({frag:c,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(c,v,i){var r=this;this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){r.loader&&r.loader.destroy();var a=r.loader=c.loader=d?new d(o):new t(o),f=m(c,v),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};v.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){r.resetLoader(c,a),r.updateStatsFromPart(c,v);var U={frag:c,part:v,payload:x.data,networkDetails:B};i(U),n(U)},onError:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,part:v,response:x,networkDetails:k}))},onAbort:function(x,P,k){c.stats.aborted=v.stats.aborted,r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,part:v,networkDetails:k}))},onTimeout:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,part:v,networkDetails:k}))}})})},e.updateStatsFromPart=function(c,v){var i=c.stats,r=v.stats,o=r.total;if(i.loaded+=r.loaded,o){var d=Math.round(c.duration/v.duration),t=Math.min(Math.round(i.loaded/o),d),n=d-t,l=n*Math.round(i.loaded/t);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var a=i.loading,f=r.loading;a.start?a.first+=f.first-f.start:(a.start=f.start,a.first=f.first),a.end=f.end},e.resetLoader=function(c,v){c.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},u}();function m(u,e){e===void 0&&(e=null);var s=e||u,c={frag:u,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},v=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(M.isFiniteNumber)(v)&&Object(M.isFiniteNumber)(i)&&(c.rangeStart=v,c.rangeEnd=i),c}var p=function(u){L(e,u);function e(s){for(var c,v=arguments.length,i=new Array(v>1?v-1:0),r=1;r<v;r++)i[r-1]=arguments[r];return c=u.call.apply(u,[this].concat(i))||this,c.data=void 0,c.data=s,c}return e}(C(Error))},"./src/loader/fragment.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"ElementaryStreamTypes",function(){return E}),g.d(R,"BaseSegment",function(){return m}),g.d(R,"Fragment",function(){return p}),g.d(R,"Part",function(){return u});var M=g("./src/polyfills/number.ts"),_=g("./node_modules/url-toolkit/src/url-toolkit.js"),L=g.n(_),C=g("./src/utils/logger.ts"),b=g("./src/loader/level-key.ts"),O=g("./src/loader/load-stats.ts");function A(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(v,i){return v.__proto__=i,v},y(e,s)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),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(c){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[E.AUDIO]=null,v[E.VIDEO]=null,v[E.AUDIOVIDEO]=null,v),this.baseurl=c}var s=e.prototype;return s.setByteRange=function(v,i){var r=v.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(_.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),e}(),p=function(e){A(s,e);function s(v,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 O.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=v,r}var c=s.prototype;return c.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},c.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=b.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},c.setElementaryStreamInfo=function(i,r,o,d,t,n){n===void 0&&(n=!1);var l=this.elementaryStreams,a=l[i];if(!a){l[i]={startPTS:r,endPTS:o,startDTS:d,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,d),a.endDTS=Math.max(a.endDTS,t)},c.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&&C.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(M.isFiniteNumber)(this.programDateTime))return null;var i=Object(M.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),u=function(e){A(s,e);function s(c,v,i,r,o){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new O.LoadStats,d.duration=c.decimalFloatingPoint("DURATION"),d.gap=c.bool("GAP"),d.independent=c.bool("INDEPENDENT"),d.relurl=c.enumeratedString("URI"),d.fragment=v,d.index=r;var t=c.enumeratedString("BYTERANGE");return t&&d.setByteRange(t,o),o&&(d.fragOffset=o.fragOffset+o.duration),d}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 v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),s}(m)},"./src/loader/key-loader.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return C});var M=g("./src/events.ts"),_=g("./src/errors.ts"),L=g("./src/utils/logger.ts"),C=function(){function b(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var O=b.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(M.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(M.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var y in this.loaders){var T=this.loaders[y];T&&T.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(y,T){var D=T.frag,E=D.type,m=this.loaders[E];if(!D.decryptdata){L.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(m&&(L.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){L.logger.warn("key uri is falsy");return}var e=u.loader,s=D.loader=this.loaders[E]=new e(u);this.decrypturl=p,this.decryptkey=null;var c={url:p,frag:D,responseType:"arraybuffer"},v={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(c,v,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(M.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(y,T,D){var E=D.frag;if(!E.decryptdata){L.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(M.Events.KEY_LOADED,{frag:E})},O.loaderror=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},O.loadtimeout=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},b}()},"./src/loader/level-details.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"LevelDetails",function(){return b});var M=g("./src/polyfills/number.ts");function _(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function L(O,A,y){return A&&_(O.prototype,A),y&&_(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var C=10,b=function(){function O(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 A=O.prototype;return A.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-T.lastPartSn,E=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!E||!!D,this.advanced=this.endSN>T.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},L(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(M.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||C}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var D=this.driftEnd-this.driftStart;return D*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.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 T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"LevelKey",function(){return b});var M=g("./node_modules/url-toolkit/src/url-toolkit.js"),_=g.n(M);function L(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function C(O,A,y){return A&&L(O.prototype,A),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var b=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(A,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(M.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return C(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"LoadStats",function(){return M});var M=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,g){"use strict";g.r(R),g.d(R,"default",function(){return c});var M=g("./src/polyfills/number.ts"),_=g("./node_modules/url-toolkit/src/url-toolkit.js"),L=g.n(_),C=g("./src/loader/date-range.ts"),b=g("./src/loader/fragment.ts"),O=g("./src/loader/level-details.ts"),A=g("./src/loader/level-key.ts"),y=g("./src/utils/attr-list.ts"),T=g("./src/utils/logger.ts"),D=g("./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"),u=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,l;return e.test((n=(l=_.parseURL(t))===null||l===void 0?void 0:l.path)!=null?n:"")}var c=function(){function t(){}return t.findGroup=function(l,a){for(var f=0;f<l.length;f++){var h=l[f];if(h.id===a)return h}},t.convertAVC1ToAVCOTI=function(l){var a=l.split(".");if(a.length>2){var f=a.shift()+".";return f+=parseInt(a.shift()).toString(16),f+=("000"+parseInt(a.shift()).toString(16)).slice(-4),f}return l},t.resolve=function(l,a){return _.buildAbsoluteURL(a,l,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(l,a){var f=[],h={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(l))!=null;)if(x[1]){var P=new y.AttrList(x[1]),k={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:t.resolve(x[2],a)},B=P.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),v((P.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),f.push(k)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,h[U["DATA-ID"]]=U)}return{levels:f,sessionData:S?h:null}},t.parseMasterPlaylistMedia=function(l,a,f,h){h===void 0&&(h=[]);var S,x=[],P=0;for(m.lastIndex=0;(S=m.exec(l))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===f){var B={attrs:k,bitrate:0,id:P++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:f,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(h.length){var U=t.findGroup(h,B.groupId)||h[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}x.push(B)}}return x},t.parseLevelPlaylist=function(l,a,f,h,S){var x=new O.LevelDetails(a),P=x.fragments,k=null,B=0,U=0,W=0,G=0,z=null,Y=new b.Fragment(h,a),$,Z,q,ie=-1,ne=!1;for(p.lastIndex=0,x.m3u8=l;($=p.exec(l))!==null;){ne&&(ne=!1,Y=new b.Fragment(h,a),Y.start=W,Y.sn=B,Y.cc=G,Y.level=f,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(M.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=f,Y.cc=G,Y.urlId=S,P.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=P.length);else{if($=$[0].match(u),!$){T.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":x.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":B=x.startSN=parseInt(re);break;case"SKIP":{var me=new y.AttrList(re),Te=me.decimalInteger("SKIPPED-SEGMENTS");if(Object(M.isFiniteNumber)(Te)){x.skippedSegments=Te;for(var Me=Te;Me--;)P.unshift(null);B+=Te}var Ae=me.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ae&&(x.recentlyRemovedDateranges=Ae.split(" "));break}case"TARGETDURATION":x.targetduration=parseFloat(re);break;case"VERSION":x.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":x.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 we=new y.AttrList(re),Re=new C.DateRange(we,x.dateRanges[we.ID]);Re.isValid||x.skippedSegments?x.dateRanges[Re.id]=Re:T.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 ke,_e=new y.AttrList(re),Be=_e.enumeratedString("METHOD"),Ke=_e.URI,We=_e.hexadecimalInteger("IV"),Ue=_e.enumeratedString("KEYFORMATVERSIONS"),Ze=_e.enumeratedString("KEYID"),Ce=(ke=_e.enumeratedString("KEYFORMAT"))!=null?ke:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf(Ce)>-1){T.logger.warn("Keyformat "+Ce+" is not supported from the manifest");continue}else if(Ce!=="identity")continue;Be&&(q=A.LevelKey.fromURL(a,Ke),Ke&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Be)>=0&&(q.method=Be,q.keyFormat=Ce,Ze&&(q.keyID=Ze),Ue&&(q.keyFormatVersions=Ue),q.iv=We));break}case"START":{var Oe=new y.AttrList(re),Pe=Oe.decimalFloatingPoint("TIME-OFFSET");Object(M.isFiniteNumber)(Pe)&&(x.startTimeOffset=Pe);break}case"MAP":{var Ve=new y.AttrList(re);if(Y.duration){var Ie=new b.Fragment(h,a);d(Ie,Ve,f,q),k=Ie,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else d(Y,Ve,f,q),k=Y,ne=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(re);x.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new y.AttrList(re);x.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var je=x.partList;je||(je=x.partList=[]);var st=U>0?je[je.length-1]:void 0,vt=U++,ze=new b.Part(new y.AttrList(re),Y,a,vt,st);je.push(ze),Y.duration+=ze.duration;break}case"PRELOAD-HINT":{var xt=new y.AttrList(re);x.preloadHint=xt;break}case"RENDITION-REPORT":{var gt=new y.AttrList(re);x.renditionReports=x.renditionReports||[],x.renditionReports.push(gt);break}default:T.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(P.pop(),W-=z.duration,x.partList&&(x.fragmentHint=z)):x.partList&&(o(Y,z),Y.cc=G,x.fragmentHint=Y);var it=P.length,ot=P[0],nt=P[it-1];if(W+=x.skippedSegments*x.targetduration,W>0&&it&&nt){x.averagetargetduration=W/it;var mt=nt.sn;x.endSN=mt!=="initSegment"?mt:0,ot&&(x.startCC=ot.cc,ot.initSegment||x.fragments.every(function(ct){return ct.relurl&&s(ct.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new b.Fragment(h,a),Y.relurl=nt.relurl,Y.level=f,Y.sn="initSegment",ot.initSegment=Y,x.needSidxRanges=!0))}else x.endSN=0,x.startCC=0;return x.fragmentHint&&(W+=x.fragmentHint.duration),x.totalduration=W,x.endCC=G,ie>0&&r(P,ie),x},t}();function v(t,n){["video","audio","text"].forEach(function(l){var a=t.filter(function(h){return Object(D.isCodecType)(h,l)});if(a.length){var f=a.filter(function(h){return h.lastIndexOf("avc1",0)===0||h.lastIndexOf("mp4a",0)===0});n[l+"Codec"]=f.length>0?f[0]:a[0],t=t.filter(function(h){return a.indexOf(h)===-1})}}),n.unknownCodecs=t}function i(t,n,l){var a=n[l];a&&(t[l]=a)}function r(t,n){for(var l=t[n],a=n;a--;){var f=t[a];if(!f)return;f.programDateTime=l.programDateTime-f.duration*1e3,l=f}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(M.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function d(t,n,l,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=l,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/events.ts"),L=g("./src/errors.ts"),C=g("./src/utils/logger.ts"),b=g("./src/utils/mp4-tools.ts"),O=g("./src/loader/m3u8-parser.ts"),A=g("./src/types/loader.ts"),y=g("./src/utils/attr-list.ts");function T(m){var p=m.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function D(m,p){var u=m.url;return(u===void 0||u.indexOf("data:")===0)&&(u=p.url),u}var E=function(){function m(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,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(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,c=s.pLoader,v=s.loader,i=c||v,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 c=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:c,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var c=s.id,v=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,c=this.hls.config,v=this.getInternalLoader(e);if(v){var i=v.context;if(i&&i.url===e.url){C.logger.trace("[playlist-loader]: playlist request ongoing");return}C.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),v.abort()}var r,o,d,t;switch(e.type){case A.PlaylistContextType.MANIFEST:r=c.manifestLoadingMaxRetry,o=c.manifestLoadingTimeOut,d=c.manifestLoadingRetryDelay,t=c.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:r=0,o=c.levelLoadingTimeOut;break;default:r=c.levelLoadingMaxRetry,o=c.levelLoadingTimeOut,d=c.levelLoadingRetryDelay,t=c.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var l=n.partTarget,a=n.targetduration;l&&a&&(o=Math.min(Math.max(l*3,a*.8)*1e3,o))}}var f={timeout:o,maxRetry:r,retryDelay:d,maxRetryDelay:t,highWaterMark:0},h={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(e,f,h)},p.loadsuccess=function(e,s,c,v){if(v===void 0&&(v=null),c.isSidxRequest){this.handleSidxRequest(e,c),this.handlePlaylistLoaded(e,s,c,v);return}this.resetInternalLoader(c.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,c,"no EXTM3U delimiter",v);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,c,v):this.handleMasterPlaylist(e,s,c,v)},p.loaderror=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!1,e)},p.loadtimeout=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!0)},p.handleMasterPlaylist=function(e,s,c,v){var i=this.hls,r=e.data,o=D(e,c),d=O.default.parseMasterPlaylist(r,o),t=d.levels,n=d.sessionData;if(!t.length){this.handleManifestParsingError(e,c,"no level found in manifest",v);return}var l=t.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),a=t.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),f=O.default.parseMasterPlaylistMedia(r,o,"AUDIO",l),h=O.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=O.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(f.length){var x=f.some(function(P){return!P.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(C.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(_.Events.MANIFEST_LOADED,{levels:t,audioTracks:f,subtitles:h,captions:S,url:o,stats:s,networkDetails:v,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,c,v){var i=this.hls,r=c.id,o=c.level,d=c.type,t=D(e,c),n=Object(M.isFiniteNumber)(r)?r:0,l=Object(M.isFiniteNumber)(o)?o:n,a=T(c),f=O.default.parseLevelPlaylist(e.data,t,l,a,n);if(!f.fragments.length){i.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof c.level=="number"?c.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var h={attrs:new y.AttrList({}),bitrate:0,details:f,name:"",url:t};i.trigger(_.Events.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:t,stats:s,networkDetails:v,sessionData:null})}if(s.parsing.end=performance.now(),f.needSidxRanges){var S,x=(S=f.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:x,isSidxRequest:!0,type:d,level:o,levelDetails:f,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}c.levelDetails=f,this.handlePlaylistLoaded(e,s,c,v)},p.handleSidxRequest=function(e,s){var c=new Uint8Array(e.data),v=Object(b.findBox)(c,["sidx"])[0];if(!!v){var i=Object(b.parseSegmentIndex)(v);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(d,t){var n=d.info,l=o.fragments[t];if(l.byteRange.length===0&&l.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),l.initSegment){var a=Object(b.findBox)(c,["moov"])[0],f=a?a.length:null;l.initSegment.setByteRange(String(f)+"@0")}})}}},p.handleManifestParsingError=function(e,s,c,v){this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:c,response:e,context:s,networkDetails:v})},p.handleNetworkError=function(e,s,c,v){c===void 0&&(c=!1),C.logger.warn("[playlist-loader]: A network "+(c?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=L.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=c?L.ErrorDetails.MANIFEST_LOAD_TIMEOUT:L.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case A.PlaylistContextType.LEVEL:i=c?L.ErrorDetails.LEVEL_LOAD_TIMEOUT:L.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=c?L.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=c?L.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:L.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var d={type:L.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};v&&(d.response=v),this.hls.trigger(_.Events.ERROR,d)},p.handlePlaylistLoaded=function(e,s,c,v){var i=c.type,r=c.level,o=c.id,d=c.groupId,t=c.loader,n=c.levelDetails,l=c.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,c,"invalid target duration",v);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(_.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(_.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(_.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break}},m}();R.default=E},"./src/polyfills/number.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"isFiniteNumber",function(){return M}),g.d(R,"MAX_SAFE_INTEGER",function(){return _});var M=Number.isFinite||function(L){return typeof L=="number"&&isFinite(L)},_=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,g){"use strict";g.r(R);var M=function(){function _(){}return _.getSilentFrame=function(C,b){switch(C){case"mp4a.40.2":if(b===1)return new Uint8Array([0,200,0,128,35,128]);if(b===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(b===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(b===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(b===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(b===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(b===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(b===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(b===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}},_}();R.default=M},"./src/remux/mp4-generator.ts":function(j,R,g){"use strict";g.r(R);var M=Math.pow(2,32)-1,_=function(){function L(){}return L.init=function(){L.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var b;for(b in L.types)L.types.hasOwnProperty(b)&&(L.types[b]=[b.charCodeAt(0),b.charCodeAt(1),b.charCodeAt(2),b.charCodeAt(3)]);var O=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]),A=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);L.HDLR_TYPES={video:O,audio:A};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);L.STTS=L.STSC=L.STCO=T,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,D,m,D,E),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,y))},L.box=function(b){for(var O=8,A=arguments.length,y=new Array(A>1?A-1:0),T=1;T<A;T++)y[T-1]=arguments[T];for(var D=y.length,E=D;D--;)O+=y[D].byteLength;var m=new Uint8Array(O);for(m[0]=O>>24&255,m[1]=O>>16&255,m[2]=O>>8&255,m[3]=O&255,m.set(b,4),D=0,O=8;D<E;D++)m.set(y[D],O),O+=y[D].byteLength;return m},L.hdlr=function(b){return L.box(L.types.hdlr,L.HDLR_TYPES[b])},L.mdat=function(b){return L.box(L.types.mdat,b)},L.mdhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1));return L.box(L.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},L.mdia=function(b){return L.box(L.types.mdia,L.mdhd(b.timescale,b.duration),L.hdlr(b.type),L.minf(b))},L.mfhd=function(b){return L.box(L.types.mfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255]))},L.minf=function(b){return b.type==="audio"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(b)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(b))},L.moof=function(b,O,A){return L.box(L.types.moof,L.mfhd(b),L.traf(A,O))},L.moov=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trak(b[O]);return L.box.apply(null,[L.types.moov,L.mvhd(b[0].timescale,b[0].duration)].concat(A).concat(L.mvex(b)))},L.mvex=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trex(b[O]);return L.box.apply(null,[L.types.mvex].concat(A))},L.mvhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1)),T=new Uint8Array([1,0,0,0,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,A>>24,A>>16&255,A>>8&255,A&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 L.box(L.types.mvhd,T)},L.sdtp=function(b){var O=b.samples||[],A=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,A[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return L.box(L.types.sdtp,A)},L.stbl=function(b){return L.box(L.types.stbl,L.stsd(b),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))},L.avc1=function(b){var O=[],A=[],y,T,D;for(y=0;y<b.sps.length;y++)T=b.sps[y],D=T.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(T));for(y=0;y<b.pps.length;y++)T=b.pps[y],D=T.byteLength,A.push(D>>>8&255),A.push(D&255),A=A.concat(Array.prototype.slice.call(T));var E=L.box(L.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|b.sps.length].concat(O).concat([b.pps.length]).concat(A))),m=b.width,p=b.height,u=b.pixelRatio[0],e=b.pixelRatio[1];return L.box(L.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,e>>24,e>>16&255,e>>8&255,e&255])))},L.esds=function(b){var O=b.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(b.config).concat([6,1,2]))},L.mp4a=function(b){var O=b.samplerate;return L.box(L.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),L.box(L.types.esds,L.esds(b)))},L.mp3=function(b){var O=b.samplerate;return L.box(L.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},L.stsd=function(b){return b.type==="audio"?b.segmentCodec==="mp3"&&b.codec==="mp3"?L.box(L.types.stsd,L.STSD,L.mp3(b)):L.box(L.types.stsd,L.STSD,L.mp4a(b)):L.box(L.types.stsd,L.STSD,L.avc1(b))},L.tkhd=function(b){var O=b.id,A=b.duration*b.timescale,y=b.width,T=b.height,D=Math.floor(A/(M+1)),E=Math.floor(A%(M+1));return L.box(L.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&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,T>>8&255,T&255,0,0]))},L.traf=function(b,O){var A=L.sdtp(b),y=b.id,T=Math.floor(O/(M+1)),D=Math.floor(O%(M+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),L.box(L.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,D>>24,D>>16&255,D>>8&255,D&255])),L.trun(b,A.length+16+20+8+16+8+8),A)},L.trak=function(b){return b.duration=b.duration||4294967295,L.box(L.types.trak,L.tkhd(b),L.mdia(b))},L.trex=function(b){var O=b.id;return L.box(L.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},L.trun=function(b,O){var A=b.samples||[],y=A.length,T=12+16*y,D=new Uint8Array(T),E,m,p,u,e,s;for(O+=8+T,D.set([b.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),E=0;E<y;E++)m=A[E],p=m.duration,u=m.size,e=m.flags,s=m.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,u>>>24&255,u>>>16&255,u>>>8&255,u&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 L.box(L.types.trun,D)},L.initSegment=function(b){L.types||L.init();var O=L.moov(b),A=new Uint8Array(L.FTYP.byteLength+O.byteLength);return A.set(L.FTYP),A.set(O,L.FTYP.byteLength),A},L}();_.types=void 0,_.HDLR_TYPES=void 0,_.STTS=void 0,_.STSC=void 0,_.STCO=void 0,_.STSZ=void 0,_.VMHD=void 0,_.SMHD=void 0,_.STSD=void 0,_.FTYP=void 0,_.DINF=void 0,R.default=_},"./src/remux/mp4-remuxer.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return e}),g.d(R,"normalizePts",function(){return s}),g.d(R,"flushTextTrackMetadataCueSamples",function(){return v}),g.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var M=g("./src/polyfills/number.ts"),_=g("./src/remux/aac-helper.ts"),L=g("./src/remux/mp4-generator.ts"),C=g("./src/events.ts"),b=g("./src/errors.ts"),O=g("./src/utils/logger.ts"),A=g("./src/types/loader.ts"),y=g("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(d){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(d[l]=n[l])}return d},T.apply(this,arguments)}var D=10*1e3,E=1024,m=1152,p=null,u=null,e=function(){function d(n,l,a,f){if(f===void 0&&(f=""),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=l,this.typeSupported=a,this.ISGenerated=!1,p===null){var h=navigator.userAgent||"",S=h.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(u===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);u=x?parseInt(x[1]):0}}var t=d.prototype;return t.destroy=function(){},t.resetTimeStamp=function(l){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=l},t.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(l){var a=!1,f=l.reduce(function(h,S){var x=S.pts-h;return x<-4294967296?(a=!0,s(h,S.pts)):x>0?h:S.pts},l[0].pts);return a&&O.logger.debug("PTS rollover detected"),f},t.remux=function(l,a,f,h,S,x,P,k){var B,U,W,G,z,Y,$=S,Z=S,q=l.pid>-1,ie=a.pid>-1,ne=a.samples.length,ae=l.samples.length>0,te=P&&ne>0||ne>1,fe=(!q||ae)&&(!ie||te)||this.ISGenerated||P;if(fe){this.ISGenerated||(W=this.generateIS(l,a,S));var de=this.isVideoContiguous,re=-1,Ee;if(te&&(re=c(a.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){O.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&&(O.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(l.samples[0].pts,Te)-Te,Ae=Me/a.inputTimeScale;$+=Math.max(0,Ae),Z+=Math.max(0,-Ae)}if(ae){if(l.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(l,a,S)),U=this.remuxAudio(l,$,this.isAudioContiguous,x,ie||te||k===A.PlaylistLevelType.AUDIO?Z:void 0),te){var we=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(l,a,S)),B=this.remuxVideo(a,Z,de,we)}}else te&&(B=this.remuxVideo(a,Z,de,0));B&&(B.firstKeyFrame=re,B.independent=re!==-1,B.firstKeyFramePTS=Ee)}}return this.ISGenerated&&(f.samples.length&&(z=v(f,S,this._initPTS,this._initDTS)),h.samples.length&&(G=i(h,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(l,a,f){var h=l.samples,S=a.samples,x=this.typeSupported,P={},k=!Object(M.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,G;if(k&&(U=W=1/0),l.config&&h.length){switch(l.timescale=l.samplerate,l.segmentCodec){case"mp3":x.mpeg?(B="audio/mpeg",l.codec=""):x.mp3&&(l.codec="mp3");break}P.audio={id:"audio",container:B,codec:l.codec,initSegment:l.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):L.default.initSegment([l]),metadata:{channelCount:l.channelCount}},k&&(G=l.inputTimeScale,U=W=h[0].pts-Math.round(G*f))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:L.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){G=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*f);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(P).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:P,initPTS:U,timescale:G}},t.remuxVideo=function(l,a,f,h){var S=l.inputTimeScale,x=l.samples,P=[],k=x.length,B=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,q=!1;if(!f||U===null){var ie=a*S,ne=x[0].pts-s(x[0].dts,x[0].pts);U=ie-ne}for(var ae=0;ae<k;ae++){var te=x[ae];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<x[ae>0?ae-1:ae].dts&&(q=!0)}q&&x.sort(function(Dt,Ut){var pt=Dt.dts-Ut.dts,Jt=Dt.pts-Ut.pts;return pt||Jt}),z=x[0].dts,Y=x[x.length-1].dts;var fe=Y-z,de=fe?Math.round(fe/(k-1)):G||l.inputTimeScale/30;if(f){var re=z-U,Ee=re>de,me=re<-1;if(Ee||me){Ee?O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),z=U;var Te=x[0].pts-re;x[0].dts=z,x[0].pts=Te,O.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,Ae=0,we=0;we<k;we++){for(var Re=x[we],ke=Re.units,_e=ke.length,Be=0,Ke=0;Ke<_e;Ke++)Be+=ke[Ke].data.length;Ae+=Be,Me+=_e,Re.length=Be,Re.dts=Math.max(Re.dts,z),$=Math.min(Re.pts,$),Z=Math.max(Re.pts,Z)}Y=x[k-1].dts;var We=Ae+4*Me+8,Ue;try{Ue=new Uint8Array(We)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:We,reason:"fail allocating video mdat "+We});return}var Ze=new DataView(Ue.buffer);Ze.setUint32(0,We),Ue.set(L.default.types.mdat,4);for(var Ce=!1,qe=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,Ie=0;Ie<k;Ie++){for(var Le=x[Ie],rt=Le.units,je=0,st=0,vt=rt.length;st<vt;st++){var ze=rt[st],xt=ze.data,gt=ze.data.byteLength;Ze.setUint32(W,gt),W+=4,Ue.set(xt,W),W+=gt,je+=4+gt}var it=void 0;if(Ie<k-1)G=x[Ie+1].dts-Le.dts,it=x[Ie+1].pts-Le.pts;else{var ot=this.config,nt=Ie>0?Le.dts-x[Ie-1].dts:de;if(it=Ie>0?Le.pts-x[Ie-1].pts:de,ot.stretchShortVideoTrack&&this.nextAudioPts!==null){var mt=Math.floor(ot.maxBufferHole*S),ct=(h?$+h*S:this.nextAudioPts)-Le.pts;ct>mt?(G=ct-nt,G<0?G=nt:Ce=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ct/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=nt}else G=nt}var Xt=Math.round(Le.pts-Le.dts);qe=Math.min(qe,G),Pe=Math.max(Pe,G),Oe=Math.min(Oe,it),Ve=Math.max(Ve,it),P.push(new r(Le.key,G,je,Xt))}if(P.length){if(p){if(p<70){var bt=P[0].flags;bt.dependsOn=2,bt.isNonSync=0}}else if(u&&Ve-Oe<Pe-qe&&de/Pe<.025&&P[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var St=z,Xe=0,kt=P.length;Xe<kt;Xe++){var Rt=St+P[Xe].duration,Bt=St+P[Xe].cts;if(Xe<kt-1){var Pt=Rt+P[Xe+1].cts;P[Xe].duration=Pt-Bt}else P[Xe].duration=Xe?P[Xe-1].duration:de;P[Xe].cts=0,St=Rt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Ce||!G?de:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var Qt=L.default.moof(l.sequenceNumber++,z,T({},l,{samples:P})),$t="video",at={data1:Qt,data2:Ue,startPTS:$/S,endPTS:(Z+G)/S,startDTS:z/S,endDTS:U/S,type:$t,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:l.dropped};return l.samples=[],l.dropped=0,console.assert(Ue.length,"MDAT length must not be zero"),at},t.remuxAudio=function(l,a,f,h,S){var x=l.inputTimeScale,P=l.samplerate?l.samplerate:x,k=x/P,B=l.segmentCodec==="aac"?E:m,U=B*k,W=this._initPTS,G=l.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=l.samples,Z=G?0:8,q=this.nextAudioPts||-1,ie=a*x;if(this.isAudioContiguous=f=f||$.length&&q>0&&(h&&Math.abs(ie-q)<9e3||Math.abs(s($[0].pts-W,ie)-q)<20*U),$.forEach(function(ze){ze.pts=s(ze.pts-W,ie)}),!f||q<0){if($=$.filter(function(ze){return ze.pts>=0}),!$.length)return;S===0?q=0:h&&!Y?q=Math.max(0,ie):q=$[0].pts}if(l.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/x);if(re<=-ne*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(de/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/x)+" 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),O.logger.warn("[mp4-remuxer]: Injecting "+me+" audio frame @ "+(te/x).toFixed(3)+"s due to "+Math.round(1e3*re/x)+" ms gap.");for(var Te=0;Te<me;Te++){var Me=Math.max(te,0),Ae=_.default.getSilentFrame(l.manifestCodec||l.codec,l.channelCount);Ae||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=fe.unit.subarray()),$.splice(ae,0,{unit:Ae,pts:Me}),te+=U,ae++}}fe.pts=te,te+=U}for(var we=null,Re=null,ke,_e=0,Be=$.length;Be--;)_e+=$[Be].unit.byteLength;for(var Ke=0,We=$.length;Ke<We;Ke++){var Ue=$[Ke],Ze=Ue.unit,Ce=Ue.pts;if(Re!==null){var qe=z[Ke-1];qe.duration=Math.round((Ce-Re)/k)}else if(f&&l.segmentCodec==="aac"&&(Ce=q),we=Ce,_e>0){_e+=Z;try{ke=new Uint8Array(_e)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating audio mdat "+_e});return}if(!G){var Oe=new DataView(ke.buffer);Oe.setUint32(0,_e),ke.set(L.default.types.mdat,4)}}else return;ke.set(Ze,Z);var Pe=Ze.byteLength;Z+=Pe,z.push(new r(!0,B,Pe,0)),Re=Ce}var Ve=z.length;if(!!Ve){var Ie=z[z.length-1];this.nextAudioPts=q=Re+k*Ie.duration;var Le=G?new Uint8Array(0):L.default.moof(l.sequenceNumber++,we/k,T({},l,{samples:z}));l.samples=[];var rt=we/x,je=q/x,st="audio",vt={data1:Le,data2:ke,startPTS:rt,endPTS:je,startDTS:rt,endDTS:je,type:st,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,console.assert(ke.length,"MDAT length must not be zero"),vt}},t.remuxEmptyAudio=function(l,a,f,h){var S=l.inputTimeScale,x=l.samplerate?l.samplerate:S,P=S/x,k=this.nextAudioPts,B=(k!==null?k:h.startDTS*S)+this._initDTS,U=h.endDTS*S+this._initDTS,W=P*E,G=Math.ceil((U-B)/W),z=_.default.getSilentFrame(l.manifestCodec||l.codec,l.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){O.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 l.samples=Y,this.remuxAudio(l,a,f,!1)},d}();function s(d,t){var n;if(t===null)return d;for(t<d?n=-8589934592:n=8589934592;Math.abs(d-t)>4294967296;)d+=n;return d}function c(d){for(var t=0;t<d.length;t++)if(d[t].key)return t;return-1}function v(d,t,n,l){var a=d.samples.length;if(!!a){for(var f=d.inputTimeScale,h=0;h<a;h++){var S=d.samples[h];S.pts=s(S.pts-n,t*f)/f,S.dts=s(S.dts-l,t*f)/f}var x=d.samples;return d.samples=[],{samples:x}}}function i(d,t,n){var l=d.samples.length;if(!!l){for(var a=d.inputTimeScale,f=0;f<l;f++){var h=d.samples[f];h.pts=s(h.pts-n,t*a)/a}d.samples.sort(function(x,P){return x.pts-P.pts});var S=d.samples;return d.samples=[],{samples:S}}}var r=function(t,n,l,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=l,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,g){"use strict";g.r(R);var M=g("./src/polyfills/number.ts"),_=g("./src/remux/mp4-remuxer.ts"),L=g("./src/utils/mp4-tools.ts"),C=g("./src/loader/fragment.ts"),b=g("./src/utils/logger.ts"),O=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 T=y.prototype;return T.destroy=function(){},T.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},T.resetNextTimestamp=function(){this.lastEndTime=null},T.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},T.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(L.parseInitSegment)(E);m||(m=A(u.audio,C.ElementaryStreamTypes.AUDIO)),p||(p=A(u.video,C.ElementaryStreamTypes.VIDEO));var e={};u.audio&&u.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:u.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:u.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:b.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,m,p,u,e){var s,c=this.initPTS,v=this.lastEndTime,i={audio:void 0,video:void 0,text:u,id3:p,initSegment:void 0};Object(M.isFiniteNumber)(v)||(v=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(r),d=this.initData),!d||!d.length)return b.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(L.getStartDTS)(d,r);Object(M.isFiniteNumber)(c)||(this.initPTS=o.initPTS=c=t-e);var n=Object(L.getDuration)(r,d),l=E?t-c:v,a=l+n;Object(L.offsetStartDTS)(d,r,c),n>0?this.lastEndTime=a:(b.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!d.audio,h=!!d.video,S="";f&&(S+="audio"),h&&(S+="video");var x={data1:r,startPTS:l,startDTS:l,endPTS:a,endDTS:a,type:S,hasAudio:f,hasVideo:h,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=o;var P=(s=this.initPTS)!=null?s:0;return i.id3=Object(_.flushTextTrackMetadataCueSamples)(p,e,P,P),u.samples.length&&(i.text=Object(_.flushTextTrackUserdataCueSamples)(u,e,P)),i},y}();function A(y,T){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"||T===C.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=O},"./src/task-loop.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return M});var M=function(){function _(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var L=_.prototype;return L.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},L.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},L.onHandlerDestroyed=function(){},L.hasInterval=function(){return!!this._tickInterval},L.hasNextTick=function(){return!!this._tickTimer},L.setInterval=function(b){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,b),!0)},L.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},L.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},L.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},L.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},L.doTick=function(){},_}()},"./src/types/cmcd.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"CMCDVersion",function(){return M}),g.d(R,"CMCDObjectType",function(){return _}),g.d(R,"CMCDStreamingFormat",function(){return L}),g.d(R,"CMCDStreamType",function(){return C});var M=1,_;(function(b){b.MANIFEST="m",b.AUDIO="a",b.VIDEO="v",b.MUXED="av",b.INIT="i",b.CAPTION="c",b.TIMED_TEXT="tt",b.KEY="k",b.OTHER="o"})(_||(_={}));var L;(function(b){b.DASH="d",b.HLS="h",b.SMOOTH="s",b.OTHER="o"})(L||(L={}));var C;(function(b){b.VOD="v",b.LIVE="l"})(C||(C={}))},"./src/types/demuxer.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"MetadataSchema",function(){return M});var M;(function(_){_.audioId3="org.id3",_.dateRange="com.apple.quicktime.HLS",_.emsg="https://aomedia.org/emsg/ID3"})(M||(M={}))},"./src/types/level.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"HlsSkip",function(){return L}),g.d(R,"getSkipValue",function(){return C}),g.d(R,"HlsUrlParameters",function(){return b}),g.d(R,"Level",function(){return O});function M(A,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(A,D.key,D)}}function _(A,y,T){return y&&M(A.prototype,y),T&&M(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var L;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(L||(L={}));function C(A,y){var T=A.canSkipUntil,D=A.canSkipDateRanges,E=A.endSN,m=y!==void 0?y-E:0;return T&&m<T?D?L.v2:L.Yes:L.No}var b=function(){function A(T,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=D,this.skip=E}var y=A.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()},A}(),O=function(){function A(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(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return _(A,[{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(T){var D=T%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),A}()},"./src/types/loader.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"PlaylistContextType",function(){return M}),g.d(R,"PlaylistLevelType",function(){return _});var M;(function(L){L.MANIFEST="manifest",L.LEVEL="level",L.AUDIO_TRACK="audioTrack",L.SUBTITLE_TRACK="subtitleTrack"})(M||(M={}));var _;(function(L){L.MAIN="main",L.AUDIO="audio",L.SUBTITLE="subtitle"})(_||(_={}))},"./src/types/transmuxer.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"ChunkMetadata",function(){return M});var M=function(C,b,O,A,y,T){A===void 0&&(A=0),y===void 0&&(y=-1),T===void 0&&(T=!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=_(),this.buffering={audio:_(),video:_(),audiovideo:_()},this.level=C,this.sn=b,this.id=O,this.size=A,this.part=y,this.partial=T};function _(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"AttrList",function(){return L});var M=/^(\d+)x(\d+)$/,_=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function C(O){typeof O=="string"&&(O=C.parseAttrList(O));for(var A in O)O.hasOwnProperty(A)&&(this[A]=O[A])}var b=C.prototype;return b.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var T=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)T[D]=parseInt(y.slice(D*2,D*2+2),16);return T}else return null},b.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.decimalFloatingPoint=function(A){return parseFloat(this[A])},b.optionalFloat=function(A,y){var T=this[A];return T?parseFloat(T):y},b.enumeratedString=function(A){return this[A]},b.bool=function(A){return this[A]==="YES"},b.decimalResolution=function(A){var y=M.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},C.parseAttrList=function(A){var y,T={},D='"';for(_.lastIndex=0;(y=_.exec(A))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),T[y[1]]=E}return T},C}()},"./src/utils/binary-search.ts":function(j,R,g){"use strict";g.r(R);var M={search:function(L,C){for(var b=0,O=L.length-1,A=null,y=null;b<=O;){A=(b+O)/2|0,y=L[A];var T=C(y);if(T>0)b=A+1;else if(T<0)O=A-1;else return y}return null}};R.default=M},"./src/utils/buffer-helper.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"BufferHelper",function(){return L});var M=g("./src/utils/logger.ts"),_={length:0,start:function(){return 0},end:function(){return 0}},L=function(){function C(){}return C.isBuffered=function(O,A){try{if(O){for(var y=C.getBuffered(O),T=0;T<y.length;T++)if(A>=y.start(T)&&A<=y.end(T))return!0}}catch{}return!1},C.bufferInfo=function(O,A,y){try{if(O){var T=C.getBuffered(O),D=[],E;for(E=0;E<T.length;E++)D.push({start:T.start(E),end:T.end(E)});return this.bufferedInfo(D,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},C.bufferedInfo=function(O,A,y){A=Math.max(0,A),O.sort(function(r,o){var d=r.start-o.start;return d||o.end-r.end});var T=[];if(y)for(var D=0;D<O.length;D++){var E=T.length;if(E){var m=T[E-1].end;O[D].start-m<y?O[D].end>m&&(T[E-1].end=O[D].end):T.push(O[D])}else T.push(O[D])}else T=O;for(var p=0,u,e=A,s=A,c=0;c<T.length;c++){var v=T[c].start,i=T[c].end;if(A+y>=v&&A<i)e=v,s=i,p=s-A;else if(A+y<v){u=v;break}}return{len:p,start:e||0,end:s||0,nextStart:u}},C.getBuffered=function(O){try{return O.buffered}catch(A){return M.logger.log("failed to get media.buffered",A),_}},C}()},"./src/utils/cea-608-parser.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"Row",function(){return s}),g.d(R,"CaptionScreen",function(){return c});var M=g("./src/utils/logger.ts"),_={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},L=function(n){var l=n;return _.hasOwnProperty(n)&&(l=_[n]),String.fromCharCode(l)},C=15,b=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={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},T={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,f){this.verboseLevel>=a&&M.logger.log(this.time+" ["+a+"] "+f)},t}(),p=function(n){for(var l=[],a=0;a<n.length;a++)l.push(n[a].toString(16));return l},u=function(){function t(l,a,f,h,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=a||!1,this.italics=f||!1,this.background=h||"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 f=["foreground","underline","italics","background","flash"],h=0;h<f.length;h++){var S=f[h];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(l,a,f,h,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new u(a,f,h,S,x)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,f){this.uchar=a,this.penState.copy(f)},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(l){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<b;a++)this.chars.push(new e);this.logger=l,this.pos=0,this.currPenState=new u}var n=t.prototype;return n.equals=function(a){for(var f=!0,h=0;h<b;h++)if(!this.chars[h].equals(a.chars[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<b;f++)this.chars[f].copy(a.chars[f])},n.isEmpty=function(){for(var a=!0,f=0;f<b;f++)if(!this.chars[f].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>b&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=b)},n.moveCursor=function(a){var f=this.pos+a;if(a>1)for(var h=this.pos+1;h<f+1;h++)this.chars[h].setPenState(this.currPenState);this.setCursor(f)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var f=L(a);if(this.pos>=b){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var f;for(f=a;f<b;f++)this.chars[f].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=[],f=!0,h=0;h<b;h++){var S=this.chars[h].uchar;S!==" "&&(f=!1),a.push(S)}return f?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var f=this.chars[this.pos];f.setPenState(this.currPenState)},t}(),c=function(){function t(l){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<C;a++)this.rows.push(new s(l));this.logger=l,this.currRow=C-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<C;a++)this.rows[a].clear();this.currRow=C-1},n.equals=function(a){for(var f=!0,h=0;h<C;h++)if(!this.rows[h].equals(a.rows[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<C;f++)this.rows[f].copy(a.rows[f])},n.isEmpty=function(){for(var a=!0,f=0;f<C;f++)if(!this.rows[f].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 f=this.rows[this.currRow];f.insertChar(a)},n.setPen=function(a){var f=this.rows[this.currRow];f.setPenStyles(a)},n.moveCursor=function(a){var f=this.rows[this.currRow];f.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var f=this.rows[this.currRow];f.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var f=a.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var h=0;h<C;h++)this.rows[h].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var P=x.rows[S].cueStartTime,k=this.logger.time;if(P&&k!==null&&P<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[f-this.nrRollUpRows+B+1].copy(x.rows[S+B])}}this.currRow=f;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,f=this.rows.splice(a,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var f=[],h="",S=-1,x=0;x<C;x++){var P=this.rows[x].getTextString();P&&(S=x+1,a?f.push("Row "+S+": '"+P+"'"):f.push(P.trim()))}return f.length>0&&(a?h="["+f.join(" | ")+"]":h=f.join(`
20
- `)),h},n.getTextAndFormat=function(){return this.rows},t}(),v=function(){function t(l,a,f){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=l,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new c(f),this.nonDisplayedMemory=new c(f),this.lastOutputScreen=new c(f),this.currRollUpRow=this.displayedMemory.rows[C-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}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[C-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 f=0;f<a.length;f++)this.writeScreen.insertChar(a[f]);var h=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,h+": "+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 f={flash:!1};if(f.underline=a%2===1,f.italics=a>=46,f.italics)f.foreground="white";else{var h=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=S[h]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},n.outputDataUpdate=function(a){a===void 0&&(a=!1);var f=this.logger.time;f!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=f:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,f,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),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(l,a,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var h=new m;this.channels=[null,new v(l,a,h),new v(l+1,f,h)],this.cmdHistory=d(),this.logger=h}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,f){this.channels[a].setHandler(f)},n.addData=function(a,f){var h,S,x,P=!1;this.logger.time=a;for(var k=0;k<f.length;k+=2)if(S=f[k]&127,x=f[k+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([f[k],f[k+1]])+"] -> ("+p([S,x])+")"),h=this.parseCmd(S,x),h||(h=this.parseMidrow(S,x)),h||(h=this.parsePAC(S,x)),h||(h=this.parseBackgroundAttributes(S,x)),!h&&(P=this.parseChars(S,x),P)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(P)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!h&&!P&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([f[k],f[k+1]]))}},n.parseCmd=function(a,f){var h=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&f>=32&&f<=47,x=(a===23||a===31)&&f>=33&&f<=35;if(!(S||x))return!1;if(o(a,f,h))return r(null,null,h),this.logger.log(E.DEBUG,"Repeated command ("+p([a,f])+") is dropped"),!0;var P=a===20||a===21||a===23?1:2,k=this.channels[P];return a===20||a===21||a===28||a===29?f===32?k.ccRCL():f===33?k.ccBS():f===34?k.ccAOF():f===35?k.ccAON():f===36?k.ccDER():f===37?k.ccRU(2):f===38?k.ccRU(3):f===39?k.ccRU(4):f===40?k.ccFON():f===41?k.ccRDC():f===42?k.ccTR():f===43?k.ccRTD():f===44?k.ccEDM():f===45?k.ccCR():f===46?k.ccENM():f===47&&k.ccEOC():k.ccTO(f-32),r(a,f,h),this.currentChannel=P,!0},n.parseMidrow=function(a,f){var h=0;if((a===17||a===25)&&f>=32&&f<=47){if(a===17?h=1:h=2,h!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[h];return S?(S.ccMIDROW(f),this.logger.log(E.DEBUG,"MIDROW ("+p([a,f])+")"),!0):!1}return!1},n.parsePAC=function(a,f){var h,S=this.cmdHistory,x=(a>=17&&a<=23||a>=25&&a<=31)&&f>=64&&f<=127,P=(a===16||a===24)&&f>=64&&f<=95;if(!(x||P))return!1;if(o(a,f,S))return r(null,null,S),!0;var k=a<=23?1:2;f>=64&&f<=95?h=k===1?O[a]:y[a]:h=k===1?A[a]:T[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(h,f)),r(a,f,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,f){var h,S={color:null,italics:!1,indent:null,underline:!1,row:a};return f>95?h=f-96:h=f-64,S.underline=(h&1)===1,h<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(h/2)]:h<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((h-16)/2)*4,S},n.parseChars=function(a,f){var h,S=null,x=null;if(a>=25?(h=2,x=a-8):(h=1,x=a),x>=17&&x<=19){var P;x===17?P=f+80:x===18?P=f+112:P=f+144,this.logger.log(E.INFO,"Special char '"+L(P)+"' in channel "+h),S=[P]}else a>=32&&a<=127&&(S=f===0?[a]:[a,f]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,f,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,f){var h=(a===16||a===24)&&f>=32&&f<=47,S=(a===23||a===31)&&f>=45&&f<=47;if(!(h||S))return!1;var x,P={};a===16||a===24?(x=Math.floor((f-32)/2),P.background=D[x],f%2===1&&(P.background=P.background+"_semi")):f===45?P.background="transparent":(P.foreground="black",f===47&&(P.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(P),r(a,f,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var f=this.channels[a];f&&f.reset()}this.cmdHistory=d()},n.cueSplitAtTime=function(a){for(var f=0;f<this.channels.length;f++){var h=this.channels[f];h&&h.cueSplitAtTime(a)}},t}();function r(t,n,l){l.a=t,l.b=n}function o(t,n,l){return l.a===t&&l.b===n}function d(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"isCodecType",function(){return _}),g.d(R,"isCodecSupportedInMp4",function(){return L});var M={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 _(C,b){var O=M[b];return!!O&&O[C.slice(0,4)]===!0}function L(C,b){return MediaSource.isTypeSupported((b||"video")+'/mp4;codecs="'+C+'"')}},"./src/utils/cues.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/utils/vttparser.ts"),_=g("./src/utils/webvtt-parser.ts"),L=g("./src/utils/texttrack-utils.ts"),C=/\s/,b={newCue:function(A,y,T,D){for(var E=[],m,p,u,e,s,c=self.VTTCue||self.TextTrackCue,v=0;v<D.rows.length;v++)if(m=D.rows[v],u=!0,e=0,s="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)C.test(m.chars[i].uchar)&&u?e++:(s+=m.chars[i].uchar,u=!1);m.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(M.fixLineBreaks)(s.trim()),o=Object(_.generateCueId)(y,T,r);(!A||!A.cues||!A.cues.getCueById(o))&&(p=new c(y,T,r),p.id=o,p.line=v+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return A&&E.length&&(E.sort(function(d,t){return d.line==="auto"||t.line==="auto"?0:d.line>8&&t.line>8?t.line-d.line:d.line-t.line}),E.forEach(function(d){return Object(L.addCueToTrack)(A,d)})),E}};R.default=b},"./src/utils/discontinuities.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"findFirstFragWithCC",function(){return C}),g.d(R,"shouldAlignOnDiscontinuities",function(){return b}),g.d(R,"findDiscontinuousReferenceFrag",function(){return O}),g.d(R,"adjustSlidingStart",function(){return y}),g.d(R,"alignStream",function(){return T}),g.d(R,"alignPDT",function(){return E}),g.d(R,"alignFragmentByPDTDelta",function(){return m}),g.d(R,"alignMediaPlaylistByPDT",function(){return p});var M=g("./src/polyfills/number.ts"),_=g("./src/utils/logger.ts"),L=g("./src/controller/level-helper.ts");function C(u,e){for(var s=null,c=0,v=u.length;c<v;c++){var i=u[c];if(i&&i.cc===e){s=i;break}}return s}function b(u,e,s){return!!(e.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function O(u,e){var s=u.fragments,c=e.fragments;if(!c.length||!s.length){_.logger.log("No fragments to align");return}var v=C(s,c[0].cc);if(!v||v&&!v.startPTS){_.logger.log("No frag in previous level to align on");return}return v}function A(u,e){if(u){var s=u.start+e;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function y(u,e){for(var s=e.fragments,c=0,v=s.length;c<v;c++)A(s[c],u);e.fragmentHint&&A(e.fragmentHint,u),e.alignedSliding=!0}function T(u,e,s){!e||(D(u,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(L.adjustSliding)(e.details,s))}function D(u,e,s){if(b(u,s,e)){var c=O(s.details,e);c&&Object(M.isFiniteNumber)(c.start)&&(_.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(c.start,e))}}function E(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=u.fragments[0].programDateTime,v=(c-s)/1e3+e.fragments[0].start;v&&Object(M.isFiniteNumber)(v)&&(_.logger.log("Adjusting PTS using programDateTime delta "+(c-s)+"ms, sliding:"+v.toFixed(3)+" "+u.url+" "),y(v,u))}}function m(u,e){var s=u.programDateTime;if(!!s){var c=(s-e)/1e3;u.start=u.startPTS=c,u.endPTS=c+u.duration}}function p(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=e.fragments[0].start,v=s-c*1e3;u.fragments.forEach(function(i){m(i,v)}),u.fragmentHint&&m(u.fragmentHint,v),u.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/utils/ewma.ts"),_=function(){function L(b,O,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new M.default(b),this.fast_=new M.default(O)}var C=L.prototype;return C.update=function(O,A){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new M.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new M.default(A,T.getEstimate(),T.getTotalWeight()))},C.sample=function(O,A){O=Math.max(O,this.minDelayMs_);var y=8*A,T=O/1e3,D=y/T;this.fast_.sample(T,D),this.slow_.sample(T,D)},C.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},C.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},C.destroy=function(){},L}();R.default=_},"./src/utils/ewma.ts":function(j,R,g){"use strict";g.r(R);var M=function(){function _(C,b,O){b===void 0&&(b=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=C,this.alpha_=C?Math.exp(Math.log(.5)/C):0,this.estimate_=b,this.totalWeight_=O}var L=_.prototype;return L.sample=function(b,O){var A=Math.pow(this.alpha_,b);this.estimate_=O*(1-A)+A*this.estimate_,this.totalWeight_+=b},L.getTotalWeight=function(){return this.totalWeight_},L.getEstimate=function(){if(this.alpha_){var b=1-Math.pow(this.alpha_,this.totalWeight_);if(b)return this.estimate_/b}return this.estimate_},_}();R.default=M},"./src/utils/fetch-loader.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"fetchSupported",function(){return m});var M=g("./src/polyfills/number.ts"),_=g("./src/loader/load-stats.ts"),L=g("./src/demux/chunk-cache.ts");function C(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,T(c,v)}function b(c){var v=typeof Map=="function"?new Map:void 0;return b=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 v!="undefined"){if(v.has(r))return v.get(r);v.set(r,o)}function o(){return O(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),T(o,r)},b(c)}function O(c,v,i){return A()?O=Reflect.construct.bind():O=function(o,d,t){var n=[null];n.push.apply(n,d);var l=Function.bind.apply(o,n),a=new l;return t&&T(a,t.prototype),a},O.apply(null,arguments)}function A(){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(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function T(c,v){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},T(c,v)}function D(c){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(c)}function E(){return E=Object.assign?Object.assign.bind():function(c){for(var v=1;v<arguments.length;v++){var i=arguments[v];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(c[r]=i[r])}return c},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 c(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 _.LoadStats}var v=c.prototype;return v.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},v.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},v.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},v.load=function(r,o,d){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 l=u(r,this.controller.signal),a=d.onProgress,f=r.responseType==="arraybuffer",h=f?"byteLength":"length";this.context=r,this.config=o,this.callbacks=d,this.request=this.fetchSetup(r,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),d.onTimeout(n,r,t.response)},o.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var x=S.status,P=S.statusText;throw new s(P||"fetch, bad network response",x,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(M.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):f?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[h];var P={url:x.url,data:S};a&&!Object(M.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,x),d.onSuccess(P,n,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var x=S&&S.code||0,P=S?S.message:null;d.onError({code:x,text:P},r,S?S.details:null)}})},v.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},v.loadProgressively=function(r,o,d,t,n){t===void 0&&(t=0);var l=new L.default,a=r.body.getReader(),f=function h(){return a.read().then(function(S){if(S.done)return l.dataLength&&n(o,d,l.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,P=x.length;return o.loaded+=P,P<t||l.dataLength?(l.push(x),l.dataLength>=t&&n(o,d,l.flush(),r)):n(o,d,x,r),h()}).catch(function(){return Promise.reject()})};return f()},c}();function u(c,v){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(E({},c.headers))};return c.rangeEnd&&i.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),i}function e(c,v){return new self.Request(c.url,v)}var s=function(c){C(v,c);function v(i,r,o){var d;return d=c.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=r,d.details=o,d}return v}(b(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"IMSC1_CODEC",function(){return y}),g.d(R,"parseIMSC1",function(){return m});var M=g("./src/utils/mp4-tools.ts"),_=g("./src/utils/vttparser.ts"),L=g("./src/utils/vttcue.ts"),C=g("./src/demux/id3.ts"),b=g("./src/utils/timescale-conversion.ts"),O=g("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var l=arguments[n];for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&(t[a]=l[a])}return t},A.apply(this,arguments)}var y="stpp.ttml.im1t",T=/^(\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,l,a,f){var h=Object(M.findBox)(new Uint8Array(t),["mdat"]);if(h.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var S=h.map(function(P){return Object(C.utf8ArrayToStr)(P)}),x=Object(b.toTimescaleFromScale)(n,1,l);try{S.forEach(function(P){return a(p(P,x))})}catch(P){f(P)}}function p(t,n){var l=new DOMParser,a=l.parseFromString(t,"text/xml"),f=a.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var h={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(h).reduce(function(U,W){return U[W]=f.getAttribute("ttp:"+W)||h[W],U},{}),x=f.getAttribute("xml:space")!=="preserve",P=e(u(f,"styling","style")),k=e(u(f,"layout","region")),B=u(f,"body","[begin]");return[].map.call(B,function(U){var W=s(U,x);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 L.default(G-n,Y-n,W);$.id=Object(O.generateCueId)($.startTime,$.endTime,$.text);var Z=k[U.getAttribute("region")],q=P[U.getAttribute("style")];$.position=10,$.size=80;var ie=c(Z,q,P),ne=ie.textAlign;if(ne){var ae=E[ne];ae&&($.lineAlign=ae),$.align=ne}return A($,ie),$}).filter(function(U){return U!==null})}function u(t,n,l){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(l)):[]}function e(t){return t.reduce(function(n,l){var a=l.getAttribute("xml:id");return a&&(n[a]=l),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(l,a,f){var h;return a.nodeName==="br"&&f?l+`
21
- `:(h=a.childNodes)!==null&&h!==void 0&&h.length?s(a,n):n?l+a.textContent.trim().replace(/\s+/g," "):l+a.textContent},"")}function c(t,n,l){var a="http://www.w3.org/ns/ttml#styling",f=null,h=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&l.hasOwnProperty(S)&&(f=l[S]),h.reduce(function(x,P){var k=v(n,a,P)||v(t,a,P)||v(f,a,P);return k&&(x[P]=k),x},{})}function v(t,n,l){return t&&t.hasAttributeNS(n,l)?t.getAttributeNS(n,l):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var l=Object(_.parseTimeStamp)(t);return l===null&&(T.test(t)?l=o(t,n):D.test(t)&&(l=d(t,n))),l}function o(t,n){var l=T.exec(t),a=(l[4]|0)+(l[5]|0)/n.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+a/n.frameRate}function d(t,n){var l=D.exec(t),a=Number(l[1]),f=l[2];switch(f){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,g){"use strict";g.r(R),g.d(R,"enableLogs",function(){return O}),g.d(R,"logger",function(){return A});var M=function(){},_={trace:M,debug:M,log:M,warn:M,info:M,error:M},L=_;function C(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):M}function b(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];D.forEach(function(m){L[m]=y[m]?y[m].bind(y):C(m)})}function O(y){if(self.console&&y===!0||typeof y=="object"){b(y,"debug","log","info","warn","error");try{L.log()}catch{L=_}}else L=_}var A=L},"./src/utils/mediakeys-helper.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"KeySystems",function(){return M}),g.d(R,"requestMediaKeySystemAccess",function(){return _});var M;(function(L){L.WIDEVINE="com.widevine.alpha",L.PLAYREADY="com.microsoft.playready"})(M||(M={}));var _=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,g){"use strict";g.r(R),g.d(R,"getMediaSource",function(){return M});function M(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"RemuxerTrackIdConfig",function(){return O}),g.d(R,"bin2str",function(){return A}),g.d(R,"readUint16",function(){return y}),g.d(R,"readUint32",function(){return T}),g.d(R,"readSint32",function(){return D}),g.d(R,"writeUint32",function(){return E}),g.d(R,"findBox",function(){return m}),g.d(R,"parseSegmentIndex",function(){return p}),g.d(R,"parseInitSegment",function(){return u}),g.d(R,"getStartDTS",function(){return e}),g.d(R,"getDuration",function(){return s}),g.d(R,"computeRawDurationFromSamples",function(){return c}),g.d(R,"offsetStartDTS",function(){return v}),g.d(R,"segmentValidRange",function(){return i}),g.d(R,"appendUint8Array",function(){return r}),g.d(R,"parseSamples",function(){return o}),g.d(R,"parseSEIMessageFromNALu",function(){return n}),g.d(R,"parseEmsg",function(){return a});var M=g("./src/utils/typed-array.ts"),_=g("./src/loader/fragment.ts"),L=g("./src/demux/id3.ts"),C=Math.pow(2,32)-1,b=[].push,O={video:1,audio:2,id3:3,text:4};function A(f){return String.fromCharCode.apply(null,f)}function y(f,h){var S=f[h]<<8|f[h+1];return S<0?65536+S:S}function T(f,h){var S=D(f,h);return S<0?4294967296+S:S}function D(f,h){return f[h]<<24|f[h+1]<<16|f[h+2]<<8|f[h+3]}function E(f,h,S){f[h]=S>>24,f[h+1]=S>>16&255,f[h+2]=S>>8&255,f[h+3]=S&255}function m(f,h){var S=[];if(!h.length)return S;for(var x=f.byteLength,P=0;P<x;){var k=T(f,P),B=A(f.subarray(P+4,P+8)),U=k>1?P+k:x;if(B===h[0])if(h.length===1)S.push(f.subarray(P+8,U));else{var W=m(f.subarray(P+8,U),h.slice(1));W.length&&b.apply(S,W)}P=U}return S}function p(f){var h=[],S=f[0],x=8,P=T(f,x);x+=4;var k=0,B=0;S===0?x+=8:x+=16,x+=2;var U=f.length+B,W=y(f,x);x+=2;for(var G=0;G<W;G++){var z=x,Y=T(f,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=T(f,z);z+=4,h.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/P,start:U,end:U+$-1}}),U+=$,z+=4,x=z}return{earliestPresentationTime:k,timescale:P,version:S,referencesCount:W,references:h}}function u(f){for(var h=[],S=m(f,["moov","trak"]),x=0;x<S.length;x++){var P=S[x],k=m(P,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=T(k,U),G=m(P,["mdia","mdhd"])[0];if(G){B=G[0],U=B===0?12:20;var z=T(G,U),Y=m(P,["mdia","hdlr"])[0];if(Y){var $=A(Y.subarray(8,12)),Z={soun:_.ElementaryStreamTypes.AUDIO,vide:_.ElementaryStreamTypes.VIDEO}[$];if(Z){var q=m(P,["mdia","minf","stbl","stsd"])[0],ie=void 0;q&&(ie=A(q.subarray(12,16))),h[W]={timescale:z,type:Z},h[Z]={timescale:z,id:W,codec:ie}}}}}}var ne=m(f,["moov","mvex","trex"]);return ne.forEach(function(ae){var te=T(ae,4),fe=h[te];fe&&(fe.default={duration:T(ae,12),flags:T(ae,20)})}),h}function e(f,h){return m(h,["moof","traf"]).reduce(function(S,x){var P=m(x,["tfdt"])[0],k=P[0],B=m(x,["tfhd"]).reduce(function(U,W){var G=T(W,4),z=f[G];if(z){var Y=T(P,4);k===1&&(Y*=Math.pow(2,32),Y+=T(P,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(f,h){for(var S=0,x=0,P=0,k=m(f,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=m(U,["tfhd"])[0],G=T(W,4),z=h[G];if(!!z){var Y=z.default,$=T(W,0)|(Y==null?void 0:Y.flags),Z=Y==null?void 0:Y.duration;$&8&&($&2?Z=T(W,12):Z=T(W,8));for(var q=z.timescale||9e4,ie=m(U,["trun"]),ne=0;ne<ie.length;ne++){if(S=c(ie[ne]),!S&&Z){var ae=T(ie[ne],4);S=Z*ae}z.type===_.ElementaryStreamTypes.VIDEO?x+=S/q:z.type===_.ElementaryStreamTypes.AUDIO&&(P+=S/q)}}}if(x===0&&P===0){for(var te=0,fe=m(f,["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 x||P}function c(f){var h=T(f,0),S=8;h&1&&(S+=4),h&4&&(S+=4);for(var x=0,P=T(f,4),k=0;k<P;k++){if(h&256){var B=T(f,S);x+=B,S+=4}h&512&&(S+=4),h&1024&&(S+=4),h&2048&&(S+=4)}return x}function v(f,h,S){m(h,["moof","traf"]).forEach(function(x){m(x,["tfhd"]).forEach(function(P){var k=T(P,4),B=f[k];if(!!B){var U=B.timescale||9e4;m(x,["tfdt"]).forEach(function(W){var G=W[0],z=T(W,4);if(G===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=T(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(C+1)),$=Math.floor(z%(C+1));E(W,4,Y),E(W,8,$)}})}})})}function i(f){var h={valid:null,remainder:null},S=m(f,["moof"]);if(S){if(S.length<2)return h.remainder=f,h}else return h;var x=S[S.length-1];return h.valid=Object(M.sliceUint8)(f,0,x.byteOffset-8),h.remainder=Object(M.sliceUint8)(f,x.byteOffset-8),h}function r(f,h){var S=new Uint8Array(f.length+h.length);return S.set(f),S.set(h,f.length),S}function o(f,h){var S=[],x=h.samples,P=h.timescale,k=h.id,B=!1,U=m(x,["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=T(Z,4);return q===1&&(ie*=Math.pow(2,32),ie+=T(Z,8)),ie/P})[0];return $!==void 0&&(f=$),m(Y,["tfhd"]).map(function(Z){var q=T(Z,4),ie=T(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=T(Z,me),me+=4),de&&(re=T(Z,me),me+=4),Ee&&(me+=4),h.type==="video"&&(B=d(h.codec)),m(Y,["trun"]).map(function(Te){var Me=Te[0],Ae=T(Te,0)&16777215,we=(Ae&1)!==0,Re=0,ke=(Ae&4)!==0,_e=(Ae&256)!==0,Be=0,Ke=(Ae&512)!==0,We=0,Ue=(Ae&1024)!==0,Ze=(Ae&2048)!==0,Ce=0,qe=T(Te,4),Oe=8;we&&(Re=T(Te,Oe),Oe+=4),ke&&(Oe+=4);for(var Pe=Re+G,Ve=0;Ve<qe;Ve++){if(_e?(Be=T(Te,Oe),Oe+=4):Be=fe,Ke?(We=T(Te,Oe),Oe+=4):We=re,Ue&&(Oe+=4),Ze&&(Me===0?Ce=T(Te,Oe):Ce=D(Te,Oe),Oe+=4),h.type===_.ElementaryStreamTypes.VIDEO)for(var Ie=0;Ie<We;){var Le=T(x,Pe);Pe+=4;var rt=x[Pe]&31;if(t(B,rt)){var je=x.subarray(Pe,Pe+Le);n(je,f+Ce/P,S)}Pe+=Le,Ie+=Le+4}f+=Be/P}}))})})}),S}function d(f){if(!f)return!1;var h=f.indexOf("."),S=h<0?f:f.substring(0,h);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(f,h){return f?h===39||h===40:h===6}function n(f,h,S){var x=l(f),P=0;P++;for(var k=0,B=0,U=!1,W=0;P<x.length;){k=0;do{if(P>=x.length)break;W=x[P++],k+=W}while(W===255);B=0;do{if(P>=x.length)break;W=x[P++],B+=W}while(W===255);var G=x.length-P;if(!U&&k===4&&P<x.length){U=!0;var z=x[P++];if(z===181){var Y=y(x,P);if(P+=2,Y===49){var $=T(x,P);if(P+=4,$===1195456820){var Z=x[P++];if(Z===3){var q=x[P++],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]=x[P++]}S.push({type:Z,payloadType:k,pts:h,bytes:te})}}}}}else if(k===5&&B<G){if(U=!0,B>16){for(var de=[],re=0;re<16;re++){var Ee=x[P++].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]=x[P++];S.push({payloadType:k,pts:h,uuid:de.join(""),userData:Object(L.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(B<G)P+=B;else if(B>G)break}}function l(f){for(var h=f.byteLength,S=[],x=1;x<h-2;)f[x]===0&&f[x+1]===0&&f[x+2]===3?(S.push(x+2),x+=2):x++;if(S.length===0)return f;var P=h-S.length,k=new Uint8Array(P),B=0;for(x=0;x<P;B++,x++)B===S[0]&&(B++,S.shift()),k[x]=f[B];return k}function a(f){var h=f[0],S="",x="",P=0,k=0,B=0,U=0,W=0,G=0;if(h===0){for(;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1,P=T(f,12),k=T(f,16),U=T(f,20),W=T(f,24),G=28}else if(h===1){G+=4,P=T(f,G),G+=4;var z=T(f,G);G+=4;var Y=T(f,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=T(f,G),G+=4,W=T(f,G),G+=4;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1}var $=f.subarray(G,f.byteLength);return{schemeIdUri:S,value:x,timeScale:P,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"default",function(){return M});var M=function(){function _(C,b){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=C,this.trackName=b}var L=_.prototype;return L.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},L.newCue=function(b,O,A){(this.startTime===null||this.startTime>b)&&(this.startTime=b),this.endTime=O,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},L.reset=function(){this.cueRanges=[],this.startTime=null},_}()},"./src/utils/texttrack-utils.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"sendAddTrackEvent",function(){return _}),g.d(R,"addCueToTrack",function(){return L}),g.d(R,"clearCurrentCues",function(){return C}),g.d(R,"removeCuesInRange",function(){return b}),g.d(R,"getCuesInRange",function(){return A});var M=g("./src/utils/logger.ts");function _(y,T){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,T.dispatchEvent(D)}function L(y,T){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(T.id))try{if(y.addCue(T),!y.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(m){M.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function C(y){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);T==="disabled"&&(y.mode=T)}function b(y,T,D,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=A(y.cues,T,D),u=0;u<p.length;u++)(!E||E(p[u]))&&y.removeCue(p[u]);m==="disabled"&&(y.mode=m)}function O(y,T){if(T<y[0].startTime)return 0;var D=y.length-1;if(T>y[D].endTime)return-1;for(var E=0,m=D;E<=m;){var p=Math.floor((m+E)/2);if(T<y[p].startTime)m=p-1;else if(T>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-T<T-y[m].startTime?E:m}function A(y,T,D){var E=[],m=O(y,T);if(m>-1)for(var p=m,u=y.length;p<u;p++){var e=y[p];if(e.startTime>=T&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(j,R,g){"use strict";g.r(R);var M={toString:function(L){for(var C="",b=L.length,O=0;O<b;O++)C+="["+L.start(O).toFixed(3)+","+L.end(O).toFixed(3)+"]";return C}};R.default=M},"./src/utils/timescale-conversion.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"toTimescaleFromBase",function(){return _}),g.d(R,"toTimescaleFromScale",function(){return L}),g.d(R,"toMsFromMpegTsClock",function(){return C}),g.d(R,"toMpegTsClockFromTimescale",function(){return b});var M=9e4;function _(O,A,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var D=O*A*y;return T?Math.round(D):D}function L(O,A,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),_(O,A,1/y,T)}function C(O,A){return A===void 0&&(A=!1),_(O,1e3,1/M,A)}function b(O,A){return A===void 0&&(A=1),_(O,M,1/A)}},"./src/utils/typed-array.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"sliceUint8",function(){return M});function M(_,L,C){return Uint8Array.prototype.slice?_.slice(L,C):new Uint8Array(Array.prototype.slice.call(_,L,C))}},"./src/utils/vttcue.ts":function(j,R,g){"use strict";g.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var M=["","lr","rl"],_=["start","middle","end","left","right"];function L(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var D=T.toLowerCase();return~y.indexOf(D)?D:!1}function C(y){return L(M,y)}function b(y){return L(_,y)}function O(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var u in p)y[u]=p[u]}return y}function A(y,T,D){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",u=!1,e=y,s=T,c=D,v=null,i="",r=!0,o="auto",d="start",t=50,n="middle",l=50,a="middle";Object.defineProperty(E,"id",O({},m,{get:function(){return p},set:function(h){p=""+h}})),Object.defineProperty(E,"pauseOnExit",O({},m,{get:function(){return u},set:function(h){u=!!h}})),Object.defineProperty(E,"startTime",O({},m,{get:function(){return e},set:function(h){if(typeof h!="number")throw new TypeError("Start time must be set to a number.");e=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},m,{get:function(){return s},set:function(h){if(typeof h!="number")throw new TypeError("End time must be set to a number.");s=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},m,{get:function(){return c},set:function(h){c=""+h,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},m,{get:function(){return v},set:function(h){v=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},m,{get:function(){return i},set:function(h){var S=C(h);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},m,{get:function(){return r},set:function(h){r=!!h,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},m,{get:function(){return o},set:function(h){if(typeof h!="number"&&h!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},m,{get:function(){return d},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},m,{get:function(){return t},set:function(h){if(h<0||h>100)throw new Error("Position must be between 0 and 100.");t=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},m,{get:function(){return n},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},m,{get:function(){return l},set:function(h){if(h<0||h>100)throw new Error("Size must be between 0 and 100.");l=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},m,{get:function(){return a},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"parseTimeStamp",function(){return L}),g.d(R,"fixLineBreaks",function(){return T}),g.d(R,"VTTParser",function(){return D});var M=g("./src/utils/vttcue.ts"),_=function(){function E(){}var m=E.prototype;return m.decode=function(u,e){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},E}();function L(E){function m(u,e,s,c){return(u|0)*3600+(e|0)*60+(s|0)+parseFloat(c||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 C=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(u,e){!this.get(u)&&e!==""&&(this.values[u]=e)},m.get=function(u,e,s){return s?this.has(u)?this.values[u]:e[s]:this.has(u)?this.values[u]:e},m.has=function(u){return u in this.values},m.alt=function(u,e,s){for(var c=0;c<s.length;++c)if(e===s[c]){this.set(u,e);break}},m.integer=function(u,e){/^-?\d+$/.test(e)&&this.set(u,parseInt(e,10))},m.percent=function(u,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},E}();function b(E,m,p,u){var e=u?E.split(u):[E];for(var s in e)if(typeof e[s]=="string"){var c=e[s].split(p);if(c.length===2){var v=c[0],i=c[1];m(v,i)}}}var O=new M.default(0,0,""),A=O.align==="middle"?"middle":"center";function y(E,m,p){var u=E;function e(){var v=L(E);if(v===null)throw new Error("Malformed timestamp: "+u);return E=E.replace(/^[^\sa-zA-Z-]+/,""),v}function s(v,i){var r=new C;b(v,function(t,n){var l;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":l=n.split(","),r.integer(t,l[0]),r.percent(t,l[0])&&r.set("snapToLines",!1),r.alt(t,l[0],["auto"]),l.length===2&&r.alt("lineAlign",l[1],["start",A,"end"]);break;case"position":l=n.split(","),r.percent(t,l[0]),l.length===2&&r.alt("positionAlign",l[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&O.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",A);var d=r.get("position","auto");d==="auto"&&O.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function c(){E=E.replace(/^\s+/,"")}if(c(),m.startTime=e(),c(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);E=E.slice(3),c(),m.endTime=e(),c(),s(E,m)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
22
- `)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new _,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(u){var e=this;u&&(e.buffer+=e.decoder.decode(u,{stream:!0}));function s(){var d=e.buffer,t=0;for(d=T(d);t<d.length&&d[t]!=="\r"&&d[t]!==`
19
+ initSegmentChange: `+Z);var ie=new C.TransmuxConfig(c,v,s,o,n);this.configureTransmuxer(ie)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:P,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(h){var ne=h.push(e,P,t,q);Object(C.isPromise)(ne)?ne.then(function(ae){f.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var c=this.transmuxer,v=this.worker;if(v)v.postMessage({cmd:"flush",chunkMeta:e});else if(c){var i=c.flush(e);Object(C.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var c=this;e.forEach(function(v){c.handleTransmuxComplete(v)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,c=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":b.logger[s.data.logType]&&b.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,c.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,c=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):c&&c.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return O});var M=m("./src/demux/transmuxer.ts"),_=m("./src/events.ts"),L=m("./src/utils/logger.ts"),C=m("./node_modules/eventemitter3/index.js"),b=m.n(C);function O(E){var g=new C.EventEmitter,p=function(s,c){E.postMessage({event:s,data:c})};g.on(_.Events.FRAG_DECRYPTED,p),g.on(_.Events.ERROR,p);var u=function(){var s=function(i){var r=function(d){p("workerLog",{logType:i,message:d})};L.logger[i]=r};for(var c in L.logger)s(c)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var c=JSON.parse(s.config);E.transmuxer=new M.default(g,s.typeSupported,c,s.vendor,s.id),Object(L.enableLogs)(c.debug),u(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var v=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(M.isPromise)(v)?v.then(function(o){A(E,o)}):A(E,v);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(M.isPromise)(r)?r.then(function(o){T(E,o,i)}):T(E,r,i);break}default:break}})}function A(E,g){if(D(g.remuxResult))return!1;var p=[],u=g.remuxResult,e=u.audio,s=u.video;return e&&y(p,e),s&&y(p,s),E.postMessage({event:"transmuxComplete",data:g},p),!0}function y(E,g){g.data1&&E.push(g.data1.buffer),g.data2&&E.push(g.data2.buffer)}function T(E,g,p){var u=g.reduce(function(e,s){return A(E,s)||e},!1);u||E.postMessage({event:"transmuxComplete",data:g[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,m){"use strict";m.r(R),m.d(R,"default",function(){return p}),m.d(R,"isPromise",function(){return s}),m.d(R,"TransmuxConfig",function(){return c}),m.d(R,"TransmuxState",function(){return v});var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/crypt/decrypter.ts"),C=m("./src/demux/aacdemuxer.ts"),b=m("./src/demux/mp4demuxer.ts"),O=m("./src/demux/tsdemuxer.ts"),A=m("./src/demux/mp3demuxer.ts"),y=m("./src/remux/mp4-remuxer.ts"),T=m("./src/remux/passthrough-remuxer.ts"),D=m("./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 g=[{demux:O.default,remux:y.default},{demux:b.default,remux:T.default},{demux:C.default,remux:y.default},{demux:A.default,remux:y.default}],p=function(){function i(o,d,t,n,l){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=d,this.config=t,this.vendor=n,this.id=l}var r=i.prototype;return r.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},r.push=function(d,t,n,l){var a=this,f=n.transmuxing;f.executeStart=E();var h=new Uint8Array(d),S=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;l&&(this.currentTransmuxState=l);var k=l||x,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,G=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=P.audioCodec,Z=P.videoCodec,q=P.defaultInitPts,ie=P.duration,ne=P.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,$,Z,ie),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ae=u(h,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var fe=te.softwareDecrypt(h,ae.key.buffer,ae.iv.buffer);if(!fe)return f.executeEnd=E(),e(n);h=new Uint8Array(fe)}else return this.decryptionPromise=te.webCryptoDecrypt(h,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(h,U,W)&&this.configureTransmuxer(h,P);var de=this.transmux(h,ae,z,G,n),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,f.executeEnd=E(),de},r.flush=function(d){var t=this,n=d.transmuxing;n.executeStart=E();var l=this.decrypter,a=this.currentTransmuxState,f=this.decryptionPromise;if(f)return f.then(function(){return t.flush(d)});var h=[],S=a.timeOffset;if(l){var x=l.flush();x&&h.push(this.push(x,null,d))}var P=this.demuxer,k=this.remuxer;if(!P||!k)return this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(d)];var B=P.flush(S);return s(B)?B.then(function(U){return t.flushRemux(h,U,d),h}):(this.flushRemux(h,B,d),h)},r.flushRemux=function(d,t,n){var l=t.audioTrack,a=t.videoTrack,f=t.id3Track,h=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,P=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(l,a,f,h,P,x,!0,this.id);d.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(d){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(d),n.resetTimeStamp(d))},r.resetContiguity=function(){var d=this.demuxer,t=this.remuxer;!d||!t||(d.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(d,t,n,l){var a=this.demuxer,f=this.remuxer;!a||!f||(a.resetInitSegment(d,t,n,l),f.resetInitSegment(d,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(d,t,n,l,a){var f;return t&&t.method==="SAMPLE-AES"?f=this.transmuxSampleAes(d,t,n,l,a):f=this.transmuxUnencrypted(d,n,l,a),f},r.transmuxUnencrypted=function(d,t,n,l){var a=this.demuxer.demux(d,t,!1,!this.config.progressive),f=a.audioTrack,h=a.videoTrack,S=a.id3Track,x=a.textTrack,P=this.remuxer.remux(f,h,S,x,t,n,!1,this.id);return{remuxResult:P,chunkMeta:l}},r.transmuxSampleAes=function(d,t,n,l,a){var f=this;return this.demuxer.demuxSampleAes(d,t,n).then(function(h){var S=f.remuxer.remux(h.audioTrack,h.videoTrack,h.id3Track,h.textTrack,n,l,!1,f.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(d,t){for(var n=this.config,l=this.observer,a=this.typeSupported,f=this.vendor,h=t.audioCodec,S=t.defaultInitPts,x=t.duration,P=t.initSegmentData,k=t.videoCodec,B,U=0,W=g.length;U<W;U++)if(g[U].demux.probe(d)){B=g[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:b.default,remux:T.default});var G=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(l,n,a,f)),(!G||!(G instanceof $))&&(this.demuxer=new $(l,n,a),this.probe=$.probe),this.resetInitSegment(P,h,k,x),this.resetInitialTimestamp(S)},r.needsProbing=function(d,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new L.default(this.observer,this.config)),d},i}();function u(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 c=function(r,o,d,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=d,this.duration=t,this.defaultInitPts=n},v=function(r,o,d,t,n,l){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=d,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=l}},"./src/demux/tsdemuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"discardEPB",function(){return c});var M=m("./src/demux/adts.ts"),_=m("./src/demux/mpegaudio.ts"),L=m("./src/demux/exp-golomb.ts"),C=m("./src/demux/sample-aes.ts"),b=m("./src/events.ts"),O=m("./src/utils/mp4-tools.ts"),A=m("./src/utils/logger.ts"),y=m("./src/errors.ts"),T=m("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(v){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(v[o]=r[o])}return v},D.apply(this,arguments)}var E=function(){function v(r,o,d){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=d}v.probe=function(o){return o[0]===71&&o[188]===71},v.createTrack=function(o,d){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:O.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?d:void 0}};var i=v.prototype;return i.resetInitSegment=function(o,d,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=v.createTrack("video"),this._audioTrack=v.createTrack("audio",n),this._id3Track=v.createTrack("id3"),this._txtTrack=v.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,d=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),d&&(d.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,d,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var l,a=this._avcTrack,f=this._audioTrack,h=this._id3Track,S=this._txtTrack,x=a.pid,P=a.pesData,k=f.pid,B=h.pid,U=f.pesData,W=h.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(O.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:f,videoTrack:a,id3Track:h,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 x:ie&&(P&&(l=e(P))&&this.parseAVCPES(a,S,l,!1),P={data:[],size:0}),P&&(P.data.push(o.subarray(te,q+188)),P.size+=q+188-te);break;case k:if(ie){if(U&&(l=e(U)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,l);break;case"mp3":this.parseMPEGPES(f,l);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:ie&&(W&&(l=e(W))&&this.parseID3PES(h,l),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=u(o,te,this.typeSupported,t);x=fe.avc,x>0&&(a.pid=x),k=fe.audio,k>0&&(f.pid=k,f.segmentCodec=fe.segmentCodec),B=fe.id3,B>0&&(h.pid=B),G!==null&&!z&&(A.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(b.Events.ERROR,b.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=P,f.pesData=U,h.pesData=W;var de={audioTrack:f,videoTrack:a,id3Track:h,textTrack:S};return n&&this.extractRemainingSamples(de),de},i.flush=function(){var o=this.remainderData;this.remainderData=null;var d;return o?d=this.demux(o,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(o){var d=o.audioTrack,t=o.videoTrack,n=o.id3Track,l=o.textTrack,a=t.pesData,f=d.pesData,h=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,l,S,!0),t.pesData=null):t.pesData=a,f&&(S=e(f))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,S);break;case"mp3":this.parseMPEGPES(d,S);break}d.pesData=null}else f!=null&&f.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=f;h&&(S=e(h))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=h},i.demuxSampleAes=function(o,d,t){var n=this.demux(o,t,!0,!this.config.progressive),l=this.sampleAes=new C.default(this.observer,this.config,d);return this.decrypt(n,l)},i.decrypt=function(o,d){return new Promise(function(t){var n=o.audioTrack,l=o.videoTrack;n.samples&&n.segmentCodec==="aac"?d.decryptAacSamples(n.samples,0,function(){l.samples?d.decryptAvcSamples(l.samples,0,0,function(){t(o)}):t(o)}):l.samples&&d.decryptAvcSamples(l.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,d,t,n){var l=this,a=this.parseAVCNALu(o,t.data),f=!1,h=this.avcSample,S,x=!1;t.data=null,h&&a.length&&!o.audFound&&(s(h,o),h=this.avcSample=g(!1,t.pts,t.dts,"")),a.forEach(function(P){switch(P.type){case 1:{S=!0,h||(h=l.avcSample=g(!0,t.pts,t.dts,"")),f&&(h.debug+="NDR "),h.frame=!0;var k=P.data;if(x&&k.length>4){var B=new L.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(h.key=!0)}break}case 5:S=!0,h||(h=l.avcSample=g(!0,t.pts,t.dts,"")),f&&(h.debug+="IDR "),h.key=!0,h.frame=!0;break;case 6:{S=!0,f&&h&&(h.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(c(P.data),t.pts,d.samples);break}case 7:if(S=!0,x=!0,f&&h&&(h.debug+="SPS "),!o.sps){var U=new L.default(P.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[P.data],o.duration=l._duration;for(var G=P.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,f&&h&&(h.debug+="PPS "),o.pps||(o.pps=[P.data]);break;case 9:S=!1,o.audFound=!0,h&&s(h,o),h=l.avcSample=g(!1,t.pts,t.dts,f?"AUD ":"");break;case 12:S=!0;break;default:S=!1,h&&(h.debug+="unknown NAL "+P.type+" ");break}if(h&&S){var Z=h.units;Z.push(P)}}),n&&h&&(s(h,o),this.avcSample=null)},i.getLastNalUnit=function(o){var d,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(d=t)!==null&&d!==void 0&&d.units){var l=t.units;n=l[l.length-1]}return n},i.parseAVCNALu=function(o,d){var t=d.byteLength,n=o.naluState||0,l=n,a=[],f=0,h,S,x,P=-1,k=0;for(n===-1&&(P=0,k=d[0]&31,n=0,f=1);f<t;){if(h=d[f++],!n){n=h?0:1;continue}if(n===1){n=h?0:2;continue}if(!h)n=3;else if(h===1){if(P>=0){var B={data:d.subarray(P,f-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(l&&f<=4-l&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-l)),S=f-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(d.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}f<t?(x=d[f]&31,P=f,k=x,n=0):n=-1}else n=0}if(P>=0&&n>=0){var G={data:d.subarray(P,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+d.byteLength);Y.set(z.data,0),Y.set(d,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,d){var t=0,n=this.aacOverFlow,l=d.data;if(n){this.aacOverFlow=null;var a=n.missing,f=n.sample.unit.byteLength;if(a===-1){var h=new Uint8Array(f+l.byteLength);h.set(n.sample.unit,0),h.set(l,f),l=h}else{var S=f-a;n.sample.unit.set(l.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var x,P;for(x=t,P=l.length;x<P-1&&!M.isHeader(l,x);x++);if(x!==t){var k,B;if(x<P-1?(k="AAC PES did not start with ADTS header,offset:"+x,B=!1):(k="no ADTS header found in AAC PES",B=!0),A.logger.warn("parsing error:"+k),this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}M.initTrackConfig(o,this.observer,l,x,this.audioCodec);var U;if(d.pts!==void 0)U=d.pts;else if(n){var W=M.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;x<P;)if(z=M.appendFrame(o,l,x,U,G),x+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;x<P-1&&!M.isHeader(l,x);x++);},i.parseMPEGPES=function(o,d){var t=d.data,n=t.length,l=0,a=0,f=d.pts;if(f===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(_.isHeader(t,a)){var h=_.appendFrame(o,t,a,f,l);if(h)a+=h.length,l++;else break}else a++},i.parseID3PES=function(o,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},d,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});o.samples.push(t)},v}();function g(v,i,r,o){return{key:v,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(v,i){return(v[i+10]&31)<<8|v[i+11]}function u(v,i,r,o){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(v[i+1]&15)<<8|v[i+2],n=i+3+t-4,l=(v[i+10]&15)<<8|v[i+11];for(i+=12+l;i<n;){var a=(v[i+1]&31)<<8|v[i+2];switch(v[i]){case 207:if(!o){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=a);break;case 21:d.id3===-1&&(d.id3=a);break;case 219:if(!o){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=a,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((v[i+3]&15)<<8|v[i+4])+5}return d}function e(v){var i=0,r,o,d,t,n,l=v.data;if(!v||v.size===0)return null;for(;l[0].length<19&&l.length>1;){var a=new Uint8Array(l[0].length+l[1].length);a.set(l[0]),a.set(l[1],l[0].length),l[0]=a,l.splice(1,1)}r=l[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){if(o=(r[4]<<8)+r[5],o&&o>v.size-6)return null;var h=r[7];h&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,h&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&&(A.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),d=r[8];var S=d+9;if(v.size<=S)return null;v.size-=S;for(var x=new Uint8Array(v.size),P=0,k=l.length;P<k;P++){r=l[P];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;x.set(r,i),i+=B}return o&&(o-=d+3),{data:x,pts:t,dts:n,len:o}}return null}function s(v,i){if(v.units.length&&v.frame){if(v.pts===void 0){var r=i.samples,o=r.length;if(o){var d=r[o-1];v.pts=d.pts,v.dts=d.dts}else{i.dropped++;return}}i.samples.push(v)}v.debug.length&&A.logger.log(v.pts+"/"+v.dts+":"+v.debug)}function c(v){for(var i=v.byteLength,r=[],o=1;o<i-2;)v[o]===0&&v[o+1]===0&&v[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return v;var d=i-r.length,t=new Uint8Array(d),n=0;for(o=0;o<d;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=v[n];return t}R.default=E},"./src/errors.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ErrorTypes",function(){return M}),m.d(R,"ErrorDetails",function(){return _});var M;(function(L){L.NETWORK_ERROR="networkError",L.MEDIA_ERROR="mediaError",L.KEY_SYSTEM_ERROR="keySystemError",L.MUX_ERROR="muxError",L.OTHER_ERROR="otherError"})(M||(M={}));var _;(function(L){L.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",L.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",L.KEY_SYSTEM_NO_SESSION="keySystemNoSession",L.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",L.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",L.MANIFEST_LOAD_ERROR="manifestLoadError",L.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",L.MANIFEST_PARSING_ERROR="manifestParsingError",L.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",L.LEVEL_EMPTY_ERROR="levelEmptyError",L.LEVEL_LOAD_ERROR="levelLoadError",L.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",L.LEVEL_SWITCH_ERROR="levelSwitchError",L.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",L.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",L.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",L.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",L.FRAG_LOAD_ERROR="fragLoadError",L.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",L.FRAG_DECRYPT_ERROR="fragDecryptError",L.FRAG_PARSING_ERROR="fragParsingError",L.REMUX_ALLOC_ERROR="remuxAllocError",L.KEY_LOAD_ERROR="keyLoadError",L.KEY_LOAD_TIMEOUT="keyLoadTimeOut",L.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",L.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",L.BUFFER_APPEND_ERROR="bufferAppendError",L.BUFFER_APPENDING_ERROR="bufferAppendingError",L.BUFFER_STALLED_ERROR="bufferStalledError",L.BUFFER_FULL_ERROR="bufferFullError",L.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",L.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",L.INTERNAL_EXCEPTION="internalException",L.INTERNAL_ABORTED="aborted",L.UNKNOWN="unknown"})(_||(_={}))},"./src/events.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"Events",function(){return M});var M;(function(_){_.MEDIA_ATTACHING="hlsMediaAttaching",_.MEDIA_ATTACHED="hlsMediaAttached",_.MEDIA_DETACHING="hlsMediaDetaching",_.MEDIA_DETACHED="hlsMediaDetached",_.BUFFER_RESET="hlsBufferReset",_.BUFFER_CODECS="hlsBufferCodecs",_.BUFFER_CREATED="hlsBufferCreated",_.BUFFER_APPENDING="hlsBufferAppending",_.BUFFER_APPENDED="hlsBufferAppended",_.BUFFER_EOS="hlsBufferEos",_.BUFFER_FLUSHING="hlsBufferFlushing",_.BUFFER_FLUSHED="hlsBufferFlushed",_.MANIFEST_LOADING="hlsManifestLoading",_.MANIFEST_LOADED="hlsManifestLoaded",_.MANIFEST_PARSED="hlsManifestParsed",_.LEVEL_SWITCHING="hlsLevelSwitching",_.LEVEL_SWITCHED="hlsLevelSwitched",_.LEVEL_LOADING="hlsLevelLoading",_.LEVEL_LOADED="hlsLevelLoaded",_.LEVEL_UPDATED="hlsLevelUpdated",_.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",_.LEVELS_UPDATED="hlsLevelsUpdated",_.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",_.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",_.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",_.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",_.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",_.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",_.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",_.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",_.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",_.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",_.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",_.CUES_PARSED="hlsCuesParsed",_.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",_.INIT_PTS_FOUND="hlsInitPtsFound",_.FRAG_LOADING="hlsFragLoading",_.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",_.FRAG_LOADED="hlsFragLoaded",_.FRAG_DECRYPTED="hlsFragDecrypted",_.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",_.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",_.FRAG_PARSING_METADATA="hlsFragParsingMetadata",_.FRAG_PARSED="hlsFragParsed",_.FRAG_BUFFERED="hlsFragBuffered",_.FRAG_CHANGED="hlsFragChanged",_.FPS_DROP="hlsFpsDrop",_.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",_.ERROR="hlsError",_.DESTROYING="hlsDestroying",_.KEY_LOADING="hlsKeyLoading",_.KEY_LOADED="hlsKeyLoaded",_.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",_.BACK_BUFFER_REACHED="hlsBackBufferReached"})(M||(M={}))},"./src/hls.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return i});var M=m("./node_modules/url-toolkit/src/url-toolkit.js"),_=m.n(M),L=m("./src/loader/playlist-loader.ts"),C=m("./src/loader/key-loader.ts"),b=m("./src/controller/id3-track-controller.ts"),O=m("./src/controller/latency-controller.ts"),A=m("./src/controller/level-controller.ts"),y=m("./src/controller/fragment-tracker.ts"),T=m("./src/controller/stream-controller.ts"),D=m("./src/is-supported.ts"),E=m("./src/utils/logger.ts"),g=m("./src/config.ts"),p=m("./node_modules/eventemitter3/index.js"),u=m.n(p),e=m("./src/events.ts"),s=m("./src/errors.ts");function c(r,o){for(var d=0;d<o.length;d++){var t=o[d];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function v(r,o,d){return o&&c(r.prototype,o),d&&c(r,d),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(d){d===void 0&&(d={}),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(g.mergeConfig)(r.DefaultConfig,d);this.userConfig=d,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(g.enableStreamingMode)(t);var n=t.abrController,l=t.bufferController,a=t.capLevelController,f=t.fpsController,h=this.abrController=new n(this),S=this.bufferController=new l(this),x=this.capLevelController=new a(this),P=new f(this),k=new L.default(this),B=new C.default(this),U=new b.default(this),W=this.levelController=new A.default(this),G=new y.FragmentTracker(this),z=this.streamController=new T.default(this,G);x.setStreamController(z),P.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[h,S,x,P,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(O.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,l){if(t){var a=n?new t(this,n):new t(this);return l&&l.push(a),a}return null},o.on=function(t,n,l){l===void 0&&(l=this),this._emitter.on(t,n,l)},o.once=function(t,n,l){l===void 0&&(l=this),this._emitter.once(t,n,l)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,l,a){l===void 0&&(l=this),this._emitter.off(t,n,l,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,l){return this._emitter.emit(t,n,l)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(l){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:l})}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,l=this.url,a=this.url=M.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&l&&l!==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)},v(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 l=t.length,a=0;a<l;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,l;return n===-1&&t&&t.length?l=t.length-1:l=n,l}},{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:g.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isSupported",function(){return L}),m.d(R,"changeTypeSupported",function(){return C});var M=m("./src/utils/mediasource-helper.ts");function _(){return self.SourceBuffer||self.WebKitSourceBuffer}function L(){var b=Object(M.getMediaSource)();if(!b)return!1;var O=_(),A=b&&typeof b.isTypeSupported=="function"&&b.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!A&&!!y}function C(){var b,O=_();return typeof(O==null||(b=O.prototype)===null||b===void 0?void 0:b.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"DateRangeAttribute",function(){return A}),m.d(R,"DateRange",function(){return y});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/attr-list.ts"),L=m("./src/utils/logger.ts");function C(){return C=Object.assign?Object.assign.bind():function(T){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var g in E)Object.prototype.hasOwnProperty.call(E,g)&&(T[g]=E[g])}return T},C.apply(this,arguments)}function b(T,D){for(var E=0;E<D.length;E++){var g=D[E];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(T,g.key,g)}}function O(T,D,E){return D&&b(T.prototype,D),E&&b(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var A;(function(T){T.ID="ID",T.CLASS="CLASS",T.START_DATE="START-DATE",T.DURATION="DURATION",T.END_DATE="END-DATE",T.END_ON_NEXT="END-ON-NEXT",T.PLANNED_DURATION="PLANNED-DURATION",T.SCTE35_OUT="SCTE35-OUT",T.SCTE35_IN="SCTE35-IN"})(A||(A={}));var y=function(){function T(D,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var g=E.attr;for(var p in g)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==g[p]){L.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=C(new _.AttrList({}),g,D)}if(this.attr=D,this._startDate=new Date(D[A.START_DATE]),A.END_DATE in this.attr){var u=new Date(this.attr[A.END_DATE]);Object(M.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}return O(T,[{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(A.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(A.DURATION);if(Object(M.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(M.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return E}),m.d(R,"LoadError",function(){return p});var M=m("./src/polyfills/number.ts"),_=m("./src/errors.ts");function L(u,e){u.prototype=Object.create(e.prototype),u.prototype.constructor=u,y(u,e)}function C(u){var e=typeof Map=="function"?new Map:void 0;return C=function(c){if(c===null||!A(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(c))return e.get(c);e.set(c,v)}function v(){return b(c,arguments,T(this).constructor)}return v.prototype=Object.create(c.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),y(v,c)},C(u)}function b(u,e,s){return O()?b=Reflect.construct.bind():b=function(v,i,r){var o=[null];o.push.apply(o,i);var d=Function.bind.apply(v,o),t=new d;return r&&y(t,r.prototype),t},b.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,v){return c.__proto__=v,c},y(u,e)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},T(u)}var D=Math.pow(2,17),E=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=u.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(c,v){var i=this,r=c.url;if(!r)return Promise.reject(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){i.loader&&i.loader.destroy();var a=i.loader=c.loader=d?new d(o):new t(o),f=g(c),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:c.sn==="initSegment"?1/0:D};c.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){i.resetLoader(c,a),n({frag:c,part:null,payload:x.data,networkDetails:B})},onError:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,response:x,networkDetails:k}))},onAbort:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,networkDetails:k}))},onTimeout:function(x,P,k){i.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,networkDetails:k}))},onProgress:function(x,P,k,B){v&&v({frag:c,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(c,v,i){var r=this;this.abort();var o=this.config,d=o.fLoader,t=o.loader;return new Promise(function(n,l){r.loader&&r.loader.destroy();var a=r.loader=c.loader=d?new d(o):new t(o),f=g(c,v),h={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};v.stats=a.stats,a.load(f,h,{onSuccess:function(x,P,k,B){r.resetLoader(c,a),r.updateStatsFromPart(c,v);var U={frag:c,part:v,payload:x.data,networkDetails:B};i(U),n(U)},onError:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,part:v,response:x,networkDetails:k}))},onAbort:function(x,P,k){c.stats.aborted=v.stats.aborted,r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,part:v,networkDetails:k}))},onTimeout:function(x,P,k){r.resetLoader(c,a),l(new p({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,part:v,networkDetails:k}))}})})},e.updateStatsFromPart=function(c,v){var i=c.stats,r=v.stats,o=r.total;if(i.loaded+=r.loaded,o){var d=Math.round(c.duration/v.duration),t=Math.min(Math.round(i.loaded/o),d),n=d-t,l=n*Math.round(i.loaded/t);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var a=i.loading,f=r.loading;a.start?a.first+=f.first-f.start:(a.start=f.start,a.first=f.first),a.end=f.end},e.resetLoader=function(c,v){c.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},u}();function g(u,e){e===void 0&&(e=null);var s=e||u,c={frag:u,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},v=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(M.isFiniteNumber)(v)&&Object(M.isFiniteNumber)(i)&&(c.rangeStart=v,c.rangeEnd=i),c}var p=function(u){L(e,u);function e(s){for(var c,v=arguments.length,i=new Array(v>1?v-1:0),r=1;r<v;r++)i[r-1]=arguments[r];return c=u.call.apply(u,[this].concat(i))||this,c.data=void 0,c.data=s,c}return e}(C(Error))},"./src/loader/fragment.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ElementaryStreamTypes",function(){return E}),m.d(R,"BaseSegment",function(){return g}),m.d(R,"Fragment",function(){return p}),m.d(R,"Part",function(){return u});var M=m("./src/polyfills/number.ts"),_=m("./node_modules/url-toolkit/src/url-toolkit.js"),L=m.n(_),C=m("./src/utils/logger.ts"),b=m("./src/loader/level-key.ts"),O=m("./src/loader/load-stats.ts");function A(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(v,i){return v.__proto__=i,v},y(e,s)}function T(e,s){for(var c=0;c<s.length;c++){var v=s[c];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(e,v.key,v)}}function D(e,s,c){return s&&T(e.prototype,s),c&&T(e,c),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var g=function(){function e(c){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[E.AUDIO]=null,v[E.VIDEO]=null,v[E.AUDIOVIDEO]=null,v),this.baseurl=c}var s=e.prototype;return s.setByteRange=function(v,i){var r=v.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(_.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),e}(),p=function(e){A(s,e);function s(v,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 O.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=v,r}var c=s.prototype;return c.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},c.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=b.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},c.setElementaryStreamInfo=function(i,r,o,d,t,n){n===void 0&&(n=!1);var l=this.elementaryStreams,a=l[i];if(!a){l[i]={startPTS:r,endPTS:o,startDTS:d,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,d),a.endDTS=Math.max(a.endDTS,t)},c.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&&C.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(M.isFiniteNumber)(this.programDateTime))return null;var i=Object(M.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}(g),u=function(e){A(s,e);function s(c,v,i,r,o){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new O.LoadStats,d.duration=c.decimalFloatingPoint("DURATION"),d.gap=c.bool("GAP"),d.independent=c.bool("INDEPENDENT"),d.relurl=c.enumeratedString("URI"),d.fragment=v,d.index=r;var t=c.enumeratedString("BYTERANGE");return t&&d.setByteRange(t,o),o&&(d.fragOffset=o.fragOffset+o.duration),d}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 v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),s}(g)},"./src/loader/key-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return C});var M=m("./src/events.ts"),_=m("./src/errors.ts"),L=m("./src/utils/logger.ts"),C=function(){function b(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var O=b.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(M.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(M.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var y in this.loaders){var T=this.loaders[y];T&&T.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(y,T){var D=T.frag,E=D.type,g=this.loaders[E];if(!D.decryptdata){L.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(g&&(L.logger.warn("abort previous key loader for type:"+E),g.abort()),!p){L.logger.warn("key uri is falsy");return}var e=u.loader,s=D.loader=this.loaders[E]=new e(u);this.decrypturl=p,this.decryptkey=null;var c={url:p,frag:D,responseType:"arraybuffer"},v={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(c,v,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(M.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(y,T,D){var E=D.frag;if(!E.decryptdata){L.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(M.Events.KEY_LOADED,{frag:E})},O.loaderror=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},O.loadtimeout=function(y,T){var D=T.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(M.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},b}()},"./src/loader/level-details.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"LevelDetails",function(){return b});var M=m("./src/polyfills/number.ts");function _(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function L(O,A,y){return A&&_(O.prototype,A),y&&_(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var C=10,b=function(){function O(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 A=O.prototype;return A.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-T.lastPartSn,E=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!E||!!D,this.advanced=this.endSN>T.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},L(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(M.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||C}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var D=this.driftEnd-this.driftStart;return D*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.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 T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"LevelKey",function(){return b});var M=m("./node_modules/url-toolkit/src/url-toolkit.js"),_=m.n(M);function L(O,A){for(var y=0;y<A.length;y++){var T=A[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function C(O,A,y){return A&&L(O.prototype,A),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var b=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(A,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(M.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return C(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"LoadStats",function(){return M});var M=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,m){"use strict";m.r(R),m.d(R,"default",function(){return c});var M=m("./src/polyfills/number.ts"),_=m("./node_modules/url-toolkit/src/url-toolkit.js"),L=m.n(_),C=m("./src/loader/date-range.ts"),b=m("./src/loader/fragment.ts"),O=m("./src/loader/level-details.ts"),A=m("./src/loader/level-key.ts"),y=m("./src/utils/attr-list.ts"),T=m("./src/utils/logger.ts"),D=m("./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,g=/#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"),u=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,l;return e.test((n=(l=_.parseURL(t))===null||l===void 0?void 0:l.path)!=null?n:"")}var c=function(){function t(){}return t.findGroup=function(l,a){for(var f=0;f<l.length;f++){var h=l[f];if(h.id===a)return h}},t.convertAVC1ToAVCOTI=function(l){var a=l.split(".");if(a.length>2){var f=a.shift()+".";return f+=parseInt(a.shift()).toString(16),f+=("000"+parseInt(a.shift()).toString(16)).slice(-4),f}return l},t.resolve=function(l,a){return _.buildAbsoluteURL(a,l,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(l,a){var f=[],h={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(l))!=null;)if(x[1]){var P=new y.AttrList(x[1]),k={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:t.resolve(x[2],a)},B=P.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),v((P.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),f.push(k)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,h[U["DATA-ID"]]=U)}return{levels:f,sessionData:S?h:null}},t.parseMasterPlaylistMedia=function(l,a,f,h){h===void 0&&(h=[]);var S,x=[],P=0;for(g.lastIndex=0;(S=g.exec(l))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===f){var B={attrs:k,bitrate:0,id:P++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:f,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(h.length){var U=t.findGroup(h,B.groupId)||h[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}x.push(B)}}return x},t.parseLevelPlaylist=function(l,a,f,h,S){var x=new O.LevelDetails(a),P=x.fragments,k=null,B=0,U=0,W=0,G=0,z=null,Y=new b.Fragment(h,a),$,Z,q,ie=-1,ne=!1;for(p.lastIndex=0,x.m3u8=l;($=p.exec(l))!==null;){ne&&(ne=!1,Y=new b.Fragment(h,a),Y.start=W,Y.sn=B,Y.cc=G,Y.level=f,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(M.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=f,Y.cc=G,Y.urlId=S,P.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=P.length);else{if($=$[0].match(u),!$){T.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":x.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":B=x.startSN=parseInt(re);break;case"SKIP":{var me=new y.AttrList(re),Te=me.decimalInteger("SKIPPED-SEGMENTS");if(Object(M.isFiniteNumber)(Te)){x.skippedSegments=Te;for(var Me=Te;Me--;)P.unshift(null);B+=Te}var Ae=me.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ae&&(x.recentlyRemovedDateranges=Ae.split(" "));break}case"TARGETDURATION":x.targetduration=parseFloat(re);break;case"VERSION":x.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":x.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 we=new y.AttrList(re),Re=new C.DateRange(we,x.dateRanges[we.ID]);Re.isValid||x.skippedSegments?x.dateRanges[Re.id]=Re:T.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 ke,_e=new y.AttrList(re),Be=_e.enumeratedString("METHOD"),Ke=_e.URI,We=_e.hexadecimalInteger("IV"),Ue=_e.enumeratedString("KEYFORMATVERSIONS"),Ze=_e.enumeratedString("KEYID"),Ce=(ke=_e.enumeratedString("KEYFORMAT"))!=null?ke:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf(Ce)>-1){T.logger.warn("Keyformat "+Ce+" is not supported from the manifest");continue}else if(Ce!=="identity")continue;Be&&(q=A.LevelKey.fromURL(a,Ke),Ke&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Be)>=0&&(q.method=Be,q.keyFormat=Ce,Ze&&(q.keyID=Ze),Ue&&(q.keyFormatVersions=Ue),q.iv=We));break}case"START":{var Oe=new y.AttrList(re),Pe=Oe.decimalFloatingPoint("TIME-OFFSET");Object(M.isFiniteNumber)(Pe)&&(x.startTimeOffset=Pe);break}case"MAP":{var Ve=new y.AttrList(re);if(Y.duration){var Ie=new b.Fragment(h,a);d(Ie,Ve,f,q),k=Ie,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else d(Y,Ve,f,q),k=Y,ne=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(re);x.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new y.AttrList(re);x.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var je=x.partList;je||(je=x.partList=[]);var st=U>0?je[je.length-1]:void 0,vt=U++,ze=new b.Part(new y.AttrList(re),Y,a,vt,st);je.push(ze),Y.duration+=ze.duration;break}case"PRELOAD-HINT":{var xt=new y.AttrList(re);x.preloadHint=xt;break}case"RENDITION-REPORT":{var gt=new y.AttrList(re);x.renditionReports=x.renditionReports||[],x.renditionReports.push(gt);break}default:T.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(P.pop(),W-=z.duration,x.partList&&(x.fragmentHint=z)):x.partList&&(o(Y,z),Y.cc=G,x.fragmentHint=Y);var it=P.length,ot=P[0],nt=P[it-1];if(W+=x.skippedSegments*x.targetduration,W>0&&it&&nt){x.averagetargetduration=W/it;var mt=nt.sn;x.endSN=mt!=="initSegment"?mt:0,ot&&(x.startCC=ot.cc,ot.initSegment||x.fragments.every(function(ct){return ct.relurl&&s(ct.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new b.Fragment(h,a),Y.relurl=nt.relurl,Y.level=f,Y.sn="initSegment",ot.initSegment=Y,x.needSidxRanges=!0))}else x.endSN=0,x.startCC=0;return x.fragmentHint&&(W+=x.fragmentHint.duration),x.totalduration=W,x.endCC=G,ie>0&&r(P,ie),x},t}();function v(t,n){["video","audio","text"].forEach(function(l){var a=t.filter(function(h){return Object(D.isCodecType)(h,l)});if(a.length){var f=a.filter(function(h){return h.lastIndexOf("avc1",0)===0||h.lastIndexOf("mp4a",0)===0});n[l+"Codec"]=f.length>0?f[0]:a[0],t=t.filter(function(h){return a.indexOf(h)===-1})}}),n.unknownCodecs=t}function i(t,n,l){var a=n[l];a&&(t[l]=a)}function r(t,n){for(var l=t[n],a=n;a--;){var f=t[a];if(!f)return;f.programDateTime=l.programDateTime-f.duration*1e3,l=f}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(M.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function d(t,n,l,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=l,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/events.ts"),L=m("./src/errors.ts"),C=m("./src/utils/logger.ts"),b=m("./src/utils/mp4-tools.ts"),O=m("./src/loader/m3u8-parser.ts"),A=m("./src/types/loader.ts"),y=m("./src/utils/attr-list.ts");function T(g){var p=g.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function D(g,p){var u=g.url;return(u===void 0||u.indexOf("data:")===0)&&(u=p.url),u}var E=function(){function g(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var p=g.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,c=s.pLoader,v=s.loader,i=c||v,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 c=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:c,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var c=s.id,v=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var c=s.id,v=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:c,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,c=this.hls.config,v=this.getInternalLoader(e);if(v){var i=v.context;if(i&&i.url===e.url){C.logger.trace("[playlist-loader]: playlist request ongoing");return}C.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),v.abort()}var r,o,d,t;switch(e.type){case A.PlaylistContextType.MANIFEST:r=c.manifestLoadingMaxRetry,o=c.manifestLoadingTimeOut,d=c.manifestLoadingRetryDelay,t=c.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:r=0,o=c.levelLoadingTimeOut;break;default:r=c.levelLoadingMaxRetry,o=c.levelLoadingTimeOut,d=c.levelLoadingRetryDelay,t=c.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var l=n.partTarget,a=n.targetduration;l&&a&&(o=Math.min(Math.max(l*3,a*.8)*1e3,o))}}var f={timeout:o,maxRetry:r,retryDelay:d,maxRetryDelay:t,highWaterMark:0},h={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(e,f,h)},p.loadsuccess=function(e,s,c,v){if(v===void 0&&(v=null),c.isSidxRequest){this.handleSidxRequest(e,c),this.handlePlaylistLoaded(e,s,c,v);return}this.resetInternalLoader(c.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,c,"no EXTM3U delimiter",v);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,c,v):this.handleMasterPlaylist(e,s,c,v)},p.loaderror=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!1,e)},p.loadtimeout=function(e,s,c){c===void 0&&(c=null),this.handleNetworkError(s,c,!0)},p.handleMasterPlaylist=function(e,s,c,v){var i=this.hls,r=e.data,o=D(e,c),d=O.default.parseMasterPlaylist(r,o),t=d.levels,n=d.sessionData;if(!t.length){this.handleManifestParsingError(e,c,"no level found in manifest",v);return}var l=t.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),a=t.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),f=O.default.parseMasterPlaylistMedia(r,o,"AUDIO",l),h=O.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=O.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(f.length){var x=f.some(function(P){return!P.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(C.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(_.Events.MANIFEST_LOADED,{levels:t,audioTracks:f,subtitles:h,captions:S,url:o,stats:s,networkDetails:v,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,c,v){var i=this.hls,r=c.id,o=c.level,d=c.type,t=D(e,c),n=Object(M.isFiniteNumber)(r)?r:0,l=Object(M.isFiniteNumber)(o)?o:n,a=T(c),f=O.default.parseLevelPlaylist(e.data,t,l,a,n);if(!f.fragments.length){i.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof c.level=="number"?c.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var h={attrs:new y.AttrList({}),bitrate:0,details:f,name:"",url:t};i.trigger(_.Events.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:t,stats:s,networkDetails:v,sessionData:null})}if(s.parsing.end=performance.now(),f.needSidxRanges){var S,x=(S=f.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:x,isSidxRequest:!0,type:d,level:o,levelDetails:f,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}c.levelDetails=f,this.handlePlaylistLoaded(e,s,c,v)},p.handleSidxRequest=function(e,s){var c=new Uint8Array(e.data),v=Object(b.findBox)(c,["sidx"])[0];if(!!v){var i=Object(b.parseSegmentIndex)(v);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(d,t){var n=d.info,l=o.fragments[t];if(l.byteRange.length===0&&l.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),l.initSegment){var a=Object(b.findBox)(c,["moov"])[0],f=a?a.length:null;l.initSegment.setByteRange(String(f)+"@0")}})}}},p.handleManifestParsingError=function(e,s,c,v){this.hls.trigger(_.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:c,response:e,context:s,networkDetails:v})},p.handleNetworkError=function(e,s,c,v){c===void 0&&(c=!1),C.logger.warn("[playlist-loader]: A network "+(c?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=L.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=c?L.ErrorDetails.MANIFEST_LOAD_TIMEOUT:L.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case A.PlaylistContextType.LEVEL:i=c?L.ErrorDetails.LEVEL_LOAD_TIMEOUT:L.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=c?L.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=c?L.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:L.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var d={type:L.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};v&&(d.response=v),this.hls.trigger(_.Events.ERROR,d)},p.handlePlaylistLoaded=function(e,s,c,v){var i=c.type,r=c.level,o=c.id,d=c.groupId,t=c.loader,n=c.levelDetails,l=c.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,c,"invalid target duration",v);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(_.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(_.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(_.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:d||"",stats:s,networkDetails:v,deliveryDirectives:l});break}},g}();R.default=E},"./src/polyfills/number.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isFiniteNumber",function(){return M}),m.d(R,"MAX_SAFE_INTEGER",function(){return _});var M=Number.isFinite||function(L){return typeof L=="number"&&isFinite(L)},_=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,m){"use strict";m.r(R);var M=function(){function _(){}return _.getSilentFrame=function(C,b){switch(C){case"mp4a.40.2":if(b===1)return new Uint8Array([0,200,0,128,35,128]);if(b===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(b===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(b===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(b===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(b===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(b===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(b===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(b===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}},_}();R.default=M},"./src/remux/mp4-generator.ts":function(j,R,m){"use strict";m.r(R);var M=Math.pow(2,32)-1,_=function(){function L(){}return L.init=function(){L.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var b;for(b in L.types)L.types.hasOwnProperty(b)&&(L.types[b]=[b.charCodeAt(0),b.charCodeAt(1),b.charCodeAt(2),b.charCodeAt(3)]);var O=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]),A=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);L.HDLR_TYPES={video:O,audio:A};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);L.STTS=L.STSC=L.STCO=T,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,D,g,D,E),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,y))},L.box=function(b){for(var O=8,A=arguments.length,y=new Array(A>1?A-1:0),T=1;T<A;T++)y[T-1]=arguments[T];for(var D=y.length,E=D;D--;)O+=y[D].byteLength;var g=new Uint8Array(O);for(g[0]=O>>24&255,g[1]=O>>16&255,g[2]=O>>8&255,g[3]=O&255,g.set(b,4),D=0,O=8;D<E;D++)g.set(y[D],O),O+=y[D].byteLength;return g},L.hdlr=function(b){return L.box(L.types.hdlr,L.HDLR_TYPES[b])},L.mdat=function(b){return L.box(L.types.mdat,b)},L.mdhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1));return L.box(L.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},L.mdia=function(b){return L.box(L.types.mdia,L.mdhd(b.timescale,b.duration),L.hdlr(b.type),L.minf(b))},L.mfhd=function(b){return L.box(L.types.mfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255]))},L.minf=function(b){return b.type==="audio"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(b)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(b))},L.moof=function(b,O,A){return L.box(L.types.moof,L.mfhd(b),L.traf(A,O))},L.moov=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trak(b[O]);return L.box.apply(null,[L.types.moov,L.mvhd(b[0].timescale,b[0].duration)].concat(A).concat(L.mvex(b)))},L.mvex=function(b){for(var O=b.length,A=[];O--;)A[O]=L.trex(b[O]);return L.box.apply(null,[L.types.mvex].concat(A))},L.mvhd=function(b,O){O*=b;var A=Math.floor(O/(M+1)),y=Math.floor(O%(M+1)),T=new Uint8Array([1,0,0,0,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,A>>24,A>>16&255,A>>8&255,A&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 L.box(L.types.mvhd,T)},L.sdtp=function(b){var O=b.samples||[],A=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,A[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return L.box(L.types.sdtp,A)},L.stbl=function(b){return L.box(L.types.stbl,L.stsd(b),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))},L.avc1=function(b){var O=[],A=[],y,T,D;for(y=0;y<b.sps.length;y++)T=b.sps[y],D=T.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(T));for(y=0;y<b.pps.length;y++)T=b.pps[y],D=T.byteLength,A.push(D>>>8&255),A.push(D&255),A=A.concat(Array.prototype.slice.call(T));var E=L.box(L.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|b.sps.length].concat(O).concat([b.pps.length]).concat(A))),g=b.width,p=b.height,u=b.pixelRatio[0],e=b.pixelRatio[1];return L.box(L.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&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,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,e>>24,e>>16&255,e>>8&255,e&255])))},L.esds=function(b){var O=b.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(b.config).concat([6,1,2]))},L.mp4a=function(b){var O=b.samplerate;return L.box(L.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),L.box(L.types.esds,L.esds(b)))},L.mp3=function(b){var O=b.samplerate;return L.box(L.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},L.stsd=function(b){return b.type==="audio"?b.segmentCodec==="mp3"&&b.codec==="mp3"?L.box(L.types.stsd,L.STSD,L.mp3(b)):L.box(L.types.stsd,L.STSD,L.mp4a(b)):L.box(L.types.stsd,L.STSD,L.avc1(b))},L.tkhd=function(b){var O=b.id,A=b.duration*b.timescale,y=b.width,T=b.height,D=Math.floor(A/(M+1)),E=Math.floor(A%(M+1));return L.box(L.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&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,T>>8&255,T&255,0,0]))},L.traf=function(b,O){var A=L.sdtp(b),y=b.id,T=Math.floor(O/(M+1)),D=Math.floor(O%(M+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),L.box(L.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,D>>24,D>>16&255,D>>8&255,D&255])),L.trun(b,A.length+16+20+8+16+8+8),A)},L.trak=function(b){return b.duration=b.duration||4294967295,L.box(L.types.trak,L.tkhd(b),L.mdia(b))},L.trex=function(b){var O=b.id;return L.box(L.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},L.trun=function(b,O){var A=b.samples||[],y=A.length,T=12+16*y,D=new Uint8Array(T),E,g,p,u,e,s;for(O+=8+T,D.set([b.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),E=0;E<y;E++)g=A[E],p=g.duration,u=g.size,e=g.flags,s=g.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,u>>>24&255,u>>>16&255,u>>>8&255,u&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 L.box(L.types.trun,D)},L.initSegment=function(b){L.types||L.init();var O=L.moov(b),A=new Uint8Array(L.FTYP.byteLength+O.byteLength);return A.set(L.FTYP),A.set(O,L.FTYP.byteLength),A},L}();_.types=void 0,_.HDLR_TYPES=void 0,_.STTS=void 0,_.STSC=void 0,_.STCO=void 0,_.STSZ=void 0,_.VMHD=void 0,_.SMHD=void 0,_.STSD=void 0,_.FTYP=void 0,_.DINF=void 0,R.default=_},"./src/remux/mp4-remuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return e}),m.d(R,"normalizePts",function(){return s}),m.d(R,"flushTextTrackMetadataCueSamples",function(){return v}),m.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var M=m("./src/polyfills/number.ts"),_=m("./src/remux/aac-helper.ts"),L=m("./src/remux/mp4-generator.ts"),C=m("./src/events.ts"),b=m("./src/errors.ts"),O=m("./src/utils/logger.ts"),A=m("./src/types/loader.ts"),y=m("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(d){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(d[l]=n[l])}return d},T.apply(this,arguments)}var D=10*1e3,E=1024,g=1152,p=null,u=null,e=function(){function d(n,l,a,f){if(f===void 0&&(f=""),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=l,this.typeSupported=a,this.ISGenerated=!1,p===null){var h=navigator.userAgent||"",S=h.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(u===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);u=x?parseInt(x[1]):0}}var t=d.prototype;return t.destroy=function(){},t.resetTimeStamp=function(l){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=l},t.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(l){var a=!1,f=l.reduce(function(h,S){var x=S.pts-h;return x<-4294967296?(a=!0,s(h,S.pts)):x>0?h:S.pts},l[0].pts);return a&&O.logger.debug("PTS rollover detected"),f},t.remux=function(l,a,f,h,S,x,P,k){var B,U,W,G,z,Y,$=S,Z=S,q=l.pid>-1,ie=a.pid>-1,ne=a.samples.length,ae=l.samples.length>0,te=P&&ne>0||ne>1,fe=(!q||ae)&&(!ie||te)||this.ISGenerated||P;if(fe){this.ISGenerated||(W=this.generateIS(l,a,S));var de=this.isVideoContiguous,re=-1,Ee;if(te&&(re=c(a.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){O.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&&(O.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(l.samples[0].pts,Te)-Te,Ae=Me/a.inputTimeScale;$+=Math.max(0,Ae),Z+=Math.max(0,-Ae)}if(ae){if(l.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(l,a,S)),U=this.remuxAudio(l,$,this.isAudioContiguous,x,ie||te||k===A.PlaylistLevelType.AUDIO?Z:void 0),te){var we=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(l,a,S)),B=this.remuxVideo(a,Z,de,we)}}else te&&(B=this.remuxVideo(a,Z,de,0));B&&(B.firstKeyFrame=re,B.independent=re!==-1,B.firstKeyFramePTS=Ee)}}return this.ISGenerated&&(f.samples.length&&(z=v(f,S,this._initPTS,this._initDTS)),h.samples.length&&(G=i(h,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(l,a,f){var h=l.samples,S=a.samples,x=this.typeSupported,P={},k=!Object(M.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,G;if(k&&(U=W=1/0),l.config&&h.length){switch(l.timescale=l.samplerate,l.segmentCodec){case"mp3":x.mpeg?(B="audio/mpeg",l.codec=""):x.mp3&&(l.codec="mp3");break}P.audio={id:"audio",container:B,codec:l.codec,initSegment:l.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):L.default.initSegment([l]),metadata:{channelCount:l.channelCount}},k&&(G=l.inputTimeScale,U=W=h[0].pts-Math.round(G*f))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:L.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){G=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*f);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(P).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:P,initPTS:U,timescale:G}},t.remuxVideo=function(l,a,f,h){var S=l.inputTimeScale,x=l.samples,P=[],k=x.length,B=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,q=!1;if(!f||U===null){var ie=a*S,ne=x[0].pts-s(x[0].dts,x[0].pts);U=ie-ne}for(var ae=0;ae<k;ae++){var te=x[ae];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<x[ae>0?ae-1:ae].dts&&(q=!0)}q&&x.sort(function(Dt,Ut){var pt=Dt.dts-Ut.dts,Jt=Dt.pts-Ut.pts;return pt||Jt}),z=x[0].dts,Y=x[x.length-1].dts;var fe=Y-z,de=fe?Math.round(fe/(k-1)):G||l.inputTimeScale/30;if(f){var re=z-U,Ee=re>de,me=re<-1;if(Ee||me){Ee?O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),z=U;var Te=x[0].pts-re;x[0].dts=z,x[0].pts=Te,O.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,Ae=0,we=0;we<k;we++){for(var Re=x[we],ke=Re.units,_e=ke.length,Be=0,Ke=0;Ke<_e;Ke++)Be+=ke[Ke].data.length;Ae+=Be,Me+=_e,Re.length=Be,Re.dts=Math.max(Re.dts,z),$=Math.min(Re.pts,$),Z=Math.max(Re.pts,Z)}Y=x[k-1].dts;var We=Ae+4*Me+8,Ue;try{Ue=new Uint8Array(We)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:We,reason:"fail allocating video mdat "+We});return}var Ze=new DataView(Ue.buffer);Ze.setUint32(0,We),Ue.set(L.default.types.mdat,4);for(var Ce=!1,qe=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,Ie=0;Ie<k;Ie++){for(var Le=x[Ie],rt=Le.units,je=0,st=0,vt=rt.length;st<vt;st++){var ze=rt[st],xt=ze.data,gt=ze.data.byteLength;Ze.setUint32(W,gt),W+=4,Ue.set(xt,W),W+=gt,je+=4+gt}var it=void 0;if(Ie<k-1)G=x[Ie+1].dts-Le.dts,it=x[Ie+1].pts-Le.pts;else{var ot=this.config,nt=Ie>0?Le.dts-x[Ie-1].dts:de;if(it=Ie>0?Le.pts-x[Ie-1].pts:de,ot.stretchShortVideoTrack&&this.nextAudioPts!==null){var mt=Math.floor(ot.maxBufferHole*S),ct=(h?$+h*S:this.nextAudioPts)-Le.pts;ct>mt?(G=ct-nt,G<0?G=nt:Ce=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ct/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=nt}else G=nt}var Xt=Math.round(Le.pts-Le.dts);qe=Math.min(qe,G),Pe=Math.max(Pe,G),Oe=Math.min(Oe,it),Ve=Math.max(Ve,it),P.push(new r(Le.key,G,je,Xt))}if(P.length){if(p){if(p<70){var bt=P[0].flags;bt.dependsOn=2,bt.isNonSync=0}}else if(u&&Ve-Oe<Pe-qe&&de/Pe<.025&&P[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var St=z,Xe=0,kt=P.length;Xe<kt;Xe++){var Rt=St+P[Xe].duration,Bt=St+P[Xe].cts;if(Xe<kt-1){var Pt=Rt+P[Xe+1].cts;P[Xe].duration=Pt-Bt}else P[Xe].duration=Xe?P[Xe-1].duration:de;P[Xe].cts=0,St=Rt}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Ce||!G?de:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var Qt=L.default.moof(l.sequenceNumber++,z,T({},l,{samples:P})),$t="video",at={data1:Qt,data2:Ue,startPTS:$/S,endPTS:(Z+G)/S,startDTS:z/S,endDTS:U/S,type:$t,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:l.dropped};return l.samples=[],l.dropped=0,console.assert(Ue.length,"MDAT length must not be zero"),at},t.remuxAudio=function(l,a,f,h,S){var x=l.inputTimeScale,P=l.samplerate?l.samplerate:x,k=x/P,B=l.segmentCodec==="aac"?E:g,U=B*k,W=this._initPTS,G=l.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=l.samples,Z=G?0:8,q=this.nextAudioPts||-1,ie=a*x;if(this.isAudioContiguous=f=f||$.length&&q>0&&(h&&Math.abs(ie-q)<9e3||Math.abs(s($[0].pts-W,ie)-q)<20*U),$.forEach(function(ze){ze.pts=s(ze.pts-W,ie)}),!f||q<0){if($=$.filter(function(ze){return ze.pts>=0}),!$.length)return;S===0?q=0:h&&!Y?q=Math.max(0,ie):q=$[0].pts}if(l.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/x);if(re<=-ne*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(de/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/x)+" 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),O.logger.warn("[mp4-remuxer]: Injecting "+me+" audio frame @ "+(te/x).toFixed(3)+"s due to "+Math.round(1e3*re/x)+" ms gap.");for(var Te=0;Te<me;Te++){var Me=Math.max(te,0),Ae=_.default.getSilentFrame(l.manifestCodec||l.codec,l.channelCount);Ae||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=fe.unit.subarray()),$.splice(ae,0,{unit:Ae,pts:Me}),te+=U,ae++}}fe.pts=te,te+=U}for(var we=null,Re=null,ke,_e=0,Be=$.length;Be--;)_e+=$[Be].unit.byteLength;for(var Ke=0,We=$.length;Ke<We;Ke++){var Ue=$[Ke],Ze=Ue.unit,Ce=Ue.pts;if(Re!==null){var qe=z[Ke-1];qe.duration=Math.round((Ce-Re)/k)}else if(f&&l.segmentCodec==="aac"&&(Ce=q),we=Ce,_e>0){_e+=Z;try{ke=new Uint8Array(_e)}catch{this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MUX_ERROR,details:b.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating audio mdat "+_e});return}if(!G){var Oe=new DataView(ke.buffer);Oe.setUint32(0,_e),ke.set(L.default.types.mdat,4)}}else return;ke.set(Ze,Z);var Pe=Ze.byteLength;Z+=Pe,z.push(new r(!0,B,Pe,0)),Re=Ce}var Ve=z.length;if(!!Ve){var Ie=z[z.length-1];this.nextAudioPts=q=Re+k*Ie.duration;var Le=G?new Uint8Array(0):L.default.moof(l.sequenceNumber++,we/k,T({},l,{samples:z}));l.samples=[];var rt=we/x,je=q/x,st="audio",vt={data1:Le,data2:ke,startPTS:rt,endPTS:je,startDTS:rt,endDTS:je,type:st,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,console.assert(ke.length,"MDAT length must not be zero"),vt}},t.remuxEmptyAudio=function(l,a,f,h){var S=l.inputTimeScale,x=l.samplerate?l.samplerate:S,P=S/x,k=this.nextAudioPts,B=(k!==null?k:h.startDTS*S)+this._initDTS,U=h.endDTS*S+this._initDTS,W=P*E,G=Math.ceil((U-B)/W),z=_.default.getSilentFrame(l.manifestCodec||l.codec,l.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){O.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 l.samples=Y,this.remuxAudio(l,a,f,!1)},d}();function s(d,t){var n;if(t===null)return d;for(t<d?n=-8589934592:n=8589934592;Math.abs(d-t)>4294967296;)d+=n;return d}function c(d){for(var t=0;t<d.length;t++)if(d[t].key)return t;return-1}function v(d,t,n,l){var a=d.samples.length;if(!!a){for(var f=d.inputTimeScale,h=0;h<a;h++){var S=d.samples[h];S.pts=s(S.pts-n,t*f)/f,S.dts=s(S.dts-l,t*f)/f}var x=d.samples;return d.samples=[],{samples:x}}}function i(d,t,n){var l=d.samples.length;if(!!l){for(var a=d.inputTimeScale,f=0;f<l;f++){var h=d.samples[f];h.pts=s(h.pts-n,t*a)/a}d.samples.sort(function(x,P){return x.pts-P.pts});var S=d.samples;return d.samples=[],{samples:S}}}var r=function(t,n,l,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=l,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,m){"use strict";m.r(R);var M=m("./src/polyfills/number.ts"),_=m("./src/remux/mp4-remuxer.ts"),L=m("./src/utils/mp4-tools.ts"),C=m("./src/loader/fragment.ts"),b=m("./src/utils/logger.ts"),O=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 T=y.prototype;return T.destroy=function(){},T.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},T.resetNextTimestamp=function(){this.lastEndTime=null},T.resetInitSegment=function(E,g,p){this.audioCodec=g,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},T.generateInitSegment=function(E){var g=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(L.parseInitSegment)(E);g||(g=A(u.audio,C.ElementaryStreamTypes.AUDIO)),p||(p=A(u.video,C.ElementaryStreamTypes.VIDEO));var e={};u.audio&&u.video?e.audiovideo={container:"video/mp4",codec:g+","+p,initSegment:E,id:"main"}:u.audio?e.audio={container:"audio/mp4",codec:g,initSegment:E,id:"audio"}:u.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:b.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,g,p,u,e){var s,c=this.initPTS,v=this.lastEndTime,i={audio:void 0,video:void 0,text:u,id3:p,initSegment:void 0};Object(M.isFiniteNumber)(v)||(v=this.lastEndTime=e||0);var r=g.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(r),d=this.initData),!d||!d.length)return b.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(L.getStartDTS)(d,r);Object(M.isFiniteNumber)(c)||(this.initPTS=o.initPTS=c=t-e);var n=Object(L.getDuration)(r,d),l=E?t-c:v,a=l+n;Object(L.offsetStartDTS)(d,r,c),n>0?this.lastEndTime=a:(b.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!d.audio,h=!!d.video,S="";f&&(S+="audio"),h&&(S+="video");var x={data1:r,startPTS:l,startDTS:l,endPTS:a,endDTS:a,type:S,hasAudio:f,hasVideo:h,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=o;var P=(s=this.initPTS)!=null?s:0;return i.id3=Object(_.flushTextTrackMetadataCueSamples)(p,e,P,P),u.samples.length&&(i.text=Object(_.flushTextTrackUserdataCueSamples)(u,e,P)),i},y}();function A(y,T){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"||T===C.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=O},"./src/task-loop.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var L=_.prototype;return L.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},L.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},L.onHandlerDestroyed=function(){},L.hasInterval=function(){return!!this._tickInterval},L.hasNextTick=function(){return!!this._tickTimer},L.setInterval=function(b){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,b),!0)},L.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},L.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},L.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},L.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},L.doTick=function(){},_}()},"./src/types/cmcd.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"CMCDVersion",function(){return M}),m.d(R,"CMCDObjectType",function(){return _}),m.d(R,"CMCDStreamingFormat",function(){return L}),m.d(R,"CMCDStreamType",function(){return C});var M=1,_;(function(b){b.MANIFEST="m",b.AUDIO="a",b.VIDEO="v",b.MUXED="av",b.INIT="i",b.CAPTION="c",b.TIMED_TEXT="tt",b.KEY="k",b.OTHER="o"})(_||(_={}));var L;(function(b){b.DASH="d",b.HLS="h",b.SMOOTH="s",b.OTHER="o"})(L||(L={}));var C;(function(b){b.VOD="v",b.LIVE="l"})(C||(C={}))},"./src/types/demuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"MetadataSchema",function(){return M});var M;(function(_){_.audioId3="org.id3",_.dateRange="com.apple.quicktime.HLS",_.emsg="https://aomedia.org/emsg/ID3"})(M||(M={}))},"./src/types/level.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"HlsSkip",function(){return L}),m.d(R,"getSkipValue",function(){return C}),m.d(R,"HlsUrlParameters",function(){return b}),m.d(R,"Level",function(){return O});function M(A,y){for(var T=0;T<y.length;T++){var D=y[T];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(A,D.key,D)}}function _(A,y,T){return y&&M(A.prototype,y),T&&M(A,T),Object.defineProperty(A,"prototype",{writable:!1}),A}var L;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(L||(L={}));function C(A,y){var T=A.canSkipUntil,D=A.canSkipDateRanges,E=A.endSN,g=y!==void 0?y-E:0;return T&&g<T?D?L.v2:L.Yes:L.No}var b=function(){function A(T,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=D,this.skip=E}var y=A.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()},A}(),O=function(){function A(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(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return _(A,[{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(T){var D=T%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),A}()},"./src/types/loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"PlaylistContextType",function(){return M}),m.d(R,"PlaylistLevelType",function(){return _});var M;(function(L){L.MANIFEST="manifest",L.LEVEL="level",L.AUDIO_TRACK="audioTrack",L.SUBTITLE_TRACK="subtitleTrack"})(M||(M={}));var _;(function(L){L.MAIN="main",L.AUDIO="audio",L.SUBTITLE="subtitle"})(_||(_={}))},"./src/types/transmuxer.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"ChunkMetadata",function(){return M});var M=function(C,b,O,A,y,T){A===void 0&&(A=0),y===void 0&&(y=-1),T===void 0&&(T=!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=_(),this.buffering={audio:_(),video:_(),audiovideo:_()},this.level=C,this.sn=b,this.id=O,this.size=A,this.part=y,this.partial=T};function _(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"AttrList",function(){return L});var M=/^(\d+)x(\d+)$/,_=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function C(O){typeof O=="string"&&(O=C.parseAttrList(O));for(var A in O)O.hasOwnProperty(A)&&(this[A]=O[A])}var b=C.prototype;return b.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var T=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)T[D]=parseInt(y.slice(D*2,D*2+2),16);return T}else return null},b.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},b.decimalFloatingPoint=function(A){return parseFloat(this[A])},b.optionalFloat=function(A,y){var T=this[A];return T?parseFloat(T):y},b.enumeratedString=function(A){return this[A]},b.bool=function(A){return this[A]==="YES"},b.decimalResolution=function(A){var y=M.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},C.parseAttrList=function(A){var y,T={},D='"';for(_.lastIndex=0;(y=_.exec(A))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),T[y[1]]=E}return T},C}()},"./src/utils/binary-search.ts":function(j,R,m){"use strict";m.r(R);var M={search:function(L,C){for(var b=0,O=L.length-1,A=null,y=null;b<=O;){A=(b+O)/2|0,y=L[A];var T=C(y);if(T>0)b=A+1;else if(T<0)O=A-1;else return y}return null}};R.default=M},"./src/utils/buffer-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"BufferHelper",function(){return L});var M=m("./src/utils/logger.ts"),_={length:0,start:function(){return 0},end:function(){return 0}},L=function(){function C(){}return C.isBuffered=function(O,A){try{if(O){for(var y=C.getBuffered(O),T=0;T<y.length;T++)if(A>=y.start(T)&&A<=y.end(T))return!0}}catch{}return!1},C.bufferInfo=function(O,A,y){try{if(O){var T=C.getBuffered(O),D=[],E;for(E=0;E<T.length;E++)D.push({start:T.start(E),end:T.end(E)});return this.bufferedInfo(D,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},C.bufferedInfo=function(O,A,y){A=Math.max(0,A),O.sort(function(r,o){var d=r.start-o.start;return d||o.end-r.end});var T=[];if(y)for(var D=0;D<O.length;D++){var E=T.length;if(E){var g=T[E-1].end;O[D].start-g<y?O[D].end>g&&(T[E-1].end=O[D].end):T.push(O[D])}else T.push(O[D])}else T=O;for(var p=0,u,e=A,s=A,c=0;c<T.length;c++){var v=T[c].start,i=T[c].end;if(A+y>=v&&A<i)e=v,s=i,p=s-A;else if(A+y<v){u=v;break}}return{len:p,start:e||0,end:s||0,nextStart:u}},C.getBuffered=function(O){try{return O.buffered}catch(A){return M.logger.log("failed to get media.buffered",A),_}},C}()},"./src/utils/cea-608-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"Row",function(){return s}),m.d(R,"CaptionScreen",function(){return c});var M=m("./src/utils/logger.ts"),_={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},L=function(n){var l=n;return _.hasOwnProperty(n)&&(l=_[n]),String.fromCharCode(l)},C=15,b=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={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},T={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 g=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var n=t.prototype;return n.log=function(a,f){this.verboseLevel>=a&&M.logger.log(this.time+" ["+a+"] "+f)},t}(),p=function(n){for(var l=[],a=0;a<n.length;a++)l.push(n[a].toString(16));return l},u=function(){function t(l,a,f,h,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=a||!1,this.italics=f||!1,this.background=h||"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 f=["foreground","underline","italics","background","flash"],h=0;h<f.length;h++){var S=f[h];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(l,a,f,h,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new u(a,f,h,S,x)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,f){this.uchar=a,this.penState.copy(f)},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(l){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<b;a++)this.chars.push(new e);this.logger=l,this.pos=0,this.currPenState=new u}var n=t.prototype;return n.equals=function(a){for(var f=!0,h=0;h<b;h++)if(!this.chars[h].equals(a.chars[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<b;f++)this.chars[f].copy(a.chars[f])},n.isEmpty=function(){for(var a=!0,f=0;f<b;f++)if(!this.chars[f].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>b&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=b)},n.moveCursor=function(a){var f=this.pos+a;if(a>1)for(var h=this.pos+1;h<f+1;h++)this.chars[h].setPenState(this.currPenState);this.setCursor(f)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var f=L(a);if(this.pos>=b){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var f;for(f=a;f<b;f++)this.chars[f].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=[],f=!0,h=0;h<b;h++){var S=this.chars[h].uchar;S!==" "&&(f=!1),a.push(S)}return f?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var f=this.chars[this.pos];f.setPenState(this.currPenState)},t}(),c=function(){function t(l){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<C;a++)this.rows.push(new s(l));this.logger=l,this.currRow=C-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<C;a++)this.rows[a].clear();this.currRow=C-1},n.equals=function(a){for(var f=!0,h=0;h<C;h++)if(!this.rows[h].equals(a.rows[h])){f=!1;break}return f},n.copy=function(a){for(var f=0;f<C;f++)this.rows[f].copy(a.rows[f])},n.isEmpty=function(){for(var a=!0,f=0;f<C;f++)if(!this.rows[f].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 f=this.rows[this.currRow];f.insertChar(a)},n.setPen=function(a){var f=this.rows[this.currRow];f.setPenStyles(a)},n.moveCursor=function(a){var f=this.rows[this.currRow];f.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var f=this.rows[this.currRow];f.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var f=a.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var h=0;h<C;h++)this.rows[h].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var P=x.rows[S].cueStartTime,k=this.logger.time;if(P&&k!==null&&P<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[f-this.nrRollUpRows+B+1].copy(x.rows[S+B])}}this.currRow=f;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,f=this.rows.splice(a,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var f=[],h="",S=-1,x=0;x<C;x++){var P=this.rows[x].getTextString();P&&(S=x+1,a?f.push("Row "+S+": '"+P+"'"):f.push(P.trim()))}return f.length>0&&(a?h="["+f.join(" | ")+"]":h=f.join(`
20
+ `)),h},n.getTextAndFormat=function(){return this.rows},t}(),v=function(){function t(l,a,f){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=l,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new c(f),this.nonDisplayedMemory=new c(f),this.lastOutputScreen=new c(f),this.currRollUpRow=this.displayedMemory.rows[C-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}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[C-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 f=0;f<a.length;f++)this.writeScreen.insertChar(a[f]);var h=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,h+": "+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 f={flash:!1};if(f.underline=a%2===1,f.italics=a>=46,f.italics)f.foreground="white";else{var h=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=S[h]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},n.outputDataUpdate=function(a){a===void 0&&(a=!1);var f=this.logger.time;f!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=f:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,f,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),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(l,a,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var h=new g;this.channels=[null,new v(l,a,h),new v(l+1,f,h)],this.cmdHistory=d(),this.logger=h}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,f){this.channels[a].setHandler(f)},n.addData=function(a,f){var h,S,x,P=!1;this.logger.time=a;for(var k=0;k<f.length;k+=2)if(S=f[k]&127,x=f[k+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([f[k],f[k+1]])+"] -> ("+p([S,x])+")"),h=this.parseCmd(S,x),h||(h=this.parseMidrow(S,x)),h||(h=this.parsePAC(S,x)),h||(h=this.parseBackgroundAttributes(S,x)),!h&&(P=this.parseChars(S,x),P)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(P)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!h&&!P&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([f[k],f[k+1]]))}},n.parseCmd=function(a,f){var h=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&f>=32&&f<=47,x=(a===23||a===31)&&f>=33&&f<=35;if(!(S||x))return!1;if(o(a,f,h))return r(null,null,h),this.logger.log(E.DEBUG,"Repeated command ("+p([a,f])+") is dropped"),!0;var P=a===20||a===21||a===23?1:2,k=this.channels[P];return a===20||a===21||a===28||a===29?f===32?k.ccRCL():f===33?k.ccBS():f===34?k.ccAOF():f===35?k.ccAON():f===36?k.ccDER():f===37?k.ccRU(2):f===38?k.ccRU(3):f===39?k.ccRU(4):f===40?k.ccFON():f===41?k.ccRDC():f===42?k.ccTR():f===43?k.ccRTD():f===44?k.ccEDM():f===45?k.ccCR():f===46?k.ccENM():f===47&&k.ccEOC():k.ccTO(f-32),r(a,f,h),this.currentChannel=P,!0},n.parseMidrow=function(a,f){var h=0;if((a===17||a===25)&&f>=32&&f<=47){if(a===17?h=1:h=2,h!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[h];return S?(S.ccMIDROW(f),this.logger.log(E.DEBUG,"MIDROW ("+p([a,f])+")"),!0):!1}return!1},n.parsePAC=function(a,f){var h,S=this.cmdHistory,x=(a>=17&&a<=23||a>=25&&a<=31)&&f>=64&&f<=127,P=(a===16||a===24)&&f>=64&&f<=95;if(!(x||P))return!1;if(o(a,f,S))return r(null,null,S),!0;var k=a<=23?1:2;f>=64&&f<=95?h=k===1?O[a]:y[a]:h=k===1?A[a]:T[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(h,f)),r(a,f,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,f){var h,S={color:null,italics:!1,indent:null,underline:!1,row:a};return f>95?h=f-96:h=f-64,S.underline=(h&1)===1,h<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(h/2)]:h<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((h-16)/2)*4,S},n.parseChars=function(a,f){var h,S=null,x=null;if(a>=25?(h=2,x=a-8):(h=1,x=a),x>=17&&x<=19){var P;x===17?P=f+80:x===18?P=f+112:P=f+144,this.logger.log(E.INFO,"Special char '"+L(P)+"' in channel "+h),S=[P]}else a>=32&&a<=127&&(S=f===0?[a]:[a,f]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,f,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,f){var h=(a===16||a===24)&&f>=32&&f<=47,S=(a===23||a===31)&&f>=45&&f<=47;if(!(h||S))return!1;var x,P={};a===16||a===24?(x=Math.floor((f-32)/2),P.background=D[x],f%2===1&&(P.background=P.background+"_semi")):f===45?P.background="transparent":(P.foreground="black",f===47&&(P.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(P),r(a,f,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var f=this.channels[a];f&&f.reset()}this.cmdHistory=d()},n.cueSplitAtTime=function(a){for(var f=0;f<this.channels.length;f++){var h=this.channels[f];h&&h.cueSplitAtTime(a)}},t}();function r(t,n,l){l.a=t,l.b=n}function o(t,n,l){return l.a===t&&l.b===n}function d(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"isCodecType",function(){return _}),m.d(R,"isCodecSupportedInMp4",function(){return L});var M={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 _(C,b){var O=M[b];return!!O&&O[C.slice(0,4)]===!0}function L(C,b){return MediaSource.isTypeSupported((b||"video")+'/mp4;codecs="'+C+'"')}},"./src/utils/cues.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/vttparser.ts"),_=m("./src/utils/webvtt-parser.ts"),L=m("./src/utils/texttrack-utils.ts"),C=/\s/,b={newCue:function(A,y,T,D){for(var E=[],g,p,u,e,s,c=self.VTTCue||self.TextTrackCue,v=0;v<D.rows.length;v++)if(g=D.rows[v],u=!0,e=0,s="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)C.test(g.chars[i].uchar)&&u?e++:(s+=g.chars[i].uchar,u=!1);g.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(M.fixLineBreaks)(s.trim()),o=Object(_.generateCueId)(y,T,r);(!A||!A.cues||!A.cues.getCueById(o))&&(p=new c(y,T,r),p.id=o,p.line=v+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return A&&E.length&&(E.sort(function(d,t){return d.line==="auto"||t.line==="auto"?0:d.line>8&&t.line>8?t.line-d.line:d.line-t.line}),E.forEach(function(d){return Object(L.addCueToTrack)(A,d)})),E}};R.default=b},"./src/utils/discontinuities.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"findFirstFragWithCC",function(){return C}),m.d(R,"shouldAlignOnDiscontinuities",function(){return b}),m.d(R,"findDiscontinuousReferenceFrag",function(){return O}),m.d(R,"adjustSlidingStart",function(){return y}),m.d(R,"alignStream",function(){return T}),m.d(R,"alignPDT",function(){return E}),m.d(R,"alignFragmentByPDTDelta",function(){return g}),m.d(R,"alignMediaPlaylistByPDT",function(){return p});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/logger.ts"),L=m("./src/controller/level-helper.ts");function C(u,e){for(var s=null,c=0,v=u.length;c<v;c++){var i=u[c];if(i&&i.cc===e){s=i;break}}return s}function b(u,e,s){return!!(e.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function O(u,e){var s=u.fragments,c=e.fragments;if(!c.length||!s.length){_.logger.log("No fragments to align");return}var v=C(s,c[0].cc);if(!v||v&&!v.startPTS){_.logger.log("No frag in previous level to align on");return}return v}function A(u,e){if(u){var s=u.start+e;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function y(u,e){for(var s=e.fragments,c=0,v=s.length;c<v;c++)A(s[c],u);e.fragmentHint&&A(e.fragmentHint,u),e.alignedSliding=!0}function T(u,e,s){!e||(D(u,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(L.adjustSliding)(e.details,s))}function D(u,e,s){if(b(u,s,e)){var c=O(s.details,e);c&&Object(M.isFiniteNumber)(c.start)&&(_.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(c.start,e))}}function E(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=u.fragments[0].programDateTime,v=(c-s)/1e3+e.fragments[0].start;v&&Object(M.isFiniteNumber)(v)&&(_.logger.log("Adjusting PTS using programDateTime delta "+(c-s)+"ms, sliding:"+v.toFixed(3)+" "+u.url+" "),y(v,u))}}function g(u,e){var s=u.programDateTime;if(!!s){var c=(s-e)/1e3;u.start=u.startPTS=c,u.endPTS=c+u.duration}}function p(u,e){if(!(!e.fragments.length||!u.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,c=e.fragments[0].start,v=s-c*1e3;u.fragments.forEach(function(i){g(i,v)}),u.fragmentHint&&g(u.fragmentHint,v),u.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/ewma.ts"),_=function(){function L(b,O,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new M.default(b),this.fast_=new M.default(O)}var C=L.prototype;return C.update=function(O,A){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new M.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new M.default(A,T.getEstimate(),T.getTotalWeight()))},C.sample=function(O,A){O=Math.max(O,this.minDelayMs_);var y=8*A,T=O/1e3,D=y/T;this.fast_.sample(T,D),this.slow_.sample(T,D)},C.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},C.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},C.destroy=function(){},L}();R.default=_},"./src/utils/ewma.ts":function(j,R,m){"use strict";m.r(R);var M=function(){function _(C,b,O){b===void 0&&(b=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=C,this.alpha_=C?Math.exp(Math.log(.5)/C):0,this.estimate_=b,this.totalWeight_=O}var L=_.prototype;return L.sample=function(b,O){var A=Math.pow(this.alpha_,b);this.estimate_=O*(1-A)+A*this.estimate_,this.totalWeight_+=b},L.getTotalWeight=function(){return this.totalWeight_},L.getEstimate=function(){if(this.alpha_){var b=1-Math.pow(this.alpha_,this.totalWeight_);if(b)return this.estimate_/b}return this.estimate_},_}();R.default=M},"./src/utils/fetch-loader.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"fetchSupported",function(){return g});var M=m("./src/polyfills/number.ts"),_=m("./src/loader/load-stats.ts"),L=m("./src/demux/chunk-cache.ts");function C(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,T(c,v)}function b(c){var v=typeof Map=="function"?new Map:void 0;return b=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 v!="undefined"){if(v.has(r))return v.get(r);v.set(r,o)}function o(){return O(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),T(o,r)},b(c)}function O(c,v,i){return A()?O=Reflect.construct.bind():O=function(o,d,t){var n=[null];n.push.apply(n,d);var l=Function.bind.apply(o,n),a=new l;return t&&T(a,t.prototype),a},O.apply(null,arguments)}function A(){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(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function T(c,v){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},T(c,v)}function D(c){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(c)}function E(){return E=Object.assign?Object.assign.bind():function(c){for(var v=1;v<arguments.length;v++){var i=arguments[v];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(c[r]=i[r])}return c},E.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function c(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 _.LoadStats}var v=c.prototype;return v.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},v.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},v.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},v.load=function(r,o,d){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 l=u(r,this.controller.signal),a=d.onProgress,f=r.responseType==="arraybuffer",h=f?"byteLength":"length";this.context=r,this.config=o,this.callbacks=d,this.request=this.fetchSetup(r,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),d.onTimeout(n,r,t.response)},o.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var x=S.status,P=S.statusText;throw new s(P||"fetch, bad network response",x,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(M.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):f?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[h];var P={url:x.url,data:S};a&&!Object(M.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,x),d.onSuccess(P,n,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var x=S&&S.code||0,P=S?S.message:null;d.onError({code:x,text:P},r,S?S.details:null)}})},v.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},v.loadProgressively=function(r,o,d,t,n){t===void 0&&(t=0);var l=new L.default,a=r.body.getReader(),f=function h(){return a.read().then(function(S){if(S.done)return l.dataLength&&n(o,d,l.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,P=x.length;return o.loaded+=P,P<t||l.dataLength?(l.push(x),l.dataLength>=t&&n(o,d,l.flush(),r)):n(o,d,x,r),h()}).catch(function(){return Promise.reject()})};return f()},c}();function u(c,v){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(E({},c.headers))};return c.rangeEnd&&i.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),i}function e(c,v){return new self.Request(c.url,v)}var s=function(c){C(v,c);function v(i,r,o){var d;return d=c.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=r,d.details=o,d}return v}(b(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"IMSC1_CODEC",function(){return y}),m.d(R,"parseIMSC1",function(){return g});var M=m("./src/utils/mp4-tools.ts"),_=m("./src/utils/vttparser.ts"),L=m("./src/utils/vttcue.ts"),C=m("./src/demux/id3.ts"),b=m("./src/utils/timescale-conversion.ts"),O=m("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var l=arguments[n];for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&(t[a]=l[a])}return t},A.apply(this,arguments)}var y="stpp.ttml.im1t",T=/^(\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 g(t,n,l,a,f){var h=Object(M.findBox)(new Uint8Array(t),["mdat"]);if(h.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var S=h.map(function(P){return Object(C.utf8ArrayToStr)(P)}),x=Object(b.toTimescaleFromScale)(n,1,l);try{S.forEach(function(P){return a(p(P,x))})}catch(P){f(P)}}function p(t,n){var l=new DOMParser,a=l.parseFromString(t,"text/xml"),f=a.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var h={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(h).reduce(function(U,W){return U[W]=f.getAttribute("ttp:"+W)||h[W],U},{}),x=f.getAttribute("xml:space")!=="preserve",P=e(u(f,"styling","style")),k=e(u(f,"layout","region")),B=u(f,"body","[begin]");return[].map.call(B,function(U){var W=s(U,x);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 L.default(G-n,Y-n,W);$.id=Object(O.generateCueId)($.startTime,$.endTime,$.text);var Z=k[U.getAttribute("region")],q=P[U.getAttribute("style")];$.position=10,$.size=80;var ie=c(Z,q,P),ne=ie.textAlign;if(ne){var ae=E[ne];ae&&($.lineAlign=ae),$.align=ne}return A($,ie),$}).filter(function(U){return U!==null})}function u(t,n,l){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(l)):[]}function e(t){return t.reduce(function(n,l){var a=l.getAttribute("xml:id");return a&&(n[a]=l),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(l,a,f){var h;return a.nodeName==="br"&&f?l+`
21
+ `:(h=a.childNodes)!==null&&h!==void 0&&h.length?s(a,n):n?l+a.textContent.trim().replace(/\s+/g," "):l+a.textContent},"")}function c(t,n,l){var a="http://www.w3.org/ns/ttml#styling",f=null,h=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&l.hasOwnProperty(S)&&(f=l[S]),h.reduce(function(x,P){var k=v(n,a,P)||v(t,a,P)||v(f,a,P);return k&&(x[P]=k),x},{})}function v(t,n,l){return t&&t.hasAttributeNS(n,l)?t.getAttributeNS(n,l):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var l=Object(_.parseTimeStamp)(t);return l===null&&(T.test(t)?l=o(t,n):D.test(t)&&(l=d(t,n))),l}function o(t,n){var l=T.exec(t),a=(l[4]|0)+(l[5]|0)/n.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+a/n.frameRate}function d(t,n){var l=D.exec(t),a=Number(l[1]),f=l[2];switch(f){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,m){"use strict";m.r(R),m.d(R,"enableLogs",function(){return O}),m.d(R,"logger",function(){return A});var M=function(){},_={trace:M,debug:M,log:M,warn:M,info:M,error:M},L=_;function C(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):M}function b(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];D.forEach(function(g){L[g]=y[g]?y[g].bind(y):C(g)})}function O(y){if(self.console&&y===!0||typeof y=="object"){b(y,"debug","log","info","warn","error");try{L.log()}catch{L=_}}else L=_}var A=L},"./src/utils/mediakeys-helper.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"KeySystems",function(){return M}),m.d(R,"requestMediaKeySystemAccess",function(){return _});var M;(function(L){L.WIDEVINE="com.widevine.alpha",L.PLAYREADY="com.microsoft.playready"})(M||(M={}));var _=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,m){"use strict";m.r(R),m.d(R,"getMediaSource",function(){return M});function M(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"RemuxerTrackIdConfig",function(){return O}),m.d(R,"bin2str",function(){return A}),m.d(R,"readUint16",function(){return y}),m.d(R,"readUint32",function(){return T}),m.d(R,"readSint32",function(){return D}),m.d(R,"writeUint32",function(){return E}),m.d(R,"findBox",function(){return g}),m.d(R,"parseSegmentIndex",function(){return p}),m.d(R,"parseInitSegment",function(){return u}),m.d(R,"getStartDTS",function(){return e}),m.d(R,"getDuration",function(){return s}),m.d(R,"computeRawDurationFromSamples",function(){return c}),m.d(R,"offsetStartDTS",function(){return v}),m.d(R,"segmentValidRange",function(){return i}),m.d(R,"appendUint8Array",function(){return r}),m.d(R,"parseSamples",function(){return o}),m.d(R,"parseSEIMessageFromNALu",function(){return n}),m.d(R,"parseEmsg",function(){return a});var M=m("./src/utils/typed-array.ts"),_=m("./src/loader/fragment.ts"),L=m("./src/demux/id3.ts"),C=Math.pow(2,32)-1,b=[].push,O={video:1,audio:2,id3:3,text:4};function A(f){return String.fromCharCode.apply(null,f)}function y(f,h){var S=f[h]<<8|f[h+1];return S<0?65536+S:S}function T(f,h){var S=D(f,h);return S<0?4294967296+S:S}function D(f,h){return f[h]<<24|f[h+1]<<16|f[h+2]<<8|f[h+3]}function E(f,h,S){f[h]=S>>24,f[h+1]=S>>16&255,f[h+2]=S>>8&255,f[h+3]=S&255}function g(f,h){var S=[];if(!h.length)return S;for(var x=f.byteLength,P=0;P<x;){var k=T(f,P),B=A(f.subarray(P+4,P+8)),U=k>1?P+k:x;if(B===h[0])if(h.length===1)S.push(f.subarray(P+8,U));else{var W=g(f.subarray(P+8,U),h.slice(1));W.length&&b.apply(S,W)}P=U}return S}function p(f){var h=[],S=f[0],x=8,P=T(f,x);x+=4;var k=0,B=0;S===0?x+=8:x+=16,x+=2;var U=f.length+B,W=y(f,x);x+=2;for(var G=0;G<W;G++){var z=x,Y=T(f,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=T(f,z);z+=4,h.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/P,start:U,end:U+$-1}}),U+=$,z+=4,x=z}return{earliestPresentationTime:k,timescale:P,version:S,referencesCount:W,references:h}}function u(f){for(var h=[],S=g(f,["moov","trak"]),x=0;x<S.length;x++){var P=S[x],k=g(P,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=T(k,U),G=g(P,["mdia","mdhd"])[0];if(G){B=G[0],U=B===0?12:20;var z=T(G,U),Y=g(P,["mdia","hdlr"])[0];if(Y){var $=A(Y.subarray(8,12)),Z={soun:_.ElementaryStreamTypes.AUDIO,vide:_.ElementaryStreamTypes.VIDEO}[$];if(Z){var q=g(P,["mdia","minf","stbl","stsd"])[0],ie=void 0;q&&(ie=A(q.subarray(12,16))),h[W]={timescale:z,type:Z},h[Z]={timescale:z,id:W,codec:ie}}}}}}var ne=g(f,["moov","mvex","trex"]);return ne.forEach(function(ae){var te=T(ae,4),fe=h[te];fe&&(fe.default={duration:T(ae,12),flags:T(ae,20)})}),h}function e(f,h){return g(h,["moof","traf"]).reduce(function(S,x){var P=g(x,["tfdt"])[0],k=P[0],B=g(x,["tfhd"]).reduce(function(U,W){var G=T(W,4),z=f[G];if(z){var Y=T(P,4);k===1&&(Y*=Math.pow(2,32),Y+=T(P,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(f,h){for(var S=0,x=0,P=0,k=g(f,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=g(U,["tfhd"])[0],G=T(W,4),z=h[G];if(!!z){var Y=z.default,$=T(W,0)|(Y==null?void 0:Y.flags),Z=Y==null?void 0:Y.duration;$&8&&($&2?Z=T(W,12):Z=T(W,8));for(var q=z.timescale||9e4,ie=g(U,["trun"]),ne=0;ne<ie.length;ne++){if(S=c(ie[ne]),!S&&Z){var ae=T(ie[ne],4);S=Z*ae}z.type===_.ElementaryStreamTypes.VIDEO?x+=S/q:z.type===_.ElementaryStreamTypes.AUDIO&&(P+=S/q)}}}if(x===0&&P===0){for(var te=0,fe=g(f,["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 x||P}function c(f){var h=T(f,0),S=8;h&1&&(S+=4),h&4&&(S+=4);for(var x=0,P=T(f,4),k=0;k<P;k++){if(h&256){var B=T(f,S);x+=B,S+=4}h&512&&(S+=4),h&1024&&(S+=4),h&2048&&(S+=4)}return x}function v(f,h,S){g(h,["moof","traf"]).forEach(function(x){g(x,["tfhd"]).forEach(function(P){var k=T(P,4),B=f[k];if(!!B){var U=B.timescale||9e4;g(x,["tfdt"]).forEach(function(W){var G=W[0],z=T(W,4);if(G===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=T(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(C+1)),$=Math.floor(z%(C+1));E(W,4,Y),E(W,8,$)}})}})})}function i(f){var h={valid:null,remainder:null},S=g(f,["moof"]);if(S){if(S.length<2)return h.remainder=f,h}else return h;var x=S[S.length-1];return h.valid=Object(M.sliceUint8)(f,0,x.byteOffset-8),h.remainder=Object(M.sliceUint8)(f,x.byteOffset-8),h}function r(f,h){var S=new Uint8Array(f.length+h.length);return S.set(f),S.set(h,f.length),S}function o(f,h){var S=[],x=h.samples,P=h.timescale,k=h.id,B=!1,U=g(x,["moof"]);return U.map(function(W){var G=W.byteOffset-8,z=g(W,["traf"]);z.map(function(Y){var $=g(Y,["tfdt"]).map(function(Z){var q=Z[0],ie=T(Z,4);return q===1&&(ie*=Math.pow(2,32),ie+=T(Z,8)),ie/P})[0];return $!==void 0&&(f=$),g(Y,["tfhd"]).map(function(Z){var q=T(Z,4),ie=T(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=T(Z,me),me+=4),de&&(re=T(Z,me),me+=4),Ee&&(me+=4),h.type==="video"&&(B=d(h.codec)),g(Y,["trun"]).map(function(Te){var Me=Te[0],Ae=T(Te,0)&16777215,we=(Ae&1)!==0,Re=0,ke=(Ae&4)!==0,_e=(Ae&256)!==0,Be=0,Ke=(Ae&512)!==0,We=0,Ue=(Ae&1024)!==0,Ze=(Ae&2048)!==0,Ce=0,qe=T(Te,4),Oe=8;we&&(Re=T(Te,Oe),Oe+=4),ke&&(Oe+=4);for(var Pe=Re+G,Ve=0;Ve<qe;Ve++){if(_e?(Be=T(Te,Oe),Oe+=4):Be=fe,Ke?(We=T(Te,Oe),Oe+=4):We=re,Ue&&(Oe+=4),Ze&&(Me===0?Ce=T(Te,Oe):Ce=D(Te,Oe),Oe+=4),h.type===_.ElementaryStreamTypes.VIDEO)for(var Ie=0;Ie<We;){var Le=T(x,Pe);Pe+=4;var rt=x[Pe]&31;if(t(B,rt)){var je=x.subarray(Pe,Pe+Le);n(je,f+Ce/P,S)}Pe+=Le,Ie+=Le+4}f+=Be/P}}))})})}),S}function d(f){if(!f)return!1;var h=f.indexOf("."),S=h<0?f:f.substring(0,h);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(f,h){return f?h===39||h===40:h===6}function n(f,h,S){var x=l(f),P=0;P++;for(var k=0,B=0,U=!1,W=0;P<x.length;){k=0;do{if(P>=x.length)break;W=x[P++],k+=W}while(W===255);B=0;do{if(P>=x.length)break;W=x[P++],B+=W}while(W===255);var G=x.length-P;if(!U&&k===4&&P<x.length){U=!0;var z=x[P++];if(z===181){var Y=y(x,P);if(P+=2,Y===49){var $=T(x,P);if(P+=4,$===1195456820){var Z=x[P++];if(Z===3){var q=x[P++],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]=x[P++]}S.push({type:Z,payloadType:k,pts:h,bytes:te})}}}}}else if(k===5&&B<G){if(U=!0,B>16){for(var de=[],re=0;re<16;re++){var Ee=x[P++].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]=x[P++];S.push({payloadType:k,pts:h,uuid:de.join(""),userData:Object(L.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(B<G)P+=B;else if(B>G)break}}function l(f){for(var h=f.byteLength,S=[],x=1;x<h-2;)f[x]===0&&f[x+1]===0&&f[x+2]===3?(S.push(x+2),x+=2):x++;if(S.length===0)return f;var P=h-S.length,k=new Uint8Array(P),B=0;for(x=0;x<P;B++,x++)B===S[0]&&(B++,S.shift()),k[x]=f[B];return k}function a(f){var h=f[0],S="",x="",P=0,k=0,B=0,U=0,W=0,G=0;if(h===0){for(;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1,P=T(f,12),k=T(f,16),U=T(f,20),W=T(f,24),G=28}else if(h===1){G+=4,P=T(f,G),G+=4;var z=T(f,G);G+=4;var Y=T(f,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=T(f,G),G+=4,W=T(f,G),G+=4;A(f.subarray(G,G+1))!=="\0";)S+=A(f.subarray(G,G+1)),G+=1;for(S+=A(f.subarray(G,G+1)),G+=1;A(f.subarray(G,G+1))!=="\0";)x+=A(f.subarray(G,G+1)),G+=1;x+=A(f.subarray(G,G+1)),G+=1}var $=f.subarray(G,f.byteLength);return{schemeIdUri:S,value:x,timeScale:P,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"default",function(){return M});var M=function(){function _(C,b){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=C,this.trackName=b}var L=_.prototype;return L.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},L.newCue=function(b,O,A){(this.startTime===null||this.startTime>b)&&(this.startTime=b),this.endTime=O,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},L.reset=function(){this.cueRanges=[],this.startTime=null},_}()},"./src/utils/texttrack-utils.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"sendAddTrackEvent",function(){return _}),m.d(R,"addCueToTrack",function(){return L}),m.d(R,"clearCurrentCues",function(){return C}),m.d(R,"removeCuesInRange",function(){return b}),m.d(R,"getCuesInRange",function(){return A});var M=m("./src/utils/logger.ts");function _(y,T){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,T.dispatchEvent(D)}function L(y,T){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(T.id))try{if(y.addCue(T),!y.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(g){M.logger.debug("[texttrack-utils]: "+g);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function C(y){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);T==="disabled"&&(y.mode=T)}function b(y,T,D,E){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=A(y.cues,T,D),u=0;u<p.length;u++)(!E||E(p[u]))&&y.removeCue(p[u]);g==="disabled"&&(y.mode=g)}function O(y,T){if(T<y[0].startTime)return 0;var D=y.length-1;if(T>y[D].endTime)return-1;for(var E=0,g=D;E<=g;){var p=Math.floor((g+E)/2);if(T<y[p].startTime)g=p-1;else if(T>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-T<T-y[g].startTime?E:g}function A(y,T,D){var E=[],g=O(y,T);if(g>-1)for(var p=g,u=y.length;p<u;p++){var e=y[p];if(e.startTime>=T&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(j,R,m){"use strict";m.r(R);var M={toString:function(L){for(var C="",b=L.length,O=0;O<b;O++)C+="["+L.start(O).toFixed(3)+","+L.end(O).toFixed(3)+"]";return C}};R.default=M},"./src/utils/timescale-conversion.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"toTimescaleFromBase",function(){return _}),m.d(R,"toTimescaleFromScale",function(){return L}),m.d(R,"toMsFromMpegTsClock",function(){return C}),m.d(R,"toMpegTsClockFromTimescale",function(){return b});var M=9e4;function _(O,A,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var D=O*A*y;return T?Math.round(D):D}function L(O,A,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),_(O,A,1/y,T)}function C(O,A){return A===void 0&&(A=!1),_(O,1e3,1/M,A)}function b(O,A){return A===void 0&&(A=1),_(O,M,1/A)}},"./src/utils/typed-array.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"sliceUint8",function(){return M});function M(_,L,C){return Uint8Array.prototype.slice?_.slice(L,C):new Uint8Array(Array.prototype.slice.call(_,L,C))}},"./src/utils/vttcue.ts":function(j,R,m){"use strict";m.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var M=["","lr","rl"],_=["start","middle","end","left","right"];function L(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var D=T.toLowerCase();return~y.indexOf(D)?D:!1}function C(y){return L(M,y)}function b(y){return L(_,y)}function O(y){for(var T=arguments.length,D=new Array(T>1?T-1:0),E=1;E<T;E++)D[E-1]=arguments[E];for(var g=1;g<arguments.length;g++){var p=arguments[g];for(var u in p)y[u]=p[u]}return y}function A(y,T,D){var E=this,g={enumerable:!0};E.hasBeenReset=!1;var p="",u=!1,e=y,s=T,c=D,v=null,i="",r=!0,o="auto",d="start",t=50,n="middle",l=50,a="middle";Object.defineProperty(E,"id",O({},g,{get:function(){return p},set:function(h){p=""+h}})),Object.defineProperty(E,"pauseOnExit",O({},g,{get:function(){return u},set:function(h){u=!!h}})),Object.defineProperty(E,"startTime",O({},g,{get:function(){return e},set:function(h){if(typeof h!="number")throw new TypeError("Start time must be set to a number.");e=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},g,{get:function(){return s},set:function(h){if(typeof h!="number")throw new TypeError("End time must be set to a number.");s=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},g,{get:function(){return c},set:function(h){c=""+h,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},g,{get:function(){return v},set:function(h){v=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},g,{get:function(){return i},set:function(h){var S=C(h);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},g,{get:function(){return r},set:function(h){r=!!h,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},g,{get:function(){return o},set:function(h){if(typeof h!="number"&&h!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},g,{get:function(){return d},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},g,{get:function(){return t},set:function(h){if(h<0||h>100)throw new Error("Position must be between 0 and 100.");t=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},g,{get:function(){return n},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},g,{get:function(){return l},set:function(h){if(h<0||h>100)throw new Error("Size must be between 0 and 100.");l=h,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},g,{get:function(){return a},set:function(h){var S=b(h);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"parseTimeStamp",function(){return L}),m.d(R,"fixLineBreaks",function(){return T}),m.d(R,"VTTParser",function(){return D});var M=m("./src/utils/vttcue.ts"),_=function(){function E(){}var g=E.prototype;return g.decode=function(u,e){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},E}();function L(E){function g(u,e,s,c){return(u|0)*3600+(e|0)*60+(s|0)+parseFloat(c||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?g(p[2],p[3],0,p[4]):g(p[1],p[2],p[3],p[4]):null}var C=function(){function E(){this.values=Object.create(null)}var g=E.prototype;return g.set=function(u,e){!this.get(u)&&e!==""&&(this.values[u]=e)},g.get=function(u,e,s){return s?this.has(u)?this.values[u]:e[s]:this.has(u)?this.values[u]:e},g.has=function(u){return u in this.values},g.alt=function(u,e,s){for(var c=0;c<s.length;++c)if(e===s[c]){this.set(u,e);break}},g.integer=function(u,e){/^-?\d+$/.test(e)&&this.set(u,parseInt(e,10))},g.percent=function(u,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},E}();function b(E,g,p,u){var e=u?E.split(u):[E];for(var s in e)if(typeof e[s]=="string"){var c=e[s].split(p);if(c.length===2){var v=c[0],i=c[1];g(v,i)}}}var O=new M.default(0,0,""),A=O.align==="middle"?"middle":"center";function y(E,g,p){var u=E;function e(){var v=L(E);if(v===null)throw new Error("Malformed timestamp: "+u);return E=E.replace(/^[^\sa-zA-Z-]+/,""),v}function s(v,i){var r=new C;b(v,function(t,n){var l;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":l=n.split(","),r.integer(t,l[0]),r.percent(t,l[0])&&r.set("snapToLines",!1),r.alt(t,l[0],["auto"]),l.length===2&&r.alt("lineAlign",l[1],["start",A,"end"]);break;case"position":l=n.split(","),r.percent(t,l[0]),l.length===2&&r.alt("positionAlign",l[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&O.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",A);var d=r.get("position","auto");d==="auto"&&O.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function c(){E=E.replace(/^\s+/,"")}if(c(),g.startTime=e(),c(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);E=E.slice(3),c(),g.endTime=e(),c(),s(E,g)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
22
+ `)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new _,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=E.prototype;return g.parse=function(u){var e=this;u&&(e.buffer+=e.decoder.decode(u,{stream:!0}));function s(){var d=e.buffer,t=0;for(d=T(d);t<d.length&&d[t]!=="\r"&&d[t]!==`
23
23
  `;)++t;var n=d.slice(0,t);return d[t]==="\r"&&++t,d[t]===`
24
24
  `&&++t,e.buffer=d.slice(t),n}function c(d){b(d,function(t,n){},/:/)}try{var v="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;v=s();var i=v.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:v=s(),e.state){case"HEADER":/:/.test(v)?c(v):v||(e.state="ID");continue;case"NOTE":v||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(v)){e.state="NOTE";break}if(!v)continue;if(e.cue=new M.default(0,0,""),e.state="CUE",v.indexOf("-->")===-1){e.cue.id=v;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(v,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var o=v.indexOf("-->")!==-1;if(!v||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
- `),e.cue.text+=v}continue;case"BADCUE":v||(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 u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
25
+ `),e.cue.text+=v}continue;case"BADCUE":v||(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},g.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
26
26
 
27
- `,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){u.onparsingerror&&u.onparsingerror(e)}return u.onflush&&u.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,g){"use strict";g.r(R),g.d(R,"generateCueId",function(){return D}),g.d(R,"parseWebVTT",function(){return m});var M=g("./src/polyfills/number.ts"),_=g("./src/utils/vttparser.ts"),L=g("./src/demux/id3.ts"),C=g("./src/utils/timescale-conversion.ts"),b=g("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,A=function(u,e,s){return s===void 0&&(s=0),u.slice(s,s+e.length)===e},y=function(u){var e=parseInt(u.slice(-3)),s=parseInt(u.slice(-6,-4)),c=parseInt(u.slice(-9,-7)),v=u.length>9?parseInt(u.substring(0,u.indexOf(":"))):0;if(!Object(M.isFiniteNumber)(e)||!Object(M.isFiniteNumber)(s)||!Object(M.isFiniteNumber)(c)||!Object(M.isFiniteNumber)(v))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return e+=1e3*s,e+=60*1e3*c,e+=60*60*1e3*v,e},T=function(u){for(var e=5381,s=u.length;s;)e=e*33^u.charCodeAt(--s);return(e>>>0).toString()};function D(p,u,e){return T(p.toString())+T(u.toString())+T(e)}var E=function(u,e,s){var c=u[e],v=u[c.prevCC];if(!v||!v.new&&c.new){u.ccOffset=u.presentationOffset=c.start,c.new=!1;return}for(;(i=v)!==null&&i!==void 0&&i.new;){var i;u.ccOffset+=c.start-v.start,c.new=!1,c=v,v=u[c.prevCC]}u.presentationOffset=s};function m(p,u,e,s,c,v,i,r){var o=new _.VTTParser,d=Object(L.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(O,`
27
+ `,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){u.onparsingerror&&u.onparsingerror(e)}return u.onflush&&u.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,m){"use strict";m.r(R),m.d(R,"generateCueId",function(){return D}),m.d(R,"parseWebVTT",function(){return g});var M=m("./src/polyfills/number.ts"),_=m("./src/utils/vttparser.ts"),L=m("./src/demux/id3.ts"),C=m("./src/utils/timescale-conversion.ts"),b=m("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,A=function(u,e,s){return s===void 0&&(s=0),u.slice(s,s+e.length)===e},y=function(u){var e=parseInt(u.slice(-3)),s=parseInt(u.slice(-6,-4)),c=parseInt(u.slice(-9,-7)),v=u.length>9?parseInt(u.substring(0,u.indexOf(":"))):0;if(!Object(M.isFiniteNumber)(e)||!Object(M.isFiniteNumber)(s)||!Object(M.isFiniteNumber)(c)||!Object(M.isFiniteNumber)(v))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return e+=1e3*s,e+=60*1e3*c,e+=60*60*1e3*v,e},T=function(u){for(var e=5381,s=u.length;s;)e=e*33^u.charCodeAt(--s);return(e>>>0).toString()};function D(p,u,e){return T(p.toString())+T(u.toString())+T(e)}var E=function(u,e,s){var c=u[e],v=u[c.prevCC];if(!v||!v.new&&c.new){u.ccOffset=u.presentationOffset=c.start,c.new=!1;return}for(;(i=v)!==null&&i!==void 0&&i.new;){var i;u.ccOffset+=c.start-v.start,c.new=!1,c=v,v=u[c.prevCC]}u.presentationOffset=s};function g(p,u,e,s,c,v,i,r){var o=new _.VTTParser,d=Object(L.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(O,`
28
28
  `).split(`
29
29
  `),t=[],n=Object(C.toMpegTsClockFromTimescale)(u,e),l="00:00.000",a=0,f=0,h,S=!0;o.oncue=function(x){var P=s[c],k=s.ccOffset,B=(a-n)/9e4;P!=null&&P.new&&(f!==void 0?k=s.ccOffset=P.start:E(s,c,B)),B&&(k=B-s.presentationOffset);var U=x.endTime-x.startTime,W=Object(b.normalizePts)((x.startTime+k-f)*9e4,v*9e4)/9e4;x.startTime=Math.max(W,0),x.endTime=Math.max(W+U,0);var G=x.text.trim();x.text=decodeURIComponent(encodeURIComponent(G)),x.id||(x.id=D(x.startTime,x.endTime,G)),x.endTime>0&&t.push(x)},o.onparsingerror=function(x){h=x},o.onflush=function(){if(h){r(h);return}i(t)},d.forEach(function(x){if(S)if(A(x,"X-TIMESTAMP-MAP=")){S=!1,x.slice(16).split(",").forEach(function(P){A(P,"LOCAL:")?l=P.slice(6):A(P,"MPEGTS:")&&(a=parseInt(P.slice(7)))});try{f=y(l)/1e3}catch(P){h=P}return}else x===""&&(S=!1);o.parse(x+`
30
- `)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,g){"use strict";g.r(R);var M=g("./src/utils/logger.ts"),_=g("./src/loader/load-stats.ts"),L=/^age:\s*[\d.]+\s*$/m,C=function(){function b(A){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=A?A.xhrSetup:null,this.stats=new _.LoadStats,this.retryDelay=0}var O=b.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.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()))},O.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(y,T,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=T,this.callbacks=D,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var y=this.config,T=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,T.url)}catch{D.open("GET",T.url,!0),m(D,T.url)}D.readyState||D.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var u in p)D.setRequestHeader(u,p[u])}catch(e){this.callbacks.onError({code:D.status,text:e.message},T,D);return}T.rangeEnd&&D.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},O.readystatechange=function(){var y=this.context,T=this.loader,D=this.stats;if(!(!y||!T)){var E=T.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){T.onreadystatechange=null,T.onprogress=null;var p=T.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var u,e;if(y.responseType==="arraybuffer"?(u=T.response,e=u.byteLength):(u=T.responseText,e=u.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,u,T),!this.callbacks)return;var c={url:T.responseURL,data:u};this.callbacks.onSuccess(c,D,y,T)}else D.retry>=m.maxRetry||p>=400&&p<499?(M.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(M.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)}},O.loadtimeout=function(){M.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(y){var T=this.stats;T.loaded=y.loaded,y.lengthComputable&&(T.total=y.total)},O.getCacheAge=function(){var y=null;if(this.loader&&L.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},b}();R.default=C}}).default})});var zt=jt(Lr()),Tt=jt(Ht());var At=class extends Error{constructor(g,M=At.MEDIA_ERR_CUSTOM,_){var L;super(g);this.name="MediaError",this.code=M,this.fatal=_!=null?_:M>=At.MEDIA_ERR_NETWORK&&M<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(L=At.defaultMessages[this.code])!=null?L:"")}},Ne=At;Ne.MEDIA_ERR_ABORTED=1,Ne.MEDIA_ERR_NETWORK=2,Ne.MEDIA_ERR_DECODE=3,Ne.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ne.MEDIA_ERR_ENCRYPTED=5,Ne.MEDIA_ERR_CUSTOM=100,Ne.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 dr=jt(Ht());var or=(j,R)=>j in R,Vt={ANY:"any",MUTED:"muted"},wt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},lr={MSE:"mse",NATIVE:"native"},ht={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Yt={HLS:ht.M3U8},Gi=Object.keys(Yt),Hi=[...Object.values(ht),"hls","HLS"];var yt=(j,R,g,M)=>{j.addEventListener(R,g,M),j.addEventListener("teardown",()=>{j.removeEventListener(R,g)},{once:!0})};function Ar(j,R,g){R&&g>R&&(g=R);for(let M=0;M<j.length;M++)if(j.start(M)<=g&&j.end(M)>=g)return!0;return!1}var _r=j=>{let R=j.indexOf("?");if(R<0)return[j];let g=j.slice(0,R),M=j.slice(R);return[g,M]},ur=j=>{let R=j.type;if(R){let M=R.toUpperCase();return or(M,Yt)?Yt[M]:R}let{src:g}=j;return g?Oi(g):""},Oi=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let g=R.lastIndexOf(".");if(g<0)return"";let _=R.slice(g+1).toUpperCase();return or(_,ht)?ht[_]:""};var bi=Object.values(Vt),Or=j=>typeof j=="boolean"||typeof j=="string"&&bi.includes(j),br=({autoplay:j},R,g)=>{if(!R)return()=>{};let M=!1,_=!1,L=Or(j)?j:!!j,C=()=>{M||yt(R,"playing",()=>{M=!0},{once:!0})};if(C(),yt(R,"loadstart",()=>{M=!1,C(),fr(R,L)},{once:!0}),yt(R,"loadstart",()=>{g||(_=!Number.isFinite(R.duration)),fr(R,L)},{once:!0}),g&&g.once(dr.default.Events.LEVEL_LOADED,(O,A)=>{var y;_=(y=A.details.live)!=null?y:!1}),!L){let O=()=>{!_||(g!=null&&g.liveSyncPosition?R.currentTime=g.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};g&&yt(R,"play",()=>{R.preload==="metadata"?g.once(dr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{M||(L=Or(O)?O:!!O,fr(R,L))}},fr=(j,R)=>{if(!R)return;let g=j.muted,M=()=>j.muted=g;switch(R){case Vt.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(M)});break;case Vt.MUTED:j.muted=!0,j.play().catch(M);break;default:j.play().catch(()=>{});break}};var Rr=({preload:j,src:R},g,M)=>{if(!g)return()=>{};let _=T=>{T!=null&&["","none","metadata","auto"].includes(T)?g.setAttribute("preload",T):g.removeAttribute("preload")};if(!M)return _(j),_;let L=!1,C=!1,b=M.config.maxBufferLength,O=M.config.maxBufferSize,A=T=>{_(T);let D=T!=null?T:g.preload;C||D==="none"||(D==="metadata"?(M.config.maxBufferLength=1,M.config.maxBufferSize=1):(M.config.maxBufferLength=b,M.config.maxBufferSize=O),y())},y=()=>{!L&&R&&(L=!0,M.loadSource(R))};return yt(g,"play",()=>{C=!0,M.config.maxBufferLength=b,M.config.maxBufferSize=O,y()},{once:!0}),A(j),A};var _t=jt(Ht());function Pr(j,R){R.on(_t.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(_,{tracks:L})=>{L.forEach(C=>{var A;let b=(A=C.subtitleTrack)!=null?A:C.closedCaptions,O=R.subtitleTracks.findIndex(({lang:y,name:T,type:D})=>y==(b==null?void 0:b.lang)&&T===C.label&&D.toLowerCase()===C.kind);Ir(j,C.kind,C.label,b==null?void 0:b.lang,`${C.kind}${O}`)})});let g=()=>{var C;if(!R.subtitleTracks.length)return;let _=Array.from(j.textTracks).find(b=>b.id&&b.mode==="showing"&&["subtitles","captions"].includes(b.kind)),L=`${(C=R.subtitleTracks[R.subtitleTrack])==null?void 0:C.type.toLowerCase()}${R.subtitleTrack}`;if(_&&(R.subtitleTrack<0||(_==null?void 0:_.id)!==L)){let b=R.subtitleTracks.findIndex(({lang:O,name:A,type:y})=>O==_.language&&A===_.label&&y.toLowerCase()===_.kind);R.subtitleTrack=b}_&&(_==null?void 0:_.id)===L&&_.cues&&Array.from(_.cues).forEach(b=>{_.addCue(b)})};j.textTracks.addEventListener("change",g),R.on(_t.default.Events.CUES_PARSED,(_,{track:L,cues:C})=>{let b=j.textTracks.getTrackById(L);if(!b)return;let O=b.mode==="disabled";O&&(b.mode="hidden"),C.forEach(A=>{var y;(y=b.cues)!=null&&y.getCueById(A.id)||b.addCue(A)}),O&&(b.mode="disabled")}),R.once(_t.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",g),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let M=()=>{Array.from(j.textTracks).forEach(_=>{var L,C;if(!["subtitles","caption"].includes(_.kind)&&_.label==="thumbnails"){if(!((L=_.cues)!=null&&L.length)){let b=j.querySelector('track[label="thumbnails"]'),O=(C=b==null?void 0:b.getAttribute("src"))!=null?C:"";b==null||b.removeAttribute("src"),setTimeout(()=>{b==null||b.setAttribute("src",O)},0)}_.mode!=="hidden"&&(_.mode="hidden")}})};R.once(_t.default.Events.MANIFEST_LOADED,M),R.once(_t.default.Events.MEDIA_ATTACHED,M)}function Ir(j,R,g,M,_){let L=document.createElement("track");return L.kind=R,L.label=g,M&&(L.srclang=M),_&&(L.id=_),L.track.mode="disabled",L.setAttribute("data-removeondestroy",""),j.append(L),L.track}function Ri(j,R){let g=Array.prototype.find.call(j.querySelectorAll("track"),M=>M.track===R);g==null||g.remove()}var Mr,Cr,Pi=(Cr=(Mr=globalThis==null?void 0:globalThis.navigator)==null?void 0:Mr.userAgent)!=null?Cr:"",Ii=Pi.toLowerCase().indexOf("android")!==-1,Ot=new WeakMap,kr="mux.com",Fr,wr,Br=(wr=(Fr=Tt.default).isSupported)==null?void 0:wr.call(Fr),Mi=Ii,dn=()=>zt.default.utils.now(),cr=zt.default.utils.generateUUID,cn=(j,{domain:R=kr}={})=>{if(!j)return;let[g,M=""]=_r(j);return`https://stream.${R}/${g}.m3u8${M}`},Ci=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},Fi=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},wi=j=>{var R,g,M;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:Nr(j)&&(M=(g=Ci(j.playbackId))!=null?g:Fi(j.src))!=null?M:cr()},hn=j=>{var R;return(R=Ot.get(j))==null?void 0:R.error},vn=(j,R,g)=>{ki(R,g);let{metadata:M={}}=j,{view_session_id:_=cr()}=M,L=wi(j);M.view_session_id=_,M.video_id=L,j.metadata=M,Ot.set(R,{});let C=Bi(j,R);Ni(j,R,C),Ki(j,R,C);let b=br(j,R,C),O=Rr(j,R,C);return{engine:C,setAutoplay:b,setPreload:O}},ki=(j,R)=>{let g=R==null?void 0:R.engine;g&&(g.detachMedia(),g.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",Wr),j.removeEventListener("error",hr),j.removeEventListener("durationchange",Kr),Ot.delete(j),j.dispatchEvent(new Event("teardown")))};function Ur(j,R){var A;let g=ur(j);if(!(g===ht.M3U8))return!0;let _=!g||((A=R==null?void 0:R.canPlayType(g))!=null?A:!0),{preferPlayback:L}=j,C=L===lr.MSE,b=L===lr.NATIVE;return _&&(b||!(Br&&(C||Mi)))}var Bi=(j,R)=>{let{debug:g,streamType:M,startTime:_=-1,metadata:L,experimentalCmcd:C}=j,O=ur(j)===ht.M3U8,A=Ur(j,R);if(O&&!A&&Br){let y={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},T=Ui(M),D=C?{useHeaders:!0,sessionId:L.view_session_id,contentId:L.video_id}:void 0;return new Tt.default({debug:g,startPosition:_,cmcd:D,...y,...T})}},Ui=j=>[wt.LIVE,wt.DVR].includes(j)?{backBufferLength:8}:[wt.LL_LIVE,wt.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Nr=({playbackId:j,src:R,customDomain:g})=>{if(j)return!0;if(typeof R!="string")return!1;let M=window==null?void 0:window.location.href,_=new URL(R,M).hostname.toLocaleLowerCase();return _.includes(kr)||!!g&&_.includes(g.toLocaleLowerCase())},Ni=(j,R,g)=>{var L;let{envKey:M}=j,_=Nr(j);if((M||_)&&R){let{playerInitTime:C,playerSoftwareName:b,playerSoftwareVersion:O,beaconCollectionDomain:A,debug:y,disableCookies:T}=j,D={...j.metadata,video_title:((L=j==null?void 0:j.metadata)==null?void 0:L.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(m):m;zt.default.monitor(R,{debug:y,beaconCollectionDomain:A,hlsjs:g,Hls:g?Tt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...M?{env_key:M}:{},player_software_name:b,player_software:b,player_software_version:O,player_init_time:C,...D}})}},Ki=(j,R,g)=>{var L;if(!R){console.warn("attempting to load media before mediaEl exists");return}let M=Ur(j,R),{src:_}=j;R&&M?(typeof _=="string"?(R.setAttribute("src",_),j.startTime&&(((L=Ot.get(R))!=null?L:{}).startTime=j.startTime,R.addEventListener("durationchange",Kr,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",Wr),R.addEventListener("error",hr)):g&&_?(g.on(Tt.default.Events.ERROR,(C,b)=>{let O={[Tt.default.ErrorTypes.NETWORK_ERROR]:Ne.MEDIA_ERR_NETWORK,[Tt.default.ErrorTypes.MEDIA_ERROR]:Ne.MEDIA_ERR_DECODE},A=new Ne("",O[b.type]);A.fatal=b.fatal,A.data=b,R.dispatchEvent(new CustomEvent("error",{detail:A}))}),R.addEventListener("error",hr),Pr(R,g),g.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 Kr(j){var M;let R=j.target,g=(M=Ot.get(R))==null?void 0:M.startTime;if(!!g&&Ar(R.seekable,R.duration,g)){let _=R.preload==="auto";_&&(R.preload="none"),R.currentTime=g,_&&(R.preload="auto")}}async function Wr(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:g,code:M}=R.error,_=new Ne(g,M);if(R.src&&(M!==Ne.MEDIA_ERR_DECODE||M!==void 0))try{let{status:L}=await fetch(R.src);_.data={response:{code:L}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:_}))}function hr(j){var M,_;if(!(j instanceof CustomEvent)||!(j.detail instanceof Ne))return;let R=j.target,g=j.detail;!g||!g.fatal||(((M=Ot.get(R))!=null?M:{}).error=g,(_=R.mux)==null||_.emit("error",{player_error_code:g.code,player_error_message:g.message}))}var export_Hls=Tt.default;var export_mux=zt.default;export{Vt as AutoplayTypes,ht as ExtensionMimeTypeMap,export_Hls as Hls,Ne as MediaError,Yt as MimeTypeShorthandMap,lr as PlaybackTypes,wt as StreamTypes,Ir as addTextTrack,Hi as allMediaTypes,dn as generatePlayerInitTime,cr as generateUUID,hn as getError,Ui as getStreamTypeConfig,vn as initialize,or as isKeyOf,Nr as isMuxVideoSrc,Ki as loadMedia,export_mux as mux,Ri as removeTextTrack,Bi as setupHls,Ni as setupMux,Gi as shorthandKeys,ki as teardown,cn as toMuxVideoURL};
30
+ `)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,m){"use strict";m.r(R);var M=m("./src/utils/logger.ts"),_=m("./src/loader/load-stats.ts"),L=/^age:\s*[\d.]+\s*$/m,C=function(){function b(A){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=A?A.xhrSetup:null,this.stats=new _.LoadStats,this.retryDelay=0}var O=b.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.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()))},O.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(y,T,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=T,this.callbacks=D,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var y=this.config,T=this.context;if(!!y){var D=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var g=this.xhrSetup;try{if(g)try{g(D,T.url)}catch{D.open("GET",T.url,!0),g(D,T.url)}D.readyState||D.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var u in p)D.setRequestHeader(u,p[u])}catch(e){this.callbacks.onError({code:D.status,text:e.message},T,D);return}T.rangeEnd&&D.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},O.readystatechange=function(){var y=this.context,T=this.loader,D=this.stats;if(!(!y||!T)){var E=T.readyState,g=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){T.onreadystatechange=null,T.onprogress=null;var p=T.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var u,e;if(y.responseType==="arraybuffer"?(u=T.response,e=u.byteLength):(u=T.responseText,e=u.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,u,T),!this.callbacks)return;var c={url:T.responseURL,data:u};this.callbacks.onSuccess(c,D,y,T)}else D.retry>=g.maxRetry||p>=400&&p<499?(M.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(M.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,g.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},O.loadtimeout=function(){M.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(y){var T=this.stats;T.loaded=y.loaded,y.lengthComputable&&(T.total=y.total)},O.getCacheAge=function(){var y=null;if(this.loader&&L.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},b}();R.default=C}}).default})});var zt=jt(Lr()),Tt=jt(Ht());var At=class extends Error{constructor(m,M=At.MEDIA_ERR_CUSTOM,_){var L;super(m);this.name="MediaError",this.code=M,this.fatal=_!=null?_:M>=At.MEDIA_ERR_NETWORK&&M<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(L=At.defaultMessages[this.code])!=null?L:"")}},Ne=At;Ne.MEDIA_ERR_ABORTED=1,Ne.MEDIA_ERR_NETWORK=2,Ne.MEDIA_ERR_DECODE=3,Ne.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ne.MEDIA_ERR_ENCRYPTED=5,Ne.MEDIA_ERR_CUSTOM=100,Ne.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 cr=jt(Ht());var or=(j,R)=>j in R,Vt={ANY:"any",MUTED:"muted"},wt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},lr={MSE:"mse",NATIVE:"native"},ur={HEADER:"header",QUERY:"query"},Hi=Object.values(ur),ht={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Yt={HLS:ht.M3U8},Vi=Object.keys(Yt),Yi=[...Object.values(ht),"hls","HLS"];var yt=(j,R,m,M)=>{j.addEventListener(R,m,M),j.addEventListener("teardown",()=>{j.removeEventListener(R,m)},{once:!0})};function Ar(j,R,m){R&&m>R&&(m=R);for(let M=0;M<j.length;M++)if(j.start(M)<=m&&j.end(M)>=m)return!0;return!1}var _r=j=>{let R=j.indexOf("?");if(R<0)return[j];let m=j.slice(0,R),M=j.slice(R);return[m,M]},fr=j=>{let R=j.type;if(R){let M=R.toUpperCase();return or(M,Yt)?Yt[M]:R}let{src:m}=j;return m?Oi(m):""},Oi=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let m=R.lastIndexOf(".");if(m<0)return"";let _=R.slice(m+1).toUpperCase();return or(_,ht)?ht[_]:""};var bi=Object.values(Vt),Or=j=>typeof j=="boolean"||typeof j=="string"&&bi.includes(j),br=({autoplay:j},R,m)=>{let M=!1,_=!1,L=Or(j)?j:!!j,C=()=>{M||yt(R,"playing",()=>{M=!0},{once:!0})};if(C(),yt(R,"loadstart",()=>{M=!1,C(),dr(R,L)},{once:!0}),yt(R,"loadstart",()=>{m||(_=!Number.isFinite(R.duration)),dr(R,L)},{once:!0}),m&&m.once(cr.default.Events.LEVEL_LOADED,(O,A)=>{var y;_=(y=A.details.live)!=null?y:!1}),!L){let O=()=>{!_||(m!=null&&m.liveSyncPosition?R.currentTime=m.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};m&&yt(R,"play",()=>{R.preload==="metadata"?m.once(cr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{M||(L=Or(O)?O:!!O,dr(R,L))}},dr=(j,R)=>{if(!R)return;let m=j.muted,M=()=>j.muted=m;switch(R){case Vt.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(M)});break;case Vt.MUTED:j.muted=!0,j.play().catch(M);break;default:j.play().catch(()=>{});break}};var Rr=({preload:j,src:R},m,M)=>{let _=T=>{T!=null&&["","none","metadata","auto"].includes(T)?m.setAttribute("preload",T):m.removeAttribute("preload")};if(!M)return _(j),_;let L=!1,C=!1,b=M.config.maxBufferLength,O=M.config.maxBufferSize,A=T=>{_(T);let D=T!=null?T:m.preload;C||D==="none"||(D==="metadata"?(M.config.maxBufferLength=1,M.config.maxBufferSize=1):(M.config.maxBufferLength=b,M.config.maxBufferSize=O),y())},y=()=>{!L&&R&&(L=!0,M.loadSource(R))};return yt(m,"play",()=>{C=!0,M.config.maxBufferLength=b,M.config.maxBufferSize=O,y()},{once:!0}),A(j),A};var _t=jt(Ht());function Pr(j,R){R.on(_t.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(_,{tracks:L})=>{L.forEach(C=>{var A;let b=(A=C.subtitleTrack)!=null?A:C.closedCaptions,O=R.subtitleTracks.findIndex(({lang:y,name:T,type:D})=>y==(b==null?void 0:b.lang)&&T===C.label&&D.toLowerCase()===C.kind);Ir(j,C.kind,C.label,b==null?void 0:b.lang,`${C.kind}${O}`)})});let m=()=>{var C;if(!R.subtitleTracks.length)return;let _=Array.from(j.textTracks).find(b=>b.id&&b.mode==="showing"&&["subtitles","captions"].includes(b.kind)),L=`${(C=R.subtitleTracks[R.subtitleTrack])==null?void 0:C.type.toLowerCase()}${R.subtitleTrack}`;if(_&&(R.subtitleTrack<0||(_==null?void 0:_.id)!==L)){let b=R.subtitleTracks.findIndex(({lang:O,name:A,type:y})=>O==_.language&&A===_.label&&y.toLowerCase()===_.kind);R.subtitleTrack=b}_&&(_==null?void 0:_.id)===L&&_.cues&&Array.from(_.cues).forEach(b=>{_.addCue(b)})};j.textTracks.addEventListener("change",m),R.on(_t.default.Events.CUES_PARSED,(_,{track:L,cues:C})=>{let b=j.textTracks.getTrackById(L);if(!b)return;let O=b.mode==="disabled";O&&(b.mode="hidden"),C.forEach(A=>{var y;(y=b.cues)!=null&&y.getCueById(A.id)||b.addCue(A)}),O&&(b.mode="disabled")}),R.once(_t.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",m),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let M=()=>{Array.from(j.textTracks).forEach(_=>{var L,C;if(!["subtitles","caption"].includes(_.kind)&&_.label==="thumbnails"){if(!((L=_.cues)!=null&&L.length)){let b=j.querySelector('track[label="thumbnails"]'),O=(C=b==null?void 0:b.getAttribute("src"))!=null?C:"";b==null||b.removeAttribute("src"),setTimeout(()=>{b==null||b.setAttribute("src",O)},0)}_.mode!=="hidden"&&(_.mode="hidden")}})};R.once(_t.default.Events.MANIFEST_LOADED,M),R.once(_t.default.Events.MEDIA_ATTACHED,M)}function Ir(j,R,m,M,_){let L=document.createElement("track");return L.kind=R,L.label=m,M&&(L.srclang=M),_&&(L.id=_),L.track.mode="disabled",L.setAttribute("data-removeondestroy",""),j.append(L),L.track}function Ri(j,R){let m=Array.prototype.find.call(j.querySelectorAll("track"),M=>M.track===R);m==null||m.remove()}var Mr,Cr,Pi=(Cr=(Mr=globalThis==null?void 0:globalThis.navigator)==null?void 0:Mr.userAgent)!=null?Cr:"",Ii=Pi.toLowerCase().indexOf("android")!==-1,Ot=new WeakMap,kr="mux.com",Fr,wr,Br=(wr=(Fr=Tt.default).isSupported)==null?void 0:wr.call(Fr),Mi=Ii,hn=()=>zt.default.utils.now(),Ci=zt.default.utils.generateUUID,vn=(j,{domain:R=kr}={})=>{if(!j)return;let[m,M=""]=_r(j);return`https://stream.${R}/${m}.m3u8${M}`},Fi=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},wi=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},ki=j=>{var R,m,M;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:Nr(j)&&(M=(m=Fi(j.playbackId))!=null?m:wi(j.src))!=null?M:j.src},gn=j=>{var R;return(R=Ot.get(j))==null?void 0:R.error},mn=(j,R,m)=>{Bi(R,m);let{metadata:M={}}=j,{view_session_id:_=Ci()}=M,L=ki(j);M.view_session_id=_,M.video_id=L,j.metadata=M,Ot.set(R,{});let C=Ui(j,R);Ki(j,R,C),Wi(j,R,C);let b=br(j,R,C),O=Rr(j,R,C);return{engine:C,setAutoplay:b,setPreload:O}},Bi=(j,R)=>{let m=R==null?void 0:R.engine;m&&(m.detachMedia(),m.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",Wr),j.removeEventListener("error",hr),j.removeEventListener("durationchange",Kr),Ot.delete(j),j.dispatchEvent(new Event("teardown")))};function Ur(j,R){var A;let m=fr(j);if(!(m===ht.M3U8))return!0;let _=!m||((A=R.canPlayType(m))!=null?A:!0),{preferPlayback:L}=j,C=L===lr.MSE,b=L===lr.NATIVE;return _&&(b||!(Br&&(C||Mi)))}var Ui=(j,R)=>{let{debug:m,streamType:M,startTime:_=-1,metadata:L,experimentalCmcd:C,preferCmcd:b}=j,A=fr(j)===ht.M3U8,y=Ur(j,R);if(A&&!y&&Br){let T={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},D=Ni(M),E=C?{useHeaders:b===ur.HEADER,sessionId:L.view_session_id,contentId:L.video_id}:void 0;return new Tt.default({debug:m,startPosition:_,cmcd:E,...T,...D})}},Ni=j=>[wt.LIVE,wt.DVR].includes(j)?{backBufferLength:8}:[wt.LL_LIVE,wt.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Nr=({playbackId:j,src:R,customDomain:m})=>{if(j)return!0;if(typeof R!="string")return!1;let M=window==null?void 0:window.location.href,_=new URL(R,M).hostname.toLocaleLowerCase();return _.includes(kr)||!!m&&_.includes(m.toLocaleLowerCase())},Ki=(j,R,m)=>{var L;let{envKey:M}=j,_=Nr(j);if(M||_){let{playerInitTime:C,playerSoftwareName:b,playerSoftwareVersion:O,beaconCollectionDomain:A,debug:y,disableCookies:T}=j,D={...j.metadata,video_title:((L=j==null?void 0:j.metadata)==null?void 0:L.video_title)||void 0},E=g=>typeof g.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(g):g;zt.default.monitor(R,{debug:y,beaconCollectionDomain:A,hlsjs:m,Hls:m?Tt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...M?{env_key:M}:{},player_software_name:b,player_software:b,player_software_version:O,player_init_time:C,...D}})}},Wi=(j,R,m)=>{var L;let M=Ur(j,R),{src:_}=j;R&&M?(typeof _=="string"?(R.setAttribute("src",_),j.startTime&&(((L=Ot.get(R))!=null?L:{}).startTime=j.startTime,R.addEventListener("durationchange",Kr,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",Wr),R.addEventListener("error",hr)):m&&_?(m.on(Tt.default.Events.ERROR,(C,b)=>{let O={[Tt.default.ErrorTypes.NETWORK_ERROR]:Ne.MEDIA_ERR_NETWORK,[Tt.default.ErrorTypes.MEDIA_ERROR]:Ne.MEDIA_ERR_DECODE},A=new Ne("",O[b.type]);A.fatal=b.fatal,A.data=b,R.dispatchEvent(new CustomEvent("error",{detail:A}))}),R.addEventListener("error",hr),Pr(R,m),m.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 Kr(j){var M;let R=j.target,m=(M=Ot.get(R))==null?void 0:M.startTime;if(!!m&&Ar(R.seekable,R.duration,m)){let _=R.preload==="auto";_&&(R.preload="none"),R.currentTime=m,_&&(R.preload="auto")}}async function Wr(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:m,code:M}=R.error,_=new Ne(m,M);if(R.src&&(M!==Ne.MEDIA_ERR_DECODE||M!==void 0))try{let{status:L}=await fetch(R.src);_.data={response:{code:L}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:_}))}function hr(j){var M,_;if(!(j instanceof CustomEvent)||!(j.detail instanceof Ne))return;let R=j.target,m=j.detail;!m||!m.fatal||(((M=Ot.get(R))!=null?M:{}).error=m,(_=R.mux)==null||_.emit("error",{player_error_code:m.code,player_error_message:m.message}))}var export_Hls=Tt.default;var export_mux=zt.default;export{Vt as AutoplayTypes,Hi as CmcdTypeValues,ur as CmcdTypes,ht as ExtensionMimeTypeMap,export_Hls as Hls,Ne as MediaError,Yt as MimeTypeShorthandMap,lr as PlaybackTypes,wt as StreamTypes,Ir as addTextTrack,Yi as allMediaTypes,hn as generatePlayerInitTime,Ci as generateUUID,gn as getError,Ni as getStreamTypeConfig,mn as initialize,or as isKeyOf,Nr as isMuxVideoSrc,Wi as loadMedia,export_mux as mux,Ri as removeTextTrack,Ui as setupHls,Ki as setupMux,Vi as shorthandKeys,Bi as teardown,vn as toMuxVideoURL};
31
31
  /*!
32
32
  * JavaScript Cookie v2.1.3
33
33
  * https://github.com/js-cookie/js-cookie